import bisect
from random import randint


class Solution(object):
    def countOffers(self, scores, lowerLimits, upperLimits):
        res = []
        if len(lowerLimits) != len(upperLimits):
            return res

        scores.sort()  # bugfixed

        for i in xrange(len(lowerLimits)):
            res.append(bisect.bisect_right(scores, upperLimits[i]) - bisect.bisect_left(scores, lowerLimits[i]))

        return res

    def jobOffers(self, scores, lowerLimits, upperLimits):

        if len(lowerLimits) != len(upperLimits):
            return []
        intervals = []
        for i in range(len(lowerLimits)):
            intervals.append([lowerLimits[i], upperLimits[i]])

        result = []
        for interval in intervals:
            result.append(sum([(score >= interval[0]) & (score <= interval[1]) for score in scores]))

        return result


if __name__ == '__main__':
    print Solution().countOffers([1, 3, 5, 6, 8], [2], [6])
    print Solution().jobOffers([1, 3, 5, 6, 8], [2], [6])
    print Solution().countOffers([4, 8, 7], [2, 4], [8, 4])
    print Solution().jobOffers([4, 8, 7], [2, 4], [8, 4])

    for _ in xrange(100):
        a = [randint(0, 20) for _ in xrange(30)]
        b = [randint(0, 10) for _ in xrange(10)]
        c = [randint(11, 30) for _ in xrange(10)]
        d = Solution().countOffers(a, b, c)
        e = Solution().jobOffers(a, b, c)
        if d != e:
            print a, b, c, d, e
            print "wrong"

    print "correct"
