Python Segment Tree Geeksforgeeks Sql