Problem p03283 (python)

Fixed submission:
N,M,Q = map(int,input().split())

Section = [[0]*N for _ in range(N)]
for _ in range(M):
    L,R = map(int,input().split())
    Section[L-1][R-1] += 1

Sum = [[0]*(N+1) for _ in range(N+1)]
for i in range(N):
    for j in range(N):
        Sum[i+1][j+1] = Sum[i][j+1]+Sum[i+1][j]-Sum[i][j]+Section[i][j]

Ans = [[0]*N for _ in range(N)]
for i in range(N):
    for j in range(i,N):
        Ans[i][j] = Sum[j+1][j+1]-Sum[i][j+1]

for _ in range(Q):
    p,q = map(int,input().split())
    print(Ans[p-1][q-1])

Buggy submission (verdict: Runtime Error):
import sys
s = sys.stdin.readlines()
N,M,Q = map(int,s[0].split())

Section = [[0]*N for _ in range(N)]
for L,R in (map(int, e.split()) for e in s[1:M+1):
    Section[L-1][R-1] += 1

Sum = [[0]*(N+1) for _ in range(N+1)]
for i in range(N):
    for j in range(N):
        Sum[i+1][j+1] = Sum[i][j+1]+Sum[i+1][j]-Sum[i][j]+Section[i][j]

Ans = [[0]*N for _ in range(N)]
for i in range(N):
    for j in range(i,N):
        Ans[i][j] = Sum[j+1][j+1]-Sum[i][j+1]

for p,q in (map(int, e.split()) for e in s[M+1:]
    print(Ans[p-1][q-1])

Buggy submission (verdict: Runtime Error):
Last login: Fri Aug 10 20:02:16 on ttys001
MacBook-Pro-29:~ lisbun$ ls
Desktop		Dropbox		Music		homework.txt	tmp
Documents	Library		Pictures	sample
Downloads	Movies		Public		tcpip
MacBook-Pro-29:~ lisbun$ cd tmp/python/
MacBook-Pro-29:python lisbun$ ls
practice001.py	practice003.py	practice005.py	practice007.py	practice009.py
practice002.py	practice004.py	practice006.py	practice008.py
MacBook-Pro-29:python lisbun$ vim test.py
MacBook-Pro-29:python lisbun$ python test.py
Traceback (most recent call last):
  File "test.py", line 1, in <module>
    from Crypto.Util.number import *
ImportError: No module named Crypto.Util.number
MacBook-Pro-29:python lisbun$ 
MacBook-Pro-29:python lisbun$ 
MacBook-Pro-29:python lisbun$ ls
practice001.py	practice003.py	practice005.py	practice007.py	practice009.py
practice002.py	practice004.py	practice006.py	practice008.py	test.py
MacBook-Pro-29:python lisbun$ nvim
MacBook-Pro-29:python lisbun$ ls
practice001.py	practice003.py	practice005.py	practice007.py	practice009.py
practice002.py	practice004.py	practice006.py	practice008.py	test.py
MacBook-Pro-29:python lisbun$ nvim practice010.py
MacBook-Pro-29:python lisbun$ nvim func-animal-speed.py
MacBook-Pro-29:python lisbun$ python3 func-animal-speed.py 
+--------+------+------+------+
|動物名前|名古屋|大　阪|靜　岡|
+--------+------+------+------+
Traceback (most recent call last):
  File "func-animal-speed.py", line 35, in <module>
    s = calc_animal(animal, speed)
  File "func-animal-speed.py", line 21, in calc_animal
    for city in sorted(distance_dict.value()):
AttributeError: 'dict' object has no attribute 'value'
MacBook-Pro-29:python lisbun$ nvim func-animal-speed.py
MacBook-Pro-29:python lisbun$ python3 func-animal-speed.py 
+--------+------+------+------+
|動物名前|名古屋|大　阪|靜　岡|
+--------+------+------+------+
Traceback (most recent call last):
  File "func-animal-speed.py", line 35, in <module>
    s = calc_animal(animal, speed)
  File "func-animal-speed.py", line 22, in calc_animal
    dist = distance_dict[city]
KeyError: 183.7
MacBook-Pro-29:python lisbun$ nvim func-animal-speed.py
MacBook-Pro-29:python lisbun$ python3 func-animal-speed.py 
+--------+------+------+------+
|動物名前|名古屋|大　阪|靜　岡|
+--------+------+------+------+
|チーター|   1.7|   3.2|   4.6|
|トナカイ|   2.3|   4.4|   6.3|
|シマウマ|   3.1|   5.8|   8.5|
|ライオン|   3.2|   6.0|   8.8|
|キ リ ン|   3.7|   7.0|  10.2|
|ラ ク ダ|   6.1|  11.7|  16.9|
+--------+------+------+------+
MacBook-Pro-29:python lisbun$ nvim func-animal-speed.py
MacBook-Pro-29:python lisbun$ python3 func-animal-speed.py 
  File "func-animal-speed.py", line 21
    for city in sorted(distance_dict.keys(),key=x:x[x.keys]):
                                                 ^
SyntaxError: invalid syntax
MacBook-Pro-29:python lisbun$ nvim func-animal-speed.py
MacBook-Pro-29:python lisbun$ python3 func-animal-speed.py 
+--------+------+------+------+
|動物名前|名古屋|大　阪|靜　岡|
+--------+------+------+------+
Traceback (most recent call last):
  File "func-animal-speed.py", line 35, in <module>
    s = calc_animal(animal, speed)
  File "func-animal-speed.py", line 21, in calc_animal
    for city in sorted(distance_dict.keys(),key=lambda x:x[x.keys]):
  File "func-animal-speed.py", line 21, in <lambda>
    for city in sorted(distance_dict.keys(),key=lambda x:x[x.keys]):
AttributeError: 'str' object has no attribute 'keys'
MacBook-Pro-29:python lisbun$ nvim func-animal-speed.py
MacBook-Pro-29:python lisbun$ python3 func-animal-speed.py 
+--------+------+------+------+
|動物名前|名古屋|大　阪|靜　岡|
+--------+------+------+------+
|チーター|   1.7|   3.2|   4.6|
|トナカイ|   2.3|   4.4|   6.3|
|シマウマ|   3.1|   5.8|   8.5|
|ライオン|   3.2|   6.0|   8.8|
|キ リ ン|   3.7|   7.0|  10.2|
|ラ ク ダ|   6.1|  11.7|  16.9|
+--------+------+------+------+
MacBook-Pro-29:python lisbun$ nvim func-animal-speed.py
MacBook-Pro-29:python lisbun$ python3 func-animal-speed.py 
+--------+------+------+------+
|動物名前|靜　岡|名古屋|大　阪|
+--------+------+------+------+
|チーター|   1.7|   3.2|   4.6|
|トナカイ|   2.3|   4.4|   6.3|
|シマウマ|   3.1|   5.8|   8.5|
|ライオン|   3.2|   6.0|   8.8|
|キ リ ン|   3.7|   7.0|  10.2|
|ラ ク ダ|   6.1|  11.7|  16.9|
+--------+------+------+------+
MacBook-Pro-29:python lisbun$ nvim func-animal-speed.py
MacBook-Pro-29:python lisbun$ python3 func-animal-speed.py 
+--------+------+------+------+
|動物名前|靜　岡|名古屋|大　阪|
+--------+------+------+------+
|チーター|   1.7|   3.2|   4.6|
|トナカイ|   2.3|   4.4|   6.3|
|シマウマ|   3.1|   5.8|   8.5|
|ライオン|   3.2|   6.0|   8.8|
|キ リ ン|   3.7|   7.0|  10.2|
|ラ ク ダ|   6.1|  11.7|  16.9|
+--------+------+------+------+
MacBook-Pro-29:python lisbun$ nvim func-animal-speed.py
MacBook-Pro-29:python lisbun$ python3 func-animal-speed.py 
+--------+------+------+------+
|動物名前|靜　岡|名古屋|大　阪|
+--------+------+------+------+
|チーター|   1.7|   3.2|   4.6|
|トナカイ|   2.3|   4.4|   6.3|
|シマウマ|   3.1|   5.8|   8.5|
|ライオン|   3.2|   6.0|   8.8|
|キ リ ン|   3.7|   7.0|  10.2|
|ラ ク ダ|   6.1|  11.7|  16.9|
+--------+------+------+------+
MacBook-Pro-29:python lisbun$ ls
func-animal-speed.py	practice003.py		practice006.py		practice009.py
practice001.py		practice004.py		practice007.py		practice010.py
practice002.py		practice005.py		practice008.py		test.py
MacBook-Pro-29:python lisbun$ nvim practice010.py 
MacBook-Pro-29:python lisbun$ python3 practice010.py 
2 3 1
1 1
1 2
2 2
1 2
3
MacBook-Pro-29:python lisbun$ python3 practice010.py 
10 3 2
1 5
2 8
7 10
1 7
3 10
1
1
MacBook-Pro-29:python lisbun$ python3 practice010.py 
10 3 2
1 5
2 8
7 10
1 7
3 10
1
1
MacBook-Pro-29:python lisbun$ python3 practice010.py 
10 10 10
1 6
2 9
4 5
4 7
4 7
5 8
6 6
6 7
7 9
10 10
1 8
1 9
1 10
2 8
2 9
2 10
3 8
3 9
3 10
1 10
7
9
10
6
8
9
5
7
8
10
MacBook-Pro-29:python lisbun$ nvim practice010.py 
MacBook-Pro-29:python lisbun$ python3 practice010.py 
10 10 10
1 6
2 9
4 5
4 7
4 7
5 8
6 6
6 7
7 9
10 10
1 8
1 9
1 10
2 8
2 9
2 10
3 8
3 9
3 10
1 10
6
8
9
5
7
8
5
7
8
9
MacBook-Pro-29:python lisbun$ nvim practice010.py 
MacBook-Pro-29:python lisbun$ python3 practice010.py 
10 10 1 
1 6
2 9
4 5
4 7
4 7
5 8
6 6
6 7
7 9
10 10
3 8
5
MacBook-Pro-29:python lisbun$ 1 1 1
-bash: 1: command not found
MacBook-Pro-29:python lisbun$ python3 practice010.py 
1 1 1
5 8
Traceback (most recent call last):
  File "practice010.py", line 7, in <module>
    L[l-1] += 1
IndexError: list index out of range
MacBook-Pro-29:python lisbun$ python3 practice010.py 
10 1 1
5 8
3 8
1
MacBook-Pro-29:python lisbun$ 10 6 1
-bash: 10: command not found
MacBook-Pro-29:python lisbun$ python3 practice010.py 
10 6 1
4 5
4 7
4 7
5 8
6 6
6 7
3 8
6
MacBook-Pro-29:python lisbun$ nvim practice010.py 
MacBook-Pro-29:python lisbun$ python3 practice010.py 
2 3 1
1 1
1 2
2 2
1 2
2
MacBook-Pro-29:python lisbun$ nvim practice010.py 
MacBook-Pro-29:python lisbun$ python3 practice010.py 
2 3 1
1 1
1 2
2 2
1 2
3
MacBook-Pro-29:python lisbun$ python3 practice010.py 
10 3 2
1 5
2 8
7 10
1 7
3 10
1
1
MacBook-Pro-29:python lisbun$ python3 practice010.py 
10 10 10
1 6
2 9
4 5
4 7
4 7
5 8
6 6
6 7
7 9
10 10
1 8
1 9
1 10
2 8
2 9
2 10
3 8
3 9
3 10
1 10
7
9
10
6
8
9
6
7
8
10
MacBook-Pro-29:python lisbun$ nvim practice010.py 
MacBook-Pro-29:python lisbun$ python3
Python 3.7.0 (default, Jun 28 2018, 05:55:06) 
[Clang 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> try:
...                                                                                                        ... 
  File "<stdin>", line 3
    
    ^
IndentationError: expected an indented block
>>> 
>>> try:
... b=3/a
  File "<stdin>", line 2
    b=3/a
    ^
IndentationError: expected an indented block
>>> try:
...     b=3/a
...     print(b)
... except ZeroDivisionError as e:
...     print(e)
... 
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
NameError: name 'a' is not defined
>>> a = 0
>>> try:
...     b=3/a
...     print(b)
... except ZeroDivisionError as e:
...     print(e)
... 
division by zero
>>> quit()
MacBook-Pro-29:python lisbun$ ls
func-animal-speed.py	practice003.py		practice006.py		practice009.py
practice001.py		practice004.py		practice007.py		practice010.py
practice002.py		practice005.py		practice008.py		test.py
MacBook-Pro-29:python lisbun$ nvim practice010.py 
MacBook-Pro-29:python lisbun$ nvim practice010.py 
MacBook-Pro-29:python lisbun$ pip install pillow qrcode
Collecting pillow
  Downloading https://files.pythonhosted.org/packages/a8/56/0f2427d8df966e002fbb748d8537d8f037321b762997a6f05d24cb7334d7/Pillow-5.2.0-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (3.6MB)
    100% |████████████████████████████████| 3.6MB 3.0MB/s 
Collecting qrcode
  Downloading https://files.pythonhosted.org/packages/79/be/11999004f7e6e5db0fa410c2feacd67c07f472f4500fde0026101f31d0df/qrcode-6.0-py2.py3-none-any.whl
Collecting six (from qrcode)
  Using cached https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Installing collected packages: pillow, six, qrcode
Successfully installed pillow-5.2.0 qrcode-6.0 six-1.11.0
MacBook-Pro-29:python lisbun$ pip install -U pip
Requirement already up-to-date: pip in /usr/local/lib/python2.7/site-packages (18.0)
MacBook-Pro-29:python lisbun$ pip3 install pillow qrcode
Collecting pillow
  Downloading https://files.pythonhosted.org/packages/8d/50/362dc2580ae2539331768c0c3295730c791d79216c9a271114022e8c9895/Pillow-5.2.0-cp37-cp37m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (3.6MB)
    100% |████████████████████████████████| 3.6MB 5.9MB/s 
Collecting qrcode
  Using cached https://files.pythonhosted.org/packages/79/be/11999004f7e6e5db0fa410c2feacd67c07f472f4500fde0026101f31d0df/qrcode-6.0-py2.py3-none-any.whl
Requirement already satisfied: six in /usr/local/lib/python3.7/site-packages (from qrcode) (1.11.0)
Installing collected packages: pillow, qrcode
Successfully installed pillow-5.2.0 qrcode-6.0
MacBook-Pro-29:python lisbun$ pip3 install -U pip3
Collecting pip3
  Could not find a version that satisfies the requirement pip3 (from versions: )
No matching distribution found for pip3
MacBook-Pro-29:python lisbun$ ls
func-animal-speed.py	practice003.py		practice006.py		practice009.py
practice001.py		practice004.py		practice007.py		practice010.py
practice002.py		practice005.py		practice008.py		test.py
MacBook-Pro-29:python lisbun$ nvim practice011.py
MacBook-Pro-29:python lisbun$ python3 practice011.py 
Traceback (most recent call last):
  File "practice011.py", line 1, in <module>
    import qrcode
ModuleNotFoundError: No module named 'qrcode'
MacBook-Pro-29:python lisbun$ python3
Python 3.7.0 (default, Jun 28 2018, 05:55:06) 
[Clang 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import qrcode
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'qrcode'
>>> :q
  File "<stdin>", line 1
    :q
    ^
SyntaxError: invalid syntax
>>> pip3 install pillow qrcode
  File "<stdin>", line 1
    pip3 install pillow qrcode
               ^
SyntaxError: invalid syntax
>>> pip3 install pillow qrcode
  File "<stdin>", line 1
    pip3 install pillow qrcode
               ^
SyntaxError: invalid syntax
>>> quit()
MacBook-Pro-29:python lisbun$ pip3 install pillow qrcode
Requirement already satisfied: pillow in /usr/local/lib/python3.7/site-packages (5.2.0)
Requirement already satisfied: qrcode in /usr/local/lib/python3.7/site-packages (6.0)
Requirement already satisfied: six in /usr/local/lib/python3.7/site-packages (from qrcode) (1.11.0)
MacBook-Pro-29:python lisbun$ python3
Python 3.7.0 (default, Jun 28 2018, 05:55:06) 
[Clang 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import qrcode
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'qrcode'
>>> exit
Use exit() or Ctrl-D (i.e. EOF) to exit
>>> exit()
MacBook-Pro-29:python lisbun$ python3 practice011.py 
Traceback (most recent call last):
  File "practice011.py", line 1, in <module>
    import qrcode
ModuleNotFoundError: No module named 'qrcode'
MacBook-Pro-29:python lisbun$ nvim practice011.py
MacBook-Pro-29:python lisbun$ python3 practice011.py 
  File "practice011.py", line 1
    import pillow qrcode
                       ^
SyntaxError: invalid syntax
MacBook-Pro-29:python lisbun$ nvim practice011.py
MacBook-Pro-29:python lisbun$ python3 practice011.py 
Traceback (most recent call last):
  File "practice011.py", line 1, in <module>
    import pillow
ModuleNotFoundError: No module named 'pillow'
MacBook-Pro-29:python lisbun$ nvim practice011.py
MacBook-Pro-29:python lisbun$ python3 practice011.py 
Traceback (most recent call last):
  File "practice011.py", line 1, in <module>
    import qrcode
ModuleNotFoundError: No module named 'qrcode'
MacBook-Pro-29:python lisbun$ pip3 install pyqrcode
Collecting pyqrcode
  Downloading https://files.pythonhosted.org/packages/37/61/f07226075c347897937d4086ef8e55f0a62ae535e28069884ac68d979316/PyQRCode-1.2.1.tar.gz
Building wheels for collected packages: pyqrcode
  Running setup.py bdist_wheel for pyqrcode ... done
  Stored in directory: /Users/lisbun/Library/Caches/pip/wheels/54/61/2f/a4f51b09473db5737db0f654ed10eb9a4ee01f83a7412de349
Successfully built pyqrcode
Installing collected packages: pyqrcode
Successfully installed pyqrcode-1.2.1
MacBook-Pro-29:python lisbun$ python3 practice011.py 
Traceback (most recent call last):
  File "practice011.py", line 1, in <module>
    import qrcode
ModuleNotFoundError: No module named 'qrcode'
MacBook-Pro-29:python lisbun$ nvim practice011.py
MacBook-Pro-29:python lisbun$ python3 practice011.py 
Traceback (most recent call last):
  File "practice011.py", line 1, in <module>
    import pyqrcode
ModuleNotFoundError: No module named 'pyqrcode'
MacBook-Pro-29:python lisbun$ pip3 install pyqrcode
Requirement already satisfied: pyqrcode in /usr/local/lib/python3.7/site-packages (1.2.1)
MacBook-Pro-29:python lisbun$ nvim practice011.py
MacBook-Pro-29:python lisbun$ python3 practice011.py 
Traceback (most recent call last):
  File "practice011.py", line 1, in <module>
    import qrcode
ModuleNotFoundError: No module named 'qrcode'
MacBook-Pro-29:python lisbun$ nvim practice011.py
MacBook-Pro-29:python lisbun$ python3 practice011.py 
Traceback (most recent call last):
  File "practice011.py", line 1, in <module>
    import qr
ModuleNotFoundError: No module named 'qr'
MacBook-Pro-29:python lisbun$ get pip3
-bash: get: command not found
MacBook-Pro-29:python lisbun$ python3 -m ensurepip
Looking in links: /var/folders/jn/sxhr5y7n4zv236vmfpg8j_2c0000gn/T/tmphvozewu6
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/easy_install.py'
Consider using the `--user` option or check the permissions.

MacBook-Pro-29:python lisbun$ python3 -m pip list
/opt/local/bin/python3: No module named pip
MacBook-Pro-29:python lisbun$ python3 -m ensurepip
Looking in links: /var/folders/jn/sxhr5y7n4zv236vmfpg8j_2c0000gn/T/tmphpxv78_1
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/easy_install.py'
Consider using the `--user` option or check the permissions.

MacBook-Pro-29:python lisbun$ brew install py37-pip
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
aws-okta                            kustomize                           pulumi
cash-cli                            lsusb                               range-v3
docker-credential-helper-ecr        miniserve                           serverless
docker-machine-driver-hyperkit      pcapplusplus                        wiremock-standalone
fauna-shell                         perltidy                            xsimd
gambit                              petsc-complex                       zlog
==> Updated Formulae
libuv ✔                             glslviewer                          openapi-generator
openssl ✔                           gnumeric                            opencoarrays
ace                                 gocryptfs                           openssl@1.1
acpica                              goenv                               openvdb
activemq                            goffice                             osmium-tool
angular-cli                         goreleaser                          p11-kit
annie                               grails                              pc6001vx
ansible                             graphite2                           pcb2gcode
ansible-cmdb                        groovy                              percona-server@5.6
apache-flink                        groovysdk                           perl-build
arangodb                            grpc                                pgbouncer
ark                                 grunt-completion                    php
arm-linux-gnueabihf-binutils        gst-plugins-bad                     pkcs11-helper
armadillo                           gtk-vnc                             postgresql
automake                            hadolint                            postgresql@9.4
aws-elasticbeanstalk                hadoop                              postgresql@9.5
aws-sdk-cpp                         harfbuzz                            postgresql@9.6
awscli                              heroku                              prest
azure-cli                           hh                                  presto
b2-tools                            hugo                                protobuf-c
babl                                icdiff                              pyenv
ballerina                           igv                                 qemu
bat                                 imagemagick                         qpdf
bdw-gc                              imagemagick@6                       quicktype
beast                               imageoptim-cli                      radare2
bench                               influxdb                            rancher-cli
bettercap                           ios-webkit-debug-proxy              roswell
bind                                jenkins                             rsyslog
bitrise                             jenkins-lts                         rtv
byobu                               jfrog-cli-go                        s-nail
ceres-solver                        jhipster                            safe
chakra                              kafka                               schismtracker
checkstyle                          kontena                             scrcpy
cimg                                kops                                singular
closure-compiler                    kubernetes-service-catalog-client   skaffold
cmake                               libatomic_ops                       skktools
cmark-gfm                           libgsf                              sleuthkit
cockroach                           libical                             sonarqube
commandbox                          libomp                              spdlog
composer                            libpcap                             sphinx-doc
convox                              libphonenumber                      sqoop
cquery                              libpq                               ssh-permit-a38
crystal                             libpqxx                             sshguard
dartsim                             libqalculate                        sshtrix
dateutils                           librealsense                        stern
ddclient                            libsoup                             stone-soup
di                                  libssh                              swift
discount                            libtensorflow                       swift-protobuf
dmd                                 lighttpd                            swiftformat
docfx                               linkerd                             sysdig
draco                               lxc                                 telegraf
druid                               lynis                               teleport
duck                                macvim                              termius
dwarfutils                          mariadb                             terraform
dxpy                                mariadb@10.1                        terragrunt
dynare                              mariadb@10.2                        thors-serializer
efl                                 memcached                           tmate
elektra                             metabase                            tox
erlang                              micro                               translate-shell
erlang@19                           micronaut                           travis
erlang@20                           mint                                tty-solitaire
exomizer                            mkcert                              twoping
expat                               mkdocs                              ubertooth
exploitdb                           mkl-dnn                             unixodbc
fd                                  mongoose                            uriparser
fdclone                             mono                                v8
fibjs                               mosquitto                           vegeta
firebase-cli                        mpd                                 virtuoso
flow                                mujs                                vrpn
fluent-bit                          nagios                              vsts-cli
fn                                  naturaldocs                         webdis
folly                               nco                                 wine
fortio                              neo4j                               winetricks
fselect                             nnn                                 wireguard-tools
fwup                                node                                wp-cli
gegl                                node-build                          wtf
geoipupdate                         node@6                              xcodegen
get_iplayer                         node@8                              xtensor
gimme                               nsd                                 yafc
git-annex                           ntl                                 yara
git-archive-all                     ntp                                 you-get
git-extras                          nyancat                             zanata-client
gjstest                             ocaml                               zero-install
glib                                ocrmypdf
glib-networking                     octave
==> Deleted Formulae
dirmngr                    gnupg@2.0                  gpg-agent                  node@4

Error: No available formula with the name "py37-pip" 
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
  git -C "$(brew --repo homebrew/core)" fetch --unshallow

Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.
MacBook-Pro-29:python lisbun$ sudo port install py37-pip
Password:
Sorry, try again.
Password:
Warning: port definitions are more than two weeks old, consider updating them by running 'port selfupdate'.
Warning: xcodebuild exists but failed to execute
Warning: Xcode does not appear to be installed; most ports will likely fail to build.
--->  Computing dependencies for py37-pip
The following dependencies will be installed: 
 pip_select
 py37-setuptools
Continue? [Y/n]: Y
--->  Fetching archive for pip_select
--->  Attempting to fetch pip_select-0.1_0.darwin_17.noarch.tbz2 from http://kmq.jp.packages.macports.org/pip_select
--->  Attempting to fetch pip_select-0.1_0.darwin_17.noarch.tbz2.rmd160 from http://kmq.jp.packages.macports.org/pip_select
--->  Installing pip_select @0.1_0
--->  Activating pip_select @0.1_0
--->  Cleaning pip_select
--->  Fetching archive for py37-setuptools
--->  Attempting to fetch py37-setuptools-40.0.0_0.darwin_17.noarch.tbz2 from http://kmq.jp.packages.macports.org/py37-setuptools
--->  Attempting to fetch py37-setuptools-40.0.0_0.darwin_17.noarch.tbz2.rmd160 from http://kmq.jp.packages.macports.org/py37-setuptools
--->  Installing py37-setuptools @40.0.0_0
--->  Activating py37-setuptools @40.0.0_0
--->  Cleaning py37-setuptools
--->  Fetching archive for py37-pip
--->  Attempting to fetch py37-pip-18.0_0.darwin_17.noarch.tbz2 from http://kmq.jp.packages.macports.org/py37-pip
--->  Attempting to fetch py37-pip-18.0_0.darwin_17.noarch.tbz2.rmd160 from http://kmq.jp.packages.macports.org/py37-pip
--->  Installing py37-pip @18.0_0
--->  Activating py37-pip @18.0_0
--->  Cleaning py37-pip
--->  Updating database of binaries
--->  Updating database of C++ stdlib usage
--->  Scanning binaries for linking errors
--->  No broken files found.                             
--->  No broken ports found.
--->  Some of the ports you installed have notes:
  py37-pip has the following notes:
    To make the Python 3.7 version of pip the one that is run when you execute the commands without a
    version suffix, e.g. 'pip', run:
    
    port select --set pip pip37
MacBook-Pro-29:python lisbun$ python3 -m ensurepip
Looking in links: /var/folders/jn/sxhr5y7n4zv236vmfpg8j_2c0000gn/T/tmpf9915z_d
Requirement already satisfied: setuptools in /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (40.0.0)
Requirement already satisfied: pip in /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (18.0)
MacBook-Pro-29:python lisbun$ python3 practice011.py 
Traceback (most recent call last):
  File "practice011.py", line 1, in <module>
    import qr
ModuleNotFoundError: No module named 'qr'
MacBook-Pro-29:python lisbun$ nvim practice011.py
MacBook-Pro-29:python lisbun$ python3 practice011.py 
Traceback (most recent call last):
  File "practice011.py", line 1, in <module>
    import qrcode
ModuleNotFoundError: No module named 'qrcode'
MacBook-Pro-29:python lisbun$ python3 -m pip list
Package    Version
---------- -------
pip        18.0   
setuptools 40.0.0 
tkinter    0.0.0  
MacBook-Pro-29:python lisbun$ pip3 install pillow qrcode
Requirement already satisfied: pillow in /usr/local/lib/python3.7/site-packages (5.2.0)
Requirement already satisfied: qrcode in /usr/local/lib/python3.7/site-packages (6.0)
Requirement already satisfied: six in /usr/local/lib/python3.7/site-packages (from qrcode) (1.11.0)
MacBook-Pro-29:python lisbun$ python3 practice011.py 
Traceback (most recent call last):
  File "practice011.py", line 1, in <module>
    import qrcode
ModuleNotFoundError: No module named 'qrcode'
MacBook-Pro-29:python lisbun$ sudo ln -s /opt/local/Library/Frameworks/Python.framework/Versions/3.6/bin/pip3 /opt/local/bin/pip3
MacBook-Pro-29:python lisbun$ python3 practice011.py 
Traceback (most recent call last):
  File "practice011.py", line 1, in <module>
    import qrcode
ModuleNotFoundError: No module named 'qrcode'
MacBook-Pro-29:python lisbun$ pip3 install pillow qrcode
Requirement already satisfied: pillow in /usr/local/lib/python3.7/site-packages (5.2.0)
Requirement already satisfied: qrcode in /usr/local/lib/python3.7/site-packages (6.0)
Requirement already satisfied: six in /usr/local/lib/python3.7/site-packages (from qrcode) (1.11.0)
MacBook-Pro-29:python lisbun$ pip37 install pillow qrcode
-bash: pip37: command not found
MacBook-Pro-29:python lisbun$ port select --set pip pip37
Warning: port definitions are more than two weeks old, consider updating them by running 'port selfupdate'.
Selecting 'pip37' for 'pip' failed: could not create new link "/opt/local/bin/pip" pointing to "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/bin/pip": permission denied
MacBook-Pro-29:python lisbun$ port selfupdate
Error: Insufficient privileges to write to MacPorts install prefix.
MacBook-Pro-29:python lisbun$ sudo port selfupdate
--->  Updating MacPorts base sources using rsync
MacPorts base version 2.5.3 installed,
MacPorts base version 2.5.3 downloaded.
--->  Updating the ports tree
--->  MacPorts base is already the latest version

The ports tree has been updated. To upgrade your installed ports, you should run
  port upgrade outdated
MacBook-Pro-29:python lisbun$ port select --set pip pip37
Selecting 'pip37' for 'pip' failed: could not create new link "/opt/local/bin/pip" pointing to "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/bin/pip": permission denied
MacBook-Pro-29:python lisbun$ pip37 install pillow qrcode
-bash: pip37: command not found
MacBook-Pro-29:python lisbun$ sudo pip37 install pillow qrcode
sudo: pip37: command not found
MacBook-Pro-29:python lisbun$ port select --set pip pip37
Selecting 'pip37' for 'pip' failed: could not create new link "/opt/local/bin/pip" pointing to "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/bin/pip": permission denied
MacBook-Pro-29:python lisbun$ sudo python3 get-pip.py
(null): can't open file 'get-pip.py': [Errno 2] No such file or directory
MacBook-Pro-29:python lisbun$ sudo python get-pip.py
/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: can't open file 'get-pip.py': [Errno 2] No such file or directory
MacBook-Pro-29:python lisbun$ pip3 install pillow qrcode
Requirement already satisfied: pillow in /usr/local/lib/python3.7/site-packages (5.2.0)
Requirement already satisfied: qrcode in /usr/local/lib/python3.7/site-packages (6.0)
Requirement already satisfied: six in /usr/local/lib/python3.7/site-packages (from qrcode) (1.11.0)
MacBook-Pro-29:python lisbun$ pip37 install pillow qrcode
-bash: pip37: command not found
MacBook-Pro-29:python lisbun$ /opt/local/Library/Frameworks/Python.framework/Versions/3.7/bin/pip install pillow qrcode
Collecting pillow
  Using cached https://files.pythonhosted.org/packages/8d/50/362dc2580ae2539331768c0c3295730c791d79216c9a271114022e8c9895/Pillow-5.2.0-cp37-cp37m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Collecting qrcode
  Using cached https://files.pythonhosted.org/packages/79/be/11999004f7e6e5db0fa410c2feacd67c07f472f4500fde0026101f31d0df/qrcode-6.0-py2.py3-none-any.whl
Collecting six (from qrcode)
  Using cached https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Installing collected packages: pillow, six, qrcode
Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/Pillow-5.2.0.dist-info'
Consider using the `--user` option or check the permissions.

MacBook-Pro-29:python lisbun$ sudo /opt/local/Library/Frameworks/Python.framework/Versions/3.7/bin/pip install pillow qrcode
The directory '/Users/lisbun/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/lisbun/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pillow
  Downloading https://files.pythonhosted.org/packages/8d/50/362dc2580ae2539331768c0c3295730c791d79216c9a271114022e8c9895/Pillow-5.2.0-cp37-cp37m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (3.6MB)
    100% |████████████████████████████████| 3.6MB 4.1MB/s 
Collecting qrcode
  Downloading https://files.pythonhosted.org/packages/79/be/11999004f7e6e5db0fa410c2feacd67c07f472f4500fde0026101f31d0df/qrcode-6.0-py2.py3-none-any.whl
Collecting six (from qrcode)
  Downloading https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Installing collected packages: pillow, six, qrcode
Successfully installed pillow-5.2.0 qrcode-6.0 six-1.11.0
MacBook-Pro-29:python lisbun$ python3 practice011.py 
MacBook-Pro-29:python lisbun$ sudo ln -s /opt/local/Library/Frameworks/Python.framework/Versions/3.7/bin/pip /opt/local/bin/pip3
ln: /opt/local/bin/pip3: File exists
MacBook-Pro-29:python lisbun$ rm /opt/local/bin/pip3
rm: /opt/local/bin/pip3: Permission denied
MacBook-Pro-29:python lisbun$ sudo rm /opt/local/bin/pip3
MacBook-Pro-29:python lisbun$ sudo ln -s /opt/local/Library/Frameworks/Python.framework/Versions/3.7/bin/pip /opt/local/bin/pip3
MacBook-Pro-29:python lisbun$ sudo pip3 install pillow qrcode
The directory '/Users/lisbun/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/lisbun/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: pillow in /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (5.2.0)
Requirement already satisfied: qrcode in /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (6.0)
Requirement already satisfied: six in /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from qrcode) (1.11.0)
MacBook-Pro-29:python lisbun$ ls
func-animal-speed.py	practice004.py		practice008.py		qrcode-test.png
practice001.py		practice005.py		practice009.py		test.py
practice002.py		practice006.py		practice010.py
practice003.py		practice007.py		practice011.py
MacBook-Pro-29:python lisbun$ open qrcode-test.png 
MacBook-Pro-29:python lisbun$ vim practice010.py 
MacBook-Pro-29:python lisbun$ nvim practice0
MacBook-Pro-29:python lisbun$ nvim practice010.py 

import sys
s = sys.stdin.readlines()
N,M,Q = map(int,s[0].split())

Section = [[0]*N for _ in range(N)]
for L,R in (map(int, e.split()) for e in s[1:M+1):
    Section[L-1][R-1] += 1

Sum = [[0]*(N+1) for _ in range(N+1)]
for i in range(N):
    for j in range(N):
        Sum[i+1][j+1] = Sum[i][j+1]+Sum[i+1][j]-Sum[i][j]+Section[i][j]

Ans = [[0]*N for _ in range(N)]
for i in range(N):
    for j in range(i,N):
        Ans[i][j] = Sum[j+1][j+1]-Sum[i][j+1]

for p,q in (map(int, e.split()) for e in s[M+1:]
    print(Ans[p-1][q-1])