How do I typeset polynomial long division with multiple variables using LaTeX? I want to do polynomial long division with two and more divisors. I know there was a similar question already answered here, but the answer couldn't help since I want the long division to look like that: 
I could already solve it for when having only one divisor, but when having two it doesn't look good anymore. Can somebody help me fixing that?
This is the code I currently have:
\usepackage[ngerman]{babel} \usepackage{latexsym} \usepackage{amsfonts} \usepackage{amsmath} \usepackage{amssymb} \usepackage{amsthm} \usepackage{bbm} %\usepackage{enumerate} \usepackage{enumitem} \usepackage{MnSymbol} \usepackage[colorlinks=true,urlcolor=blue]{hyperref} \usepackage{listings} \usepackage{mdframed} \usepackage{pgfplots} \usepackage{todonotes} \usepackage[utf8]{inputenc} %deutsche Umlaute \input longdiv.tex \usepackage[]{algorithm2e} \newcommand\Mydiv[2]{% \strut#1$\kern.25em\smash{\raise.3ex\hbox{$\big)$}}$\mkern-8mu \overline{\enspace\strut#2}} $$ \begin{array}{rll} q_1: x \phantom{000000000} \\[-3pt] q_2: -1 \phantom{00000000} \\[-3pt] \Mydiv{\begin{array}{r} xy-1\\ x+y \end{array}}{x^2y-2x-y+4} \\[-3pt] \underline{x^2y- \phantom{0} x \phantom{000000}} \\ 4 \\[-3pt] \end{array} $$ This gives me this result:
I don't like the way the two divisors are taller than the bracet, but I couldn't figure out how to fix it... Thank you very much already!
! LaTeX Error: \usepackage before \documentclass.). Also, when you include an image of the output (which is helpful), then a real screenshot might be easier to read than a photo.