You should be able to replace all this:
!wget https://github.com/jgm/pandoc/releases/download/2.11.3.2/pandoc-2.11.3.2-1-amd64.deb
!sudo dpkg -i pandoc-2.11.3.2-1-amd64.deb
!apt install libgl1-mesa-glx -y
!wget -q -O- https://download.calibre-ebook.com/linux-installer.sh | sudo sh /dev/stdin
With simply this: !apt install pandoc calibre