ZhenlongDai/ACPR huggingface dataset:
Problem: p03478
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
input_line = input()
x, y, z = map(str, input_line.split())

resultNum = 0

for i in range(int(x)):
  loopCnt = len(str(i))
  addNum = 0
  for j in range(loopCnt):
    addNum += int(str(i)[j])
  if int(y) <= addNum <= int(z):
    resultNum += i

print(resultNum)

Failing test case input:
111 1 011

Expected output:
4060


Actual output:
3949


Fixed submission (verdict: Accepted):
input_line = input()
x, y, z = map(str, input_line.split())

resultNum = 0

for i in range(int(x)+1):
  loopCnt = len(str(i))
  addNum = 0
  for j in range(loopCnt):
    addNum += int(str(i)[j])
  if int(y) <= addNum <= int(z):
    resultNum += i

print(resultNum)

Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,a,b = map(int,input().split())
ans = 0
for i in range(n+1):
    if a <= sum(list(map(int,list(str(i)))))<= b:
        ans += 1
print(ans)

Failing test case input:
20 1 6

Expected output:
116


Actual output:
13


Fixed submission (verdict: Accepted):
n,a,b = map(int,input().split())
ans = 0
for i in range(n+1):
    if a <= sum(list(map(int,list(str(i)))))<= b:
        ans += i
print(ans)

Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,a,b=map(int, input().split())
ret = 0
for i in range(1, n+1):
  c = n 
  if a<=c and c <=b:
    ret += i
print(ret)

Failing test case input:
101 2 19

Expected output:
5040


Actual output:
0


Fixed submission (verdict: Accepted):
n,a,b=map(int, input().split())
ret = 0
for i in range(1, n+1):
    c = eval('+'.join(str(i)))
    if a<=c and c <=b:
        ret += i
print(ret)

Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = input().split()

ans = 0
for i in range(int(a[0])+1):
    i=str(i)
    i.split()
    sum_num=0
    for j in i:
        sum_num+=int(j)
    if sum_num>=int(a[1]) and sum_num<=int(a[2]):
        ans += int(i)
        print(i)

print(ans)

Failing test case input:
111 1 181

Expected output:
6216


Actual output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
6216


Fixed submission (verdict: Accepted):
a = input().split()

ans = 0
for i in range(int(a[0])+1):
    i=str(i)
    i.split()
    sum_num=0
    for j in i:
        sum_num+=int(j)
    if sum_num>=int(a[1]) and sum_num<=int(a[2]):
        ans += int(i)

print(ans)

Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B=map(int,input().split())
ans=0
for i in range(N+1):
  if A<=sum(map(int,str(i)))<=B:
    ans+=1
print(ans)

Failing test case input:
6 -2 6

Expected output:
21


Actual output:
7


Fixed submission (verdict: Accepted):
N,A,B=map(int,input().split())
ans=0
for i in range(N+1):
  if A<=sum(map(int,str(i)))<=B:
    ans+=i
print(ans)
Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,a,b=map(int,input().split())

def sumdigit(num):
    sum=0
    for i in num:
        sum+=int(i)
    return sum

ans=0
for i in range(1,n+1):
    sum=sumdigit(str(i))
    if a<=sum<=b:
        ans+=1
print(ans)


Failing test case input:
101 -1 6

Expected output:
817


Actual output:
29


Fixed submission (verdict: Accepted):
n,a,b=map(int,input().split())

def sumdigit(num):
    sum=0
    for i in num:
        sum+=int(i)
    return sum

ans=0
for i in range(1,n+1):
    sum=sumdigit(str(i))
    if a<=sum<=b:
        ans+=i
print(ans)

Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, A, B = input().split()
count=0
for i in range(int(N)):
    if int(A) <= sum(map(int, N)) <= int(B):
        count+=1
print(count)

Failing test case input:
100 3 010

Expected output:
2266


Actual output:
0


Fixed submission (verdict: Accepted):
N, A, B = map(int, input().split())
count=0
for i in range(int(N)+1):
    if int(A) <= sum(map(int, str(i))) <= int(B):
        count+=i
print(count)

Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,a,b = map(int, input().split())

count=0
for i in range(1,n+1):
  if sum(int(j) for j in str(i))<=b:
    count+=i

print(count)

Failing test case input:
010 6 010

Expected output:
30


Actual output:
55


Fixed submission (verdict: Accepted):
n,a,b = map(int, input().split())

count=0
for i in range(1,n+1):
  if a<=sum(int(j) for j in str(i))<=b:
    count+=i

print(count)

Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, a, b = map(int, input().split())

allsum = 0

for i in range(1,n+1):
  l = list(str(i))
  li = [int(s) for s in l]
  tmpsum = sum(li)
  print (tmpsum)
  
  
  if ((tmpsum >= a) and (tmpsum <= b)):
    print("ok")
    allsum = allsum + i
print(allsum)

Failing test case input:
100 4 12

Expected output:
3146


Actual output:
1
2
3
4
ok
5
ok
6
ok
7
ok
8
ok
9
ok
1
2
3
4
ok
5
ok
6
ok
7
ok
8
ok
9
ok
10
ok
2
3
4
ok
5
ok
6
ok
7
ok
8
ok
9
ok
10
ok
11
ok
3
4
ok
5
ok
6
ok
7
ok
8
ok
9
ok
10
ok
11
ok
12
ok
4
ok
5
ok
6
ok
7
ok
8
ok
9
ok
10
ok
11
ok
12
ok
13
5
ok
6
ok
7
ok
8
ok
9
ok
10
ok
11
ok
12
ok
13
14
6
ok
7
ok
8
ok
9
ok
10
ok
11
ok
12
ok
13
14
15
7
ok
8
ok
9
ok
10
ok
11
ok
12
ok
13
14
15
16
8
ok
9
ok
10
ok
11
ok
12
ok
13
14
15
16
17
9
ok
10
ok
11
ok
12
ok
13
14
15
16
17
18
1
3146


Fixed submission (verdict: Accepted):
n, a, b = map(int, input().split())

allsum = 0

for i in range(1,n+1):
  l = list(str(i))
  li = [int(s) for s in l]
  tmpsum = sum(li)
  
  
  if ((tmpsum >= a) and (tmpsum <= b)):
    allsum = allsum + i
print(allsum)
Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B = map(int, input(">>").split())
count = 0

for i in range(1,N+1):
    
    m = 0
    tmp = i
    for t in range(1, len(str(i))+1):
        
        
        m += tmp%10
        tmp /= 10
        tmp = int(tmp)
    
    if( A <=m and m <= B):
        count += i

print(count)

Failing test case input:
101 2 19

Expected output:
5040


Actual output:
>>5040


Fixed submission (verdict: Accepted):
N,A,B = map(int, input().split())
count = 0

for i in range(1,N+1):
    
    m = 0
    tmp = i
    for t in range(1, len(str(i))+1):
        
        
        m += tmp%10
        tmp /= 10
        tmp = int(tmp)
    
    if( A <=m and m <= B):
        count += i

print(count)

Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,a,b=map(int,input().split())
ans=0
for i in range(n):
    tmp=sum([int(j) for j in list(str(i+1))])
    if a<=tmp<=b:
        ans+=1
print(ans)


Failing test case input:
100 4 16

Expected output:
4554

Actual output:
87


Fixed submission (verdict: Accepted):
n,a,b=map(int,input().split())
ans=0
for i in range(n):
    tmp=sum([int(j) for j in list(str(i+1))])
    if a<=tmp<=b:
        ans+=i+1
print(ans)

Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,a,b = map(int,input().split())
ans = 0
for i in range(2):
  for j in range(10):
    for k in range(10):
      for l in range(10):
        for m in range(10):
          if i*10000+j*1000+k*100+l*10+m <= n and a <= i+j+k+l+m <= b:
            ans += 1
print(ans)

Failing test case input:
37 1 6

Expected output:
332


Actual output:
21


Fixed submission (verdict: Accepted):
n,a,b = map(int,input().split())
ans = 0
for i in range(2):
  for j in range(10):
    for k in range(10):
      for l in range(10):
        for m in range(10):
          if i*10000+j*1000+k*100+l*10+m <= n and a <= i+j+k+l+m <= b:
            ans += i*10000+j*1000+k*100+l*10+m
print(ans)

Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, A, B = map(int, input().split())
sums = 0
cnt = 0
for i in range(1, N+1):
    words_i = str(i)
    for word_i in words_i:
        sums += int(word_i)
        if A <= sums <= B:
            cnt += 1
        sums = 0
print(cnt)

Failing test case input:
100 5 12

Expected output:
3036


Actual output:
100


Fixed submission (verdict: Accepted):
N, A, B = map(int, input().split())
sums = 0
cnt = 0
for i in range(1, N+1):
    words_i = str(i)
    for word_i in words_i:
        sums += int(word_i)
    if A <= sums <= B:
        cnt += i
    sums = 0
print(cnt)

Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B=map(int,input().split())
total=0
for i in range(1,N+1):
    S=list(str(i))
    tmp=0
    for j in S:
        tmp+=int(j)
    if 2<=tmp<=5:
        total+=i
print(total)

Failing test case input:
101 -1 6

Expected output:
817


Actual output:
475


Fixed submission (verdict: Accepted):
N,A,B=map(int,input().split())
total=0
for i in range(1,N+1):
    S=list(str(i))
    tmp=0
    for j in S:
        tmp+=int(j)
    if A<=tmp<=B:
        total+=i
print(total)
Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B = (int(x) for x in input().split())
ans = 0
for n in range(1,N+1):
  temp = [int(x) for x in str(n)]
  if A <= sum(temp) <= B:
    ans+= sum(temp)
print(ans)

Failing test case input:
100 2 100

Expected output:
4939


Actual output:
898


Fixed submission (verdict: Accepted):
N,A,B = (int(x) for x in input().split())
ans = 0
for n in range(1,N+1):
  temp = [int(x) for x in str(n)]
  if A <= sum(temp) <= B:
    ans+= n
print(ans)

Problem: p03478
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N,A,B = map(int,input().split())

ans = 0
for i in range(1,N+1):
  d = sum(list(map(int,list(str(i)))))
  if A <= d <= B:
    ans += 1

print(ans)


Failing test case input:
100 1 011

Expected output:
2894


Actual output:
72


Fixed submission (verdict: Accepted):
N,A,B = map(int,input().split())

ans = 0
for i in range(1,N+1):
  d = sum(list(map(int,list(str(i)))))
  if A <= d <= B:
    ans += i

print(ans)

Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B = map(int,input().split())
count=0
for n in range(1,N+1):
    sumn=0
    strn = str(n)
    for lenn in range(len(strn)):
        if lenn == 0:
            sumn += n%10
        else:

            sumn += int(n/(10*lenn))%10

    if sumn >= A:
        if sumn <= B:
            count+=n
print(count)

Failing test case input:
111 0 001

Expected output:
111


Actual output:
11


Fixed submission (verdict: Accepted):
N,A,B = map(int,input().split())
count=0
for n in range(1,N+1):
    sumn=0
    strn = str(n)
    for lenn in range(len(strn)):
        if lenn == 0:
            sumn += n%10
        else:

            sumn += int(n/(10**lenn))%10

    if sumn >= A:
        if sumn <= B:
            count+=n
print(count)

Problem: p03478
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n, a, b = list(map(int, input().split()))
total = 0

for i in range(1,n + 1):
    length = len(str(i)) 
    ele = []
    for j in range(1, length + 1):
        num = str(i)[-j]
        num = int(num)
        ele.append(num)
    s = sum(ele)
    if a <= s and s <= b:
        total += s
print(total)


Failing test case input:
10 1 6

Expected output:
31


Actual output:
22


Fixed submission (verdict: Accepted):
n, a, b = list(map(int, input().split()))
total = 0

for i in range(1,n + 1):
    length = len(str(i)) 
    ele = []
    
    l = str(i)
    array = list(map(int, l))
    s = sum(array)
    if a <= s and s <= b:
        total += i
print(total)

Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,a,b = map(int, input().split())
res = 0
for i in range(1,n+1):
  tmp = 0
  for j in range(len(str(i))):
    tmp += int(str(i)[j])
  if a <= tmp <= b:
    res += 1
print(res)

Failing test case input:
101 6 111

Expected output:
4565


Actual output:
79


Fixed submission (verdict: Accepted):
n,a,b = map(int, input().split())
res = 0
for i in range(1,n+1):
  tmp = 0
  for j in range(len(str(i))):
    tmp += int(str(i)[j])
  if a <= tmp <= b:
    res += i
print(res)
Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,a,b = map(int,input().split())
ans = 0
for i in range(n):
  if a<=sum(map(int,list(str(i))))<=b:
    ans += i
print(ans)

Failing test case input:
001 -1 6

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n,a,b = map(int,input().split())
ans = 0
for i in range(n+1):
  if a<=sum(map(int,list(str(i))))<=b:
    ans += i
print(ans)

Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,a,b=map(int,input().split())

cnt=0
for i in range(1,n+1):
  ss=str(i)
  x=0
  for s in ss:
    x+=int(s)
  if x>=a and x <= b:
    cnt+=1
    
print(cnt)

Failing test case input:
011 -1 110

Expected output:
66


Actual output:
11


Fixed submission (verdict: Accepted):
n,a,b=map(int,input().split())

cnt=0
for i in range(1,n+1):
  ss=str(i)
  x=0
  for s in ss:
    x+=int(s)
  if x>=a and x <= b:
    cnt+=i
    
print(cnt)

Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B = map(int, input().strip().split(' '))
ans = 0
for i in range(1,N+1):
  if A <= sum(map(int, str(i))) <= B:
    ans += 1
print(ans)


Failing test case input:
100 1 010

Expected output:
2410


Actual output:
64


Fixed submission (verdict: Accepted):
N,A,B = map(int, input().strip().split(' '))
ans = 0
for i in range(1,N+1):
  if A <= sum(map(int, str(i))) <= B:
    ans += i
print(ans)

Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,a,b=map(int,input().split())
num=0
for i in range (n+1):
  if 2 <= sum(list(map(int,list(str(i)))))<=5:
    num+=i
print(num)


Failing test case input:
100 4 12

Expected output:
3146


Actual output:
374


Fixed submission (verdict: Accepted):
n,a,b=map(int,input().split())
num=0
for i in range (n+1):
  if a <= sum(list(map(int,list(str(i)))))<=b:
    num+=i
print(num)
Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

N, A, B = map(int, input().split())

sum = 0
for i in range(1, N+1):
  if i < 10:
    if A <= i and i <= B:
        sum += i
  elif i < 100:
    temp = int(i/10) + i%10
    print(temp)
    if A <= temp and temp <= B:
      sum += i
  elif i < 1000:
    temp = int(i/100) + int(i%100/10) + i%100%10
    if A <= temp and temp <= B:
      sum += i
  else:
    temp = int(i/1000) + int(i%1000/100) + int(i%1000%100/10) + i%1000%100%10
    if A <= temp and temp <= B:
      sum += i

print(sum)
    

Failing test case input:
101 6 111

Expected output:
4565


Actual output:
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
11
3
4
5
6
7
8
9
10
11
12
4
5
6
7
8
9
10
11
12
13
5
6
7
8
9
10
11
12
13
14
6
7
8
9
10
11
12
13
14
15
7
8
9
10
11
12
13
14
15
16
8
9
10
11
12
13
14
15
16
17
9
10
11
12
13
14
15
16
17
18
4565


Fixed submission (verdict: Accepted):
N, A, B = map(int, input().split())
 
sum = 0
for i in range(1, N+1):
  if i < 10:
    if A <= i and i <= B:
        sum += i
  elif i < 100:
    temp = int(i/10) + i%10
    if A <= temp and temp <= B:
      sum += i
  elif i < 1000:
    temp = int(i/100) + int(i%100/10) + i%100%10
    if A <= temp and temp <= B:
      sum += i
  elif i < 10000:
    temp = int(i/1000) + int(i%1000/100) + int(i%1000%100/10) + i%1000%100%10
    if A <= temp and temp <= B:
      sum += i
  else:
    temp = int(i/10000)
    if A <= temp and temp <= B:
      sum += i
      
print(sum)

Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,a,b = map(int, input().split())

i=0
souwa=0
while i<N:
  j=i
  sum =0
  while j>0:
    sum=sum+j%10
    j=round(j/10)
  
  if sum>a and sum<b:
    souwa=souwa+sum
  
  
  i=i+1
print(souwa)

Failing test case input:
10 2 4

Expected output:
9


Actual output:
3


Fixed submission (verdict: Accepted):
N,a,b = map(int, input().split())

i=0
souwa=0
while i<=N:
  j=i
  sum =0
  while j>0:
    sum=sum+j%10
    j=int(j/10)
  
  if sum>=a and sum<=b:
    
    souwa=souwa+i
  
  
  i=i+1
print(souwa)
Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, a, b = list(map(int, input().split()))
res = 0
for num in range(1, n+1):
    n_list = list(map(int, list(str(num))))
    total = sum(n_list)
    print(n_list)
    if a <= total and total <= b:
        res += num
print(res)


Failing test case input:
111 0 001

Expected output:
111


Actual output:
[1]
[2]
[3]
[4]
[5]
[6]
[7]
[8]
[9]
[1, 0]
[1, 1]
[1, 2]
[1, 3]
[1, 4]
[1, 5]
[1, 6]
[1, 7]
[1, 8]
[1, 9]
[2, 0]
[2, 1]
[2, 2]
[2, 3]
[2, 4]
[2, 5]
[2, 6]
[2, 7]
[2, 8]
[2, 9]
[3, 0]
[3, 1]
[3, 2]
[3, 3]
[3, 4]
[3, 5]
[3, 6]
[3, 7]
[3, 8]
[3, 9]
[4, 0]
[4, 1]
[4, 2]
[4, 3]
[4, 4]
[4, 5]
[4, 6]
[4, 7]
[4, 8]
[4, 9]
[5, 0]
[5, 1]
[5, 2]
[5, 3]
[5, 4]
[5, 5]
[5, 6]
[5, 7]
[5, 8]
[5, 9]
[6, 0]
[6, 1]
[6, 2]
[6, 3]
[6, 4]
[6, 5]
[6, 6]
[6, 7]
[6, 8]
[6, 9]
[7, 0]
[7, 1]
[7, 2]
[7, 3]
[7, 4]
[7, 5]
[7, 6]
[7, 7]
[7, 8]
[7, 9]
[8, 0]
[8, 1]
[8, 2]
[8, 3]
[8, 4]
[8, 5]
[8, 6]
[8, 7]
[8, 8]
[8, 9]
[9, 0]
[9, 1]
[9, 2]
[9, 3]
[9, 4]
[9, 5]
[9, 6]
[9, 7]
[9, 8]
[9, 9]
[1, 0, 0]
[1, 0, 1]
[1, 0, 2]
[1, 0, 3]
[1, 0, 4]
[1, 0, 5]
[1, 0, 6]
[1, 0, 7]
[1, 0, 8]
[1, 0, 9]
[1, 1, 0]
[1, 1, 1]
111


Fixed submission (verdict: Accepted):
n, a, b = list(map(int, input().split()))
res = 0
for num in range(1, n+1):
    n_list = list(map(int, list(str(num))))
    total = sum(n_list)
    if a <= total and total <= b:
        res += num
print(res)

Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, A, B = map(int, input().split())
cnt = 0
for i in range(1, N + 1):
    total = 0
    str_i = str(i)
    len_i = len(str_i)
    for l in range(len_i):
        total += int(str_i[l])
    if A <= total <= B:
        cnt += 1
print(cnt)


Failing test case input:
21 0 4

Expected output:
97


Actual output:
10


Fixed submission (verdict: Accepted):
N, A, B = map(int, input().split())
Total = 0
for i in range(1, N + 1):
    total = 0
    str_i = str(i)
    len_i = len(str_i)
    for l in range(len_i):
        total += int(str_i[l])
    if A <= total <= B:
        Total += i
print(Total)

Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
charN,charA,charB =input().split()

N = int(charN)
A = int(charA)
B = int(charB)


total = 0
for i in range(N):
    tmp = 0
    chartmp = str(i+1)
    for j in range(len(chartmp)):
        tmp = tmp + int(chartmp[j])
    print(tmp)
    if (tmp>=A and tmp <= B):
        total = total + (i+1)
print(total)

Failing test case input:
100 2 010

Expected output:
2299


Actual output:
1
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
11
3
4
5
6
7
8
9
10
11
12
4
5
6
7
8
9
10
11
12
13
5
6
7
8
9
10
11
12
13
14
6
7
8
9
10
11
12
13
14
15
7
8
9
10
11
12
13
14
15
16
8
9
10
11
12
13
14
15
16
17
9
10
11
12
13
14
15
16
17
18
1
2299


Fixed submission (verdict: Accepted):
N,A,B = (int(i) for i in input().split())

total = 0

for i in range(N+1):
    summy = 0
    char = str(i)
    for j in range(len(char)):
        summy = summy + int(char[j])

    if (summy>=A and summy<=B):
        total = total + i
        
print(total)
Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B = map(int, input().split())

sum = 0
for i in range(N+1):
    count = 0
    for num in str(i):
        count += int(num)

    if A <= count <= B:
        sum+=1
print(sum)


Failing test case input:
21 0 10

Expected output:
231


Actual output:
22


Fixed submission (verdict: Accepted):
n, a, b = map(int, input().split())
 
sum = 0
for i in range(n+1) :
    count = 0
    for num in str(i) :
        count += int(num)
 
    if (count >= a) and (count <= b) :
        sum += i
            
print(sum)

Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,a,b=list(map(int,input().split()))
sum([i for i in range(1,n+1) if a<=sum([int(c) for c in str(i)])<=b])

Failing test case input:
20 3 6

Expected output:
72


Actual output:

Fixed submission (verdict: Accepted):
n,a,b=map(int,input().split())
print(sum([i for i in range(1,n+1) if a<=sum([int(c) for c in str(i)])<=b]))

Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,a,b=map(int,input().split())
sum([i for i in range(n+1) if a<=sum([int(c) for c in str(i)])<=b])

Failing test case input:
110 3 010

Expected output:
3110


Actual output:

Fixed submission (verdict: Accepted):
n,a,b=map(int,input().split())
print(sum([i for i in range(1,n+1) if a<=sum([int(c) for c in str(i)])<=b]))

Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n + 1):
    s=sum(map(int, str(i)))
    print(s)
    if a <= s <= b:
        ans += i
print(ans)


Failing test case input:
36 -2 1

Expected output:
11


Actual output:
1
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
11
3
4
5
6
7
8
9
11


Fixed submission (verdict: Accepted):
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n + 1):
    s=sum(map(int, str(i)))
    if a <= s <= b:
        ans += i
print(ans)

Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def DigitsSUM(Num):
    sumN = 0
    while Num > 0:
        sumN += Num % 10
        Num/=10
    return int(sumN)


N,A,B = input().split()
LowerLimit=int(A)
UpperLimit=int(B)
num = int(N)
sumary = []
counter = 0
for i in range(1,num+1):
    sumN = DigitsSUM(i)
    if LowerLimit <= sumN and sumN <= UpperLimit+1:
        print(i, sumN)
        counter+=int(i)
        
print(counter)




Failing test case input:
001 -2 6

Expected output:
1


Actual output:
1 1
1


Fixed submission (verdict: Accepted):
def DigitsSUM(Num):
    sumN = 0
    while Num > 0:
        sumN += int(Num) % 10
        Num /= 10
    return int(sumN)


N,A,B = input().split()
LowerLimit=int(A)
UpperLimit=int(B)
num = int(N)
sumary = []
counter = 0
for i in range(1,num+1):
    sumN = DigitsSUM(i)
    
    if LowerLimit <= sumN and sumN <= UpperLimit:
        counter+=int(i)
        
print(counter)
Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,a,b = map(int,input().split())
num = 0

for i in range(n+1):
    if a <= sum(list(map(int,list(str(i))))) <= b:
        num = num + 1

print(num)

Failing test case input:
10 2 4

Expected output:
9


Actual output:
3


Fixed submission (verdict: Accepted):
n,a,b = map(int,input().split())
num = 0

for i in range(n+1):
    if a <= sum(list(map(int,list(str(i))))) <= b:
        num = num + i

print(num)

Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, a, b = map(int, input().split())
counter = 0

for i in range(1, n):
    str_i = str(i)
    sum_i = sum(map(int, str_i))
    if a <= sum_i <= b:
        counter += i

print(counter)

Failing test case input:
101 1 011

Expected output:
2995


Actual output:
2894


Fixed submission (verdict: Accepted):
n, a, b = map(int, input().split())
counter = 0

for i in range(n+1):
    str_i = str(i)
    sum_i = sum(map(int, str_i))
    if a <= sum_i <= b:
        counter += i

print(counter)

Problem: p03478
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, a, b = map(int, input().split())
count = 0
total = 0
for i in range(1,n+1,1):
    str_i = str(i)
    for j in range(len(str_i)):
        total+=int(str_i[j])
    if total >= a and total <= b:
        print(i)
        count+=i
    total=0
print(count)
    

Failing test case input:
101 3 12

Expected output:
3212


Actual output:
3
4
5
6
7
8
9
12
13
14
15
16
17
18
19
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
50
51
52
53
54
55
56
57
60
61
62
63
64
65
66
70
71
72
73
74
75
80
81
82
83
84
90
91
92
93
3212


Fixed submission (verdict: Accepted):
n, a, b = map(int, input().split())
count = 0
total = 0
for i in range(1,n+1,1):
    str_i = str(i)
    for j in range(len(str_i)):
        total+=int(str_i[j])
    if total >= a and total <= b:
        count+=i
    total=0
print(count)
Problem: p03166
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from collections import defaultdict

n,m=map(int,input().split())
adj=defaultdict(list)
deg=[0]*(n+1)
for i in range(m):
    x,y=map(int,input().split())
    adj[x].append(y)
    deg[y]+=1

dist=[0]*(n+1)

que=[]
for i in range(1,n+1):
    if deg[i]==0:
        que.append(i)

while que:
    v=que.pop()
    for i in adj[v]:
        deg[i]-=1
        if deg[i]==0:
            que.append(i)
            dist[i]=max(dist[i],dist[v]+1)

print(max(dist))
 


Failing test case input:
6 3
2 6
4 6
5 2

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
from collections import defaultdict

n,m=map(int,input().split())
adj=defaultdict(list)
deg=[0]*(n+1)
for i in range(m):
    x,y=map(int,input().split())
    adj[x].append(y)
    deg[y]+=1

dist=[0]*(n+1)

que=[]
for i in range(1,n+1):
    if deg[i]==0:
        que.append(i)

while que:
    v=que.pop()
    for i in adj[v]:
        deg[i]-=1
        if deg[i]==0:
            que.append(i)
        dist[i]=max(dist[i],dist[v]+1)

print(max(dist))

Problem: p03166
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n, m = map(int, input().split())
adj = {}
indegrees = [0 for _ in range(n+1)]
for _ in range(m):
  cur, nxt = map(int, input().split())
  adj[cur] = adj.get(cur, []) + [nxt]
  indegrees[nxt] += 1
  
stack = []
for i in range(1, n+1):
  if indegrees[i] == 0:
    stack.append(i)
    
dp = [0 for _ in range(n+1)]
    
while stack:
  cur = stack.pop()
  for nxt in adj.get(cur, []):
    indegrees[nxt] -= 1
    if indegrees[nxt] == 0:
      stack.append(nxt)
    dp[nxt] = dp[cur] + 1
print(max(dp))

Failing test case input:
11 3
2 6
4 6
5 2

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
adj = {}
indegrees = [0 for _ in range(n+1)]
for _ in range(m):
  cur, nxt = map(int, input().split())
  adj[cur] = adj.get(cur, []) + [nxt]
  indegrees[nxt] += 1
  
stack = []
for i in range(1, n+1):
  if indegrees[i] == 0:
    stack.append(i)
    
dp = [0 for _ in range(n+1)]
    
while stack:
  cur = stack.pop()
  for nxt in adj.get(cur, []):
    indegrees[nxt] -= 1
    if indegrees[nxt] == 0:
      stack.append(nxt)
    dp[nxt] = max(dp[nxt], dp[cur] + 1)
print(max(dp))
Problem: p03166
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys

sys.setrecursionlimit(10**5+10)

N, M = [int(_) for _ in input().split()]


lst_edge = [[] for _ in range(N)]

for _ in range(M):
  x, y = map(int, input().split()) 
  
  lst_edge[x-1].append(y-1)
  print(lst_edge)
        


dp = [-1] * N


def rec(v):
  
  if dp[v] != -1:
    return dp[v]
  ans = 0
  lst_nv = lst_edge[v]
  for nv in lst_nv:
    ans = max(ans, rec(nv) + 1)
  dp[v] = ans
  return dp[v]
    

ans = 0
for v in range(N):
  ans = max(ans, rec(v))
    
print(ans)
    

Failing test case input:
15 2
2 6
4 6
5 6

Expected output:
1


Actual output:
[[], [5], [], [], [], [], [], [], [], [], [], [], [], [], []]
[[], [5], [], [5], [], [], [], [], [], [], [], [], [], [], []]
1


Fixed submission (verdict: Accepted):
import sys

sys.setrecursionlimit(10**5+10)

N, M = [int(_) for _ in input().split()]


lst_edge = [[] for _ in range(N)]

for _ in range(M):
  x, y = map(int, input().split()) 
  
  lst_edge[x-1].append(y-1)
        


dp = [-1] * N


def rec(v):
  
  if dp[v] != -1:
    return dp[v]
  ans = 0
  lst_nv = lst_edge[v]
  for nv in lst_nv:
    ans = max(ans, rec(nv) + 1)
  dp[v] = ans
  return dp[v]
    

ans = 0
for v in range(N):
  ans = max(ans, rec(v))
    
print(ans)

Problem: p03166
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

N,M = map(int, input().split())

move = []
for i in range(M):
    move.append(list(map(int, input().split())))

dp = [0] * (N+1)
done_n = -1

def findpath(now_x):
    if now_x <= done_n:
        return dp[now_x]
    for x,y in move:
        if now_x == x:
            dp[now_x] = max(dp[now_x],findpath(y) + 1)
    return dp[now_x]

maxpath = 0
for do_n in range(1,N+1):
    done_n = do_n - 1
    maxpath = max(maxpath,findpath(do_n))
    print(dp)

print(maxpath)


Failing test case input:
6 3
4 3
4 5
5 6

Expected output:
2


Actual output:
[0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 2, 1, 0]
[0, 0, 0, 0, 2, 1, 0]
[0, 0, 0, 0, 2, 1, 0]
2


Fixed submission (verdict: Accepted):
import sys
sys.setrecursionlimit(10**5)


N,M = map(int, input().split())

move = {}
for i in range(M):
    x,y = map(int, input().split())
    move.setdefault(x,[]).append(y)

dp = [-1] * (N+10)

def findpath(now_x):
    if dp[now_x] > -1:
        return dp[now_x]
    maxpath = 0
    if now_x in move.keys():
        for y in move[now_x]:
            maxpath = max(maxpath,findpath(y) + 1)
    dp[now_x] = maxpath
    return maxpath

Ans = 0
for do_x in range(1,N+1):
    Ans = max(Ans,findpath(do_x))

print(Ans)
Problem: p03166
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def solve(g):
    dp = [-1]*len(g)
    def _solve(f):
        if dp[f] == -1:
            dp[f] = 0
            for c in g[f]:
                dp[f] = max(dp[f], 1 + _solve(c))
        return dp[f]
    for f in range(len(g)):
        _solve(f)
    return max(dp)

n, m = map(int, input().split())
g = [[] for _ in range(n)]
for _ in range(m):
    f, t = map(int, input().split())
    g[f-1].append(t-1)

Failing test case input:
9 2
2 3
1 5
5 6

Expected output:
1


Actual output:

Fixed submission (verdict: Accepted):
import sys
sys.setrecursionlimit(10000)

def solve(g):
    dp = [-1]*len(g)
    def _solve(f):
        if dp[f] == -1:
            dp[f] = 0
            for c in g[f]:
                dp[f] = max(dp[f], 1 + _solve(c))
        return dp[f]
    for f in range(len(g)):
        _solve(f)
    
    return max(dp)

n, m = map(int, input().split())
g = [[] for _ in range(n)]
for _ in range(m):
    f, t = map(int, input().split())
    g[f-1].append(t-1)

print(solve(g))

Problem: p03166
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys

sys.setrecursionlimit(10**9)
n,m=map(int,input().split())

g=[[] for i in range(n)]
for i in range(m):
  v1,v2=map(int,input().split())
  v1-=1;v2-=1
  g[v1].append(v2)

dp=[-1]*n  
  
def dfs(i):
  temp=0
  if dp[i]!=-1:
    return dp[i]
  for nv in g[i]:
    if dp[nv]!=-1:
      temp=max(temp,dfs(nv)+1)
  dp[i]=temp  
  return temp  
    
res=0
for i in range(n):
  res=max(res,dfs(i))
print(res)


Failing test case input:
7 1
2 3
4 5
5 6

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
import sys

sys.setrecursionlimit(10**9)
n,m=map(int,input().split())

g=[[] for i in range(n)]
for i in range(m):
  v1,v2=map(int,input().split())
  v1-=1;v2-=1
  g[v1].append(v2)

dp=[-1]*n  
  
def dfs(i):
  if dp[i]!=-1:
    return dp[i]
  temp=0
  for nv in g[i]:
    temp=max(temp,dfs(nv)+1)
  dp[i]=temp  
  return temp  
    
res=0
for i in range(n):
  res=max(res,dfs(i))
print(res)
Problem: p03166
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from collections import deque
n, m = map(int, input().split( ))
Edg = [[] for _ in range(n)]


Visited = [0]*n
Root_check = [1]*n
Dist = [0]*n
for i in range(m):
    v1,v2 = map(int, input().split( ))
    v1-=1
    v2-=1
    Edg[v1].append(v2)
    Root_check[v2] = 0
    
Roots = []
for i in range(n):
    if Root_check[i] == 1:
        Roots.append(i)
Q = deque()
for r in Roots:
    Q.append(r)
    while len(Q) > 0:
        v = Q.popleft()
        for w in Edg[v]:
            Dist[w] = Dist[v] +1
            Q.append(w)

print(max(Dist))


Failing test case input:
11 3
2 6
8 6
5 2

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
import sys
from collections import deque
n, m = map(int, input().split( ))
Edg = [[] for _ in range(n)]
rev_Edg = [[] for _ in range(n)]
deg = [len(rev_Edg[i]) for i in range(n)]


Root_check = [1]*n
Dist = [0]*n
for i in range(m):
    v1,v2 = map(int, sys.stdin.readline().split( ))
    v1-=1
    v2-=1
    Edg[v1].append(v2)
    rev_Edg[v2].append(v1)
    deg[v2] += 1
    Root_check[v2] = 0
    

Q =deque()
for i in range(n):
    if Root_check[i] == 1:
        Q.append(i)

while len(Q) > 0:
    v = Q.popleft()
    for w in Edg[v]:
        Dist[w] = max(Dist[w],Dist[v] +1)
        deg[w] -=1 
        if deg[w] == 0:
            Q.append(w)
            


print(max(Dist))

Problem: p03166
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline  
from copy import deepcopy
from functools import lru_cache
N,M = map(int,input().split())
graph = [[] for _ in range(N)]
s = set()
for i in range(M):
    x,y = map(int,input().split())
    x -= 1; y -= 1
    s.add(y)
    graph[x].append(y)

@lru_cache(maxsize = None)
def dfs(x):
    print(x,graph[x])
    if not graph[x]:
        return 0
    stack = deepcopy(graph[x])
    ret = 0
    while stack:
        now = stack.pop(0)
        ret = max(ret,dfs(now)+1)
    return ret

ans = 0
for i in range(N):
    if i not in s:
        ans = max(ans,dfs(i))
print(ans)


Failing test case input:
7 1
6 3
2 5
4 6

Expected output:
1


Actual output:
0 []
1 []
3 []
4 []
5 [2]
2 []
6 []
1


Fixed submission (verdict: Accepted):
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline  
from copy import deepcopy
from functools import lru_cache
N,M = map(int,input().split())
graph = [[] for _ in range(N)]
s = set()
for i in range(M):
    x,y = map(int,input().split())
    x -= 1; y -= 1
    s.add(y)
    graph[x].append(y)

@lru_cache(maxsize = None)
def dfs(x):
    if not graph[x]:
        return 0
    stack = deepcopy(graph[x])
    ret = 0
    while stack:
        now = stack.pop(0)
        ret = max(ret,dfs(now)+1)
    return ret

ans = 0
for i in range(N):
    if i not in s:
        ans = max(ans,dfs(i))
print(ans)
Problem: p03166
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
sys.setrecursionlimit(10**9)

N, M = map(int, input().split())
path = [[] for _ in range(N)]
for _ in range(M):
    x, y = map(int, input().split())
    x, y = x-1, y-1
    path[x].append(y)

dp = [-1] * N
def dfs(v, dist):
    if dp[v] > -1:
        return dp[v]
    for i in path[v]:
        dp[v] = max(dp[v], dfs(i, dist+1))
    return dist

for i in range(N):
    if dp[i] < 0:
        dfs(i, 0)

print(max(dp))


Failing test case input:
8 -1
2 2
1 0
3 2
2 5
11 8

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
import sys
sys.setrecursionlimit(10**9)

N, M = map(int, input().split())
path = [[] for _ in range(N)]
for _ in range(M):
    x, y = map(int, input().split())
    x, y = x-1, y-1
    path[x].append(y)

dp = [-1] * N
def dfs(v):
    if dp[v] > -1:
        return dp[v] + 1
    ret = 0
    for i in path[v]:
        ret = max(ret, dfs(i))
    dp[v] = ret
    return ret + 1


for i in range(N):
    if dp[i] < 0:
        dfs(i)

print(max(dp))

Problem: p03166
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
sys.setrecursionlimit(10**5+10)
def memo(v):
    if dp[v]!=-1:return dp[v]
    ans = 0
    for next_v in g[v]:
        ans = max(ans,memo(next_v)+1)
    dp[v] = ans
    print("dp={}".format(dp))
    return ans

n,m = map(int,input().split())
g = [[] for _ in range(n+1)]
for _ in range(m):
    x,y = map(int,input().split())
    g[x].append(y)
    
dp = [-1]*(n+1)

ans = 0
for v in range(1,n+1):
    ans = max(ans, memo(v))
    
print(ans)

Failing test case input:
7 1
6 3
2 5
3 6

Expected output:
1


Actual output:
dp=[-1, 0, -1, -1, -1, -1, -1, -1]
dp=[-1, 0, 0, -1, -1, -1, -1, -1]
dp=[-1, 0, 0, 0, -1, -1, -1, -1]
dp=[-1, 0, 0, 0, 0, -1, -1, -1]
dp=[-1, 0, 0, 0, 0, 0, -1, -1]
dp=[-1, 0, 0, 0, 0, 0, 1, -1]
dp=[-1, 0, 0, 0, 0, 0, 1, 0]
1


Fixed submission (verdict: Accepted):
import sys
sys.setrecursionlimit(10**5+10)
def memo(v):
    if dp[v]!=-1:return dp[v]
    ans = 0
    for next_v in g[v]:
        ans = max(ans,memo(next_v)+1)
    dp[v] = ans
    return ans

n,m = map(int,input().split())
g = [[] for _ in range(n+1)]
for _ in range(m):
    x,y = map(int,input().split())
    g[x].append(y)
    
dp = [-1]*(n+1)

ans = 0
for v in range(1,n+1):
    ans = max(ans, memo(v))
    
print(ans)
Problem: p03166
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N,M = map(int,input().split())

path = [[] for _ in range(N)]
pin = [0]*N
for _ in range(M):
  ip,op = map(int,input().split())
  pin[op-1]+=1
  path[ip-1].append(op-1)

cur = []
for i in range(N):
  if pin[i]==0:
    cur.append(i)

ans = 0
while cur:
  ans += 1
  nxt = []
  for ip in cur:
    for op in path[ip]:
      pin[ip] -= 1
      if pin[ip]==0 and not(op in nxt):
        nxt.append(op)
  cur = [x for x in nxt]
print(ans-1)


Failing test case input:
6 3
2 3
4 5
2 6

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
N,M = map(int,input().split())

path = [[] for _ in range(N)]
pin = [0]*N
for _ in range(M):
  ip,op = map(int,input().split())
  pin[op-1]+=1
  path[ip-1].append(op-1)

cur = []
for i in range(N):
  if pin[i]==0:
    cur.append(i)

ans = 0
while cur:
  ans += 1
  nxt = []
  for ip in cur:
    for op in path[ip]:
      pin[op] -= 1
      if pin[op]==0 and not(op in nxt):
        nxt.append(op)
  cur = [x for x in nxt]
print(ans-1)

Problem: p03166
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from collections import defaultdict

n,m=map(int,input().split())
adj=defaultdict(list)
deg=[0]*(n+1)
for i in range(m):
    x,y=map(int,input().split())
    adj[x].append(y)
    deg[y]+=1

dist=[0]*(n+1)

que=[]
for i in range(n+1):
    if deg[i]==0:
        que.append(i)

while que:
    v=que.pop()
    for i in adj[v]:
        deg[i]-=1
        if deg[i]==0:
            que.append(i)
            dist[i]=max(dist[i],dist[v]+1)

print(max(dist))
 


Failing test case input:
6 3
2 6
4 6
5 2

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
from collections import defaultdict

n,m=map(int,input().split())
adj=defaultdict(list)
deg=[0]*(n+1)
for i in range(m):
    x,y=map(int,input().split())
    adj[x].append(y)
    deg[y]+=1

dist=[0]*(n+1)

que=[]
for i in range(1,n+1):
    if deg[i]==0:
        que.append(i)

while que:
    v=que.pop()
    for i in adj[v]:
        deg[i]-=1
        if deg[i]==0:
            que.append(i)
        dist[i]=max(dist[i],dist[v]+1)

print(max(dist))
Problem: p03166
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import collections
import sys
sys.setrecursionlimit(10**6)
def dp(node,cache,edge):
  if node in cache:
    return cache[node]
  lcl_max=0
  for child in edge[node]:
    cache[child]=dp(child,cache,edge)
    lcl_max=max(lcl_max,1+cache[child])
  return lcl_max
 
max_dis=0
cache,edge={},collections.defaultdict(list)
n,m=map(int,input().split())
for _ in range(m):
  a,b=map(int,input().split())
  edge[a].append(b)
for node in range(1,n+1):
  max_dis=max(max_dis,dp(node,cache,edge))

Failing test case input:
7 0
6 5
0 4
4 6

Expected output:
0


Actual output:

Fixed submission (verdict: Accepted):
import collections
import sys
sys.setrecursionlimit(10**9)
cache,edge={},collections.defaultdict(list)
def dp(node):
  if node in cache:
    return cache[node]
  lcl_max=0
  for child in edge[node]:
    
    lcl_max=max(lcl_max,1+dp(child))
  cache[node]=lcl_max
  return lcl_max
 
max_dis=0

n,m=map(int,input().split())
for _ in range(m):
  a,b=map(int,input().split())
  edge[a].append(b)
for node in range(1,n+1):
  max_dis=max(max_dis,dp(node))
print(max_dis)

Problem: p03166
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())
G = [[] for i in range(n)]
I = [0 for i in range(n)]
for j in range(m):
    x, y = map(int, input().split())
    G[x-1].append(y-1)
    I[y-1] += 1
S = [i for i in range(n) if I[i] == 0]
L = [0 for i in range(n)]
while S:
    i = S.pop()
    while G[i]:
        j = G[i].pop()
        I[j] -= 1
        if I[j] == 0:
            S.append(j)
            L[j] = max(L[j], L[i]+1)
print(max(L))


Failing test case input:
6 3
2 6
4 6
5 2

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
G = [[] for i in range(n)]
I = [0 for i in range(n)]
for j in range(m):
    x, y = map(int, input().split())
    G[x-1].append(y-1)
    I[y-1] += 1

Q = [i for i in range(n) if I[i] == 0]

L = [0 for i in range(n)]
while Q:
    i = Q.pop()
    while G[i]:
        j = G[i].pop()
        I[j] -= 1
        L[j] = max(L[j], L[i]+1)
        if I[j] == 0:
            Q.append(j)
print(max(L))
Problem: p03166
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N,M = map(int,input().split(" "))
inedge = [0] * N
edge = [ [] for _ in range(N) ]
for i in range(M):
    x,y = map(int,input().split(" "))
    inedge[y-1] += 1
    edge[x-1].append(y-1)

stack = []
for i in range(N):
    if inedge[i] == 0:
        stack.append((i,0))

ans = 0
while len(stack) != 0:
    nextVer,passLen = stack.pop()
    ans = max(ans,passLen)
    for e in edge[nextVer]:
        inedge[e] -= 1
        if inedge[e] == 0:
            stack.append((e,passLen+1))


print(ans)

Failing test case input:
6 3
2 6
4 6
5 2

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N,M = map(int,input().split(" "))
inedge = [0] * N
edge = [ [] for _ in range(N) ]
for i in range(M):
    x,y = map(int,input().split(" "))
    inedge[y-1] += 1
    edge[x-1].append(y-1)

stack = []
for i in range(N):
    if inedge[i] == 0:
        stack.append((i,0))

ans = [0] * N
while len(stack) != 0:
    nextVer,passLen = stack.pop()
    for e in edge[nextVer]:
        inedge[e] -= 1
        ans[e] = max(ans[e],passLen+1)
        if inedge[e] == 0:
            stack.append((e,ans[e]))

print(max(ans))

Problem: p03166
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict, deque

n, m = map(int, input().split())
xy = []
node = defaultdict(int)
branch = defaultdict(list)
dp = [0]*(n+1) 

for _ in range(m):
    x, y = map(int, input().split())
    xy.append([x, y])
    node[y] += 1 
    branch[x].append(y) 


res = []
queue = deque([i for i in range(1, n+1) if node[i]==0])
while queue:
    v = queue.popleft()
    res.append(v)
    
    for u in branch[v]:
        node[u] -= 1
        if node[u] == 0:
            queue.append(u)

for i in range(m):
    dp[xy[i][1]] = max(dp[xy[i][1]], dp[xy[i][0]]+1)
print(max(dp))

Failing test case input:
6 3
2 6
4 6
5 2

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
from collections import defaultdict, deque

n, m = map(int, input().split())
xy = []
node = defaultdict(int)
branch = defaultdict(list)
dp = [0]*(n+1) 

for _ in range(m):
    x, y = map(int, input().split())
    xy.append([x, y])
    node[y] += 1 
    branch[x].append(y) 


res = []
queue = deque([i for i in range(1, n+1) if node[i]==0])
while queue:
    v = queue.popleft()
    res.append(v)
    
    for u in branch[v]:
        dp[u] = max(dp[u], dp[v]+1)
        node[u] -= 1
        if node[u] == 0:
            queue.append(u)



print(max(dp))
Problem: p03166
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from collections import deque

N,M = map(int, input().split())
to_nodes = [[] for _ in range(N)] 
deg = [0]*N 

for _ in range(M):
    x,y = map(int, input().split())
    to_nodes[x-1].append(y-1)
    deg[y-1] += 1

st = deque()
push, pop = st.append, st.pop

for n in range(N):
    if deg[n] == 0:
        push(n) 

dp = [0]*N

while st:
    n = pop()
    nodes = to_nodes[n]
    for ni in nodes:
        deg[ni] -= 1 
        if deg[ni] == 0:
            push(ni)
            dp[ni] = max(dp[ni], dp[n] + 1)
        

print(max(dp))

''

Failing test case input:
6 3
2 6
4 6
5 2

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
from collections import deque

N,M = map(int, input().split())
to_nodes = [[] for _ in range(N)] 
deg = [0]*N 

for _ in range(M):
    x,y = map(int, input().split())
    to_nodes[x-1].append(y-1)
    deg[y-1] += 1

st = deque()
push, pop = st.append, st.popleft

for n in range(N):
    if deg[n] == 0:
        push(n) 

dp = [0]*N

while st:
    n = pop()
    nodes = to_nodes[n]
    for ni in nodes:
        deg[ni] -= 1 
        if deg[ni] == 0:
            push(ni)
            dp[ni] = max(dp[ni], dp[n] + 1)
        

print(max(dp))

''

Problem: p03166
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N,M = map(int,input().split())

path = [[] for _ in range(N)]
pin = [0]*N
for _ in range(M):
  ip,op = map(int,input().split())
  pin[op-1]+=1
  path[ip-1].append(op-1)

cur = []
for i in range(N):
  if pin[i]==0:
    cur.append(i)

ans = 0
while cur:
  ans += 1
  nxt = []
  for ip in cur:
    for op in path[ip]:
      pin[ip] -= 1
      if pin[ip]==0 and not(op in nxt):
        nxt.append(op)
  cur = [x for x in nxt]
print(ans)

Failing test case input:
4 5
1 2
1 4
3 2
2 4
3 4

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N,M = map(int,input().split())

path = [[] for _ in range(N)]
pin = [0]*N
for _ in range(M):
  ip,op = map(int,input().split())
  pin[op-1]+=1
  path[ip-1].append(op-1)

cur = []
for i in range(N):
  if pin[i]==0:
    cur.append(i)

ans = 0
while cur:
  ans += 1
  nxt = []
  for ip in cur:
    for op in path[ip]:
      pin[op] -= 1
      if pin[op]==0 and not(op in nxt):
        nxt.append(op)
  cur = [x for x in nxt]
print(ans-1)
Problem: p03166
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from collections import deque

N, M = map(int, input().split())

dp = [0] * N
E = [[] for _ in range(N)]
deg = [0] * N
for _ in range(M):
    x, y = map(int, input().split())
    E[x-1].append(y-1)
    deg[y-1] += 1

que = deque(i for i in range(N) if deg[i] == 0)
while que:
    v = que.pop()
    for u in E[v]:
        deg[u] -= 1
        if deg[u] == 0:
            que.append(u)
            dp[u] = max(dp[u], dp[v] + 1)

print(max(dp))


Failing test case input:
6 3
2 6
4 5
5 6

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
from collections import deque

N, M = map(int, input().split())

dp = [0] * N
E = [[] for _ in range(N)]
deg = [0] * N
for _ in range(M):
    x, y = map(int, input().split())
    E[x-1].append(y-1)
    deg[y-1] += 1

que = deque(v for v in range(N) if deg[v] == 0)
while que:
    v = que.pop()
    for u in E[v]:
        deg[u] -= 1
        if deg[u] == 0:
            que.appendleft(u)
            dp[u] = max(dp[u], dp[v] + 1)

print(max(dp))

Problem: p03166
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
sys.setrecursionlimit(10 ** 6)
N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    x, y = map(int, input().split())
    x, y = x - 1, y - 1
    G[x].append(y)

d = [-1] * N


def dfs(u, d1):
    if d[i] != -1:
        return d[i]

    ma = 0
    for w in G[u]:
        ma = max(ma, dfs(w, d1 + 1)) + 1

    d[i] = ma
    return ma

ans = 0
for i in range(N):
    ans = max(ans, dfs(i, 0))

print(ans)



Failing test case input:
12 3
2 3
4 5
2 6

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
import sys
sys.setrecursionlimit(10 ** 6)
N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    x, y = map(int, input().split())
    x, y = x - 1, y - 1
    G[x].append(y)
d = [-1] * N


def dfs(u):
    if d[u] != -1:
        return d[u]

    ma = 0
    for w in G[u]:
        ma = max(ma, dfs(w))

    d[u] = ma + 1
    return ma + 1


ans = 0
for i in range(N):
    ans = max(ans, dfs(i))

print(ans - 1)
Problem: p03166
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
sys.setrecursionlimit(10**5+1)

N,M = map(int,input().split())
nodes = [[] for _ in range(N)]

for _ in range(M):
  x,y = map(int,input().split())
  nodes[x-1].append(y-1)
  
dp = [-1]*N

def judge(index):
  if dp[index] != -1:
    return dp[index]
  else:
    edges = 0
    for i in nodes[index]:
      edges = max(edges, 1+judge(i))
    dp[index] = edges
    print(index,dp)
    return edges

answer = 0
for i in range(N):
  answer = max(answer, judge(i))
print(answer)

Failing test case input:
7 1
7 1
3 1
3 6

Expected output:
1


Actual output:
0 [0, -1, -1, -1, -1, -1, -1]
1 [0, 0, -1, -1, -1, -1, -1]
2 [0, 0, 0, -1, -1, -1, -1]
3 [0, 0, 0, 0, -1, -1, -1]
4 [0, 0, 0, 0, 0, -1, -1]
5 [0, 0, 0, 0, 0, 0, -1]
6 [0, 0, 0, 0, 0, 0, 1]
1


Fixed submission (verdict: Accepted):
import sys
sys.setrecursionlimit(10**5+1)

N,M = map(int,input().split())
nodes = [[] for _ in range(N)]

for _ in range(M):
  x,y = map(int,input().split())
  nodes[x-1].append(y-1)
  
dp = [-1]*N

def judge(index):
  if dp[index] != -1:
    return dp[index]
  else:
    edges = 0
    for i in nodes[index]:
      edges = max(edges, 1+judge(i))
    dp[index] = edges
    return edges

answer = 0
for i in range(N):
  answer = max(answer, judge(i))
print(answer)