Problem:


Score : 66 points

Problem Statement

  Summer vacation ended at last and the second semester has begun.
  You, a Kyoto University student, came to university and heard a rumor that somebody will barricade the entrance of your classroom.
  The barricade will be built just before the start of the A-th class and removed by Kyoto University students just before the start of the B-th class.
  All the classes conducted when the barricade is blocking the entrance will be cancelled and you will not be able to attend them.
  Today you take N classes and class i is conducted in the t_i-th period.
  You take at most one class in each period.
  Find the number of classes you can attend.

Constraints

1 \leq N \leq 1000

1 \leq A < B \leq 10^9 

1 \leq t_i \leq 10^9

All t_i values are distinct.

Input

N, A and B are given on the first line and t_i is given on the (i+1)-th line. 

N A B
t1
:
tN

Output

Print the number of classes you can attend. 

Sample Input 1

5 5 9
4
3
6
9
1

Sample Output 1

4

You can not only attend the third class. 

Sample Input 2

5 4 9
5
6
7
8
9

Sample Output 2

1

You can only attend the fifth class. 

Sample Input 3

4 3 6
9
6
8
1

Sample Output 3

4

You can attend all the classes. 

Sample Input 4

2 1 2
1
2

Sample Output 4

1

You can not attend the first class, but can attend the second. 



Sample input:
5 5 9
4
3
6
9
1


Sample output:
4

Submission status: Runtime Error

Solution code:
import numpy as np

H, W = map(int, raw_input().split())
S_list = list()
for i in range(H):
    S_list.append(raw_input())


X_mat = np.zeros((H, W), dtype='int')
S_mat_extend = np.zeros((H+2, W+2), dtype='int')
# input
for h in range(H):
    for w in range(W):
        if S_list[h][w] == 'X':
            X_mat[h, w] += 1

# make graph
G = dict()
def add_node(s, Graph=G):
    Graph[s] = {'edges':dict()}
    
def add_edge(s, t, weight=1, Graph=G):
    Graph[s]['edges'][t] = weight

def max_flow(s, t, Graph=G):
    G_ = Graph
    flow = 0
    
    while True:
        # initialize
        for v in G_.keys():
            G_[v]['reach'] = -1
            G_[v]['path'] = ''
        G_[s]['reach'] = 1
        # bfs
        ques = [s]
        while len(ques) > 0:
            v = ques.pop()
            for d in G_[v]['edges'].keys():
                if G_[v]['edges'][d] > 0 and G_[d]['reach'] == -1:
                    # update
                    G_[d]['reach'] = 1
                    G_[d]['path'] = v
                    ques.append(d)
                    if d == t:
                        flow += 1
                        break

        if G_[t]['path'] != '':
            y = t
            while True:
                x = G_[y]['path']
                G_[x]['edges'][y] -= 1
                if x not in Graph[y]['edges'].keys():
                    add_edge(y, x, weight=0, Graph=G_)
                G_[y]['edges'][x] += 1
                if x == s:
                    break
                else:
                    y = x
        else:
            break
    
    return flow


# src:sheeps
# dst:outer
add_node('src')
add_node('dst')

# grid
for i in range(H):
    for j in range(W):
        add_node(str([i, j]) + '-src')
        add_node(str([i, j]) + '-dst')
        add_edge(str([i, j]) + '-dst', str([i, j]) + '-src')
        if X_mat[i, j] == 1:
            add_edge('src', str([i, j]) + '-dst', 100000)
            add_edge(str([i, j]) + '-dst', str([i, j]) + '-src', 100000)
        if i > 0:
            add_edge(str([i, j]) + '-src', str([i-1, j]) + '-dst')
        if i < H-1:
            add_edge(str([i, j]) + '-src', str([i+1, j]) + '-dst')
        if j > 0:
            add_edge(str([i, j]) + '-src', str([i, j-1]) + '-dst')
        if j < W-1:
            add_edge(str([i, j]) + '-src', str([i, j+1]) + '-dst')
        if i == 0 or j == 0 or i == H-1 or j == W-1:
            add_edge(str([i, j]) + '-src', 'dst', 100000)

res = 0
# find -1
if X_mat[0,:].sum() + X_mat[H-1,:].sum() + X_mat[:,0].sum() + X_mat[:,W-1].sum() > 0:
    res = -1
else:
    res = max_flow('src', 'dst')


print res

Submission status: Runtime Error

Solution code:
n,k=map(int,raw_input().split())
a=[0]*25
b=[]
count=0
for i in range(n):
	b.append(raw_input())
b=list(set(b))
for i in b:
	a[ord(i[0])-65]+=1
for i in a:
	if i>0:
		count+=i
if len(set(a))==2:
	print 0
else:
    print count/k

Submission status: Runtime Error

Solution code:
from collections import Counter
N, K = map(int, raw_input().split())
C = sorted(Counter(raw_input()[0] for _ in xrange(N)).values())
a = C.pop()
b = sum(C)
for i in xrange(a, 0, -1):
    if b/i >= K-1:
        print i
        break
else:
    print 0

Submission status: Runtime Error

Solution code:
from collections import Counter
n, k = map(int, input().split())
ps = [input() for _ in range(n)]
heads = Counter((p[0] for p in ps))
ans = 0
while len(heads) >= k:
    ans += 1
    for h, c in heads.most_common()[:k]:
        if c==1:
            heads.pop(h)
        else:
            heads[h] -= 1
print(ans)

Submission status: Runtime Error

Solution code:
N, A, B = map(int, raw_input().split())
#t_li = []
cnt = 0
for i in range(len(N)):
    if A <= int(raw_input()) < B:
        cnt +=1
#    t_li.append(raw_input())

print N-cnt