SELECT
    position, count(1) AS n
  FROM (
    SELECT
        position, row_number() OVER (PARTITION BY position) rn
      FROM tbl
  ) t
  GROUP BY position, (rn+1) div 2
;# ----------------------------------------------------------------------
# Expires headers (for better cache control)
# ----------------------------------------------------------------------
# These are pretty far-future expires headers.
# They assume you control versioning with filename-based cache busting
# Additionally, consider that outdated proxies may miscache
# www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/
# If you don't use filenames to version, lower the CSS and JS to something like
# "access plus 1 week".
<IfModule mod_expires.c>
  ExpiresActive on
# Your document html
  ExpiresByType text/html "access plus 0 seconds"
# Media: images, video, audio
  ExpiresByType audio/ogg "access plus 1 month"
  ExpiresByType image/gif "access plus 1 month"
  ExpiresByType image/jpeg "access plus 1 month"
  ExpiresByType image/png "access plus 1 month"
  ExpiresByType video/mp4 "access plus 1 month"
  ExpiresByType video/ogg "access plus 1 month"
  ExpiresByType video/webm "access plus 1 month"
# CSS and JavaScript
  ExpiresByType application/javascript "access plus 1 year"
  ExpiresByType text/css "access plus 1 year"
</IfModule>class CombinationsCalculator
{
    protected $result;
    protected $combination;
    public function getCombinations($array, $group) {
        $this->result = [];
        $this->combination = [];
        $this->iteration(0, $group, $array, count($array));
        return $this->result;
    }
    protected function iteration($start, $step, $array, $n) {
        if ($step == 0) {
            array_push($this->result,$this->combination);
        }
        else {
            for ($i = $start; $i <= $n - $step; ++$i) {
                array_push($this->combination, $array[$i]);
                $this->iteration($i + 1, $step - 1, $array, $n);
                array_pop($this->combination);
            }
        }
    }
}
$calculator = new CombinationsCalculator();
$result = $calculator->getCombinations([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], 8); 
  
  +) нужно прогонять через urlencode и только потом подставлять туда. В вашем случае должно быть так: http://example.com?d=AAEBAf0GAe0%2BAgAA($dec >> 8) << 7 теряет нижние 8 бит и сдвигает на один вправо.$dec % 128 оставляет нижние 7 бит.(($res & ~0x7F) << 1) | ($res & 0x7F) и, возможно, | 0x80.((585 & ~0x7F) << 1) | (585 & 0x7F) | 0x80 = 1225.