For a cyber security competition I participate in, I\'m given a Debian virtual machine with many packages installed and asked to clean extraneous or malicious packages.
The following Bash command works for me in Debian 10 (buster). It prints all manually installed packages minus the ones that came from your Debian installation (in other words, the packages that you installed with apt install):
sudo grep -oP "Unpacking \K[^: ]+" /var/log/installer/syslog \
| sort -u | comm -13 /dev/stdin <(apt-mark showmanual | sort)
sudo is needed to search through /var/log/installer/syslog. You could also save this installer package list somewhere else if you don't want to use sudo every time.