int countSumOfTwoRepresentations2(int n, int l, int r) { var count = 0; for (var a = l; a <= r; a++) if (a <= n - a && n - a >= l && n - a <= r) count++; return count; }