Order of a pseudo code
First note that $s \le \frac{n(n-1)}2$, equality need not necessarily hold.

Your observations are all correct:


The addition (and the head of the inner loop) is executed $O(s)$ times.
The head of the outer loop  is executed $O(n)$ times.
Neither $s\in O(n)$ nor $n \in O(s)$ holds for all possible inputs.


In this situation, there are multiple ways to give a bound that holds for all inputs:


You can use the fact that $s \in O(n^2)$ and give $O(n^2)$ as a bound for the algorithm,
you can say that the runtime is in $O(\max\{n,s\})$, or
you can say that the runtime is in $O(n+s)$.


Note that the latter two statements are acually equivalent (i.e. $O(\max\{n,s\})$ and $O(n+s)$ describe the same set of functions).