import sys

PY2 = sys.version_info[0] == 2

_identity = lambda x: x


if not PY2:
    text_type = str
    string_types = (str,)
    integer_types = (int, )
    unichr = chr

    text_to_native = lambda s, enc: s

    iterkeys = lambda d: iter(d.keys())
    itervalues = lambda d: iter(d.values())
    iteritems = lambda d: iter(d.items())

    from io import StringIO, BytesIO
    import pickle
    import configparser

    izip = zip
    imap = map
    range_type = range

    cmp = lambda a, b: (a > b) - (a < b)

    input = input
    from string import ascii_lowercase
    import urllib.parse as urllib
    import urllib.parse as urlparse
    from urllib.request import urlretrieve

    console_encoding = sys.__stdout__.encoding

    def console_to_str(s):
        """ From pypa/pip project, pip.backwardwardcompat. License MIT. """
        try:
            return s.decode(console_encoding)
        except UnicodeDecodeError:
            return s.decode('utf_8')

    def reraise(tp, value, tb=None):
        if value.__traceback__ is not tb:
            raise(value.with_traceback(tb))
        raise value

else:
    text_type = unicode
    string_types = (str, unicode)
    integer_types = (int, long)
    from urllib import urlretrieve

    text_to_native = lambda s, enc: s.encode(enc)
    unichr = unichr

    iterkeys = lambda d: d.iterkeys()
    itervalues = lambda d: d.itervalues()
    iteritems = lambda d: d.iteritems()

    from cStringIO import StringIO as BytesIO
    from StringIO import StringIO
    import cPickle as pickle
    import ConfigParser as configparser

    from itertools import izip, imap
    range_type = xrange

    cmp = cmp

    input = raw_input
    from string import lower as ascii_lowercase
    import urlparse

    def console_to_str(s):
        return s.decode('utf_8')

    exec('def reraise(tp, value, tb=None):\n raise(tp, value, tb)')


number_types = integer_types + (float,)

@@ -70,17 +70,33 @@
 %0Aif 
-not 
 PY2:%0A
+    unichr = unichr%0A
     
@@ -107,19 +107,23 @@
 _type = 
-str
+unicode
 %0A    str
@@ -139,16 +139,24 @@
  = (str,
+ unicode
 )%0A    in
@@ -179,26 +179,765 @@
 nt, 
+long
 )%0A    
-unichr = chr
+from urllib import urlretrieve%0A%0A    text_to_native = lambda s, enc: s.encode(enc)%0A%0A    iterkeys = lambda d: d.iterkeys()%0A    itervalues = lambda d: d.itervalues()%0A    iteritems = lambda d: d.iteritems()%0A%0A    from cStringIO import StringIO as BytesIO%0A    from StringIO import StringIO%0A    import cPickle as pickle%0A    import ConfigParser as configparser%0A%0A    from itertools import izip, imap%0A    range_type = xrange%0A%0A    cmp = cmp%0A%0A    input = raw_input%0A    from string import lower as ascii_lowercase%0A    import urlparse%0A%0A    def console_to_str(s):%0A        return s.decode('utf_8')%0A%0A    exec('def reraise(tp, value, tb=None):%5Cn raise tp, value, tb')%0A%0Aelse:%0A    unichr = chr%0A    text_type = str%0A    string_types = (str,)%0A    integer_types = (int, )
 %0A%0A  
@@ -1878,780 +1878,8 @@
 ue%0A%0A
-else:%0A    text_type = unicode%0A    string_types = (str, unicode)%0A    integer_types = (int, long)%0A    from urllib import urlretrieve%0A%0A    text_to_native = lambda s, enc: s.encode(enc)%0A    unichr = unichr%0A%0A    iterkeys = lambda d: d.iterkeys()%0A    itervalues = lambda d: d.itervalues()%0A    iteritems = lambda d: d.iteritems()%0A%0A    from cStringIO import StringIO as BytesIO%0A    from StringIO import StringIO%0A    import cPickle as pickle%0A    import ConfigParser as configparser%0A%0A    from itertools import izip, imap%0A    range_type = xrange%0A%0A    cmp = cmp%0A%0A    input = raw_input%0A    from string import lower as ascii_lowercase%0A    import urlparse%0A%0A    def console_to_str(s):%0A        return s.decode('utf_8')%0A%0A    exec('def reraise(tp, value, tb=None):%5Cn raise(tp, value, tb)')%0A%0A
 %0Anum

Move if PY2 to top, remove parens in reraise exec/eval for py2, causing errors.