% ===========================
% Graduate Homework Template
% ===========================
\documentclass[11pt]{article}

% ---------- Page & Typography ----------
\usepackage[margin=1in]{geometry}
\usepackage{setspace}
\setstretch{1.05}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{microtype}

% ---------- Math ----------
\usepackage{amsmath, amssymb, amsthm, mathtools}
\usepackage{bm}
\usepackage{bbm}

% ---------- Colors & Links ----------
\usepackage[dvipsnames]{xcolor}
\usepackage[hidelinks]{hyperref}

% ---------- Figures / Tables ----------
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{subcaption}

% ---------- Lists ----------
\usepackage{enumitem}

% ---------- Code (optional) ----------
\usepackage{listings}
\lstset{
  basicstyle=\ttfamily\small,
  breaklines=true,
  frame=single,
  numbers=left,
  numberstyle=\tiny,
  xleftmargin=2em,
  framexleftmargin=1.5em
}

% ---------- Algorithms (optional) ----------
\usepackage{algorithm}
\usepackage{algpseudocode}

% ---------- Theorem-like Environments ----------
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}{Lemma}
\newtheorem{proposition}{Proposition}
\newtheorem{corollary}{Corollary}
\theoremstyle{definition}
\newtheorem{definition}{Definition}
\newtheorem{remark}{Remark}

% ---------- Homework Metadata ----------
\newcommand{\course}{SDE}% COURSE NAME / NUMBER}
% \newcommand{\instructor}{INSTRUCTOR NAME}
\newcommand{\semester}{Spring 2026} % semester
\newcommand{\hwnum}{HW \#}
\newcommand{\duedate}{DUE DATE}

\newcommand{\studentname}{Student Name}
\newcommand{\studentemail}{email@domain.edu}
\newcommand{\studentid}{Student ID (optional)}

% ---------- Header ----------
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\lhead{\course}
\chead{\hwnum}
\rhead{\studentname}
\cfoot{\thepage}

% ---------- Problem/Solution Environments ----------
\usepackage{tcolorbox}
\tcbset{colback=white, colframe=black!60, arc=2mm, boxrule=0.6pt}

\newcounter{problem}
\renewcommand{\theproblem}{\arabic{problem}}

\newenvironment{problem}[1][]{
  \refstepcounter{problem}
  \begin{tcolorbox}
  \textbf{Problem \theproblem.} \ifx\\#1\\\else \textit{(#1)}\fi
  \par\medskip
}{
  \end{tcolorbox}
}

% Toggle solutions on/off:
%   - show solutions:  \showsolutionstrue
%   - hide solutions:  \showsolutionsfalse
\newif\ifshowsolutions
\showsolutionstrue

\newenvironment{solution}{
  \ifshowsolutions
    \par\noindent\textbf{Solution.}\ \ignorespaces
  \else
    \expandafter\comment
  \fi
}{
  \ifshowsolutions
    \par\medskip
  \else
    \expandafter\endcomment
  \fi
}

% Need comment environment for hiding solutions
\usepackage{comment}

% ---------- Common Commands ----------
\newcommand{\R}{\mathbb{R}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\E}{\mathbb{E}}
\newcommand{\Pbb}{\mathbb{P}}
\newcommand{\Var}{\mathrm{Var}}
\newcommand{\Cov}{\mathrm{Cov}}
\newcommand{\1}{\mathbbm{1}}
\newcommand{\inner}[2]{\left\langle #1, #2 \right\rangle}
\newcommand{\norm}[1]{\left\lVert #1 \right\rVert}
\newcommand{\abs}[1]{\left\lvert #1 \right\rvert}

% ---------- Title Block ----------
\title{\vspace{-1.5em}\hwnum}
\author{
  \studentname \\
%  \studentemail \\
%  \ifx\\\studentid\\\else \studentid \\ \fi
}
\date{
  \course \quad (\semester) \\
  % Instructor: \instructor \\
  Due: \duedate
}

\begin{document}
\maketitle
\vspace{-1.0em}
\hrule
\vspace{0.8em}

% ---------- Collaboration / Integrity Statement ----------
\noindent\textbf{Collaboration statement.}
List collaborators (if any) and external resources used (texts, papers, websites, AI tools), and describe the help received.
\vspace{0.8em}

\noindent\textbf{Honor statement.}
I certify that the work submitted is my own and that I have complied with the course policies.
\vspace{1.0em}

% ===========================
% Problems
% ===========================
\hrule \hrule
\vspace{1mm}
\textbf{ HW1: 2.8, 2.16, 2.17 }. 
\vspace{1mm}

\hrule\hrule

\begin{problem}[Short optional title]
State the problem here. Include assumptions and notation clearly.
\end{problem}

\begin{solution}
Write your solution here. Use complete sentences and justify key steps.
\end{solution}

\begin{problem}
Another problem. You can include equations:
\[
  f(x) = \int_{\R} K(x,y)\,g(y)\,dy.
\]
\end{problem}

\begin{solution}
If you want to hide all solutions for a “blank template,” set \verb|\showsolutionsfalse| in the preamble.
\end{solution}

% ===========================
% Appendix (optional)
% ===========================
\appendix
\section*{Appendix (Optional)}
Put supporting lemmas, extra plots, or code snippets here.

\end{document}
