[Question]
  [
*Disclaimer:* This challenge inspired by me trying to find pairs in a large pile of socks. 
*Disclaimer:* This is looking for a very different process and output to [Help me sort my socks!](https://codegolf.stackexchange.com/questions/77031/help-me-sort-my-socks). Please don't claim it as a duplicate until you've read both ;)
---
So, I have a huge pile of socks. Of course I keep them categorized by compatibility number. Compatible socks, which I can wear together, have the same number. (Of course, every programmer does this).
My super-convenient plot device quickly scans the pile and outputs an array of compatibility numbers for the pile. It looks a bit like this:
```
[2, 3, 3, 6, 0, 4, 9, 1, 6, 7, 11, 3, 13, 3, 
5, 12, 2, 1, 10, 2, 1, 11, 2, 13, 12, 10, 1, 
7, 0, 0, 12, 12, 6, 2, 13, 6, 10, 0, 0, 12, 
5, 0, 2, 3, 4, 0, 5, 8, 1, 6, 9, 7, 10, 14, 
10, 8, 3, 8, 9, 8, 5, 11, 7, 9, 9, 9, 7, 14, 
4, 2, 8, 14, 3, 11, 12, 14, 7, 13, 11, 13, 4, 
7, 5, 12, 3, 1, 12, 4, 5, 13, 2, 13, 2, 14, 1, 
13, 11, 1, 4, 8]
```
That's good data, but it's about as much use to me as scanning the pile myself by eye. What I want to know is how many compatible pairs I need to look for, and which are going to be 'odds', which I can discard for now.
In the above example, I am looking for these pairs of socks:
```
{3=>4, 6=>2, 2=>4, 1=>4, 11=>3, 13=>4, 12=>4, 10=>2, 7=>3, 0=>3, 5=>3, 4=>3, 9=>3, 8=>3, 14=>2}
```
(4 pairs of number 3, 2 pairs of number 6 etc.)
And these numbers will have 'odd ones out'. When I've found all the pairs for these, I can discard the last one.
```
[0, 6, 10, 7, 2, 14] 
```
---
# The challenge
* Convert a list of compatible numbers to a count of pairs for each number and an array of 'odds'.
	+ The pairs will be composed of a data structure (hash, or other) showing how many pairs can be made of each compatibility number (can be skipped if no pairs can be made).
	+ The odds will be composed of a list of numbers which occur and odd number of times in the array.
* The order of the outputs is not significant.
* The size of my sock pile can, of course, be arbitrarily large.
# The Rules
* It's golf, make it short.
* No standard loopholes.
* Use any language you like.
* Please include a link to an online interpreter.
# Test Cases
Input: `[1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]`
Output:
Pairs: `{2=>1, 3=>1, 4=>2, 5=>2}`
Odds: `[1, 3, 5]`
---
Input: `[2, 3, 3, 6, 0, 4, 9, 1, 6, 7, 11, 3, 13, 3, 5, 12, 2, 1, 10, 2, 1, 11, 2, 13, 12, 10, 1, 7, 0, 0, 12, 12, 6, 2, 13, 6, 10, 0, 0, 12, 5, 0, 2, 3, 4, 0, 5, 8, 1, 6, 9, 7, 10, 14, 10, 8, 3, 8, 9, 8, 5, 11, 7, 9, 9, 9, 7, 14, 4, 2, 8, 14, 3, 11, 12, 14, 7, 13, 11, 13, 4, 7, 5, 12, 3, 1, 12, 4, 5, 13, 2, 13, 2, 14, 1, 13, 11, 1, 4, 8]`
Output:
Pairs: `{3=>4, 6=>2, 2=>4, 1=>4, 11=>3, 13=>4, 12=>4, 10=>2, 7=>3, 0=>3, 5=>3, 4=>3, 9=>3, 8=>3, 14=>2}`
Odds: `[0, 6, 10, 7, 2, 14]`
---
Input: `[1, 2, 1, 2]`
Output:
Pairs: `{1=>1, 2=>1}`
Odds: `[]`
---
Input: `[1,2,3]`
Output: 
Pairs `{}`
Odds: `[1,2,3]`
---
Input: `[]`
Output:
Pairs: `{}`
Odds: `[]`
  
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), 46 bytes
```
{.kv.map(*=>*+>1),.keys.grep:{.{$^k}%2}}o*.Bag
```
[Try it online!](https://tio.run/##RY/BCoMwEETv/Yo9tKW1IZgYNbboob9RWvCgHqxUFAoifrvVnaqwkNmdl@ykzpp3MFYdHXOKx16WX1ml9cmJE@eSqLOQZda1smiy@trLfv8qh4Meho8j72kx3nZt2lFODy3I4woEuYKMoEiQ4jachGJPAfEnNfGaAeWuSkF5sGdD8W2Xi2eaX/xTAaDN9lkhimE9TeySI0KUmTU4LZOWLYtc2BgtFQI2/KpF4wHjPAbIMsLecP2ih49pHvsA9HYY2Mttpuxz/AE "Perl 6 – Try It Online")
### Explanation
```
{                                      }o*.Bag  # Convert to Bag and feed into block
                 ,  # 2-element list
 .kv  # Key-value list (key is sock type, value is count)
    .map(       )  # Map to
         *=>*+>1   # Pair of sock type and count right-shifted by 1
                  .keys  # Keys (sock types)
                       .grep:  # Filter
                             {.{$^k}%2}  # Count is odd
```
[Answer]
# [Python 3.8](https://docs.python.org/3.8/), ~~85~~ ~~78~~ ~~73~~ 72 bytes
```
lambda s:{*((c,(d:=s.count)(c)//2)for c in s),*(c for c in s if d(c)%2)}
```
[Try it online!](https://tio.run/##RY/NDoIwEIRfZS8mrWmE/iDFxCdRD1pCJFEggAdjfHasOyLJJp3d@badds/x2jbWd/1U7Y/T7Xy/lGcadq@1EEGJcrcfNqF9NKMUQSaJkVXbU6C6oUGqtQi09FRXVEZqZeR76vq6GUUlDkaR5doqShU5RYUizW0ehWZPA8miirxhQKd/paEs7K@heTvl4pnhG3/UFtBiZ6wQxbGOEz/nKBDlyzqcnknPlkcuvFjMlQN2fKtHY4FxHgdkHuHd/P9Fi48ZHmcAzHI42PM2U/4k5fQB "Python 3.8 (pre-release) – Try It Online")
---
Output is a list where pairs are tuples, `(a, b)` rather than `a => b`, and odds are not part of a tuple.
There's a sub-70 in here somewhere just staring at me, I can feel it...
**Previous Version (73 bytes):**
```
lambda s:{*((c,s.count(c)//2)for c in s),*(c for c in s if s.count(c)%2)}
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 11 bytes
```
¢2÷øê,¢ÉÏê,
```
[Try it online!](https://tio.run/##RY@7DQMhEERboYAN@B5Qi@XAJzlw5MBVOHIPF7oBOz4KwzBjOGklZnce7HB/XNbbtdZ9s@VTvuUt@1ae5dVErScryqEWUVqUF5VFGbSxCQPPEAlNNd4CMHoqQ@Vod8PgtkZhZvHin1oIHXaAYhQP3SZp5MiM0lnPM4FMsBJzcWMeFQl7vJrYOGLI44mMEffG@UXHj1mMAwF7HD2GzMuA0vkH "05AB1E – Try It Online")
```
¢              # count occurences of each element in the input
 2÷            # integer divide by 2
   ø           # zip with the input
    ê          # sort and uniquify
     ,         # output (this is the list of pairs counts)
¢              # count occurences of each element in the input
 É             # mod 2
  Ï            # filter the input, keep only where the above is 1
   ê           # sort and uniquify
    ,          # output (this is the list of singles)
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~23~~ 21 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
{γεÙygª}Dε`2÷‚}sø`ÉÏ‚
```
Outputs as a pair of lists, where both are ordered ascending by key. Also includes the optional value=0 pairs in the output, like all answers.
(Initially) inspired by [*@Malivil*'s C# answer](https://codegolf.stackexchange.com/a/196208/52210), so make sure to upvote him as well!
[Try it online](https://tio.run/##RY87DsIwEESv4gO4iH@J03MLhBSQEKKiSIVQJFoqajgCLYqgxn0OwUWMM4MTaSXP7jx7x4d2vdlvYzwNz6EPt@Pu8@gWQ9/o8Pqe710b3k24hGvSMS61FAZVSlFIYaWopVBoqyQUPEXEJZV4DUAVk1JUhvZoKNwuUJhpvPinSkKz7aAYxUKnic85akYZWcvTg/SwPHNxY52rImzxqmdjiCGPJZJH3FtNXzT8mMbYEdDzYWnn26D86gc) or [verify all test cases](https://tio.run/##NVAxTsNAEOx5ReR6hbx35/hMkyYNFQ2dZSmJFCEaQHKCZCFLtFTU8ARaFKDO9X5EPmJm7mKtzjc7s7O758d2vbnfjs/Z9cPTfnc1yxbd7eVSLrKb/Q5ES2Z8Gb6HQ/jo7o5f/XI4rEz4Pb1@9m34W4W38A48yvFnMda1EYuYSy5OKlGgUlRBKflC1IgBrXm6lJclC0ZRmyOYGTijNKdyZguhzaJ1Duxj@4oDoDp@PUQPynMS21UxSsoOVk9gKXGGo5Ay9izTelai6pjZtEOs1akWkm9kVnP39Fy6UxRTTAU4E7QEPO5s428x0cYGtmn@AQ).
**Explanation:**
```
{           # Sort the (implicit) input-list
            #  i.e. [4,2,3,3,1,3,2,4,4,3,4,3] → [1,2,2,3,3,3,3,3,4,4,4,4]
 γ          # Split it into groups of the same keys
            #  i.e. [1,2,2,3,3,3,3,3,4,4,4,4] → [[1],[2,2],[3,3,3,3,3],[4,4,4,4]]
            # (this is shorter than the regular (unsorted) group-by `.¡}`)
  ε         # Map each inner list `y` to:
   Ù        #  Uniquify the list, so a single key wrapped in a list remains
            #   i.e. [3,3,3,3,3] → [3]
    yg      #  Push the list `y` again, and pop and push its length (the count)
            #   i.e. [3,3,3,3,3] → 5
      ª     #  Append it to the 'key-list' to create the key-count pair
            #   i.e. [3] and 5 → [3,5]
            #  i.e. [[1],[2,2],[3,3,3,3,3],[4,4,4,4]] → [[1,1],[2,2],[3,5],[4,4]]
  }D        # After the map: duplicate the list of key-count pairs
    ε       # Map it to:
     `      #  Push key and count separated to the stack
            #   i.e. [3,5] → 3 and 5
      2÷    #  Integer-divide the count by 2
            #   i.e. 5 → 2
        ‚   #  And pair them back together
            #   i.e. 3 and 2 → [3,2]
            #  i.e. [[1,1],[2,2],[3,5],[4,4]] → [[1,0],[2,1],[3,2],[4,2]]
    }s      # After this map: swap to get the initial duplicated key-count pairs again
      ø     # Zip/transpose; swapping rows/columns
            #  i.e. [[1,1],[2,2],[3,5],[4,4]] → [[1,2,3,4],[1,2,5,4]]
       `    # Push both lists separated to the stack
        É   # Check for each count whether it is odd
            #  i.e. [1,2,5,4] → [1,0,1,0]
         Ï  # Only leave the keys at the truthy indices
            #  i.e. [1,2,3,4] and [1,0,1,0] → [1,3]
          ‚ # And pair it together with the earlier created list of key-count//2 pairs
            # (after which the result is output implicitly)
```
[Answer]
# [Python 2](https://docs.python.org/2/), 68 bytes
```
lambda A:({v:A.count(v)/2for v in A},{v for v in A if A.count(v)%2})
```
[Try it online!](https://tio.run/##TZDbDoIwDIav9Sl6YwLJoqxMGSRe7DmQCw8hkigYgyTG@OxIWwYmzdb2/3rYHu/22tTYl/tDfzveT5cjuCz4dJlbn5tX3QZduMGyeUIHVQ3uqz4dzCFUJczgCr9hT6IjMc@1AmSLvZk/2/5boZaLfCJ3CiJmUgWaw2RwNGtakKFIS/MhraPJk5kEkUyC5uqIjXPIHUdqJ9Asb9lDv27EGev3SGUVYo3clknLkpW9ZGLqLRHYcFcrQSwY72ME8SmZm0xPjOVh6D@NAJwvI7KvZsoWCsbfp1MiVDE5BRTZcvF4VnULZeDC0e9/ "Python 2 – Try It Online")
Outputs a `dict` containing the number of pairs, and a `set` of left-over sock ids.
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 23 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319 "When can APL characters be counted as 1 byte each?")[SBCS](https://github.com/abrudz/SBCS ".dyalog files using a single byte character set")
Anonymous tacit prefix function. Prints (unique sock number, count of pairs) pairs, then prints list of odds.
```
∊{⊂(2|≢⍵)/⊃⎕←⍺,⌊2÷⍨≢⍵}⌸
```
[Try it online!](https://tio.run/##TZC9bsIwEMd3niJjKzlqfDbEmVnKVAn6AkhVWJDatSosICEaJREMvAATQ6VOVREjvMm9SLDv4iTSyb67/@8@7OnHPHz7nM7fZ1WF2@wLs9UDLPD7iMXf4xNmaywPuNlhcRGYZ3D7x@LE6hLzc5WSVlpo9GLh66/Czd5Gk/HQnq/Po0mVBlIEQKa86Y71u9YLw7CXtuxABBFRiXBtbBhbR5ImGbFlktvbtIwaj6c6yMlOkFQdkVEOqGNNDRhq5T554BeOKGP8Hgmv4ljNtyHSkGR4L56YeIsZ1tTVcKAYo300Iz7Fc@PmiYofBv7bHADtpVn21USZ@kOl/xZoEiBU7WPx47w7 "APL (Dyalog Unicode) – Try It Online")
`{`…`}⌸` on each (unique sock number, its indices in sock list):
 `⍵` indices in sock list; `[4,5,6]`
 `≢` count them; `3`
 `2÷⍨` let two divide them; `1.5`
 `⌊` round down; `1`
 `⍺,` prepend sock number; `[3,1]`
 `⎕←` send to console; `"3 1\r"`
 `⊃` pick the first (the sock number); `3`
 `(`…`)/` make this many copies of that:
  `≢⍵` the count of indices; `3`
  `2|` the 2-mod of that (i.e. "is it odd?"); `1`
 `⊂` enclose so all the results will be self-contained; `[1]`
`∊` **ϵ**nlist (flatten); `[1,3,5]`
[Answer]
# [R](https://www.r-project.org/), 47 bytes
```
S=table(scan());S[S%/%2>0]%/%2;names(S[!!S%%2])
```
[Try it online!](https://tio.run/##NY6xDoMwDER/xQyRYGqcBAhC7U9kRAy0YmsZSv8/vUtaWYrte/Y575zT9bPdn3t7Praj7bo5LclcjLvZlWk@ttd@tmlpmmSMW7vsxCMGsRJkEkU1iiokpd6LOnGQ1dakTJ4qFMWsRbBz2CxoIPmpvXDNw9qijsV@4gHQwDcCRkiRl2g3lRiJA1YjC0/EG4GgdvQc6/e8FBrY@fqHMqv/WaCYvw "R – Try It Online")
Returns a `table` with `names` equal to the compatibility number and the pair counts as the values, as well as the compatibility numbers (as strings) of unpaired socks.
[Answer]
# [J](http://jsoftware.com/), ~~39~~ ~~27~~ ~~26~~ 24 bytes
```
~.((,.<.@-:);[#~2|])#/.~
```
[Try it online!](https://tio.run/##RY/BDoIwEETv/YqNHICkVFoKFJTExMSTJ6/Gk0iMF3/A8Ou17FhJtul05207ffmNSicaekpJUkl9WIWi4@V88rPKMqn26lD0@e6azOZzy5Otmn0uxDgoI6niasKgJCupk6T52Aah2dNA6qACbxjQ5V9pqAr2YmieLrm4Z/jGH9UAWu2aFaJY1qHjYo4OURbWYndMOrYccuHFLlYL2PKtDocKGOexQGIL77b/L1b4mOF2DcCsm4Udp5lyQjzuzzdNNPov "J – Try It Online")
*-2 bytes thanks to ngn*
[Answer]
# [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), ~~162~~ ~~154~~ ~~136~~ ~~128~~ 108 bytes
```
a=>(a.GroupBy(x=>x).Select(x=>(x.Key,x.Count()/2)),a.GroupBy(x=>x).Where(x=>x.Count()%2>0).Select(x=>x.Key))
```
[Try it online!](https://tio.run/##dVNRb9owEH7PrzihTrIlNyOBljCaPKzapm6VVqkPfWA8hMSsFixBiWFUUX47O59jiNouOoXzfd99/hwfWX2Z1eq4rdQ@1RJqnWqVwdddkd2oQs8XAtjdl2L3R1bpciNvGBYF4IsnAvoAlhKewAriYxonLPW/VeVu@/mFHeLkwP1HuZGZNgt28H/IF3Hwb8tdoRn/GHIuXtOfnmUlKXe0D2Ey7MuQCufHmeftS5XDQ4UO3liFlMzCEq3lbw3DmnuNB/jclkVdbqT/VCkt71Uh2cXgIVVV/Qmapqk1qv/2v5eqYAMBGLmzst5vIU7gYtBg5qdtnFCybAecty2@Z//V/5nnKD9/R33N28WvwvS2nvfK9HyRQLnVCgUhhkL@hXtV6w7pToPV@QKaQEBIMXIx7sVVP1pxbqTMCpnn1H8tYEidUwEBLSeYBIQFloJSgd0Sy8HwlFknhmRgAwTUPTRx2omwkJQ79rUl2zDQFWWhO8yQKpHzM7WWDHdsfyNiRgRFhnzezDqYupjYpjGpR3YxstbJ19hSXMnuPzkdeWQPGrpPi4T@FzT8TiXoqRA7ImL/BtzVmfd79dG5CHTx0EDrtTNvVVYyzZ6B7dOqmxIkuHlxw25AlpsxwwlaMYt2g2r/RwTi9B3/AQ "C# (Visual C# Interactive Compiler) – Try It Online")
-8 bytes thanks to @Kevin Cruijssen for pointing out an unnecessary variable
-18 more bytes thanks to @Kevin Cruijssen for letting me know the 0 rule was made optional and changing the return type from dynamic to array
-8 bytes thanks to @my pronoun is monicareinstate for in-lining the grouping assignment which changes this to a true one-liner
-20 bytes thanks to @Innat3 for changing the grouping to remove an un-needed comparison
[Answer]
# JavaScript (ES10), ~~91~~ 82 bytes
Returns `[odds_array, pair_object]`.
```
a=>[[...new Set(a)].flatMap(v=>(a.map(x=>n+=v==x,n=0),o[v]=n>>1,n&1?v:[]),o={}),o]
```
[Try it online!](https://tio.run/##dVDBTsQgEL37FT0ZGpEUym6pCfgFnjySHsjabjQVNm6Dmxi/vdIZ6W7MmkxgeO/NzGPeXHTH3cfrYbr34aWfBz07baxljPn@s3juJ@LKjg2jm57cgURtiGPvKTtp4@901PpEva5KGmzstDeGU3/LH@OD7RKmv77T2c274I9h7NkY9mQgltNCQNQ55EVsLqMry5s/1WvdlhYVVLS04PBsUsKB4yhJLTiOSjCv1gwdLKKFXggO1RUEYAI6/qq2KDrTG8hENl8BorKPFq0sWom3AqUCSqEvnNjmaFAsoavCR40y8CNRkiGc26xfrPFjIq9wEYjzJZHO1aBSV5bL84rEv2R9hUnQ/AM "JavaScript (Node.js) – Try It Online")
### Commented
```
a => [               // a[] = input array
  [...new Set(a)]    // build the set of distinct values in a[]
                     // and turn it back into an array
  .flatMap(v =>      // for each value v in there:
    ( a.map(x =>     //   count the number n of values in the original array
        n += v == x, //   that are equal to v
        n = 0        //   start with n = 0
      ),             //
      o[v] =         //   set o[v] to
        n >> 1,      //     floor(n / 2)
      n & 1 ? v : [] //   yield v if n is odd, or [] otherwise
    ),               //
    o = {}           //   o = object holding the number of pairs
  ),                 // end of flatMap()
  o                  // append o
]                    //
```
[Answer]
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), 63 bytes
```
lambda s:sum([[(c,(d:=s.count(c))//2)]+d%2*[c]for c in{*s}],[])
```
[Try it online!](https://tio.run/##RY/NCsIwEIRfJRch0aDNT9tU8EliDppSFLQtrR5EfPYad6zCQmZ3vmQn/eN26lrj@mFqdvvpcrge6wMbt@P9yr3nUfJ6uxvXsbu3Nx6F2Gy0CKt6oZc@hqYbWGTn9rkcX0H6IKZ@OCeu4V5LZqgKyTLJrGSVZIraMglFngKSJ5V4TYDKfkpBGdgfQ9HtjIpmml78UgWgv52TQhRLOk3cnKNClA9rcToiHVkOubCxmqsEbOlVh8YAozwWyDzC3vL3RYOPaRrnAPT/sLDn20S5IMT0Bg "Python 3.8 (pre-release) – Try It Online")
Outputs a list, with tuples `(a, b)` indicating pair counts and solitary elements indicating left over socks. 
Interestingly, the `hash` function on integers seems to be the identity function, and so the output is conveniently ordered `[(0, count of 0 pairs), 0 if 0 has odd count, (1, count of 1 pairs), 1 if 1 has odd count, ...` as long as a contiguous sequence of numbers starting at 0 is used for sock indicators. 
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 69 bytes
```
a=>[a.filter(n=>p[n]?0:(a.map(m=>c+=m==n,c=0),p[n]=c>>1,c%2),p={}),p]
```
[Try it online!](https://tio.run/##dVDBasMwDL3vK3IZOMwLtpM2TkHeh4QcjJeMjsQJbell7NszW5rTMjp42JLek/TsT3u1Z3c6LpdXP7/36wCrBdPaYjiOl/7EPJil9d2bODBbTHZhExj3AhOA5w5EziMLzhjJ3bMKKXx9h7Nb3ezP89gX4/zBBtZKnilEmVDdYXePLs@f/nRvfXueCexoeCYxrUMgkZMkCSMkrQplKbaIHERRpCMhsVsgsKZw4q9qT6IbvcNIJfMCKzr5aMhK1FZ0a1RqpDT5oo1NQk3iCqdqSkqSoZ@KJKlEe@vtiSU9TKUvjAJ1uyqiUzeq9IPPlemL1L9k@YAJpfUH "JavaScript (Node.js) – Try It Online")
```
a=>[
  a.filter(n=>               // Filter out paired ones, return unpaired (odd) ones
    p[n]?0:                  // If we already paired it, skip
    (
      a.map(m=>c+=m==n,c=0), // Count
      p[n]=c>>1,             // Count / 2 pairs found
      c%2                    // If count % 2 != 0, there is an odd one
    ),
    p={}                     // Initial pairs dictionary
 ),p]
```
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 17 16 bytes
```
,R//Qd2{Qf%/QT2{
```
[Try it online!](https://tio.run/##K6gsyfj/XydIXz8wxag6ME1VPzDEqPr//2hDHQUjMDKGIRMkZIqMYgE "Pyth – Try It Online")
-1 byte thanks to @isaacg
Two separate operations, returns two separate lists. Includes zero-pairs, which I believe is optional? Can fix at the cost of 2 bytes, if not allowed, by prepending e# -> `e#,R//Qd2{Qf%/QT2{`
## How it works
```
,R//Qd2{Qf%/QT2{
,R//Qd2{Q            -- Returns pairs
 R      {Q            -  Right map to the input cast to a set
,                     - A two element list starting with the element of the set (implicit)
   //Qd2              - ...and ending with the count of that element in the input/2
          f%/QT2{     -- Returns odds
          f     {     - Filter the implicit input cast to a set
            /QT       - By the count of each element of the set in the input
           %   2      - Modulo 2 
                        Both lists print implicitly
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 14 bytes
```
ṢŒrH2¦€,ṪḂ$ƇƊḞ
```
[Try it online!](https://tio.run/##TZA9DsIwDIWvkqFjhuavTW/AFVDVkQV1YmPtUomRiYmBgQFxgHYFtfcIFwmJH02RrOTZ74vjZL9r26P3brxN58NGvu6f7snd@HBDl839fHLD1b/76ezGSxasrfc1qyVniqLgLOdMc1ZxJigtgxDkCSAmqMBLAkSelIBSsKMh6HROQTVJHX9UAWi1DSmMokmHil3mqDBKZDV2S6Qly2Iu3FgtUQLW1NUiUcBoHg1kKeHeMj1R4WGSygaAXDcNezlNlG04q/ET6U/RNoX5jxWP65qpKBvWfAE "Jelly – Try It Online")
Somehow, before I stepped back for a bit and questioned my decisions leading up to it, my original solution was going to be `ṢŒrZd2¦2Zµ1,[2,1]œịⱮ,ṪṪ$Ƈ`. I may have gotten a bit too attached to using divmod...
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 18 bytes
```
ọ{÷₂ᵗ}ᵐ|ọ{t%₂1&h}ˢ
```
[Try it online!](https://tio.run/##TZC/CsIwEMZf5RB0itD8qU0XfZDSQR10EAQRRKqLg@AguLmKT@Cigo6OPkV9kZrcZ1vhSL777pfLJYNZfzheTqYjVWSLBrW71Fj0PtvLZ7PJb6f8sVvn10ORP/fZ6@6969EbK2/Mm86QrfH6fS6KhBIlSHN0BAWCjKBYkOQ0ckJyTQIJnXK8YkAGlZJQGmVfkHw64GBPcccf1QFUl0NWGMWwdo4t54gximcNdsuk5ZLFXLgxLiMCbLirRaKB8TwGSGnh3qh6osbDFNshAFVvBuXyNFM2FZTgJ6o/Rdsqwv@ocb/WmfYypfQL "Brachylog – Try It Online")
[Generates](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods/10753#10753) the output, since it saves a byte over using a fork: [`ọ⟨{÷₂ᵗ}ᵐ≡{t%₂1&h}ˢ⟩`](https://tio.run/##TZC/asMwEMZf5TC0kwrWH8fy0j6I8ZBkaIZCoQRCMVkyFDwUsmU0zZRsWUwgGTv2KawXcaX7YjtwSN9999PppNnHdL74fHt/VV25iujpmaLVi/s6uc2mvVTrttl27fXb1Yfy9xy8Zhc8V/2Uywefy8fF@m/v6mPX5ZQrQZpjIigWZARlgiSnqReSaxJI4pXnFQMyHpSE0iiHguTTMQd7ijveqAmgsZywwiiGtXdsP0eGUQJrsFsmLZcs5sKNWR8pYMNdLRINjOcxQHoL96bDEzUepthOAKhxMyj3p5myhaAcPzH8KdoOkdzHiId1zHSQBRX/)
```
       |              The output is
ọ                     the list of pairs [unique element of input, # of occurrences]
 {   }ᵐ               with each pair
    ᵗ                 's last element
  ÷₂                  divided by 2 (rounding down),
       |              or
       |ọ             that same list of pairs
         {      }ˢ    filtered by
          t           the last element
           %₂         mod 2
             1        being 1,
         {    & }ˢ    and mapped to
               h      each pair's first element. 
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 18 bytes
```
{ÅγU©X2‰ø`.Áø,®sÏ,
```
[Try it online!](https://tio.run/##RY89CgIxEIWvkgMMsvnZTfYggiCCChZWFlvaaGHtOWxEsNl603sILxKT99xdGMibeV8yL6dutz8eUjrH2@e9HB4r8728Yr9dxGvsZXh28S4prY0oi2pEVaKcqFaURuuz0PA0kTqrzBsAupqUprK0i6Fxu0JhZvDin2oIzXYNxSgOOk/CmKNllMI6ngFkgBWYixvbsTxhh1cDG0sMeRyRccS9fvqi5ccMxjUBMx8lhkyXAYXNDw "05AB1E – Try It Online")
```
{       sort input
Åγ      push run-length encoded input (count each element of input)
U©X     save compatibility number in ® and count in X
2‰      divmod count by 2 (for each compatibility number, get the count of pairs and info if a single sock is remaining)
ø       split that into a list of pair counts and a list of single socks
`       push those lists onto the stack
.Á      rotate the stack, so list of compatibility numbers and the list of pair counts are at the top of the stack
ø       zip them (for each compatibility number, get the pair count)
,       print that
®       push another list of compatibility numbers
s       swap with the list of single socks
Ï       keep only compatibility numbers of single socks
,       print that
```
[Answer]
# [Red](http://www.red-lang.org), 169 bytes
```
func[a][b: copy[]m: copy#()foreach n a[alter b n unless
m/:n[put m n 0]m/:n: m/:n + 1]foreach k keys-of
m[t: m/:k either t = 1[remove/key m k][m/:k: t / 2]]insert b m b]
```
Doesn't work in TIO (Apparently `remove/key` is added only recently). It works fine in the [Red](http://www.red-lang.org) GUI console:
[![enter image description here](https://i.stack.imgur.com/KOksA.png)](https://i.stack.imgur.com/KOksA.png)
`#()` is a map structure, the list of single socks is after it.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), ~~17~~ 16 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
ü
lu mÎp¡[XÎXÊz]
```
Output is an array of the format:  
`[O1,O2,...On,[[V1,P1],[V2,P2],...[Vn,Pn]]]`  
where `O`s are odds, `V`s are values and `P`s are pairs.
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=/ApsdSBtznChW1jOWMp6XQ&footer=Vsy3K1IrVq9K&input=WzIsMywzLDYsMCw0LDksMSw2LDcsMTEsMywxMywzLDUsMTIsMiwxLDEwLDIsMSwxMSwyLDEzLDEyLDEwLDEsNywwLDAsMTIsMTIsNiwyLDEzLDYsMTAsMCwwLDEyLDUsMCwyLDMsNCwwLDUsOCwxLDYsOSw3LDEwLDE0LDEwLDgsMyw4LDksOCw1LDExLDcsOSw5LDksNywxNCw0LDIsOCwxNCwzLDExLDEyLDE0LDcsMTMsMTEsMTMsNCw3LDUsMTIsMywxLDEyLDQsNSwxMywyLDEzLDIsMTQsMSwxMywxMSwxLDQsOCwxNV0) (Footer formats the output for easier reading)
[Answer]
# APL(NARS), chars 66, bytes 132
```
{∨/c←×b←⌊2÷⍨≢¨a←a⊂⍨1+a←⍵[⍋⍵]:(⊂c/b,¨∪¨a),⊂∪⊃∪/a/⍨0≠2∣≢¨a⋄(⊂⍬),∪/a}
```
test:
```
  f←{∨/c←×b←⌊2÷⍨≢¨a←a⊂⍨1+a←⍵[⍋⍵]:(⊂c/b,¨∪¨a),⊂∪⊃∪/a/⍨0≠2∣≢¨a⋄(⊂⍬),∪/a}
  ⎕fmt f 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
┌2─────────────────────────────────────┐
│┌4──────────────────────────┐ ┌3─────┐│
││┌2───┐ ┌2───┐ ┌2───┐ ┌2───┐│ │ 1 3 5││
│││ 1 2│ │ 1 3│ │ 2 4│ │ 2 5││ └~─────┘│
││└~───┘ └~───┘ └~───┘ └~───┘2         │
│└∊──────────────────────────┘         3
└∊─────────────────────────────────────┘
  ⎕fmt f 1 2 1 2
┌2───────────────────┐
│┌2────────────┐ ┌0─┐│
││┌2───┐ ┌2───┐│ │ 0││
│││ 1 1│ │ 1 2││ └~─┘│
││└~───┘ └~───┘2     │
│└∊────────────┘     3
└∊───────────────────┘
  ⎕fmt f 1 2 3
┌2────────────┐
│┌0─┐ ┌3─────┐│
││ 0│ │ 1 2 3││
│└~─┘ └~─────┘2
└∊────────────┘
  ⎕fmt f ⍬
┌2────────┐
│┌0─┐ ┌0─┐│
││ 0│ │ 0││
│└~─┘ └~─┘2
└∊────────┘
```
but if it not be "codegolf" i would write for question of readability this 93 bytes code:
```
c←{+/⍵=⍺}⋄f←{0=≢a←⍵:⍬⍬⋄(⊂{×≢b←({0≠⌊2÷⍨⍵c a}¨b)/b←∪⍵:b,¨{⌊2÷⍨⍵c a}¨b⋄⍬}⍵),⊂∪({0≠2∣⍵c a}¨a)/a}
```
because `({0≠⌊2÷⍨⍵c a}¨b)/b` or exprestion as that has to be idiomatic...
`g(f¨b)/b` traslate the math set `{g(x):x∊b∧f(x)}`.
[Answer]
# [K4](https://kx.com/download), ~~27~~ 25 bytes
**Solution:**
```
(,#:'=&_p),,&p>_p:.5*#:'=
```
**Example:**
```
q)k)(,#:'=&_p),,&p>_p:.5*#:'=1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
2 3 4 5!1 1 2 2
1 3 5
// this is how a dictionary looks in the repl
q)k)*(,#:'=&_p),,&p>_p:.5*#:'=1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
2| 1
3| 1
4| 2
5| 2
```
**Explanation:**
```
(,#:'=&_p),,&p>_p:.5*#:'= / the solution
                        = / group input
                     #:'  / count (#:) each
                  .5*     / half (ie pair up)
                p:        / save as p
               _          / floor
             p>           / p > floor p? ie find whole pairs
            &             / where true
           ,              / enlist
          ,               / join
(        )                / do all this together
       _p                 / floor p
      &                   / where
     =                    / group
  #:'                     / count (#:) each
 ,                        / enlist
```
**Extra:**
* **-2 bytes** thanks to ngn
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 155 154 151 bytes
Thanks to ceilingcat for the suggestion.
I use `-1` as the sentinel value for the list. First, I count the length of the input list, then I increment a count array at the index pointed into from the input. Lastly, I print the pairs in `type:number of pairs` format, then any singles remaining.
I initialize `c` to zero even though it's a global because it won't necessarily be zero at the end of the function and I need to have it set correctly at the start of the function. I also use a dynamically-allocated count array so that it will be zero-initialized.
```
d,c,*a;f(int*i){for(c=0;~i[c++];);for(a=calloc(d=c,4);d--;a[i[d]]++);for(d=c;d--;)a[d]&&printf("%d:%d\t",d,a[d]/2);for(;c--;)a[c]%2&&printf("%d\t",c);}
```
[Try it online!](https://tio.run/##dVJfb4IwEH/nUzQuGgplo4iC69gnMHvbE/JA2uFqGBjF7cGwjz7W9kQlUXJJr78/d9dS7q057zpBOHFyVtiyahyJj0W9s3nis1@ZctfNGGYayROel2XNbZFwEmImPI/lqUxFlrkuSBRjYJwrdDLZ7lTBwh6NxfNYrJoREUQTTwGoGQcpz8bBtVgrOWZt9yArXh7EB3rZN0LWj5@vlqVE6CuXlf1dS4HR0UJIQ45Ms0RvENKnSDN8pAQFJqZ9hFcxG4ZHWzJwn31zgnzjWBBEzTZSCTUcBYnyU2ilYOqfM5hAizStCQpN@i8ytf0TH5jqJ8ccDBd6ZrKgP4hvkLifaQFjaW1o1kGf2LhiI4thXmoMiz4iMIamQwybKcjMbCFIeghmiHSpQSMK851ccM1aHFyWEOi@klHFN34A7a8xuEtObzBn4O19uVRJS5DjbJilUv3mNolkSO3R9tDs7dGq8u58I4xRYTsb/bSttvvjRZmv95338w8 "C (gcc) – Try It Online")
[Answer]
# [Zsh](https://www.zsh.org/), ~~81~~ 74 bytes
*-3 bytes by testing set difference in arithmetic mode instead, -4 bytes by using `local` instead of `typeset`*
```
local -A p
for x;a=(${a:#$x} ${x:|a})&&((${#x:|a}&&++p[$x]))
local p
<<<$a
```
~~[Try it online!](https://tio.run/##qyrO@J@moanxv6SyILU4tURB11GhgCstv0ihwjrRVkOlOtFKWaWiVkGlusKqJrFWU00tGsZWiFVT09DQ1i6IVqmI1dTkgplQwGVjY6OS@F@TiytNwRAIjYDQGAxNoNAUBv8DAA "Zsh – Try It Online")~~
[Try it online!](https://tio.run/##qyrO@J@moanxPyc/OTFHQddRoYArLb9IocI60VZDpTrRSlmlolZBpbrCqiaxVlNNTQMoqAzmqKlpaxdEq1TEampyQTQXcNnY2Kgk/tfk4kpTMARCIyA0BkMTKDSFwf8A "Zsh – Try It Online")
The expansion `a=(${a:#$x} ${x:|a})` puts `$x` in `$a` if it isn't there, and takes it out if it is. Then we check if `$x` just got removed, and increment our pair count if it was.
---
With a looser definition of "list", we can shave this quite a bit.
# [Zsh](https://www.zsh.org/), ~~56~~ 52 bytes
```
local -A p l
for x;((p[$x]+=1^(l[$x]^=1)))
local p l
```
~~[Try it online!](https://tio.run/##qyrO@J@moanxv6SyILU4tURB11GhQCGHKy2/SKHCWkOjIFqlIlbb1jBOIwfEirM11NTU5IIpBqr8r8nFlaZgCIRGQGgMhiZQaAqD/wE "Zsh – Try It Online")~~
[Try it online!](https://tio.run/##qyrO@J@moanxPyc/OTFHQddRoUAhhystv0ihwlpDoyBapSJW29YwTiMHxIqzNdTU1OSCKAWq@6/JxZWmYAiERkBoDIYmUGgKg/8B "Zsh – Try It Online")
Prints the leftover socks as all elements in an associative array with value `1`, not `0`.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 50 bytes
```
≔⦃⦄ηＦθ«Ｆ¬№υι«⊞υι§≔ηι⁰»§≔ηι⊕§ηι»ＩＥυ⟦ι÷§ηι²⟧ＩΦυ﹪§ηι²
```
[Try it online!](https://tio.run/##RY8xbsIwFIav4gN4iB2HOGdBDIilA1IlboBKhjJDxzLVUQtDxRIiMrm7cwdfIEdInfdjIj3p/e//P9vPq5flZvW6XA@Dfz948@bNztV9a9zNnkOzF7/76ErX2LPff5KoAuhq1/jtr71P0/5oq1HYe99@9@1XV/qTcc1f/bCv/lSFxJmu7JufaA7DfC45S6lmnCWcKc4KzgSNeRCCMgEkCyrwkgCRPJWAShGPgaDTCRV5km58UDNAU5yRwiqKdHB03KPAKiOr0DWRmiKNvfBiESsHrOhWjSEFRvsoINHCu/nziyk@JsnOAMipKcTxNFF6sfgH "Charcoal – Try It Online") Unfortunately I don't know how to get the deverbosifier to output `⦃⦄` (I just get `«»` when I try). Explanation:
```
≔⦃⦄η
```
Initialise a dictionary.
```
Ｆθ«
```
Loop over the socks.
```
Ｆ¬№υι
```
Test whether the compatibility number has been seen before. (Sadly Charcoal has no functions for determining dictionary keys, so I have to use a parallel list.)
```
«⊞υι§≔ηι⁰»
```
If it hasn't been seen then push the number to the list and zero out its dictionary entry.
```
§≔ηι⊕§ηι»
```
Increment the dictionary entry.
```
ＩＥυ⟦ι÷§ηι²⟧
```
Output the number of pairs for each compatibility number. The compatibility number and number of pairs are output on separate lines, with each pair of numbers double-spaced.
```
ＩΦυ﹪§ηι²
```
Output those compatibility numbers with odd socks, each on their own line.
52 bytes for a deverbosifier-friendly version:
```
Ｆθ«≔Φυ⁼ι§κ⁰η¿η≔⊟ηη«≔⟦ι⁰⟧η⊞υη»ＵＭη⁺κλ»ＩＥυＥι÷λ⊕μＩΦυ﹪⊟ι²
```
[Try it online!](https://tio.run/##TY9Na8MwDIbPya/Q0QYP8tmm9FS6DXoo5B56CI27mDlJGydlMPrbM1tK2hmDJb2PpNfnuuzPXamn6dL1wG4cfn1vZ4z6atmn0oPs2Sjg4zaW2jAlYDcc2kr@sG8BAedcQM23vqcuwGoOc1/eXW02S1Ib6WYuQws7JDjNopePpnYLMHv43rG87rumKduK1QJyPRq3SXMrP/y8V@3A9qUZmOVcm3vsvEM7vKu7qiTTLjn3spHtICvWcDzb/62vXx27atQd2lXWboToNBVFJCDGu7JeBSQCNgJCTNc2CFELCUltZPkIgTB4RiFFMclOCLE7wIu1CCfO1Iqgl5xiRFYSjG0lW3xsyIpjE3ozJDOUMvJFGzfLXROc4NSMkpgw9JMQspRo7/r5xZg@FmE5JSB6PQnJSzdS2ek0vd31Hw "Charcoal – Try It Online") Link is to verbose version of code. Outputs the odd sock compatibility numbers double-spaced.
56 bytes for the original (IMHO better) condition that disallows printing zero pairs of socks:
```
Ｆθ«≔Φυ⁼ι§κ⁰η¿η≔⊟ηη«≔⟦ι⁰⟧η⊞υη»ＵＭη⁺κλ»ＩΦＥυＥι÷λ⊕μ§ι¹ＩΦυ﹪⊟ι²
```
[Try it online!](https://tio.run/##bY9Na8MwDIbPya/w0QYP8tU2pafSbdDDIPfSQ2jcxsxJ2jgpg9HfnslS3F4GBkt6H72STnXZn7rSTNO56xm/CfYbBltr9aXln9oMquejZB@3sTSWa8m2w76t1A//liwSQkhWi00Y6DPjtWBzX9FdIZslZaxynt70ACbRcRaDYrS1G4DZIwy@yuuua5qyrXgtWWFG6yYZAfIjLHrdDnxX2sGvBrjrdh/Y7tvhXd91pbhxyalXjWoHVfFG4Kp@d0BjV9n84@jcumo0HV6hoStBdJoOh0SyFN8STpAsk2wNTpiuIIhRiwlZQAR8gkAcPaOYopRkJ8TYHeHDWoKOM7Uk6CUvMKJVMoyhkvs91rSKYzP6cyRzlHLaiyau/VsRnKFrTklKGO6TEeJLNHf1PDGlwxIsLwhIXl9Gsu9GKj8ep7e7@QM "Charcoal – Try It Online") Link is to verbose version of code.
Would be 43 bytes if Charcoal supported dictionary iteration:
```
≔⦃⦄ηＦθ§≔ηι∨⬤η⁻ιλ⊕§ηιＩΦＥη⟦κ÷ι²⟧§ι¹ＩΦＥηκ﹪§ηι²
```
[Answer]
# [Haskell](https://www.haskell.org/), 112 bytes
```
import Data.List
f i=(\j->([(x,l`div`2)|(x,l)<-j,l>1],[x|(x,l)<-j,l`mod`2>0]))[(x,length s+1)|x:s<-group.sort$i]
```
[Try it online!](https://tio.run/##hZDJboMwEIbveYo59ACqQdiQYKqEU4/tE1BUkLI5ZRPQikPeneKZmuQSao3k8fzfbD7n3dehKMZRlU3d9vCa97n7prp@dQS1sz4uTmwl1sCKbK9@MmFftW9vnQsrYp6yZLgLZGW9z0TspbaNKYfq1J@he@b2dXjpts6prb8bt5vaPKl0LHNVwQ7KvHn/BKtpVdWDC0cbkoQzEGi@seDO1veWruDRYclcYcPAw9yIAcdnODkcNU7IVIxT0ynMvdmjWTSkZS1wzPbQMCaw4h@1Iegmr9ETZg0PI9LMEdEomg3olkhKlCTNRR0jYyHBAVaV9PAJw3kCQkyI@obzij4tJsxnakDcroBkk42UXPxmbj5L/IMJ5i8SC2I6/gI "Haskell – Try It Online")
[Answer]
# [Japt](https://github.com/ETHproductions/japt) [`-Q`](https://codegolf.meta.stackexchange.com/a/14339/), 16 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
ü
lu mÎuUmÎíUËÊz
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LVE&code=/ApsdSBtznVVbc7tVcvKeg&input=IFsyLDIsMiwyLDEsM10)
Better solution that pairs list of first elements with list of lengths/2 using **í** instead of **â**.
# [Japt](https://github.com/ETHproductions/japt) [`-Q`](https://codegolf.meta.stackexchange.com/a/14339/), ~~14~~ 16 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
ü
lu mÎuUËâDÊz h
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LVE&code=/ApsdSBtznVVy%2bJEynogaA&input=IFsyLDIsMiwyLDEsM10)
output [sock , pairs num] list followed by odd socks.
```
ü            // sort and group input and save it
lu mÎ        // first element of groups of odd length
     u       // perpended by..
      UË     // imput mapped
        â    // unique elements
         DÊz h // concatenated to half of the length to string 
```
Thanks to @Shaggy for finding a bug.
Unfortunately using **â(x?)** => **x** is concatenated *before* returning unique elements , so it failed with *[2,2,2,2]* case. 
Fixed by using **h** method which returns a string.
[Answer]
# [Lua](https://www.lua.org/), ~~144~~ 142 bytes
```
load'r,p,o,i={},{},{},...for a=1,#i do r[i[a]]=(r[i[a]]or 0)+1 end;for a,b in pairs(r)do p[a],o[#o+1]=b//2,(b%2>0)and a or nil end;return p,o'
```
[Try it online!](https://tio.run/##RZHRqsIwDIbvfYqAHGwxzHWbOjnsvIh40Z1NKI51dNu5EZ/dkyZOIdA0/5f2b9PN9tn5X9vBFSqw49iGSVHFNpuAA3p01f2BEkmSXH0AWxlcO2g8hLM728ulUq@ExFRvDbR9880k1uB6GKwLowqaOgbC0J/XfmsuVb3bZajqr@wn1bZvwAL19K7j/tBOc6Be9JunXq3EoyOP9wwh5zggpAgFwgnB8PZIiWHNCLKnjPiMAZO@MyNZLnIUDHenHFzL@MQXdRDoI@85EysF51QpFx8nsRLZQtaSyZKlUnzJjacljgIXfGopm1ww9lMIspTk3uP7ibk8LOPyXoDssxQiL91MlY/lXwcbRgQ/TyN98FU5@vA4vxv@feYXGR2nPgTXT4o0HQe1ku1k665N5n6wvzcVD9L6@Q8 "Lua – Try It Online")
Function that takes list as argument and returns hashtable representing pairs and list of ones without match using Lua "multireturn".
Note: if there is only one sock of some color (poor guy), it still will go in pairs list with zero pairs. If this is not up to spec, please tell me (it will cost a bunch of bytes but is easily doable).
I personally consider `return` to be required, but results are also stored in globals `p` and `o`, so it in fact can be omitted.
[Answer]
# [Perl 5](https://www.perl.org/), 82 bytes
```
sub{my%H;$H{$_}++for@_;delete@H{@A=grep$H{$_}%2,keys%H};map$_/=2,values%H;\%H,\@A}
```
[Try it online!](https://tio.run/##dY9da4MwFIbv9yt2odDSU2ZirLHisNALb/YPCmJZHGVagx@DIv71uXMSe@d4ITl5n/ORo1VbBbNTJnM3XMf64Waxk41OPu12ZdOmefypKtWrNBvTU/LVKm2py@FbPTo3m@K60E7@lnD4KapBoRVf3Awu6Wma4xfd3u7963motWo3Trl/3zDgKN9ILAqe2m7XSmz6ATxMjYBhFAJjaDHyA2DUkQHz7EUTkKCLDsNcD0UvjpUGHYgsbgCe@Y/AOwBp2kc0AKmgUyKUaEmaRO0io5CwwFJJgU@IZggC9kU9Q/s9HwylTdHmyyGAPXMRyfXlzTbA/4f@OkJ3/m10f2vu3bz/OBd9cTzahD8 "Perl 5 – Try It Online")
# (`-ap`), 73 bytes
Returning hash as key value pairs list
```
s/(\b\d+)( .*)(\b\1\b)/$H{$1}++;$2/e&&redo;delete@H{@F};$_="@{[%H]} | @F"
```
[Try it online!](https://tio.run/##NY/dioMwEIXvfYqhpMVUVh2NNSIuXhXfYV2WLWahIDW0vXN99c3ORMuBzOR885NYcx8Ld/0JRfwurJz3XRPKWthGxIt7JGF/6YdIhhAfJefYX2QiulngEkW1yBJzONzNMNWDGc3TtN3cnpdafDW7dv7Yd58L/EJ73jmHkJFyL7WpeClYyQlScitAykpAJAvZLwC5GQHTNfAwIuSSg1SbkviWUadHJyabW0DqVyuKBWg/vuIFRBWfmqAmS/MmHld5lYwVtWpOcka8QzFYbzyzXJ@Xg6f8KbKz7VCAr1pCOvAPh8zHPAj@Jvu8TreHe/se7T8 "Perl 5 – Try It Online")
[Answer]
# [Lua](https://www.lua.org/), ~~133~~ ~~123~~ 119 bytes (using global output var)
```
r,o,s={},{},{}for _=1,#t do d=t[_]r[d]=(r[d]or 0)+.5 end for a,b in pairs(r)do s[a],d=math.modf(b)o[#o+1]=d>0 and a end
```
[Try it online!](https://tio.run/##jZLNasMwDMfvfQrhXmJqQpyPNh24r7DdsxDSOaaBNh6Jyw6lz5450tIw6GCgxLL0k/U38vlaj@bafbjWdmACx8deWDGo212gGdtDpaRYO9AWtHJFVfaFLlUw/X0y4pswg6bTMKG1OELbwWfd9kPQc18yFHUptLrU7hRerDbBkdtibTeyVPoQQe0L66l89N/KBLdYQIK2FRAJSAXsBUjc7rwjMScJybzn@RgBGT08SV5C6SkhsTpCw1iMJ/5QW4KWdIYeSUnR95F81rEnKROb0pojmWMqJ13UcT/bjuAUT81pkxCGelJC5hD13T2umNDFYgxnBMTLklJ6rkYqv/OV8WNwyvXXZtXa8KtvXROwt2k4L3BjHIcrqmoZ2cCnMT/YAA/AITEGnmYCGA/DKgyZOjDvVByoianPQ4PvYOl0f@/YHyJetfYaimcaLGkw4IPu1HT/kPNExW8lJePjNw "Lua – Try It Online")
# [Lua](https://www.lua.org/), 135 bytes (using output return)
```
r,o,s={},{},{}for _=1,#t do d=t[_]r[d]=(r[d]or 0)+.5 end for a,b in pairs(r)do s[a],d=math.modf(b)o[#o+1]=d>0 and a or x end return o,s
```
[Try it online!](https://tio.run/##jVJNa8MwDL33Vwj3EjM35LNNB@5hfyCDHrMQ3DlhgTYprsM2Sn9750hLeyljIJJnvSfpGXk/qGszdO@27TtoPMuvRvTiJM8XgdH0BioZirkF3YOWtqhKU@hSeuPXkQF/8lOoOw2jVIkdtB0cVWtOnuGu5FSoUmh5UPbDP/S68Xa8L@b9U1hKvQlAuUIFrvILe5jaDqYD5@DqjrNcbGXjnSMBMcZSQCAgEbAWEOJx5UCIXEiS1CGnj1AQBjcUEoqJHokQqwMMzEXY8Ve1JNGdThGRlQSxy2STjzVZGbUJ/TNUZkhl5IsmrqdYkTjBrhkdYpKhn4QkU4rmrm5XjOliEaZTEkT3X0L0VI2q7MJni8VLrQbbNt@QD/Y42FnjlmWlNUM9a3v/07S29tjruMJnODOOT0BU1X2xWz4@hpvWwwa4SsbGXTIBjPt@5ftMbpgDFQca0qj9qcZN3ydd3jrGH5vItXYeikce8n96@HN0yfj1Bw "Lua – Try It Online")
[Answer]
# [Clojure](https://clojure.org/), 102 bytes
```
(fn[d](def f(frequencies d))[(map(fn[[x y]][x(quot y 2)])f)(map first(filter #(=(mod(nth % 1)2)1)f))])
```
[Try it online!](https://tio.run/##hZDRisIwEEXf/YrBZSGBLjRp1XZhv2H3PeSh2gQrNdXagn59N5nZVIUFYSDJvSd3Jtm13WHszcRqY2E/MetUrfFgme3NeTRu15gL1JwrdqxOAVBXuGmtruw8dgPcQHLNLQ8u2Ka/DMw27WB6eGNf7NjVzA17eAfBJRee8/DEF6GFg1PfuOGjN5exHUCpCrZaLwAY6q2D5U/lAz9hCRV/0r/rGuUt91FPKWwPSiQgsbJY@UOtHkvPAa37L2oOWSeQ4vUyAYHHjd8I9AQhPk9QXy@LdN7ROAEKdjAE3k6xUJOY@EetCbrbK9zJ@JIUlSLOUdIogc1pLZAs0CpoLupYxtoQnGNqQYeMMJwnJyRK1HczPzGjh8n4nwGQ9yUnO95Gqnj10yL@l3xNyiR7BXl/@gU "Clojure – Try It Online")
I really thought clojure would have a better chance. If only I had access to fmap. :-(
[Answer]
As suggested by JoKing this can be substantially shortend to:
# [Ruby](https://www.ruby-lang.org/), 90 bytes
```
c=Hash.new(0)
ARGV.each{|s|c[s.to_i]+=1}
c.each{|k,v|p k if(p"#{k}=>#{v/2}"if v>1)&&v%2>0}
```
[Try it online!](https://tio.run/##KypNqvz/P9nWI7E4Qy8vtVzDQJPLMcg9TC81MTmjuqa4Jjm6WK8kPz4zVtvWsJYrGSqerVNWU6CQrZCZplGgpFydXWtrp1xdpm9Uq5SZplBmZ6ipplamamRnUPv//3/D/0ZAaAyGJlBoCoMA "Ruby – Try It Online")
Old version:
# [Ruby](https://www.ruby-lang.org/), 139 bytes
```
c=Hash.new(0)
ARGV[0].split(",").map(&:to_i).each{|s|c[s]+=1}
o = []
c.each{|k,v|o<<k if v.odd?}
c.each{|k,v|o<<"#{k}=>#{v/2}" if v!=1}
p o
```
[Try it online!](https://tio.run/##KypNqvz/P9nWI7E4Qy8vtVzDQJPLMcg9LNogVq@4ICezRENJR0lTLzexQEPNqiQ/PlNTLzUxOaO6prgmObo4VtvWsJYrX8FWITqWKxkqk61TVpNvY5OtkJmmUKaXn5JiX4sup6RcnV1ra6dcXaZvVKsEVqgIMqlAIf////9KhjoKRmBkDEMmSMgUGSkBAA "Ruby – Try It Online")
Pardon me for writing non-idiomatic Ruby maybe.
]