I have $n$ red integers $a_1,\ldots,a_n$ (not necessarily distinct), all with $1\leq a_i\leq n$. I also have $n$ blue integers $b_1,\ldots,b_n$ with same constraints. I want to show that there is a (red) subset of the $a_i$'s and a blue subset of the $b_j$'s that add up to the same value. I.e. that there exist two non-empty subsets $I,J\subseteq\{1,\ldots,n\}$ such that $\sum_{i\in I}a_i = \sum_{j\in J}b_j$. This is obvious if $a_1=a_2=\cdots=a_n$ and $b_1=b_2=\cdots=b_n$ and it seems that allowing the $a_i$'s and the $b_j$'s to be distinct only give me more opportunities for the existence of matching subsets but I did not manage to find a proof (or a counter-example?).
At the moment the best I can prove is: if the $a_i$'s and $b_j$'s are all $\leq \frac{n}{2}$ then a solution exists and one can even find a solution where $I,J$ are convex subsets of $\{1,\ldots,n\}$ (i.e., they are subintervals). The solution is found by a greedy algorithm that runs in linear-time.
This looks like a classic problem but I am outside my field ...
Yes, it's a "classic problem" in pigeonhole principle for olympiad problems.
Proof by contradiction. Suppose not. Without loss of generality, $ \sum a_i > \sum b_i $.
Define $f(k)$ to be the smallest value $j$ such that
$$ \sum_{i=1}^j a_i > \sum_{i=1}^k b_i$$
Note that the difference between these partial sums $ \sum_{i=1}^{f(k)} a_i - \sum_{i=1}^k b_i $ is in the set $\{1, 2, \ldots , n-1\}$, since it is not 0, and it is capped by $a_j-1$. (Use the fact that $ \sum_{i=1}^{j-1} a_i < \sum_{i=1}^k b_i$)
By pigeonhole principle, since there are $n$ differences but only $n-1$ possibilities, thus there exists 2 differences that are identical. IE
$$ \sum_{i=1}^{f(k)} a_i - \sum_{i=1}^k b_i = \sum_{i=1}^{f(l)} a_i - \sum_{i=1}^l b_i $$
Now, take the differences of the partial sums, and they will have the same sum. IE (with $k>l$)
$$ \sum_{i=f(l) + 1}^{f(k)} a_i = \sum_{i=l+1}^k b_i $$
This also proves the observation that it is sufficient to consider subintervals.
This also shows why the condition of $1 \leq a_i \leq n$ is the best possible, with obvious counterexamples if we relax the condition further.
Putnam 1993 has a similar problem, with a similar solution that you are welcome to find.