\documentclass[a4paper]{article}
\usepackage[onehalfspacing]{setspace}
\usepackage{geometry} % Required for adjusting page dimensions and margins
\usepackage{amsmath,amsfonts,stmaryrd,amssymb,mathtools,dsfont} % Math packages
\usepackage{tabularx}
\usepackage{colortbl}
\usepackage{listings}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{enumerate}
\usepackage{enumitem}
\usepackage{subcaption}
\usepackage{float}
\usepackage[table,xcdraw]{xcolor}
\usepackage{tikz-qtree}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\usepackage{forest}
\usepackage{changepage,titlesec,fancyhdr} % For styling Header and Titles
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0.5pt} % Linienbreite anpassen, falls gewünscht
\renewcommand{\headrule}{
    \makebox[\textwidth]{\rule{1.0\textwidth}{0.5pt}}
}
\usepackage{amsmath}
\pagestyle{fancy}
\usepackage{diagbox}
\usepackage{xfrac}
\usepackage{enumerate} % Custom item numbers for enumerations
\usepackage[ruled]{algorithm2e} % Algorithms
\usepackage[framemethod=tikz]{mdframed} % Allows defining custom boxed/framed environments
\usepackage{listings} % File listings, with syntax highlighting
\lstset{
	basicstyle=\ttfamily, % Typeset listings in monospace font
}

\usepackage[ddmmyyyy]{datetime}

\geometry{
	paper=a4paper, % Paper size, change to letterpaper for US letter size
	top=3cm, % Top margin
	bottom=3cm, % Bottom margin
	left=2.5cm, % Left margin
	right=2.5cm, % Right margin
	headheight=25pt, % Header height
	footskip=1.5cm, % Space from the bottom margin to the baseline of the footer
	headsep=1cm, % Space from the top margin to the baseline of the header
}

% Default config
\lhead{[Subject Name]]\\[Term]}
\chead{\bfseries{\vspace{0.5\baselineskip}[Assignment Title]}}
\rhead{[Name of 1st Author], [Matr. Nr of 1st Author]\\[Name of 2nd Author], {Matr. Nr of 2nd Author]}}

% UNCOMMENT TO USE: Config for Single Author
% \lhead{\vspace{0.5\baselineskip}[Assignment Title]}
% \chead{\bfseries{[Subject Name]\\[Term]}}
% \rhead{\vspace{0.5\baselineskip}[Name of 1st Author], [Mtr. Nr of 1st Author]}

% UNCOMMENT TO USE: Config for 3-4 Authors
% \lhead{[Name of 1st Author], [Matr. Nr of 1st Author]\\[Name of 2nd Author], [Matr. Nr of 2nd Author]}
% \chead{\bfseries{\vspace{0.5\baselineskip}HL-BPR Praktikum SS25\\Blatt 06}}
% \rhead{[Name of 3rd Author], [Matr. Nr of 3rd Author]\\[Name of 4th Author], [Matr. Nr of 4th Author]}
\fancyheadoffset[R]{0cm}

\begin{document}

\end{document}
