\DeclarePairedDelimiter\ceil{\lceil}{\rceil}
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}

\usetikzlibrary{decorations.pathmorphing, arrows.meta, positioning}
\usetikzlibrary{shapes.geometric, arrows, intersections}

\tikzstyle{problem} = [draw,outer sep=0,inner sep=5,minimum size=10]
\tikzstyle{solution} = [outer sep=0,inner sep=1,minimum size=10]
\tikzstyle{alpha} = [decorate, decoration={snake, amplitude=.5mm}, help lines] 
\tikzstyle{max edge} = [very thick, blue]
\tikzstyle{vertex} = [draw, circle, thick]
\tikzstyle{small vertex} = [draw, circle, scale=.75]
\tikzstyle{weight} = [scale=.75, fill=white, draw, circle]

\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}

\newcounter{task}[section]
\newcounter{subtask}[task]
\newcounter{tip}[task]
\newcounter{note}[task]

\let\oldthetask\thetask
\let\oldthesubtask\thesubtask

\renewcommand{\thesection}{\arabic{section}}
\renewcommand{\thesubtask}{\alph{subtask}}
\renewcommand{\thetask}{\thesection.\oldthetask}
\renewcommand{\thetip}{\#\arabic{tip}}
\renewcommand{\thenote}{\#\arabic{note}}

\makeatletter
    \newcommand{\note@nostar}[1]{\refstepcounter{note}\par\noindent\textbf{Uwaga \thenote:} #1\par}
    \newcommand{\note@star}[1]{\par\noindent\textbf{Uwaga:} #1\par}
    \newcommand{\note}{\@ifstar\note@star\note@nostar}

    \newcommand{\tip@nostar}[1]{\refstepcounter{tip}\par\noindent\textit{Wskazówka \thetip:} #1\par}
    \newcommand{\tip@star}[1]{\par\noindent\textit{Wskazówka:} #1\par}
    \newcommand{\tip}{\@ifstar\tip@star\tip@nostar}

    \renewcommand{\Function}[2]{%
      \csname ALG@cmd@\ALG@L @Function\endcsname{#1}{#2}%
      \def\jayden@currentfunction{\proc{#1}}%
    }

    \newcommand{\funclabel}[1]{%
      \@bsphack
      \protected@write\@auxout{}{%
          \string\newlabel{#1}{{\jayden@currentfunction}{\thepage}}%
      }%
      \@esphack
    }

    \newcommand{\kadet@solution}{\par\vspace{.5cm}\noindent\textbf{Proponowane rozwiązanie:}\par}
    \newenvironment{solution}{\kadet@solution}{\taskend}
\makeatother

\newcommand{\proc}[1]{{\textsc{#1}}}

\newcommand{\NP}{\texttt{NP}\xspace}
\newcommand{\NPC}{\texttt{NPC}\xspace}
\newcommand{\NPI}{\texttt{NPI}\xspace}
\renewcommand{\P}{\texttt{P}\xspace}

\newcommand{\problem}[1]{{\tt #1}\index{#1}}

\newcommand{\taskend}{\par\vspace{.1cm}\hfill$\square$\vspace{.4cm}\par}
\newcommand{\task}{%
    \vspace{.25cm}\refstepcounter{task}\par%
    \addcontentsline{toc}{subsection}{Zadanie \arabic{task}}%
    \noindent\texttt{Zadanie \thetask.\hspace{.1cm}}%
}
\newcommand{\subtask}[1][]{\refstepcounter{subtask}\par\noindent\hspace{.3cm}\thesubtask#1)\ }

\newcommand{\alphareduction}[2]{#1\ $\alpha$\ #2}

\newenvironment{shortcut}
    {\vspace{\baselineskip}\hbox{\textbf{Na skróty:}}\nointerlineskip\kern3pt\noindent\hrulefill\par\vspace{.5\baselineskip}}
    {\par\noindent\hrulefill\par\vspace{.5\baselineskip}}

\newenvironment{column}[1]{\noindent\begin{minipage}{#1\linewidth}}{\end{minipage}\vspace{.5\baselineskip}}

\floatname{algorithm}{Program}

\floatstyle{plain}
\newfloat{program}{thp}{lop}
\floatname{program}{Program}

\renewcommand\leq\leqslant
\renewcommand\geq\geqslant