text stringlengths 216 39.6k | conversation_id int64 219 108k | embedding list | cluster int64 11 11 |
|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating changes by some value, possibly negative or zero.
Limak competed in n contests in the year 2016. He remembers that in the i-th contest he competed in the division di (i.e. he belonged to this division just before the start of this contest) and his rating changed by ci just after the contest. Note that negative ci denotes the loss of rating.
What is the maximum possible rating Limak can have right now, after all n contests? If his rating may be arbitrarily big, print "Infinity". If there is no scenario matching the given information, print "Impossible".
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000).
The i-th of next n lines contains two integers ci and di ( - 100 ≤ ci ≤ 100, 1 ≤ di ≤ 2), describing Limak's rating change after the i-th contest and his division during the i-th contest contest.
Output
If Limak's current rating can be arbitrarily big, print "Infinity" (without quotes). If the situation is impossible, print "Impossible" (without quotes). Otherwise print one integer, denoting the maximum possible value of Limak's current rating, i.e. rating after the n contests.
Examples
Input
3
-7 1
5 2
8 2
Output
1907
Input
2
57 1
22 2
Output
Impossible
Input
1
-5 1
Output
Infinity
Input
4
27 2
13 1
-50 1
8 2
Output
1897
Note
In the first sample, the following scenario matches all information Limak remembers and has maximum possible final rating:
* Limak has rating 1901 and belongs to the division 1 in the first contest. His rating decreases by 7.
* With rating 1894 Limak is in the division 2. His rating increases by 5.
* Limak has rating 1899 and is still in the division 2. In the last contest of the year he gets + 8 and ends the year with rating 1907.
In the second sample, it's impossible that Limak is in the division 1, his rating increases by 57 and after that Limak is in the division 2 in the second contest.
Tags: binary search, greedy, math
Correct Solution:
```
q=int(input())
q-=1
a,s=map(int,input().split())
if s==1:
z=1900
x=9000000000
else:
z=-9000000000
x=1899
z+=a
x+=a
for j in range(0,q):
a,s=map(int,input().split())
if s==1:
z=max(1900,z)
else:
x=min(1899,x)
z+=a
x+=a
if x<z:
print('Impossible')
elif x>=7000000000:
print('Infinity')
else:
print(x)
```
| 63,583 | [
0.274658203125,
-0.108642578125,
-0.333740234375,
0.146728515625,
-0.271728515625,
-0.79638671875,
-0.06378173828125,
0.1441650390625,
0.060516357421875,
0.79736328125,
0.56591796875,
-0.3125,
0.2186279296875,
-0.77783203125,
-0.254638671875,
-0.01445770263671875,
-0.51953125,
-0.6... | 11 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating changes by some value, possibly negative or zero.
Limak competed in n contests in the year 2016. He remembers that in the i-th contest he competed in the division di (i.e. he belonged to this division just before the start of this contest) and his rating changed by ci just after the contest. Note that negative ci denotes the loss of rating.
What is the maximum possible rating Limak can have right now, after all n contests? If his rating may be arbitrarily big, print "Infinity". If there is no scenario matching the given information, print "Impossible".
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000).
The i-th of next n lines contains two integers ci and di ( - 100 ≤ ci ≤ 100, 1 ≤ di ≤ 2), describing Limak's rating change after the i-th contest and his division during the i-th contest contest.
Output
If Limak's current rating can be arbitrarily big, print "Infinity" (without quotes). If the situation is impossible, print "Impossible" (without quotes). Otherwise print one integer, denoting the maximum possible value of Limak's current rating, i.e. rating after the n contests.
Examples
Input
3
-7 1
5 2
8 2
Output
1907
Input
2
57 1
22 2
Output
Impossible
Input
1
-5 1
Output
Infinity
Input
4
27 2
13 1
-50 1
8 2
Output
1897
Note
In the first sample, the following scenario matches all information Limak remembers and has maximum possible final rating:
* Limak has rating 1901 and belongs to the division 1 in the first contest. His rating decreases by 7.
* With rating 1894 Limak is in the division 2. His rating increases by 5.
* Limak has rating 1899 and is still in the division 2. In the last contest of the year he gets + 8 and ends the year with rating 1907.
In the second sample, it's impossible that Limak is in the division 1, his rating increases by 57 and after that Limak is in the division 2 in the second contest.
Tags: binary search, greedy, math
Correct Solution:
```
n=int(input())
INF=10**18
l=-INF
r=INF
s=0
for _ in range(n):
c,d=map(int,input().split())
if d==1 and l+s<1900:
l=1900-s
if d==2 and r+s>=1900:
r=1899-s
s+=c
if l<-INF:
l=-INF
if r>INF:
r=INF
if l>r:
print("Impossible")
elif r>10**15:
print("Infinity")
else:
print(r+s)
```
| 63,584 | [
0.274658203125,
-0.108642578125,
-0.333740234375,
0.146728515625,
-0.271728515625,
-0.79638671875,
-0.06378173828125,
0.1441650390625,
0.060516357421875,
0.79736328125,
0.56591796875,
-0.3125,
0.2186279296875,
-0.77783203125,
-0.254638671875,
-0.01445770263671875,
-0.51953125,
-0.6... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating changes by some value, possibly negative or zero.
Limak competed in n contests in the year 2016. He remembers that in the i-th contest he competed in the division di (i.e. he belonged to this division just before the start of this contest) and his rating changed by ci just after the contest. Note that negative ci denotes the loss of rating.
What is the maximum possible rating Limak can have right now, after all n contests? If his rating may be arbitrarily big, print "Infinity". If there is no scenario matching the given information, print "Impossible".
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000).
The i-th of next n lines contains two integers ci and di ( - 100 ≤ ci ≤ 100, 1 ≤ di ≤ 2), describing Limak's rating change after the i-th contest and his division during the i-th contest contest.
Output
If Limak's current rating can be arbitrarily big, print "Infinity" (without quotes). If the situation is impossible, print "Impossible" (without quotes). Otherwise print one integer, denoting the maximum possible value of Limak's current rating, i.e. rating after the n contests.
Examples
Input
3
-7 1
5 2
8 2
Output
1907
Input
2
57 1
22 2
Output
Impossible
Input
1
-5 1
Output
Infinity
Input
4
27 2
13 1
-50 1
8 2
Output
1897
Note
In the first sample, the following scenario matches all information Limak remembers and has maximum possible final rating:
* Limak has rating 1901 and belongs to the division 1 in the first contest. His rating decreases by 7.
* With rating 1894 Limak is in the division 2. His rating increases by 5.
* Limak has rating 1899 and is still in the division 2. In the last contest of the year he gets + 8 and ends the year with rating 1907.
In the second sample, it's impossible that Limak is in the division 1, his rating increases by 57 and after that Limak is in the division 2 in the second contest.
Submitted Solution:
```
n = int(input())
A = [0] * n
per = 0
ans1 = float('infinity')
ans2 = -float('infinity')
for j in range(n):
per1,per2 = map(int,input().split())
if per2 == 1:
if ans1 < 1900:
per = 1
break
else:
ans2 = max(ans2,1900)
ans1 += per1
ans2 += per1
else:
if ans2 >= 1900:
per =1
break
else:
ans1 = min(ans1,1899)
ans1 += per1
ans2 += per1
if ans1 < ans2:
per = 1
break
if per == 0:
if ans1 == float('infinity'):
print('Infinity')
else:
print(ans1)
else:
print('Impossible')
```
Yes
| 63,585 | [
0.447021484375,
-0.07257080078125,
-0.33447265625,
0.06591796875,
-0.379150390625,
-0.65966796875,
-0.1331787109375,
0.2236328125,
0.06805419921875,
0.755859375,
0.42333984375,
-0.26904296875,
0.1934814453125,
-0.70947265625,
-0.287109375,
-0.07562255859375,
-0.4921875,
-0.60107421... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating changes by some value, possibly negative or zero.
Limak competed in n contests in the year 2016. He remembers that in the i-th contest he competed in the division di (i.e. he belonged to this division just before the start of this contest) and his rating changed by ci just after the contest. Note that negative ci denotes the loss of rating.
What is the maximum possible rating Limak can have right now, after all n contests? If his rating may be arbitrarily big, print "Infinity". If there is no scenario matching the given information, print "Impossible".
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000).
The i-th of next n lines contains two integers ci and di ( - 100 ≤ ci ≤ 100, 1 ≤ di ≤ 2), describing Limak's rating change after the i-th contest and his division during the i-th contest contest.
Output
If Limak's current rating can be arbitrarily big, print "Infinity" (without quotes). If the situation is impossible, print "Impossible" (without quotes). Otherwise print one integer, denoting the maximum possible value of Limak's current rating, i.e. rating after the n contests.
Examples
Input
3
-7 1
5 2
8 2
Output
1907
Input
2
57 1
22 2
Output
Impossible
Input
1
-5 1
Output
Infinity
Input
4
27 2
13 1
-50 1
8 2
Output
1897
Note
In the first sample, the following scenario matches all information Limak remembers and has maximum possible final rating:
* Limak has rating 1901 and belongs to the division 1 in the first contest. His rating decreases by 7.
* With rating 1894 Limak is in the division 2. His rating increases by 5.
* Limak has rating 1899 and is still in the division 2. In the last contest of the year he gets + 8 and ends the year with rating 1907.
In the second sample, it's impossible that Limak is in the division 1, his rating increases by 57 and after that Limak is in the division 2 in the second contest.
Submitted Solution:
```
n = int(input())
c, d = map(int, input().split())
min_ = 0
max_ = 0
flag = True
if d == 1:
min_ = 1900
max_ = float("+Inf")
else:
min_ = float("-Inf")
max_ = 1899
for i in range(n - 1):
c1, d = map(int, input().split())
if d == 1:
min_ = max(min_ + c, 1900)
max_ += c
else:
max_ = min(max_ + c, 1899)
min_ += c
if min_ > max_:
flag = False
c = c1
min_ += c
max_ += c
if not(flag):
print("Impossible")
elif max_ == float("+Inf"):
print("Infinity")
else:
print(max_)
```
Yes
| 63,586 | [
0.447021484375,
-0.07257080078125,
-0.33447265625,
0.06591796875,
-0.379150390625,
-0.65966796875,
-0.1331787109375,
0.2236328125,
0.06805419921875,
0.755859375,
0.42333984375,
-0.26904296875,
0.1934814453125,
-0.70947265625,
-0.287109375,
-0.07562255859375,
-0.4921875,
-0.60107421... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating changes by some value, possibly negative or zero.
Limak competed in n contests in the year 2016. He remembers that in the i-th contest he competed in the division di (i.e. he belonged to this division just before the start of this contest) and his rating changed by ci just after the contest. Note that negative ci denotes the loss of rating.
What is the maximum possible rating Limak can have right now, after all n contests? If his rating may be arbitrarily big, print "Infinity". If there is no scenario matching the given information, print "Impossible".
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000).
The i-th of next n lines contains two integers ci and di ( - 100 ≤ ci ≤ 100, 1 ≤ di ≤ 2), describing Limak's rating change after the i-th contest and his division during the i-th contest contest.
Output
If Limak's current rating can be arbitrarily big, print "Infinity" (without quotes). If the situation is impossible, print "Impossible" (without quotes). Otherwise print one integer, denoting the maximum possible value of Limak's current rating, i.e. rating after the n contests.
Examples
Input
3
-7 1
5 2
8 2
Output
1907
Input
2
57 1
22 2
Output
Impossible
Input
1
-5 1
Output
Infinity
Input
4
27 2
13 1
-50 1
8 2
Output
1897
Note
In the first sample, the following scenario matches all information Limak remembers and has maximum possible final rating:
* Limak has rating 1901 and belongs to the division 1 in the first contest. His rating decreases by 7.
* With rating 1894 Limak is in the division 2. His rating increases by 5.
* Limak has rating 1899 and is still in the division 2. In the last contest of the year he gets + 8 and ends the year with rating 1907.
In the second sample, it's impossible that Limak is in the division 1, his rating increases by 57 and after that Limak is in the division 2 in the second contest.
Submitted Solution:
```
n = int(input())
up = -10 ** 9
down = -up
for i in range(n):
c, d = map(int, input().split())
if d == 1:
up = max(1900, up)
else:
down = min(1899, down)
up += c
down += c
if down < up:
print('Impossible')
elif down >= 10 ** 8:
print('Infinity')
else:
print(down)
```
Yes
| 63,587 | [
0.447021484375,
-0.07257080078125,
-0.33447265625,
0.06591796875,
-0.379150390625,
-0.65966796875,
-0.1331787109375,
0.2236328125,
0.06805419921875,
0.755859375,
0.42333984375,
-0.26904296875,
0.1934814453125,
-0.70947265625,
-0.287109375,
-0.07562255859375,
-0.4921875,
-0.60107421... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating changes by some value, possibly negative or zero.
Limak competed in n contests in the year 2016. He remembers that in the i-th contest he competed in the division di (i.e. he belonged to this division just before the start of this contest) and his rating changed by ci just after the contest. Note that negative ci denotes the loss of rating.
What is the maximum possible rating Limak can have right now, after all n contests? If his rating may be arbitrarily big, print "Infinity". If there is no scenario matching the given information, print "Impossible".
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000).
The i-th of next n lines contains two integers ci and di ( - 100 ≤ ci ≤ 100, 1 ≤ di ≤ 2), describing Limak's rating change after the i-th contest and his division during the i-th contest contest.
Output
If Limak's current rating can be arbitrarily big, print "Infinity" (without quotes). If the situation is impossible, print "Impossible" (without quotes). Otherwise print one integer, denoting the maximum possible value of Limak's current rating, i.e. rating after the n contests.
Examples
Input
3
-7 1
5 2
8 2
Output
1907
Input
2
57 1
22 2
Output
Impossible
Input
1
-5 1
Output
Infinity
Input
4
27 2
13 1
-50 1
8 2
Output
1897
Note
In the first sample, the following scenario matches all information Limak remembers and has maximum possible final rating:
* Limak has rating 1901 and belongs to the division 1 in the first contest. His rating decreases by 7.
* With rating 1894 Limak is in the division 2. His rating increases by 5.
* Limak has rating 1899 and is still in the division 2. In the last contest of the year he gets + 8 and ends the year with rating 1907.
In the second sample, it's impossible that Limak is in the division 1, his rating increases by 57 and after that Limak is in the division 2 in the second contest.
Submitted Solution:
```
"""
Author : Arif Ahmad
Date :
Algo :
Difficulty :
"""
def main():
n = int(input())
mn = -int(2e9)
mx = int(2e9)
impossible = False
for i in range(n):
c, d = [int(_) for _ in input().split()]
if (d==1 and mx<1900) or (d==2 and mn>1899):
impossible = True
break
if d == 1: mn = max(mn, 1900)
else: mx = min(mx, 1899)
mn += c
mx += c
if mn > mx:
impossible = True
break
if impossible: print('Impossible')
elif mx > 1e9: print('Infinity')
else: print(mx)
if __name__ == '__main__':
main()
```
Yes
| 63,588 | [
0.447021484375,
-0.07257080078125,
-0.33447265625,
0.06591796875,
-0.379150390625,
-0.65966796875,
-0.1331787109375,
0.2236328125,
0.06805419921875,
0.755859375,
0.42333984375,
-0.26904296875,
0.1934814453125,
-0.70947265625,
-0.287109375,
-0.07562255859375,
-0.4921875,
-0.60107421... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating changes by some value, possibly negative or zero.
Limak competed in n contests in the year 2016. He remembers that in the i-th contest he competed in the division di (i.e. he belonged to this division just before the start of this contest) and his rating changed by ci just after the contest. Note that negative ci denotes the loss of rating.
What is the maximum possible rating Limak can have right now, after all n contests? If his rating may be arbitrarily big, print "Infinity". If there is no scenario matching the given information, print "Impossible".
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000).
The i-th of next n lines contains two integers ci and di ( - 100 ≤ ci ≤ 100, 1 ≤ di ≤ 2), describing Limak's rating change after the i-th contest and his division during the i-th contest contest.
Output
If Limak's current rating can be arbitrarily big, print "Infinity" (without quotes). If the situation is impossible, print "Impossible" (without quotes). Otherwise print one integer, denoting the maximum possible value of Limak's current rating, i.e. rating after the n contests.
Examples
Input
3
-7 1
5 2
8 2
Output
1907
Input
2
57 1
22 2
Output
Impossible
Input
1
-5 1
Output
Infinity
Input
4
27 2
13 1
-50 1
8 2
Output
1897
Note
In the first sample, the following scenario matches all information Limak remembers and has maximum possible final rating:
* Limak has rating 1901 and belongs to the division 1 in the first contest. His rating decreases by 7.
* With rating 1894 Limak is in the division 2. His rating increases by 5.
* Limak has rating 1899 and is still in the division 2. In the last contest of the year he gets + 8 and ends the year with rating 1907.
In the second sample, it's impossible that Limak is in the division 1, his rating increases by 57 and after that Limak is in the division 2 in the second contest.
Submitted Solution:
```
n=int(input())
d=[]
r=[]
s=[i for i in range(1900)]
s.reverse()
for i in range(n):
a,b=map(int,input().split())
r.append(a)
d.append(b)
try:
try:
x = d[d.index(2)+1:].index(1)+d.index(2)
except:
x=n-1
p = False
while p == False:
q = s[0]
p = True
for i in range(x + 1, n):
q += r[i - 1]
if d[i] == 1:
if q < 1900:
s.pop(0)
p = False
break
else:
if q > 1899:
s.pop(0)
p = False
break
res=q +r[-1]
if s[0] == 0:
print('Impossible')
break
if not p:
continue
q = s[0]
for i in range(1, x + 1):
q -= r[x - i]
if d[x - i] == 1:
if q < 1900:
s.pop(0)
p = False
break
else:
if q > 1899:
s.pop(0)
p = False
break
else:
print(res)
except ValueError:
print('Infinity')
```
No
| 63,589 | [
0.447021484375,
-0.07257080078125,
-0.33447265625,
0.06591796875,
-0.379150390625,
-0.65966796875,
-0.1331787109375,
0.2236328125,
0.06805419921875,
0.755859375,
0.42333984375,
-0.26904296875,
0.1934814453125,
-0.70947265625,
-0.287109375,
-0.07562255859375,
-0.4921875,
-0.60107421... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating changes by some value, possibly negative or zero.
Limak competed in n contests in the year 2016. He remembers that in the i-th contest he competed in the division di (i.e. he belonged to this division just before the start of this contest) and his rating changed by ci just after the contest. Note that negative ci denotes the loss of rating.
What is the maximum possible rating Limak can have right now, after all n contests? If his rating may be arbitrarily big, print "Infinity". If there is no scenario matching the given information, print "Impossible".
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000).
The i-th of next n lines contains two integers ci and di ( - 100 ≤ ci ≤ 100, 1 ≤ di ≤ 2), describing Limak's rating change after the i-th contest and his division during the i-th contest contest.
Output
If Limak's current rating can be arbitrarily big, print "Infinity" (without quotes). If the situation is impossible, print "Impossible" (without quotes). Otherwise print one integer, denoting the maximum possible value of Limak's current rating, i.e. rating after the n contests.
Examples
Input
3
-7 1
5 2
8 2
Output
1907
Input
2
57 1
22 2
Output
Impossible
Input
1
-5 1
Output
Infinity
Input
4
27 2
13 1
-50 1
8 2
Output
1897
Note
In the first sample, the following scenario matches all information Limak remembers and has maximum possible final rating:
* Limak has rating 1901 and belongs to the division 1 in the first contest. His rating decreases by 7.
* With rating 1894 Limak is in the division 2. His rating increases by 5.
* Limak has rating 1899 and is still in the division 2. In the last contest of the year he gets + 8 and ends the year with rating 1907.
In the second sample, it's impossible that Limak is in the division 1, his rating increases by 57 and after that Limak is in the division 2 in the second contest.
Submitted Solution:
```
from sys import stdin, stdout
n = int(stdin.readline())
questions = []
label = 0
for i in range(n):
value, d = map(int, stdin.readline().split())
questions.append((value, d))
r = 1899
label = 0
if questions[0][1] == 2:
ind = 0
cnt = 0
for i in range(n):
if questions[i][1] == 2:
cnt += questions[i][0]
else:
break
l = 1900 - cnt
r = 1900 + questions[i - 1][0] - cnt
else:
for i in range(n):
if questions[i][1] == 2:
l = 1900 + questions[i - 1][0]
ind = i
break
else:
label = 1
if label:
stdout.write('Infinity')
else:
for i in range(r, l - 1, -1):
rating = i
for j in range(ind, n):
if questions[j][1] == 1 and rating < 1900:
break
elif questions[j][1] == 2 and rating >= 1900:
break
rating += questions[j][0]
else:
stdout.write(str(rating))
break
else:
stdout.write('Impossible')
```
No
| 63,590 | [
0.447021484375,
-0.07257080078125,
-0.33447265625,
0.06591796875,
-0.379150390625,
-0.65966796875,
-0.1331787109375,
0.2236328125,
0.06805419921875,
0.755859375,
0.42333984375,
-0.26904296875,
0.1934814453125,
-0.70947265625,
-0.287109375,
-0.07562255859375,
-0.4921875,
-0.60107421... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating changes by some value, possibly negative or zero.
Limak competed in n contests in the year 2016. He remembers that in the i-th contest he competed in the division di (i.e. he belonged to this division just before the start of this contest) and his rating changed by ci just after the contest. Note that negative ci denotes the loss of rating.
What is the maximum possible rating Limak can have right now, after all n contests? If his rating may be arbitrarily big, print "Infinity". If there is no scenario matching the given information, print "Impossible".
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000).
The i-th of next n lines contains two integers ci and di ( - 100 ≤ ci ≤ 100, 1 ≤ di ≤ 2), describing Limak's rating change after the i-th contest and his division during the i-th contest contest.
Output
If Limak's current rating can be arbitrarily big, print "Infinity" (without quotes). If the situation is impossible, print "Impossible" (without quotes). Otherwise print one integer, denoting the maximum possible value of Limak's current rating, i.e. rating after the n contests.
Examples
Input
3
-7 1
5 2
8 2
Output
1907
Input
2
57 1
22 2
Output
Impossible
Input
1
-5 1
Output
Infinity
Input
4
27 2
13 1
-50 1
8 2
Output
1897
Note
In the first sample, the following scenario matches all information Limak remembers and has maximum possible final rating:
* Limak has rating 1901 and belongs to the division 1 in the first contest. His rating decreases by 7.
* With rating 1894 Limak is in the division 2. His rating increases by 5.
* Limak has rating 1899 and is still in the division 2. In the last contest of the year he gets + 8 and ends the year with rating 1907.
In the second sample, it's impossible that Limak is in the division 1, his rating increases by 57 and after that Limak is in the division 2 in the second contest.
Submitted Solution:
```
n = int(input())
rounds = [[*map(int, input().split())] for _ in range(n)]
if all(i[1] == 1 for i in rounds):
print('Infinity')
elif any((rounds[i][0] >= 0 and rounds[i][1] == 1 and rounds[i + 1][1] == 2) or \
(rounds[i][0] < 0 and rounds[i][1] == 2 and rounds[i + 1][1] == 1) for i in range(n - 1)):
print('Impossible')
else:
l = int(-2e7)
r = int(2e7)
def check(m):
d = 1 if m >= 1900 else 2
for i, j in rounds[::-1]:
m += -i
d = 1 if m >= 1900 else 2
if d == 1 and j == 2:
return False, -1
return True, m
t = -1
while r - l > 1:
m = (l + r) // 2
c, t1 = check(m)
t = t1 if t1 != -1 else t
if c:
l = m
else:
r = m
d = 1 if t >= 1900 else 2
if rounds[:2] == [[1, 2], [100, 1]]:
print(rounds[-10:])
for i, j in rounds:
if d != j:
print('Impossible')
exit()
t += i
d = 1 if t >= 1900 else 2
print(l)
```
No
| 63,591 | [
0.447021484375,
-0.07257080078125,
-0.33447265625,
0.06591796875,
-0.379150390625,
-0.65966796875,
-0.1331787109375,
0.2236328125,
0.06805419921875,
0.755859375,
0.42333984375,
-0.26904296875,
0.1934814453125,
-0.70947265625,
-0.287109375,
-0.07562255859375,
-0.4921875,
-0.60107421... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating changes by some value, possibly negative or zero.
Limak competed in n contests in the year 2016. He remembers that in the i-th contest he competed in the division di (i.e. he belonged to this division just before the start of this contest) and his rating changed by ci just after the contest. Note that negative ci denotes the loss of rating.
What is the maximum possible rating Limak can have right now, after all n contests? If his rating may be arbitrarily big, print "Infinity". If there is no scenario matching the given information, print "Impossible".
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000).
The i-th of next n lines contains two integers ci and di ( - 100 ≤ ci ≤ 100, 1 ≤ di ≤ 2), describing Limak's rating change after the i-th contest and his division during the i-th contest contest.
Output
If Limak's current rating can be arbitrarily big, print "Infinity" (without quotes). If the situation is impossible, print "Impossible" (without quotes). Otherwise print one integer, denoting the maximum possible value of Limak's current rating, i.e. rating after the n contests.
Examples
Input
3
-7 1
5 2
8 2
Output
1907
Input
2
57 1
22 2
Output
Impossible
Input
1
-5 1
Output
Infinity
Input
4
27 2
13 1
-50 1
8 2
Output
1897
Note
In the first sample, the following scenario matches all information Limak remembers and has maximum possible final rating:
* Limak has rating 1901 and belongs to the division 1 in the first contest. His rating decreases by 7.
* With rating 1894 Limak is in the division 2. His rating increases by 5.
* Limak has rating 1899 and is still in the division 2. In the last contest of the year he gets + 8 and ends the year with rating 1907.
In the second sample, it's impossible that Limak is in the division 1, his rating increases by 57 and after that Limak is in the division 2 in the second contest.
Submitted Solution:
```
n=int(input())
mx=5*(10**9)
mn=-10**9
flag = True
for i in range(n):
c,d=map(int,input().split())
if d==1: mn=max(mn,1900)
else: mx=min(mx,1899)
if mn>mx: flag=False #besi poriman barar poro div_2 othoba besi komar poro jodi div_1 dekhay
mn+=c;mx+=c
if not flag:print("impossible")
else:
if mx>10**9:print("Infinity") #'mx' er sathe je kono number jog biog er poro jeno sothik condition break na kore
else:print(mx) #'d==2' kokhono na thakle 'infinity'
```
No
| 63,592 | [
0.447021484375,
-0.07257080078125,
-0.33447265625,
0.06591796875,
-0.379150390625,
-0.65966796875,
-0.1331787109375,
0.2236328125,
0.06805419921875,
0.755859375,
0.42333984375,
-0.26904296875,
0.1934814453125,
-0.70947265625,
-0.287109375,
-0.07562255859375,
-0.4921875,
-0.60107421... | 11 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either.
Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i).
Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj.
You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do.
Input
The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively.
Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n.
Output
In the first line, output a single integer s — your maximum possible final score.
In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve.
In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order.
If there are several optimal sets of problems, you may output any of them.
Examples
Input
5 300
3 100
4 150
4 80
2 90
2 300
Output
2
3
3 1 4
Input
2 100
1 787
2 788
Output
0
0
Input
2 100
2 42
2 58
Output
2
2
1 2
Note
In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points.
In the second example, the length of the exam is catastrophically not enough to solve even a single problem.
In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile.
Tags: binary search, brute force, data structures, greedy, sortings
Correct Solution:
```
from collections import deque
import heapq
import sys
def input():
return sys.stdin.readline().rstrip()
n, T = map(int, input().split())
problems = [tuple(map(int, input().split())) for i in range(n)]
def possible(K):
d = []
for a, t in problems:
if a >= K:
d.append(t)
d.sort()
if len(d) < K:
return False
else:
return sum(d[:K]) <= T
l = 0
r = n + 1
while r - l > 1:
med = (r + l)//2
if possible(med):
l = med
else:
r = med
print(l)
print(l)
d = []
for i, (a, t) in enumerate(problems):
if a >= l:
d.append((t, i+1))
d.sort(key=lambda x: x[0])
ans = [v[1] for v in d[:l]]
print(*ans)
```
| 63,672 | [
0.073486328125,
0.169189453125,
-0.044158935546875,
-0.0950927734375,
-0.734375,
-0.5439453125,
-0.21826171875,
-0.0615234375,
-0.03057861328125,
0.921875,
0.257568359375,
-0.028564453125,
0.4189453125,
-0.94287109375,
-0.193359375,
0.274658203125,
-0.53076171875,
-0.890625,
-0.5... | 11 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either.
Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i).
Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj.
You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do.
Input
The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively.
Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n.
Output
In the first line, output a single integer s — your maximum possible final score.
In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve.
In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order.
If there are several optimal sets of problems, you may output any of them.
Examples
Input
5 300
3 100
4 150
4 80
2 90
2 300
Output
2
3
3 1 4
Input
2 100
1 787
2 788
Output
0
0
Input
2 100
2 42
2 58
Output
2
2
1 2
Note
In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points.
In the second example, the length of the exam is catastrophically not enough to solve even a single problem.
In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile.
Tags: binary search, brute force, data structures, greedy, sortings
Correct Solution:
```
import os
import collections
def ints():
bytes = bytearray()
while True:
buffer = os.read(0, 1024)
if len(buffer) == 0:
break
bytes.extend(buffer)
array = collections.deque(map(int, bytes.split()))
return array
def one_pass(pass_num):
global ans_k, ans_b
b_time = b_count = 0
c_time = [0] * (n + 1)
c_count = [0] * (n + 1)
k = 1
for i in a:
if b_count < k:
if value(i) >= k:
b_count += 1
b_time += time(i)
c_count[value(i)] += 1
c_time [value(i)] += time(i)
if pass_num == 2 and ans_k and value(i) >= ans_k:
ans_b.append(index(i))
if b_count == k:
if pass_num == 1 and b_time <= T:
ans_k = k
if pass_num == 2 and k == ans_k:
break
b_count -= c_count[k]
b_time -= c_time[k]
k += 1
v = ints()
n, T = v.popleft(), v.popleft()
a = []
for i in range(n):
k, t = v.popleft(), v.popleft()
a.append( (i+1, k, t) )
index = lambda x: x[0]
value = lambda x: x[1]
time = lambda x: x[2]
a.sort(key=time)
ans_k = 0
ans_b = []
one_pass(1)
one_pass(2)
print(ans_k)
print(ans_k)
print(" ".join(map(str, ans_b)))
```
| 63,673 | [
0.073486328125,
0.169189453125,
-0.044158935546875,
-0.0950927734375,
-0.734375,
-0.5439453125,
-0.21826171875,
-0.0615234375,
-0.03057861328125,
0.921875,
0.257568359375,
-0.028564453125,
0.4189453125,
-0.94287109375,
-0.193359375,
0.274658203125,
-0.53076171875,
-0.890625,
-0.5... | 11 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either.
Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i).
Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj.
You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do.
Input
The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively.
Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n.
Output
In the first line, output a single integer s — your maximum possible final score.
In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve.
In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order.
If there are several optimal sets of problems, you may output any of them.
Examples
Input
5 300
3 100
4 150
4 80
2 90
2 300
Output
2
3
3 1 4
Input
2 100
1 787
2 788
Output
0
0
Input
2 100
2 42
2 58
Output
2
2
1 2
Note
In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points.
In the second example, the length of the exam is catastrophically not enough to solve even a single problem.
In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile.
Tags: binary search, brute force, data structures, greedy, sortings
Correct Solution:
```
import sys
import math
from collections import defaultdict,deque
import heapq
def search(arr,points,t):
l=[]
n=len(arr)
cnt=0
for i in range(n):
if arr[i][0]>=points:
l.append(arr[i][1])
cnt+=1
if cnt>=points:
l.sort()
#print(l,'l')
if sum(l[:points])<=t:
return True
return False
def get(arr,points):
n=len(arr)
l=[]
for i in range(n):
if arr[i][0]>=points:
l.append([arr[i][1],arr[i][2]+1])
l.sort()
#print(l,'get')
res=[]
for i in range(points):
res.append(l[i][1])
return res
n,t=map(int,sys.stdin.readline().split())
dic=defaultdict(int)
arr=[]
for i in range(n):
a,b=map(int,sys.stdin.readline().split())
arr.append([a,b,i])
low,high=0,n
ans=0
while low<=high:
mid=(low+high)//2
if search(arr,mid,t):
ans=max(ans,mid)
low=mid+1
else:
high=mid-1
#print(ans)
if ans==0:
print(0)
print(0)
print('')
sys.exit()
l=get(arr,ans)
print(len(l))
print(len(l))
print(*l)
```
| 63,674 | [
0.073486328125,
0.169189453125,
-0.044158935546875,
-0.0950927734375,
-0.734375,
-0.5439453125,
-0.21826171875,
-0.0615234375,
-0.03057861328125,
0.921875,
0.257568359375,
-0.028564453125,
0.4189453125,
-0.94287109375,
-0.193359375,
0.274658203125,
-0.53076171875,
-0.890625,
-0.5... | 11 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either.
Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i).
Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj.
You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do.
Input
The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively.
Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n.
Output
In the first line, output a single integer s — your maximum possible final score.
In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve.
In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order.
If there are several optimal sets of problems, you may output any of them.
Examples
Input
5 300
3 100
4 150
4 80
2 90
2 300
Output
2
3
3 1 4
Input
2 100
1 787
2 788
Output
0
0
Input
2 100
2 42
2 58
Output
2
2
1 2
Note
In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points.
In the second example, the length of the exam is catastrophically not enough to solve even a single problem.
In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile.
Tags: binary search, brute force, data structures, greedy, sortings
Correct Solution:
```
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 12 18:46:09 2018
@author: Sand Boa
"""
import itertools
if __name__ == "__main__":
n:int
T:int
n, T = list(map(int,input().split()))
listi:list = []
tsum:int = 0
csum:int = 0
k:int
k = 1
a:int
b:int
t:int
ind:int
for i in range(n):
a,b = list(map(int,input().split()))
listi.append((a,b,i))
#print(listi)
listi = sorted(listi, key=lambda x: x[1])
#print(listi)
time:list = [0] * (n + 1)
count:list = [0] * (n + 1)
for (a, t, ind) in listi:
if k <= a:
tsum += t
time[a] += t
if tsum > T:
break
count[a] += 1
csum += 1
if csum == k:
csum -= count[k]
tsum -= time[k]
k += 1
max_score:int = max(csum, k - 1)
print (max_score,max_score,sep='\n')
print(*list(itertools.islice((idx + 1 for (a, t, idx) in listi if a >= max_score),max_score)))
```
| 63,675 | [
0.073486328125,
0.169189453125,
-0.044158935546875,
-0.0950927734375,
-0.734375,
-0.5439453125,
-0.21826171875,
-0.0615234375,
-0.03057861328125,
0.921875,
0.257568359375,
-0.028564453125,
0.4189453125,
-0.94287109375,
-0.193359375,
0.274658203125,
-0.53076171875,
-0.890625,
-0.5... | 11 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either.
Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i).
Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj.
You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do.
Input
The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively.
Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n.
Output
In the first line, output a single integer s — your maximum possible final score.
In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve.
In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order.
If there are several optimal sets of problems, you may output any of them.
Examples
Input
5 300
3 100
4 150
4 80
2 90
2 300
Output
2
3
3 1 4
Input
2 100
1 787
2 788
Output
0
0
Input
2 100
2 42
2 58
Output
2
2
1 2
Note
In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points.
In the second example, the length of the exam is catastrophically not enough to solve even a single problem.
In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile.
Tags: binary search, brute force, data structures, greedy, sortings
Correct Solution:
```
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 12 18:46:09 2018
@author: Sand Boa
"""
import itertools
if __name__ == "__main__":
n:int
T:int
n, T = list(map(int,input().split()))
listi:list = []
tsum:int = 0
csum:int = 0
k = 1
a:int
b:int
for i in range(n):
a,b = list(map(int,input().split()))
listi.append((a,b,i))
#print(listi)
listi = sorted(listi, key=lambda x: x[1])
#print(listi)
time:list = [0] * (n + 1)
count:list = [0] * (n + 1)
for (a, t, ind) in listi:
if k <= a:
tsum += t
time[a] += t
if tsum > T:
break
count[a] += 1
csum += 1
if csum == k:
csum -= count[k]
tsum -= time[k]
k += 1
max_score = max(csum, k - 1)
print (max_score,max_score,sep='\n')
print(*list(itertools.islice(
(idx + 1 for (a, t, idx) in listi if a >= max_score),
max_score
)))
#print(listi)
'''for a, t, idx in listi:
if idx > max_score:
print(idx,sep=" ")
'''
#print(idx+1 for in listi )
```
| 63,676 | [
0.073486328125,
0.169189453125,
-0.044158935546875,
-0.0950927734375,
-0.734375,
-0.5439453125,
-0.21826171875,
-0.0615234375,
-0.03057861328125,
0.921875,
0.257568359375,
-0.028564453125,
0.4189453125,
-0.94287109375,
-0.193359375,
0.274658203125,
-0.53076171875,
-0.890625,
-0.5... | 11 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either.
Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i).
Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj.
You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do.
Input
The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively.
Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n.
Output
In the first line, output a single integer s — your maximum possible final score.
In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve.
In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order.
If there are several optimal sets of problems, you may output any of them.
Examples
Input
5 300
3 100
4 150
4 80
2 90
2 300
Output
2
3
3 1 4
Input
2 100
1 787
2 788
Output
0
0
Input
2 100
2 42
2 58
Output
2
2
1 2
Note
In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points.
In the second example, the length of the exam is catastrophically not enough to solve even a single problem.
In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile.
Tags: binary search, brute force, data structures, greedy, sortings
Correct Solution:
```
import sys
input=sys.stdin.readline
def fun(k):
global li,t
tem=[]
count=0
for i in li:
if(i[0]>=k):
tem.append(i)
count+=1
if(count>=k):
ans=0
for i in range(k):
ans+=tem[i][1]
if(ans<=t):
return True
else:
return False
else:
return False
n,t=map(int,input().split())
li=[]
for _ in range(n):
li.append(list(map(int,input().split()))+[_])
li.sort(key=lambda x:x[1])
l=0
r=n
while(r-l>1):
mid=(l+r)//2
if(fun(mid)):
l=mid
else:
r=mid
fin=0
for i in range(l,r+1):
if(fun(i)):
fin=i
print(fin)
print(fin)
tem=[]
for i in range(n):
if(li[i][0]>=fin):
tem.append(li[i][2]+1)
print(*tem[:fin])
```
| 63,677 | [
0.073486328125,
0.169189453125,
-0.044158935546875,
-0.0950927734375,
-0.734375,
-0.5439453125,
-0.21826171875,
-0.0615234375,
-0.03057861328125,
0.921875,
0.257568359375,
-0.028564453125,
0.4189453125,
-0.94287109375,
-0.193359375,
0.274658203125,
-0.53076171875,
-0.890625,
-0.5... | 11 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either.
Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i).
Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj.
You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do.
Input
The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively.
Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n.
Output
In the first line, output a single integer s — your maximum possible final score.
In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve.
In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order.
If there are several optimal sets of problems, you may output any of them.
Examples
Input
5 300
3 100
4 150
4 80
2 90
2 300
Output
2
3
3 1 4
Input
2 100
1 787
2 788
Output
0
0
Input
2 100
2 42
2 58
Output
2
2
1 2
Note
In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points.
In the second example, the length of the exam is catastrophically not enough to solve even a single problem.
In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile.
Tags: binary search, brute force, data structures, greedy, sortings
Correct Solution:
```
# https://codeforces.com/contest/913/problem/D
import heapq
from heapq import heappush as push_
from heapq import heappop as pop_
class heapT():
def __init__(self, T):
self.Q = []
self.curT = 0
self.maxT = T
self.his = []
def push(self, t, index):
push_(self.Q, (-t, index))
self.his.append(index)
self.curT += t
while self.curT > self.maxT:
self.pop()
def pop(self):
t, ind = pop_(self.Q)
self.his.append(ind)
self.curT -= t * -1
def normalize(self, length):
while len(self.Q) > length:
self.pop()
def solve(a, n, T):
a = sorted(a, key=lambda x:x[0], reverse=True)
H = heapT(T)
max_ = -1
pos = None
for ak, t, ind in a:
H.push(t, ind)
H.normalize(ak)
if len(H.Q) > max_:
max_ = len(H.Q)
pos = len(H.his)
d = {}
if pos is not None:
for x in H.his[:pos]:
if x not in d:
d[x] = 1
else:
del d[x]
if len(d) > 0:
print(len(d))
print(len(d))
print(' '.join([str(x+1) for x in d]))
else:
print('0'+'\n'+'0')
n, T = map(int, input().split())
a = [list(map(int, input().split())) + [_] for _ in range(n)]
solve(a, n, T)
#5 300
#3 100
#4 150
#4 80
#2 90
#2 300
#7 100
#5 30
#5 40
#6 20
#2 50
#2 40
#3 10
#4 10
#2 100
#1 787
#2 788
```
| 63,678 | [
0.073486328125,
0.169189453125,
-0.044158935546875,
-0.0950927734375,
-0.734375,
-0.5439453125,
-0.21826171875,
-0.0615234375,
-0.03057861328125,
0.921875,
0.257568359375,
-0.028564453125,
0.4189453125,
-0.94287109375,
-0.193359375,
0.274658203125,
-0.53076171875,
-0.890625,
-0.5... | 11 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either.
Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i).
Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj.
You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do.
Input
The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively.
Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n.
Output
In the first line, output a single integer s — your maximum possible final score.
In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve.
In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order.
If there are several optimal sets of problems, you may output any of them.
Examples
Input
5 300
3 100
4 150
4 80
2 90
2 300
Output
2
3
3 1 4
Input
2 100
1 787
2 788
Output
0
0
Input
2 100
2 42
2 58
Output
2
2
1 2
Note
In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points.
In the second example, the length of the exam is catastrophically not enough to solve even a single problem.
In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile.
Tags: binary search, brute force, data structures, greedy, sortings
Correct Solution:
```
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 12 18:46:09 2018
@author: Sand Boa
"""
import sys
import operator # itemgetter
import itertools # islice
if __name__ == "__main__":
n, T = list(map(int,input().split()))
listi = []
for i in range(n):
a,b = list(map(int,input().split()))
listi.append((a,b,i))
#print(listi)
listi = sorted(listi, key=lambda x: x[1])
#print(listi)
time = [0] * (n + 1)
count = [0] * (n + 1)
time_sum = 0
count_sum = 0
k = 1
for (a, t, ind) in listi:
if k <= a:
time[a] += t
time_sum += t
if time_sum > T:
break
count[a] += 1
count_sum += 1
if count_sum == k:
count_sum -= count[k]
time_sum -= time[k]
k += 1
max_score = max(count_sum, k - 1)
#max_score = count_sum
print (max_score)
print (max_score)
print(*list(itertools.islice(
(idx + 1 for (a, t, idx) in listi if a >= max_score),
max_score
)))
#print(listi)
'''for a, t, idx in listi:
if idx > max_score:
print(idx,sep=" ")
'''
#print(idx+1 for in listi )
```
| 63,679 | [
0.073486328125,
0.169189453125,
-0.044158935546875,
-0.0950927734375,
-0.734375,
-0.5439453125,
-0.21826171875,
-0.0615234375,
-0.03057861328125,
0.921875,
0.257568359375,
-0.028564453125,
0.4189453125,
-0.94287109375,
-0.193359375,
0.274658203125,
-0.53076171875,
-0.890625,
-0.5... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either.
Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i).
Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj.
You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do.
Input
The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively.
Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n.
Output
In the first line, output a single integer s — your maximum possible final score.
In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve.
In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order.
If there are several optimal sets of problems, you may output any of them.
Examples
Input
5 300
3 100
4 150
4 80
2 90
2 300
Output
2
3
3 1 4
Input
2 100
1 787
2 788
Output
0
0
Input
2 100
2 42
2 58
Output
2
2
1 2
Note
In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points.
In the second example, the length of the exam is catastrophically not enough to solve even a single problem.
In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile.
Submitted Solution:
```
# -*- coding:utf-8 -*-
"""
created by shuangquan.huang at 1/11/18
"""
import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
N, T = map(int, input().split())
#
# N, T = 200000, 1000000000
ta = []
for i in range(N):
a, t = map(int, input().split())
ta.append((t, a, i+1))
# ta.append((10000, 200000, i+1))
ta.sort()
score = 0
solvedCount = 0
aks = []
heapq.heapify(aks)
sc = collections.defaultdict(list)
for i in range(N):
t, a, _ = ta[i]
if T < t:
break
T -= t
solvedCount += 1
sc[a].append((t, i))
heapq.heappush(aks, a)
removed = []
while aks and aks[0] < solvedCount:
k = heapq.heappop(aks)
removed.append(k)
v = sc[k]
solvedCount -= len(v)
for _, j in v:
T += ta[j][0]
del sc[k]
score = max(score, solvedCount)
print(score)
print(score)
vta = [(t, a, i) for t, a, i in ta if a >= score]
vta.sort()
ans = [i for _, _, i in vta[:score]]
print(" ".join(map(str, ans)))
```
Yes
| 63,680 | [
0.1270751953125,
0.145751953125,
-0.0830078125,
-0.156982421875,
-0.76025390625,
-0.43603515625,
-0.254638671875,
0.006214141845703125,
-0.0301666259765625,
1.0068359375,
0.2469482421875,
-0.0204315185546875,
0.337646484375,
-0.92919921875,
-0.161376953125,
0.16162109375,
-0.54541015... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either.
Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i).
Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj.
You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do.
Input
The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively.
Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n.
Output
In the first line, output a single integer s — your maximum possible final score.
In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve.
In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order.
If there are several optimal sets of problems, you may output any of them.
Examples
Input
5 300
3 100
4 150
4 80
2 90
2 300
Output
2
3
3 1 4
Input
2 100
1 787
2 788
Output
0
0
Input
2 100
2 42
2 58
Output
2
2
1 2
Note
In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points.
In the second example, the length of the exam is catastrophically not enough to solve even a single problem.
In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile.
Submitted Solution:
```
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
n, k = map(int, input().split())
b = []
d=dict()
e=dict()
for i in range(n):
a, t = map(int, input().split())
b.append([a,t,i+1])
b.sort(key= lambda x:x[1])
ans = 0
j = 0
curr = 1
currsum = 0
l=0
while(curr<=n):
if curr-1 in d.keys():
currsum-=d[curr-1]
l-=e[curr-1]
p=0
while (j < n):
if b[j][0] >= curr:
currsum += b[j][1]
if b[j][0] in d.keys():
d[b[j][0]]+=b[j][1]
e[b[j][0]]+=1
else:
d[b[j][0]] = b[j][1]
e[b[j][0]] = 1
l+=1
if l==curr:
j+=1
break
j+=1
if j<=n and l==curr and currsum<=k:
ans+=1
else:
break
curr+=1
c=[]
j=0
l=0
while(j<n):
if l==ans:
break
if b[j][0] >= ans:
c.append(b[j][2])
l+=1
j+=1
print(ans)
print(ans)
print(*c)
```
Yes
| 63,681 | [
0.1270751953125,
0.145751953125,
-0.0830078125,
-0.156982421875,
-0.76025390625,
-0.43603515625,
-0.254638671875,
0.006214141845703125,
-0.0301666259765625,
1.0068359375,
0.2469482421875,
-0.0204315185546875,
0.337646484375,
-0.92919921875,
-0.161376953125,
0.16162109375,
-0.54541015... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either.
Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i).
Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj.
You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do.
Input
The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively.
Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n.
Output
In the first line, output a single integer s — your maximum possible final score.
In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve.
In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order.
If there are several optimal sets of problems, you may output any of them.
Examples
Input
5 300
3 100
4 150
4 80
2 90
2 300
Output
2
3
3 1 4
Input
2 100
1 787
2 788
Output
0
0
Input
2 100
2 42
2 58
Output
2
2
1 2
Note
In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points.
In the second example, the length of the exam is catastrophically not enough to solve even a single problem.
In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile.
Submitted Solution:
```
from __future__ import print_function # for PyPy2
from collections import Counter, OrderedDict
from itertools import permutations as perm
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
import math
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1e9)+7
inf = float("inf")
n, t = gil()
a = []
for i in range(n):
b = gil();b.append(i)
a.append(b)
a.sort(key=lambda x : (x[1], -x[0]))
# print(a)
h = []
ct = 0
for ai, ti, i in a:
if ct + ti > t: break
elif len(h) > ai: continue
ct += ti
heappush(h, (ai, -ti, i))
while h and h[0][0] < len(h):
ai, ti, i = heappop(h)
ct += ti
print(len(h))
print(len(h))
for _, _, i in h:
print(i+1, end=" ")
```
Yes
| 63,682 | [
0.1270751953125,
0.145751953125,
-0.0830078125,
-0.156982421875,
-0.76025390625,
-0.43603515625,
-0.254638671875,
0.006214141845703125,
-0.0301666259765625,
1.0068359375,
0.2469482421875,
-0.0204315185546875,
0.337646484375,
-0.92919921875,
-0.161376953125,
0.16162109375,
-0.54541015... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either.
Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i).
Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj.
You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do.
Input
The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively.
Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n.
Output
In the first line, output a single integer s — your maximum possible final score.
In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve.
In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order.
If there are several optimal sets of problems, you may output any of them.
Examples
Input
5 300
3 100
4 150
4 80
2 90
2 300
Output
2
3
3 1 4
Input
2 100
1 787
2 788
Output
0
0
Input
2 100
2 42
2 58
Output
2
2
1 2
Note
In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points.
In the second example, the length of the exam is catastrophically not enough to solve even a single problem.
In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile.
Submitted Solution:
```
from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline
# M = mod = 998244353
def factors(n):return sorted(list(set(reduce(list.__add__,([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))))
# def inv_mod(n):return pow(n, mod - 2, mod)
def li():return [int(i) for i in input().rstrip('\n').split(' ')]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n').split(' ')]
def li3():return [int(i) for i in input().rstrip('\n')]
n,L = li()
l = []
for i in range(n):
l.append(li())
index = defaultdict(list)
for ind,i in enumerate(l):
index[tuple(i)].append(ind + 1)
l.sort(key = lambda x:x[1])
d = defaultdict(list)
ans = i = tot = currpoints = 0
anspattern = []
he = []
while i < n:
if l[i][1] + tot <= L:
tot += l[i][1]
heapq.heappush(d[l[i][0]],l[i][1])
currpoints += 1
if len(d[l[i][0]]) == 1:
heapq.heappush(he,l[i][0])
while len(he) and currpoints > he[0]:
temp = heapq.heappop(he)
tot -= heapq.heappop(d[temp])
currpoints -= 1
if len(d[temp]):heapq.heappush(he,temp)
if currpoints > ans:
ans = currpoints
i += 1
i = tot = currpoints = 0
he = []
d = defaultdict(list)
while i < n:
if l[i][1] + tot <= L:
tot += l[i][1]
heapq.heappush(d[l[i][0]],l[i][1])
currpoints += 1
if len(d[l[i][0]]) == 1:
heapq.heappush(he,l[i][0])
while len(he) and currpoints > he[0]:
temp = heapq.heappop(he)
tot -= heapq.heappop(d[temp])
currpoints -= 1
if len(d[temp]):heapq.heappush(he,temp)
if currpoints == ans:
anspattern = []
for i in he:
for j in d[i]:
anspattern.append(index[tuple([i,j])][-1])
index[tuple([i,j])].pop()
print(ans)
print(len(anspattern))
print(*sorted(anspattern))
exit()
i += 1
```
Yes
| 63,683 | [
0.1270751953125,
0.145751953125,
-0.0830078125,
-0.156982421875,
-0.76025390625,
-0.43603515625,
-0.254638671875,
0.006214141845703125,
-0.0301666259765625,
1.0068359375,
0.2469482421875,
-0.0204315185546875,
0.337646484375,
-0.92919921875,
-0.161376953125,
0.16162109375,
-0.54541015... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either.
Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i).
Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj.
You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do.
Input
The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively.
Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n.
Output
In the first line, output a single integer s — your maximum possible final score.
In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve.
In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order.
If there are several optimal sets of problems, you may output any of them.
Examples
Input
5 300
3 100
4 150
4 80
2 90
2 300
Output
2
3
3 1 4
Input
2 100
1 787
2 788
Output
0
0
Input
2 100
2 42
2 58
Output
2
2
1 2
Note
In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points.
In the second example, the length of the exam is catastrophically not enough to solve even a single problem.
In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile.
Submitted Solution:
```
print(2)
print(2)
print(3,1)
```
No
| 63,684 | [
0.1270751953125,
0.145751953125,
-0.0830078125,
-0.156982421875,
-0.76025390625,
-0.43603515625,
-0.254638671875,
0.006214141845703125,
-0.0301666259765625,
1.0068359375,
0.2469482421875,
-0.0204315185546875,
0.337646484375,
-0.92919921875,
-0.161376953125,
0.16162109375,
-0.54541015... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either.
Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i).
Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj.
You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do.
Input
The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively.
Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n.
Output
In the first line, output a single integer s — your maximum possible final score.
In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve.
In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order.
If there are several optimal sets of problems, you may output any of them.
Examples
Input
5 300
3 100
4 150
4 80
2 90
2 300
Output
2
3
3 1 4
Input
2 100
1 787
2 788
Output
0
0
Input
2 100
2 42
2 58
Output
2
2
1 2
Note
In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points.
In the second example, the length of the exam is catastrophically not enough to solve even a single problem.
In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile.
Submitted Solution:
```
class Prob:
idx, a, t = 0, 0, 0
def __init__(self, idx, a , t):
self.idx, self.a, self.t = idx, a, t
n, T = map(int, input().split())
probs = []
for i in range(n):
a, t = map(int, input().split())
probs.append(Prob(i+1, a, t))
probs.sort(key=lambda x: x.t)
s, e = 0, n
while s < e:
m = (s + e) // 2
cnt, sumT = 0, 0
for x in probs:
if x.a >= m and sumT + x.t <= T:
cnt += 1
sumT += x.t
if cnt > m:
s = m + 1
else:
e = m
cnt, sumT = 0, 0
for x in probs:
if x.a >= e and sumT + x.t <= T:
cnt += 1
sumT += x.t
print(cnt)
print(cnt)
for x in probs:
if x.a >= e and sumT + x.t <= T:
print(x.idx, end=' ')
```
No
| 63,685 | [
0.1270751953125,
0.145751953125,
-0.0830078125,
-0.156982421875,
-0.76025390625,
-0.43603515625,
-0.254638671875,
0.006214141845703125,
-0.0301666259765625,
1.0068359375,
0.2469482421875,
-0.0204315185546875,
0.337646484375,
-0.92919921875,
-0.161376953125,
0.16162109375,
-0.54541015... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either.
Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i).
Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj.
You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do.
Input
The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively.
Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n.
Output
In the first line, output a single integer s — your maximum possible final score.
In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve.
In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order.
If there are several optimal sets of problems, you may output any of them.
Examples
Input
5 300
3 100
4 150
4 80
2 90
2 300
Output
2
3
3 1 4
Input
2 100
1 787
2 788
Output
0
0
Input
2 100
2 42
2 58
Output
2
2
1 2
Note
In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points.
In the second example, the length of the exam is catastrophically not enough to solve even a single problem.
In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile.
Submitted Solution:
```
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 12 18:46:09 2018
@author: Sand Boa
"""
if __name__ == "__main__":
n:int
T:int
n, T = list(map(int,input().split()))
listi:list = []
tsum:int = 0
csum:int = 0
k = 1
a:int
b:int
for i in range(n):
a,b = list(map(int,input().split()))
listi.append((a,b,i))
#print(listi)
listi = sorted(listi, key=lambda x: x[1])
#print(listi)
time:list = [0] * (n + 1)
count:list = [0] * (n + 1)
for (a, t, ind) in listi:
if k <= a:
tsum += t
time[a] += t
if tsum > T:
break
count[a] += 1
csum += 1
if csum == k:
csum -= count[k]
tsum -= time[k]
k += 1
max_score = max(csum, k - 1)
print (max_score,max_score,sep='\n')
for (a, t, idx) in listi[:max_score+1]:
if idx > max_score:
print(idx,end=" ")
```
No
| 63,686 | [
0.1270751953125,
0.145751953125,
-0.0830078125,
-0.156982421875,
-0.76025390625,
-0.43603515625,
-0.254638671875,
0.006214141845703125,
-0.0301666259765625,
1.0068359375,
0.2469482421875,
-0.0204315185546875,
0.337646484375,
-0.92919921875,
-0.161376953125,
0.16162109375,
-0.54541015... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either.
Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i).
Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj.
You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do.
Input
The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively.
Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n.
Output
In the first line, output a single integer s — your maximum possible final score.
In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve.
In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order.
If there are several optimal sets of problems, you may output any of them.
Examples
Input
5 300
3 100
4 150
4 80
2 90
2 300
Output
2
3
3 1 4
Input
2 100
1 787
2 788
Output
0
0
Input
2 100
2 42
2 58
Output
2
2
1 2
Note
In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points.
In the second example, the length of the exam is catastrophically not enough to solve even a single problem.
In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile.
Submitted Solution:
```
# -*- coding:utf-8 -*-
"""
created by shuangquan.huang at 1/11/18
"""
import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
N, T = map(int, input().split())
#
# N, T = 200000, 1000000000
ta = []
for i in range(N):
a, t = map(int, input().split())
ta.append((t, a, i+1))
# ta.append((200000, 10000, i+1))
ta.sort()
solvedCount = 0
minsc = float('inf')
sc = collections.defaultdict(list)
for i in range(N):
t, a, _ = ta[i]
if T < t:
break
T -= t
solvedCount += 1
sc[a].append((t, i))
minsc = min(minsc, a)
if minsc < solvedCount:
solvedCount -= len(sc[minsc])
for _, j in sc[minsc]:
T += ta[j][0]
del sc[minsc]
minsc = min(sc.keys())
print(solvedCount)
print(solvedCount)
solved = []
for tis in sc.values():
solved.extend([ti[1]+1 for ti in tis])
print(' '.join(map(str, solved)))
```
No
| 63,687 | [
0.1270751953125,
0.145751953125,
-0.0830078125,
-0.156982421875,
-0.76025390625,
-0.43603515625,
-0.254638671875,
0.006214141845703125,
-0.0301666259765625,
1.0068359375,
0.2469482421875,
-0.0204315185546875,
0.337646484375,
-0.92919921875,
-0.161376953125,
0.16162109375,
-0.54541015... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
M-kun is a competitor in AtCoder, whose highest rating is X.
In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:
* From 400 through 599: 8-kyu
* From 600 through 799: 7-kyu
* From 800 through 999: 6-kyu
* From 1000 through 1199: 5-kyu
* From 1200 through 1399: 4-kyu
* From 1400 through 1599: 3-kyu
* From 1600 through 1799: 2-kyu
* From 1800 through 1999: 1-kyu
What kyu does M-kun have?
Constraints
* 400 \leq X \leq 1999
* X is an integer.
Input
Input is given from Standard Input in the following format:
X
Output
Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`.
Examples
Input
725
Output
7
Input
1600
Output
2
"Correct Solution:
```
x = int(input())
a = x // 200
print(10 - a)
```
| 63,736 | [
0.72021484375,
0.198486328125,
-0.331787109375,
0.07318115234375,
-0.60302734375,
-0.521484375,
0.291748046875,
0.2379150390625,
0.0770263671875,
0.60107421875,
0.77392578125,
0.1942138671875,
0.291015625,
-1.1728515625,
-0.295654296875,
0.01158905029296875,
-0.25927734375,
-1.1191... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
M-kun is a competitor in AtCoder, whose highest rating is X.
In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:
* From 400 through 599: 8-kyu
* From 600 through 799: 7-kyu
* From 800 through 999: 6-kyu
* From 1000 through 1199: 5-kyu
* From 1200 through 1399: 4-kyu
* From 1400 through 1599: 3-kyu
* From 1600 through 1799: 2-kyu
* From 1800 through 1999: 1-kyu
What kyu does M-kun have?
Constraints
* 400 \leq X \leq 1999
* X is an integer.
Input
Input is given from Standard Input in the following format:
X
Output
Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`.
Examples
Input
725
Output
7
Input
1600
Output
2
"Correct Solution:
```
X = int(input())
X = 2000 - (X+1)
X //= 200
print(X + 1)
```
| 63,737 | [
0.71044921875,
0.2039794921875,
-0.343017578125,
0.08721923828125,
-0.59716796875,
-0.50390625,
0.28173828125,
0.239501953125,
0.10528564453125,
0.58984375,
0.76904296875,
0.21142578125,
0.307861328125,
-1.150390625,
-0.28125,
-0.005462646484375,
-0.258544921875,
-1.1103515625,
-... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
M-kun is a competitor in AtCoder, whose highest rating is X.
In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:
* From 400 through 599: 8-kyu
* From 600 through 799: 7-kyu
* From 800 through 999: 6-kyu
* From 1000 through 1199: 5-kyu
* From 1200 through 1399: 4-kyu
* From 1400 through 1599: 3-kyu
* From 1600 through 1799: 2-kyu
* From 1800 through 1999: 1-kyu
What kyu does M-kun have?
Constraints
* 400 \leq X \leq 1999
* X is an integer.
Input
Input is given from Standard Input in the following format:
X
Output
Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`.
Examples
Input
725
Output
7
Input
1600
Output
2
"Correct Solution:
```
X=int(input())
kyu= 10 - X//200
print(kyu)
```
| 63,738 | [
0.72900390625,
0.1907958984375,
-0.3486328125,
0.06781005859375,
-0.59375,
-0.51904296875,
0.28125,
0.256103515625,
0.0799560546875,
0.59521484375,
0.7822265625,
0.2027587890625,
0.302001953125,
-1.1552734375,
-0.279052734375,
0.004573822021484375,
-0.268798828125,
-1.1240234375,
... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
M-kun is a competitor in AtCoder, whose highest rating is X.
In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:
* From 400 through 599: 8-kyu
* From 600 through 799: 7-kyu
* From 800 through 999: 6-kyu
* From 1000 through 1199: 5-kyu
* From 1200 through 1399: 4-kyu
* From 1400 through 1599: 3-kyu
* From 1600 through 1799: 2-kyu
* From 1800 through 1999: 1-kyu
What kyu does M-kun have?
Constraints
* 400 \leq X \leq 1999
* X is an integer.
Input
Input is given from Standard Input in the following format:
X
Output
Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`.
Examples
Input
725
Output
7
Input
1600
Output
2
"Correct Solution:
```
rating = int(input())
print(10 - rating // 200)
```
| 63,739 | [
0.7001953125,
0.203125,
-0.3720703125,
0.08233642578125,
-0.62255859375,
-0.56494140625,
0.309326171875,
0.2279052734375,
0.045257568359375,
0.57568359375,
0.736328125,
0.1856689453125,
0.3505859375,
-1.150390625,
-0.312744140625,
0.0252838134765625,
-0.255859375,
-1.1123046875,
... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
M-kun is a competitor in AtCoder, whose highest rating is X.
In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:
* From 400 through 599: 8-kyu
* From 600 through 799: 7-kyu
* From 800 through 999: 6-kyu
* From 1000 through 1199: 5-kyu
* From 1200 through 1399: 4-kyu
* From 1400 through 1599: 3-kyu
* From 1600 through 1799: 2-kyu
* From 1800 through 1999: 1-kyu
What kyu does M-kun have?
Constraints
* 400 \leq X \leq 1999
* X is an integer.
Input
Input is given from Standard Input in the following format:
X
Output
Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`.
Examples
Input
725
Output
7
Input
1600
Output
2
"Correct Solution:
```
s = int(input())
print(10 - s//200)
```
| 63,740 | [
0.70849609375,
0.199951171875,
-0.343017578125,
0.074951171875,
-0.6298828125,
-0.5244140625,
0.293212890625,
0.26123046875,
0.0814208984375,
0.599609375,
0.7548828125,
0.1954345703125,
0.326904296875,
-1.1533203125,
-0.3427734375,
-0.0102691650390625,
-0.251220703125,
-1.116210937... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
M-kun is a competitor in AtCoder, whose highest rating is X.
In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:
* From 400 through 599: 8-kyu
* From 600 through 799: 7-kyu
* From 800 through 999: 6-kyu
* From 1000 through 1199: 5-kyu
* From 1200 through 1399: 4-kyu
* From 1400 through 1599: 3-kyu
* From 1600 through 1799: 2-kyu
* From 1800 through 1999: 1-kyu
What kyu does M-kun have?
Constraints
* 400 \leq X \leq 1999
* X is an integer.
Input
Input is given from Standard Input in the following format:
X
Output
Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`.
Examples
Input
725
Output
7
Input
1600
Output
2
"Correct Solution:
```
XX = int(input())
Kyu = 10-int(XX/200)
print(Kyu)
```
| 63,741 | [
0.70947265625,
0.1854248046875,
-0.3486328125,
0.057464599609375,
-0.63525390625,
-0.529296875,
0.318115234375,
0.257080078125,
0.07818603515625,
0.5859375,
0.75537109375,
0.1903076171875,
0.31005859375,
-1.1513671875,
-0.318359375,
0.0080718994140625,
-0.267578125,
-1.130859375,
... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
M-kun is a competitor in AtCoder, whose highest rating is X.
In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:
* From 400 through 599: 8-kyu
* From 600 through 799: 7-kyu
* From 800 through 999: 6-kyu
* From 1000 through 1199: 5-kyu
* From 1200 through 1399: 4-kyu
* From 1400 through 1599: 3-kyu
* From 1600 through 1799: 2-kyu
* From 1800 through 1999: 1-kyu
What kyu does M-kun have?
Constraints
* 400 \leq X \leq 1999
* X is an integer.
Input
Input is given from Standard Input in the following format:
X
Output
Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`.
Examples
Input
725
Output
7
Input
1600
Output
2
"Correct Solution:
```
n=(int(input())-400)//200
print(8-n)
```
| 63,742 | [
0.71142578125,
0.2042236328125,
-0.330810546875,
0.075439453125,
-0.60205078125,
-0.52197265625,
0.316162109375,
0.2247314453125,
0.08758544921875,
0.62548828125,
0.7666015625,
0.1878662109375,
0.3408203125,
-1.1650390625,
-0.310546875,
0.02691650390625,
-0.255615234375,
-1.1230468... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
M-kun is a competitor in AtCoder, whose highest rating is X.
In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:
* From 400 through 599: 8-kyu
* From 600 through 799: 7-kyu
* From 800 through 999: 6-kyu
* From 1000 through 1199: 5-kyu
* From 1200 through 1399: 4-kyu
* From 1400 through 1599: 3-kyu
* From 1600 through 1799: 2-kyu
* From 1800 through 1999: 1-kyu
What kyu does M-kun have?
Constraints
* 400 \leq X \leq 1999
* X is an integer.
Input
Input is given from Standard Input in the following format:
X
Output
Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`.
Examples
Input
725
Output
7
Input
1600
Output
2
"Correct Solution:
```
# 入力
X = int(input())
print(10 - X // 200 )
```
| 63,743 | [
0.70166015625,
0.1905517578125,
-0.3466796875,
0.07427978515625,
-0.59716796875,
-0.529296875,
0.3095703125,
0.237548828125,
0.07733154296875,
0.57763671875,
0.7802734375,
0.19873046875,
0.309326171875,
-1.1796875,
-0.310546875,
-0.0006518363952636719,
-0.2430419921875,
-1.125,
-... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
M-kun is a competitor in AtCoder, whose highest rating is X.
In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:
* From 400 through 599: 8-kyu
* From 600 through 799: 7-kyu
* From 800 through 999: 6-kyu
* From 1000 through 1199: 5-kyu
* From 1200 through 1399: 4-kyu
* From 1400 through 1599: 3-kyu
* From 1600 through 1799: 2-kyu
* From 1800 through 1999: 1-kyu
What kyu does M-kun have?
Constraints
* 400 \leq X \leq 1999
* X is an integer.
Input
Input is given from Standard Input in the following format:
X
Output
Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`.
Examples
Input
725
Output
7
Input
1600
Output
2
Submitted Solution:
```
X = int(input())
print(10 - X // 200)
```
Yes
| 63,744 | [
0.728515625,
0.1651611328125,
-0.487548828125,
0.11065673828125,
-0.59765625,
-0.537109375,
0.203125,
0.266845703125,
0.0389404296875,
0.59130859375,
0.6640625,
0.1611328125,
0.301025390625,
-1.09375,
-0.361328125,
-0.034820556640625,
-0.18359375,
-1.0390625,
-0.2115478515625,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
M-kun is a competitor in AtCoder, whose highest rating is X.
In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:
* From 400 through 599: 8-kyu
* From 600 through 799: 7-kyu
* From 800 through 999: 6-kyu
* From 1000 through 1199: 5-kyu
* From 1200 through 1399: 4-kyu
* From 1400 through 1599: 3-kyu
* From 1600 through 1799: 2-kyu
* From 1800 through 1999: 1-kyu
What kyu does M-kun have?
Constraints
* 400 \leq X \leq 1999
* X is an integer.
Input
Input is given from Standard Input in the following format:
X
Output
Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`.
Examples
Input
725
Output
7
Input
1600
Output
2
Submitted Solution:
```
X = int(input())
ans = 2000-X
ans = -(-ans//200)
print(ans)
```
Yes
| 63,745 | [
0.712890625,
0.1806640625,
-0.479248046875,
0.07586669921875,
-0.60546875,
-0.53515625,
0.199462890625,
0.2486572265625,
0.051910400390625,
0.5888671875,
0.62353515625,
0.164306640625,
0.305419921875,
-1.08984375,
-0.345458984375,
-0.045562744140625,
-0.200927734375,
-1.009765625,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
M-kun is a competitor in AtCoder, whose highest rating is X.
In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:
* From 400 through 599: 8-kyu
* From 600 through 799: 7-kyu
* From 800 through 999: 6-kyu
* From 1000 through 1199: 5-kyu
* From 1200 through 1399: 4-kyu
* From 1400 through 1599: 3-kyu
* From 1600 through 1799: 2-kyu
* From 1800 through 1999: 1-kyu
What kyu does M-kun have?
Constraints
* 400 \leq X \leq 1999
* X is an integer.
Input
Input is given from Standard Input in the following format:
X
Output
Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`.
Examples
Input
725
Output
7
Input
1600
Output
2
Submitted Solution:
```
X = int(input())
print((2199-X)//200)
```
Yes
| 63,746 | [
0.724609375,
0.16015625,
-0.484375,
0.1064453125,
-0.591796875,
-0.5380859375,
0.202392578125,
0.263916015625,
0.042510986328125,
0.60009765625,
0.6650390625,
0.16552734375,
0.302978515625,
-1.09765625,
-0.359130859375,
-0.0328369140625,
-0.178466796875,
-1.037109375,
-0.20483398... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
M-kun is a competitor in AtCoder, whose highest rating is X.
In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:
* From 400 through 599: 8-kyu
* From 600 through 799: 7-kyu
* From 800 through 999: 6-kyu
* From 1000 through 1199: 5-kyu
* From 1200 through 1399: 4-kyu
* From 1400 through 1599: 3-kyu
* From 1600 through 1799: 2-kyu
* From 1800 through 1999: 1-kyu
What kyu does M-kun have?
Constraints
* 400 \leq X \leq 1999
* X is an integer.
Input
Input is given from Standard Input in the following format:
X
Output
Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`.
Examples
Input
725
Output
7
Input
1600
Output
2
Submitted Solution:
```
X = int(input())
y = X//200
print(10-y)
```
Yes
| 63,747 | [
0.72607421875,
0.1578369140625,
-0.48779296875,
0.11370849609375,
-0.60302734375,
-0.53076171875,
0.2169189453125,
0.261474609375,
0.0496826171875,
0.59619140625,
0.65625,
0.15966796875,
0.3056640625,
-1.0966796875,
-0.36083984375,
-0.0523681640625,
-0.192626953125,
-1.033203125,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
M-kun is a competitor in AtCoder, whose highest rating is X.
In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:
* From 400 through 599: 8-kyu
* From 600 through 799: 7-kyu
* From 800 through 999: 6-kyu
* From 1000 through 1199: 5-kyu
* From 1200 through 1399: 4-kyu
* From 1400 through 1599: 3-kyu
* From 1600 through 1799: 2-kyu
* From 1800 through 1999: 1-kyu
What kyu does M-kun have?
Constraints
* 400 \leq X \leq 1999
* X is an integer.
Input
Input is given from Standard Input in the following format:
X
Output
Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`.
Examples
Input
725
Output
7
Input
1600
Output
2
Submitted Solution:
```
A, B, C = map(int, input().split())
K= int(input())
if (B**K>A)&(C>B):
print("Yes")
elif (B**(K-1)>A)&(C>B**1) :
print("Yes")
elif (B**(K-2)>A)&(C>B**2) :
print("Yes")
elif (B**(K-3)>A)&(C>B**3) :
print("Yes")
elif (B**(K-4)>A)&(C>B**4) :
print("Yes")
elif (B**(K-5)>A)&(C>B**5) :
print("Yes")
elif (B**(K-6)>A)&(C>B**6) :
print("Yes")
elif (B**(K-7)>A)&(C>B**7) :
print("Yes")
else :
print("No")
```
No
| 63,748 | [
0.70458984375,
0.19970703125,
-0.452880859375,
0.1240234375,
-0.658203125,
-0.48681640625,
0.2261962890625,
0.3046875,
0.053070068359375,
0.6748046875,
0.630859375,
0.204345703125,
0.32958984375,
-1.0419921875,
-0.378173828125,
-0.022186279296875,
-0.2261962890625,
-1.0009765625,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
M-kun is a competitor in AtCoder, whose highest rating is X.
In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:
* From 400 through 599: 8-kyu
* From 600 through 799: 7-kyu
* From 800 through 999: 6-kyu
* From 1000 through 1199: 5-kyu
* From 1200 through 1399: 4-kyu
* From 1400 through 1599: 3-kyu
* From 1600 through 1799: 2-kyu
* From 1800 through 1999: 1-kyu
What kyu does M-kun have?
Constraints
* 400 \leq X \leq 1999
* X is an integer.
Input
Input is given from Standard Input in the following format:
X
Output
Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`.
Examples
Input
725
Output
7
Input
1600
Output
2
Submitted Solution:
```
N, K = map(int, input().split())
A = input("").split(" ")
A = [int(i) for i in A]
for i in range(1, N-K+1):
score = 1
p_score = 1
for j in range(i, i+K):
score = score * A[j]
p_score = p_score * A[j-1]
if score > p_score:
print("Yes")
else:
print("No")
```
No
| 63,749 | [
0.61474609375,
0.1878662109375,
-0.4052734375,
0.10107421875,
-0.64501953125,
-0.5107421875,
0.22998046875,
0.224365234375,
0.07000732421875,
0.6005859375,
0.57568359375,
0.1932373046875,
0.37109375,
-1.021484375,
-0.3662109375,
0.00562286376953125,
-0.2587890625,
-1.037109375,
-... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
M-kun is a competitor in AtCoder, whose highest rating is X.
In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:
* From 400 through 599: 8-kyu
* From 600 through 799: 7-kyu
* From 800 through 999: 6-kyu
* From 1000 through 1199: 5-kyu
* From 1200 through 1399: 4-kyu
* From 1400 through 1599: 3-kyu
* From 1600 through 1799: 2-kyu
* From 1800 through 1999: 1-kyu
What kyu does M-kun have?
Constraints
* 400 \leq X \leq 1999
* X is an integer.
Input
Input is given from Standard Input in the following format:
X
Output
Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`.
Examples
Input
725
Output
7
Input
1600
Output
2
Submitted Solution:
```
A,B,C = map(int,input().split())
K = int(input())
for i in range(K):
if C<=B:
C*=2
elif B<A and C>B:
B*=2
if B>A and C>B:
print("Yes")
else:
print("No")
```
No
| 63,750 | [
0.69482421875,
0.2071533203125,
-0.466552734375,
0.077880859375,
-0.61865234375,
-0.5029296875,
0.22119140625,
0.25439453125,
0.051055908203125,
0.65869140625,
0.62890625,
0.19384765625,
0.334228515625,
-1.064453125,
-0.342041015625,
-0.049102783203125,
-0.2318115234375,
-0.9736328... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
M-kun is a competitor in AtCoder, whose highest rating is X.
In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:
* From 400 through 599: 8-kyu
* From 600 through 799: 7-kyu
* From 800 through 999: 6-kyu
* From 1000 through 1199: 5-kyu
* From 1200 through 1399: 4-kyu
* From 1400 through 1599: 3-kyu
* From 1600 through 1799: 2-kyu
* From 1800 through 1999: 1-kyu
What kyu does M-kun have?
Constraints
* 400 \leq X \leq 1999
* X is an integer.
Input
Input is given from Standard Input in the following format:
X
Output
Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`.
Examples
Input
725
Output
7
Input
1600
Output
2
Submitted Solution:
```
x = int(input())
if x >= 1800:
ans = 1
elif x >= 1600:
ans = 2
elif x >= 1400:
ans = 3
elif x >= 1200:
ans = 4
elif x >= 1000:
ans = 5
elif x >= 800:
ans = 6
elif x >= 600:
ans = 7
else:
x = 8
print(str(int(ans)))
```
No
| 63,751 | [
0.70703125,
0.154296875,
-0.50146484375,
0.076171875,
-0.615234375,
-0.52197265625,
0.24951171875,
0.2471923828125,
0.0262908935546875,
0.61962890625,
0.6494140625,
0.1781005859375,
0.28369140625,
-1.0791015625,
-0.33935546875,
-0.050506591796875,
-0.1790771484375,
-0.98388671875,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
Constraints
* 1 \leq N,K \leq 100
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
Output
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
Examples
Input
7 3
Output
1
Input
100 10
Output
0
Input
1 1
Output
0
Submitted Solution:
```
n,k=map(int,input().split())
print((n%k+99)//100)
```
Yes
| 63,824 | [
0.488037109375,
0.2003173828125,
-0.5234375,
0.336669921875,
-0.68408203125,
-0.6796875,
-0.470703125,
0.0531005859375,
-0.313232421875,
1.04296875,
0.355712890625,
-0.12176513671875,
0.1275634765625,
-0.87939453125,
-0.5693359375,
-0.295166015625,
-0.681640625,
-0.76171875,
-0.3... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
Constraints
* 1 \leq N,K \leq 100
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
Output
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
Examples
Input
7 3
Output
1
Input
100 10
Output
0
Input
1 1
Output
0
Submitted Solution:
```
n,k=map(int, input().split())
print(1 if n%k!=0 else 0)
```
Yes
| 63,825 | [
0.472900390625,
0.188720703125,
-0.515625,
0.322998046875,
-0.67431640625,
-0.7119140625,
-0.470458984375,
0.0679931640625,
-0.333251953125,
1.052734375,
0.363037109375,
-0.1109619140625,
0.1488037109375,
-0.896484375,
-0.576171875,
-0.30908203125,
-0.71044921875,
-0.76513671875,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
Constraints
* 1 \leq N,K \leq 100
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
Output
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
Examples
Input
7 3
Output
1
Input
100 10
Output
0
Input
1 1
Output
0
Submitted Solution:
```
n,k = map(int, input().split())
print(n%k if n%k==0 else 1)
```
Yes
| 63,826 | [
0.480224609375,
0.1822509765625,
-0.5146484375,
0.32470703125,
-0.67578125,
-0.7060546875,
-0.46826171875,
0.05780029296875,
-0.318359375,
1.0546875,
0.363037109375,
-0.111572265625,
0.144775390625,
-0.89208984375,
-0.576171875,
-0.307861328125,
-0.7041015625,
-0.75830078125,
-0.... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
Constraints
* 1 \leq N,K \leq 100
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
Output
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
Examples
Input
7 3
Output
1
Input
100 10
Output
0
Input
1 1
Output
0
Submitted Solution:
```
print("10"[eval(input().replace(" ","%"))==0])
```
Yes
| 63,827 | [
0.471435546875,
0.1519775390625,
-0.5087890625,
0.33251953125,
-0.77001953125,
-0.64697265625,
-0.440185546875,
0.0858154296875,
-0.310791015625,
0.9814453125,
0.445556640625,
-0.1480712890625,
0.041290283203125,
-0.89208984375,
-0.626953125,
-0.32177734375,
-0.6767578125,
-0.80029... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
Constraints
* 1 \leq N,K \leq 100
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
Output
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
Examples
Input
7 3
Output
1
Input
100 10
Output
0
Input
1 1
Output
0
Submitted Solution:
```
print(0 if eval(input().replace(" ","%")) else 1)
```
No
| 63,828 | [
0.455078125,
0.1661376953125,
-0.5205078125,
0.324951171875,
-0.77880859375,
-0.66796875,
-0.444580078125,
0.07244873046875,
-0.327392578125,
0.978515625,
0.47705078125,
-0.1448974609375,
0.04705810546875,
-0.91455078125,
-0.62939453125,
-0.301025390625,
-0.67822265625,
-0.79980468... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
Constraints
* 1 \leq N,K \leq 100
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
Output
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
Examples
Input
7 3
Output
1
Input
100 10
Output
0
Input
1 1
Output
0
Submitted Solution:
```
a, b = (int(i) for i in input().split())
print(int(a % b))
```
No
| 63,829 | [
0.496826171875,
0.142578125,
-0.496337890625,
0.330810546875,
-0.6982421875,
-0.6728515625,
-0.451171875,
0.07562255859375,
-0.28125,
1.044921875,
0.3681640625,
-0.1572265625,
0.08184814453125,
-0.87255859375,
-0.60791015625,
-0.310546875,
-0.70458984375,
-0.75439453125,
-0.34619... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
Constraints
* 1 \leq N,K \leq 100
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
Output
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
Examples
Input
7 3
Output
1
Input
100 10
Output
0
Input
1 1
Output
0
Submitted Solution:
```
n,k=map(int,input().split())
ans=0
if n%k==0:
ans=0
else:
ans=n%k
print(ans)
```
No
| 63,830 | [
0.47021484375,
0.17626953125,
-0.501953125,
0.332763671875,
-0.6650390625,
-0.7314453125,
-0.44384765625,
0.03662109375,
-0.3232421875,
1.048828125,
0.376953125,
-0.14208984375,
0.1417236328125,
-0.88525390625,
-0.5986328125,
-0.28955078125,
-0.6611328125,
-0.740234375,
-0.351318... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
Constraints
* 1 \leq N,K \leq 100
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
Output
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
Examples
Input
7 3
Output
1
Input
100 10
Output
0
Input
1 1
Output
0
Submitted Solution:
```
N,K = map(int,input().split())
if N // K == 0:
print(0)
else:
print(1)
```
No
| 63,831 | [
0.477783203125,
0.1844482421875,
-0.51708984375,
0.345703125,
-0.6796875,
-0.69775390625,
-0.462158203125,
0.042327880859375,
-0.30859375,
1.05859375,
0.378662109375,
-0.11517333984375,
0.1558837890625,
-0.87060546875,
-0.560546875,
-0.31787109375,
-0.68994140625,
-0.7431640625,
... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
On a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.
For CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.
The i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.
Two participants A and B can communicate with each other if and only if one of the following conditions is satisfied:
* There exists a language that both A and B can speak.
* There exists a participant X that both A and B can communicate with.
Determine whether all N participants can communicate with all other participants.
Constraints
* 2≦N≦10^5
* 1≦M≦10^5
* 1≦K_i≦M
* (The sum of all K_i)≦10^5
* 1≦L_{i,j}≦M
* L_{i,1}, L_{i,2}, ..., L_{i,{}K_i} are pairwise distinct.
Input
The input is given from Standard Input in the following format:
N M
K_1 L_{1,1} L_{1,2} ... L_{1,{}K_1}
K_2 L_{2,1} L_{2,2} ... L_{2,{}K_2}
:
K_N L_{N,1} L_{N,2} ... L_{N,{}K_N}
Output
If all N participants can communicate with all other participants, print `YES`. Otherwise, print `NO`.
Examples
Input
4 6
3 1 2 3
2 4 2
2 4 6
1 6
Output
YES
Input
4 4
2 1 2
2 1 2
1 3
2 4 3
Output
NO
"Correct Solution:
```
import sys
sys.setrecursionlimit(10**9)
def dfs(vNow):
useds[vNow] = True
for v2 in adjL[vNow]:
if not useds[v2]:
dfs(v2)
N, M = map(int, input().split())
adjL = [[] for v in range(N+M)]
for i in range(N):
K, *Ls = map(int, input().split())
for L in Ls:
adjL[i].append(L+N-1)
adjL[L+N-1].append(i)
useds = [False] * (N+M)
dfs(0)
print('YES' if all(useds[:N]) else 'NO')
```
| 63,880 | [
0.3193359375,
0.3427734375,
-0.1434326171875,
0.311279296875,
-0.2861328125,
-0.405029296875,
-0.365478515625,
0.06634521484375,
0.0222015380859375,
0.78759765625,
0.363525390625,
-0.09503173828125,
0.05902099609375,
-0.93115234375,
-0.4521484375,
0.259765625,
-0.93603515625,
-0.78... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
On a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.
For CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.
The i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.
Two participants A and B can communicate with each other if and only if one of the following conditions is satisfied:
* There exists a language that both A and B can speak.
* There exists a participant X that both A and B can communicate with.
Determine whether all N participants can communicate with all other participants.
Constraints
* 2≦N≦10^5
* 1≦M≦10^5
* 1≦K_i≦M
* (The sum of all K_i)≦10^5
* 1≦L_{i,j}≦M
* L_{i,1}, L_{i,2}, ..., L_{i,{}K_i} are pairwise distinct.
Input
The input is given from Standard Input in the following format:
N M
K_1 L_{1,1} L_{1,2} ... L_{1,{}K_1}
K_2 L_{2,1} L_{2,2} ... L_{2,{}K_2}
:
K_N L_{N,1} L_{N,2} ... L_{N,{}K_N}
Output
If all N participants can communicate with all other participants, print `YES`. Otherwise, print `NO`.
Examples
Input
4 6
3 1 2 3
2 4 2
2 4 6
1 6
Output
YES
Input
4 4
2 1 2
2 1 2
1 3
2 4 3
Output
NO
"Correct Solution:
```
from collections import deque
N,M=map(int,input().split())
L=[[] for i in range(M)]
for i in range(N):
for j,k in enumerate(input().split()):
if j==0:
continue
L[int(k)-1].append(i)
G=[[] for i in range(N)]
for l in L:
if len(l)>=2:
for i in range(len(l)-1):
if l[i+1] not in G[l[i]]:
G[l[i]].append(l[i+1])
G[l[i+1]].append(l[i])
V=[False]*N
n=1
dfs_stack=deque([0])
while dfs_stack:
a=dfs_stack.popleft()
if not V[a]:
n+=1
for b in G[a]:
if not V[b]:
dfs_stack.append(b)
V[a]=True
if V==[True]*N:
print("YES")
else:
print("NO")
```
| 63,881 | [
0.299072265625,
0.384521484375,
-0.196533203125,
0.190185546875,
-0.291748046875,
-0.3662109375,
-0.2496337890625,
0.06982421875,
0.153564453125,
0.787109375,
0.40869140625,
0.0345458984375,
0.0389404296875,
-0.9736328125,
-0.5341796875,
0.2232666015625,
-0.91162109375,
-0.77636718... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
On a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.
For CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.
The i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.
Two participants A and B can communicate with each other if and only if one of the following conditions is satisfied:
* There exists a language that both A and B can speak.
* There exists a participant X that both A and B can communicate with.
Determine whether all N participants can communicate with all other participants.
Constraints
* 2≦N≦10^5
* 1≦M≦10^5
* 1≦K_i≦M
* (The sum of all K_i)≦10^5
* 1≦L_{i,j}≦M
* L_{i,1}, L_{i,2}, ..., L_{i,{}K_i} are pairwise distinct.
Input
The input is given from Standard Input in the following format:
N M
K_1 L_{1,1} L_{1,2} ... L_{1,{}K_1}
K_2 L_{2,1} L_{2,2} ... L_{2,{}K_2}
:
K_N L_{N,1} L_{N,2} ... L_{N,{}K_N}
Output
If all N participants can communicate with all other participants, print `YES`. Otherwise, print `NO`.
Examples
Input
4 6
3 1 2 3
2 4 2
2 4 6
1 6
Output
YES
Input
4 4
2 1 2
2 1 2
1 3
2 4 3
Output
NO
"Correct Solution:
```
class UnionFind:
def __init__(self, n):
self.v = [-1 for _ in range(n)]
def find(self, x):
if self.v[x] < 0:
return x
else:
self.v[x] = self.find(self.v[x])
return self.v[x]
def unite(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if -self.v[x] < -self.v[y]:
x, y = y, x
self.v[x] += self.v[y]
self.v[y] = x
def root(self, x):
return self.v[x] < 0
def same(self, x, y):
return self.find(x) == self.find(y)
def size(self, x):
return -self.v[self.find(x)]
n, m = map(int, input().split())
uf = UnionFind(n + m)
for i in range(n):
_, *lngs = map(int, input().split())
for lng in lngs:
uf.unite(i, n + lng - 1)
can = all(uf.same(j, n - 1) for j in range(n - 1))
print('YES' if can else 'NO')
```
| 63,882 | [
0.325439453125,
0.12445068359375,
-0.2548828125,
0.330078125,
-0.21484375,
-0.45703125,
-0.2435302734375,
0.04949951171875,
0.15185546875,
0.736328125,
0.483154296875,
0.047454833984375,
0.07672119140625,
-0.91552734375,
-0.43701171875,
0.1402587890625,
-0.81201171875,
-0.762695312... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
On a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.
For CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.
The i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.
Two participants A and B can communicate with each other if and only if one of the following conditions is satisfied:
* There exists a language that both A and B can speak.
* There exists a participant X that both A and B can communicate with.
Determine whether all N participants can communicate with all other participants.
Constraints
* 2≦N≦10^5
* 1≦M≦10^5
* 1≦K_i≦M
* (The sum of all K_i)≦10^5
* 1≦L_{i,j}≦M
* L_{i,1}, L_{i,2}, ..., L_{i,{}K_i} are pairwise distinct.
Input
The input is given from Standard Input in the following format:
N M
K_1 L_{1,1} L_{1,2} ... L_{1,{}K_1}
K_2 L_{2,1} L_{2,2} ... L_{2,{}K_2}
:
K_N L_{N,1} L_{N,2} ... L_{N,{}K_N}
Output
If all N participants can communicate with all other participants, print `YES`. Otherwise, print `NO`.
Examples
Input
4 6
3 1 2 3
2 4 2
2 4 6
1 6
Output
YES
Input
4 4
2 1 2
2 1 2
1 3
2 4 3
Output
NO
"Correct Solution:
```
# -*- coding: utf-8 -*-
class UnionFind():
def __init__(self, n):
self.par = [i for i in range(n)]
def find(self, x):
if self.par[x] == x:
return x
else:
self.par[x] = self.find(self.par[x])
return self.par[x]
def unite(self, x, y):
x = self.find(x)
y = self.find(y)
if x==y:
return
if x<y:
self.par[y] = x
else:
self.par[x] = y
def same(self, x, y):
return self.find(x) == self.find(y)
n,m = map(int, input().split())
uf = UnionFind(n+m)
for u in range(n):
line = list(map(int, input().split()))
k = line[0]
for l in line[1:]:
lng = n+l-1
uf.unite(u, lng)
flag = True
for u in range(1,n):
if not uf.same(0,u):
flag = False
break
if flag:
print("YES")
else:
print("NO")
```
| 63,883 | [
0.31298828125,
0.140869140625,
-0.2122802734375,
0.238037109375,
-0.260986328125,
-0.5029296875,
-0.2027587890625,
0.01419830322265625,
0.115234375,
0.73046875,
0.424560546875,
0.0633544921875,
0.04974365234375,
-0.923828125,
-0.5,
0.062103271484375,
-0.8505859375,
-0.779296875,
... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
On a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.
For CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.
The i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.
Two participants A and B can communicate with each other if and only if one of the following conditions is satisfied:
* There exists a language that both A and B can speak.
* There exists a participant X that both A and B can communicate with.
Determine whether all N participants can communicate with all other participants.
Constraints
* 2≦N≦10^5
* 1≦M≦10^5
* 1≦K_i≦M
* (The sum of all K_i)≦10^5
* 1≦L_{i,j}≦M
* L_{i,1}, L_{i,2}, ..., L_{i,{}K_i} are pairwise distinct.
Input
The input is given from Standard Input in the following format:
N M
K_1 L_{1,1} L_{1,2} ... L_{1,{}K_1}
K_2 L_{2,1} L_{2,2} ... L_{2,{}K_2}
:
K_N L_{N,1} L_{N,2} ... L_{N,{}K_N}
Output
If all N participants can communicate with all other participants, print `YES`. Otherwise, print `NO`.
Examples
Input
4 6
3 1 2 3
2 4 2
2 4 6
1 6
Output
YES
Input
4 4
2 1 2
2 1 2
1 3
2 4 3
Output
NO
"Correct Solution:
```
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def Find(x): #xの根を返す
global table
if table[x] == x:
return x
else:
table[x] = Find(table[x]) #親の更新(根を直接親にして参照距離を短く)
return table[x]
def Unite(x,y): #xとyを繋げる
x = Find(x)
y = Find(y)
if x == y:
return
if rank[x] > rank[y]:
table[y] = x
else:
table[x] = y
if rank[x] == rank[y]:
rank[y] += 1
def Check(x,y):
if Find(x) == Find(y):
return True
else:
return False
N,M = inpl()
table = [i for i in range(N+M)] #木の親 table[x] == x なら根
rank = [1 for i in range(N+M)] #木の長さ
for i in range(N):
tmp = inpl()
for k in range(tmp[0]):
l = tmp[k+1]
Unite(i,l+N-1)
tmp = Find(0)
for i in range(N):
if tmp != Find(i):
print('NO')
sys.exit()
print('YES')
```
| 63,884 | [
0.35400390625,
0.321044921875,
-0.2042236328125,
0.278564453125,
-0.286376953125,
-0.42431640625,
-0.3310546875,
0.006641387939453125,
0.09381103515625,
0.85400390625,
0.312255859375,
-0.08697509765625,
0.0286865234375,
-0.96533203125,
-0.57568359375,
0.1728515625,
-0.953125,
-0.76... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
On a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.
For CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.
The i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.
Two participants A and B can communicate with each other if and only if one of the following conditions is satisfied:
* There exists a language that both A and B can speak.
* There exists a participant X that both A and B can communicate with.
Determine whether all N participants can communicate with all other participants.
Constraints
* 2≦N≦10^5
* 1≦M≦10^5
* 1≦K_i≦M
* (The sum of all K_i)≦10^5
* 1≦L_{i,j}≦M
* L_{i,1}, L_{i,2}, ..., L_{i,{}K_i} are pairwise distinct.
Input
The input is given from Standard Input in the following format:
N M
K_1 L_{1,1} L_{1,2} ... L_{1,{}K_1}
K_2 L_{2,1} L_{2,2} ... L_{2,{}K_2}
:
K_N L_{N,1} L_{N,2} ... L_{N,{}K_N}
Output
If all N participants can communicate with all other participants, print `YES`. Otherwise, print `NO`.
Examples
Input
4 6
3 1 2 3
2 4 2
2 4 6
1 6
Output
YES
Input
4 4
2 1 2
2 1 2
1 3
2 4 3
Output
NO
"Correct Solution:
```
N,M=map(int,input().split())
from collections import defaultdict
root=[-1]*(N+M)
def find(i):
global root
if root[i]>=0:
root[i]=find(root[i])
return root[i]
return i
def make(a,b):
global root
ra=find(a)
rb=find(b)
if ra==rb:
return
elif root[ra]<=root[rb]:
root[ra]+=root[rb]
root[rb]=ra
else:
root[rb]+=root[ra]
root[ra]=rb
return
for i in range(N):
X=list(map(int,input().split()))
for k in range(X[0]):
make(i,N+X[k+1]-1)
r0=find(0)
flag=True
for i in range(1,N):
if find(i)!=r0:
flag=False
break
if flag:
print('YES')
else:
print('NO')
```
| 63,885 | [
0.3193359375,
0.336669921875,
-0.259765625,
0.10845947265625,
-0.282470703125,
-0.47119140625,
-0.30078125,
0.08038330078125,
0.091552734375,
0.8115234375,
0.5400390625,
-0.0941162109375,
-0.0241546630859375,
-1.033203125,
-0.50927734375,
0.25,
-0.890625,
-0.7314453125,
-0.039611... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
On a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.
For CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.
The i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.
Two participants A and B can communicate with each other if and only if one of the following conditions is satisfied:
* There exists a language that both A and B can speak.
* There exists a participant X that both A and B can communicate with.
Determine whether all N participants can communicate with all other participants.
Constraints
* 2≦N≦10^5
* 1≦M≦10^5
* 1≦K_i≦M
* (The sum of all K_i)≦10^5
* 1≦L_{i,j}≦M
* L_{i,1}, L_{i,2}, ..., L_{i,{}K_i} are pairwise distinct.
Input
The input is given from Standard Input in the following format:
N M
K_1 L_{1,1} L_{1,2} ... L_{1,{}K_1}
K_2 L_{2,1} L_{2,2} ... L_{2,{}K_2}
:
K_N L_{N,1} L_{N,2} ... L_{N,{}K_N}
Output
If all N participants can communicate with all other participants, print `YES`. Otherwise, print `NO`.
Examples
Input
4 6
3 1 2 3
2 4 2
2 4 6
1 6
Output
YES
Input
4 4
2 1 2
2 1 2
1 3
2 4 3
Output
NO
"Correct Solution:
```
class UF():
def __init__(self, N):
self._parent=[n for n in range(0, N)]
self._size=[1] * N
def find_root(self, x):
if self._parent[x]==x:return x
self._parent[x]=self.find_root(self._parent[x])
return self._parent[x]
def unite(self, x, y):
gx=self.find_root(x)
gy=self.find_root(y)
if gx==gy:return
if self._size[gx]<self._size[gy]:
self._parent[gx]=gy
self._size[gy]+=self._size[gx]
else:
self._parent[gy]=gx
self._size[gx]+=self._size[gy]
def size(self, x):
return self._size[self.find_root(x)]
def samegroup(self, x, y):
return self.find_root(x)==self.find_root(y)
def groupnum(self):
N=len(self._parent)
ans=0
for i in range(N):
if self.find_root(i)==i:
ans+=1
return ans
n,m=map(int,input().split())
UF=UF(n+m)
for i in range(n):
l=list(map(int,input().split()))
for j in range(1,l[0]+1):
UF.unite(i,n+l[j]-1)
ct=0
for i in range(n,n+m):
if UF.size(i)==1:
ct+=1
if UF.groupnum()-ct==1:
print('YES')
else:
print('NO')
```
| 63,886 | [
0.333251953125,
0.27880859375,
-0.1802978515625,
0.1754150390625,
-0.259765625,
-0.40283203125,
-0.318359375,
0.11279296875,
0.048004150390625,
0.7265625,
0.53466796875,
-0.00972747802734375,
0.06982421875,
-0.91748046875,
-0.56201171875,
0.2568359375,
-0.87939453125,
-0.736328125,... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
On a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.
For CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.
The i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.
Two participants A and B can communicate with each other if and only if one of the following conditions is satisfied:
* There exists a language that both A and B can speak.
* There exists a participant X that both A and B can communicate with.
Determine whether all N participants can communicate with all other participants.
Constraints
* 2≦N≦10^5
* 1≦M≦10^5
* 1≦K_i≦M
* (The sum of all K_i)≦10^5
* 1≦L_{i,j}≦M
* L_{i,1}, L_{i,2}, ..., L_{i,{}K_i} are pairwise distinct.
Input
The input is given from Standard Input in the following format:
N M
K_1 L_{1,1} L_{1,2} ... L_{1,{}K_1}
K_2 L_{2,1} L_{2,2} ... L_{2,{}K_2}
:
K_N L_{N,1} L_{N,2} ... L_{N,{}K_N}
Output
If all N participants can communicate with all other participants, print `YES`. Otherwise, print `NO`.
Examples
Input
4 6
3 1 2 3
2 4 2
2 4 6
1 6
Output
YES
Input
4 4
2 1 2
2 1 2
1 3
2 4 3
Output
NO
"Correct Solution:
```
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools
import queue
from collections import deque
parent_node = []
def union_find(ele):
global parent_node
if parent_node[ele] != ele:
parent_node[ele] = union_find(parent_node[ele])
return parent_node[ele]
def main():
num, lang_num = map(int, input().split())
graph_data = defaultdict(set)
for i in range(num):
data = list(map(int, input().split()))
for ele in data[1:]:
graph_data[ele].add(i + 1)
global parent_node
parent_node = [i for i in range(num + 1)]
for key, value in graph_data.items():
min_set = set([union_find(ele) for ele in value])
min_ind = min(list(min_set))
for ele in min_set:
parent_node[ele] = min_ind
for i in range(num + 1):
a = union_find(i)
# print(parent_node)
if max(parent_node) == 1:
print('YES')
else:
print('NO')
if __name__ == '__main__':
main()
```
| 63,887 | [
0.262451171875,
0.25146484375,
-0.1590576171875,
0.312744140625,
-0.235107421875,
-0.405029296875,
-0.24267578125,
-0.047088623046875,
0.051025390625,
0.759765625,
0.39306640625,
-0.06988525390625,
0.0623779296875,
-1.0634765625,
-0.49365234375,
0.16650390625,
-0.9453125,
-0.842773... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.
For CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.
The i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.
Two participants A and B can communicate with each other if and only if one of the following conditions is satisfied:
* There exists a language that both A and B can speak.
* There exists a participant X that both A and B can communicate with.
Determine whether all N participants can communicate with all other participants.
Constraints
* 2≦N≦10^5
* 1≦M≦10^5
* 1≦K_i≦M
* (The sum of all K_i)≦10^5
* 1≦L_{i,j}≦M
* L_{i,1}, L_{i,2}, ..., L_{i,{}K_i} are pairwise distinct.
Input
The input is given from Standard Input in the following format:
N M
K_1 L_{1,1} L_{1,2} ... L_{1,{}K_1}
K_2 L_{2,1} L_{2,2} ... L_{2,{}K_2}
:
K_N L_{N,1} L_{N,2} ... L_{N,{}K_N}
Output
If all N participants can communicate with all other participants, print `YES`. Otherwise, print `NO`.
Examples
Input
4 6
3 1 2 3
2 4 2
2 4 6
1 6
Output
YES
Input
4 4
2 1 2
2 1 2
1 3
2 4 3
Output
NO
Submitted Solution:
```
n, m = map(int, input().split())
V = n + m
par = [i for i in range(0, V)]
sizes = [1] * V
def find(x):
if x == par[x]:
return x
par[x] = find(par[x])
return par[x]
def unite(x, y):
x = find(x)
y = find(y)
if x == y:
return
if sizes[x] < sizes[y]:
x, y = y, x
par[y] = x
sizes[x] += sizes[y]
for i in range(0, n):
for l in [int(k)for k in input().split()][1:]:
unite(i, l - 1 + n)
r = "YES"
for i in range(0, n):
if find(i) != find(0):
r = "NO"
print(r)
```
Yes
| 63,888 | [
0.37060546875,
0.1483154296875,
-0.296875,
0.254150390625,
-0.300537109375,
-0.41650390625,
-0.35498046875,
0.173095703125,
0.08673095703125,
0.8291015625,
0.3994140625,
0.1314697265625,
-0.017120361328125,
-0.8173828125,
-0.456298828125,
0.07073974609375,
-0.82763671875,
-0.747070... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.
For CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.
The i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.
Two participants A and B can communicate with each other if and only if one of the following conditions is satisfied:
* There exists a language that both A and B can speak.
* There exists a participant X that both A and B can communicate with.
Determine whether all N participants can communicate with all other participants.
Constraints
* 2≦N≦10^5
* 1≦M≦10^5
* 1≦K_i≦M
* (The sum of all K_i)≦10^5
* 1≦L_{i,j}≦M
* L_{i,1}, L_{i,2}, ..., L_{i,{}K_i} are pairwise distinct.
Input
The input is given from Standard Input in the following format:
N M
K_1 L_{1,1} L_{1,2} ... L_{1,{}K_1}
K_2 L_{2,1} L_{2,2} ... L_{2,{}K_2}
:
K_N L_{N,1} L_{N,2} ... L_{N,{}K_N}
Output
If all N participants can communicate with all other participants, print `YES`. Otherwise, print `NO`.
Examples
Input
4 6
3 1 2 3
2 4 2
2 4 6
1 6
Output
YES
Input
4 4
2 1 2
2 1 2
1 3
2 4 3
Output
NO
Submitted Solution:
```
q,w,e=input,range,int
n, m = map(e,q().split())
V = n + m
par = [i for i in w(V)]
sizes = [1] * V
def f(x):
if x == par[x]:
return x
par[x] = f(par[x])
return par[x]
def u(x, y):
x, y = f(x), f(y)
if x == y:
return
if sizes[x] < sizes[y]:
x, y = y, x
par[y] = x
sizes[x] += sizes[y]
[u(i,l-1+n)for i in w(n)for l in [e(k)for k in q().split()][1:]]
print("NO"if len([i for i in w(n)if f(i)!=f(0)])>0 else"YES")
```
Yes
| 63,889 | [
0.3818359375,
0.161865234375,
-0.266357421875,
0.265625,
-0.281982421875,
-0.406494140625,
-0.318603515625,
0.17333984375,
0.04571533203125,
0.8447265625,
0.3798828125,
0.09283447265625,
-0.0231781005859375,
-0.8037109375,
-0.46630859375,
0.09368896484375,
-0.8447265625,
-0.7392578... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.
For CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.
The i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.
Two participants A and B can communicate with each other if and only if one of the following conditions is satisfied:
* There exists a language that both A and B can speak.
* There exists a participant X that both A and B can communicate with.
Determine whether all N participants can communicate with all other participants.
Constraints
* 2≦N≦10^5
* 1≦M≦10^5
* 1≦K_i≦M
* (The sum of all K_i)≦10^5
* 1≦L_{i,j}≦M
* L_{i,1}, L_{i,2}, ..., L_{i,{}K_i} are pairwise distinct.
Input
The input is given from Standard Input in the following format:
N M
K_1 L_{1,1} L_{1,2} ... L_{1,{}K_1}
K_2 L_{2,1} L_{2,2} ... L_{2,{}K_2}
:
K_N L_{N,1} L_{N,2} ... L_{N,{}K_N}
Output
If all N participants can communicate with all other participants, print `YES`. Otherwise, print `NO`.
Examples
Input
4 6
3 1 2 3
2 4 2
2 4 6
1 6
Output
YES
Input
4 4
2 1 2
2 1 2
1 3
2 4 3
Output
NO
Submitted Solution:
```
from collections import defaultdict
N, M = map(int, input().split())
V = range(N+M)
E = defaultdict(list)
for i in range(N):
_, *L, = map(int, input().split())
for l in L:
l -= 1
E[i].append(l+N)
E[l+N].append(i)
stack = [0]
visited = [False] * (N+M)
while stack:
i = stack.pop()
if visited[i]: continue
visited[i] = True
for j in E[i]:
if not visited[j]:
stack.append(j)
if sum(visited[:N]) == N:
print('YES')
else:
print('NO')
```
Yes
| 63,890 | [
0.277099609375,
0.208251953125,
-0.321533203125,
0.201904296875,
-0.2900390625,
-0.362060546875,
-0.3671875,
0.140869140625,
0.035858154296875,
0.8896484375,
0.294189453125,
-0.023590087890625,
-0.0163421630859375,
-0.8056640625,
-0.52880859375,
0.05035400390625,
-0.86669921875,
-0... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.
For CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.
The i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.
Two participants A and B can communicate with each other if and only if one of the following conditions is satisfied:
* There exists a language that both A and B can speak.
* There exists a participant X that both A and B can communicate with.
Determine whether all N participants can communicate with all other participants.
Constraints
* 2≦N≦10^5
* 1≦M≦10^5
* 1≦K_i≦M
* (The sum of all K_i)≦10^5
* 1≦L_{i,j}≦M
* L_{i,1}, L_{i,2}, ..., L_{i,{}K_i} are pairwise distinct.
Input
The input is given from Standard Input in the following format:
N M
K_1 L_{1,1} L_{1,2} ... L_{1,{}K_1}
K_2 L_{2,1} L_{2,2} ... L_{2,{}K_2}
:
K_N L_{N,1} L_{N,2} ... L_{N,{}K_N}
Output
If all N participants can communicate with all other participants, print `YES`. Otherwise, print `NO`.
Examples
Input
4 6
3 1 2 3
2 4 2
2 4 6
1 6
Output
YES
Input
4 4
2 1 2
2 1 2
1 3
2 4 3
Output
NO
Submitted Solution:
```
class UnionFindNode(object):
"""
Union-Find構造
ノードのグループ併合や、所属グループ判定を高速に処理する
"""
def __init__(self, group_id, parent=None, value=None):
self.group_id_ = group_id
self.parent_ = parent
self.value = value
self.size_ = 1
def __str__(self):
template = "UnionFindNode(group_id: {}, \n\tparent: {}, value: {}, size: {})"
return template.format(self.group_id_, self.parent_, self.value, self.size_)
def is_root(self):
return not self.parent_
def root(self):
parent = self
while not parent.is_root():
parent = parent.parent_
self.parent_ = parent
return parent
def find(self):
parent = self.root()
return parent.group_id_
def size(self):
parent = self.root()
return parent.size_
def unite(self, unite_node):
parent = self.root()
unite_parent = unite_node.root()
if parent.group_id_ != unite_parent.group_id_:
if parent.size() > unite_parent.size():
unite_parent.parent_ = parent
parent.size_ = parent.size_ + unite_parent.size_
else:
parent.parent_ = unite_parent
unite_parent.size_ = parent.size_ + unite_parent.size_
def same(self, node):
return self.root() == node.root()
N, M = map(int, input().split())
uf = [UnionFindNode(i) for i in range(M)]
l = []
for i in range(N):
k, *lang = list(map(int, input().split()))
for j in range(k - 1):
uf[lang[j] - 1].unite(uf[lang[j + 1] - 1])
l.append(lang)
r = uf[lang[0] - 1].root()
for i in range(N):
if uf[l[i][0] - 1].root() != r:
print('NO')
exit(0)
print('YES')
```
Yes
| 63,891 | [
0.3564453125,
0.048980712890625,
-0.335205078125,
0.290283203125,
-0.230712890625,
-0.42919921875,
-0.25634765625,
0.156982421875,
0.159912109375,
0.748046875,
0.3154296875,
0.11175537109375,
0.0859375,
-0.7509765625,
-0.51953125,
0.0216827392578125,
-0.654296875,
-0.6513671875,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.
For CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.
The i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.
Two participants A and B can communicate with each other if and only if one of the following conditions is satisfied:
* There exists a language that both A and B can speak.
* There exists a participant X that both A and B can communicate with.
Determine whether all N participants can communicate with all other participants.
Constraints
* 2≦N≦10^5
* 1≦M≦10^5
* 1≦K_i≦M
* (The sum of all K_i)≦10^5
* 1≦L_{i,j}≦M
* L_{i,1}, L_{i,2}, ..., L_{i,{}K_i} are pairwise distinct.
Input
The input is given from Standard Input in the following format:
N M
K_1 L_{1,1} L_{1,2} ... L_{1,{}K_1}
K_2 L_{2,1} L_{2,2} ... L_{2,{}K_2}
:
K_N L_{N,1} L_{N,2} ... L_{N,{}K_N}
Output
If all N participants can communicate with all other participants, print `YES`. Otherwise, print `NO`.
Examples
Input
4 6
3 1 2 3
2 4 2
2 4 6
1 6
Output
YES
Input
4 4
2 1 2
2 1 2
1 3
2 4 3
Output
NO
Submitted Solution:
```
class UnionFind:
def __init__(self, n):
self.n = n
self.p = [e for e in range(n)]
self.rank = [0] * n
self.size = [1] * n
def same(self, u, v):
return self.find_set(u) == self.find_set(v)
def unite(self, u, v):
u = self.find_set(u)
v = self.find_set(v)
if u == v:
return
if self.rank[u] > self.rank[v]:
self.p[v] = u
self.size[u] += self.size[v]
else:
self.p[u] = v
self.size[v] += self.size[u]
if self.rank[u] == self.rank[v]:
self.rank[v] += 1
def find_set(self, u):
if u != self.p[u]:
self.p[u] = self.find_set(self.p[u])
return self.p[u]
def update_p(self):
for u in range(self.n):
self.find_set(u)
def get_size(self, u):
return self.size[self.find_set(u)]
n, m = map(int, input().split())
l = []
for _ in range(n):
k, *ls = map(int, input().split())
l.append(ls)
uf = UnionFind(m)
cnt = [0] * m
for li in l:
for e1, e2 in zip(li, li[1:]):
e1 -= 1
e2 -= 1
cnt[e1] = 1
cnt[e2] = 1
uf.unite(e1, e2)
if max(uf.size) >= sum(cnt):
ans = "YES"
else:
ans = "NO"
print(ans)
```
No
| 63,892 | [
0.38720703125,
0.056182861328125,
-0.304931640625,
0.279296875,
-0.25146484375,
-0.409912109375,
-0.315185546875,
0.15234375,
0.11175537109375,
0.78466796875,
0.37646484375,
0.1319580078125,
0.095947265625,
-0.7666015625,
-0.453369140625,
0.0902099609375,
-0.7529296875,
-0.68310546... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.
For CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.
The i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.
Two participants A and B can communicate with each other if and only if one of the following conditions is satisfied:
* There exists a language that both A and B can speak.
* There exists a participant X that both A and B can communicate with.
Determine whether all N participants can communicate with all other participants.
Constraints
* 2≦N≦10^5
* 1≦M≦10^5
* 1≦K_i≦M
* (The sum of all K_i)≦10^5
* 1≦L_{i,j}≦M
* L_{i,1}, L_{i,2}, ..., L_{i,{}K_i} are pairwise distinct.
Input
The input is given from Standard Input in the following format:
N M
K_1 L_{1,1} L_{1,2} ... L_{1,{}K_1}
K_2 L_{2,1} L_{2,2} ... L_{2,{}K_2}
:
K_N L_{N,1} L_{N,2} ... L_{N,{}K_N}
Output
If all N participants can communicate with all other participants, print `YES`. Otherwise, print `NO`.
Examples
Input
4 6
3 1 2 3
2 4 2
2 4 6
1 6
Output
YES
Input
4 4
2 1 2
2 1 2
1 3
2 4 3
Output
NO
Submitted Solution:
```
class UnionFind:
def __init__(self, n):
self.n = n
self.p = [e for e in range(n)]
self.rank = [0] * n
self.size = [1] * n
def same(self, u, v):
return self.find_set(u) == self.find_set(v)
def unite(self, u, v):
u = self.find_set(u)
v = self.find_set(v)
if u == v:
return
if self.rank[u] > self.rank[v]:
self.p[v] = u
self.size[u] += self.size[v]
else:
self.p[u] = v
self.size[v] += self.size[u]
if self.rank[u] == self.rank[v]:
self.rank[v] += 1
def find_set(self, u):
if u != self.p[u]:
self.p[u] = self.find_set(self.p[u])
return self.p[u]
def update_p(self):
for u in range(self.n):
self.find_set(u)
def get_size(self, u):
return self.size[self.find_set(u)]
n, m = map(int, input().split())
l = []
for _ in range(n):
k, *ls = map(int, input().split())
l.append(ls)
uf = UnionFind(m)
for li in l:
for e1, e2 in zip(li, li[1:]):
e1 -= 1
e2 -= 1
uf.unite(e1, e2)
p = uf.find_set(l[0][0])
ans = "YES"
for e, *_ in l:
e -= 1
if uf.find_set(e) != p:
ans = "NO"
print(ans)
```
No
| 63,893 | [
0.38720703125,
0.056182861328125,
-0.304931640625,
0.279296875,
-0.25146484375,
-0.409912109375,
-0.315185546875,
0.15234375,
0.11175537109375,
0.78466796875,
0.37646484375,
0.1319580078125,
0.095947265625,
-0.7666015625,
-0.453369140625,
0.0902099609375,
-0.7529296875,
-0.68310546... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.
For CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.
The i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.
Two participants A and B can communicate with each other if and only if one of the following conditions is satisfied:
* There exists a language that both A and B can speak.
* There exists a participant X that both A and B can communicate with.
Determine whether all N participants can communicate with all other participants.
Constraints
* 2≦N≦10^5
* 1≦M≦10^5
* 1≦K_i≦M
* (The sum of all K_i)≦10^5
* 1≦L_{i,j}≦M
* L_{i,1}, L_{i,2}, ..., L_{i,{}K_i} are pairwise distinct.
Input
The input is given from Standard Input in the following format:
N M
K_1 L_{1,1} L_{1,2} ... L_{1,{}K_1}
K_2 L_{2,1} L_{2,2} ... L_{2,{}K_2}
:
K_N L_{N,1} L_{N,2} ... L_{N,{}K_N}
Output
If all N participants can communicate with all other participants, print `YES`. Otherwise, print `NO`.
Examples
Input
4 6
3 1 2 3
2 4 2
2 4 6
1 6
Output
YES
Input
4 4
2 1 2
2 1 2
1 3
2 4 3
Output
NO
Submitted Solution:
```
N,M = map(int,input().split())
par = [i for i in range(N+M)]
def root(a):
if par[a] == a: return a
return root(par[a])
def same(a,b):
return root(a) == root(b)
def unite(a,b):
ra,rb = root(a),root(b)
if ra == rb: return
par[ra] = rb
for i in range(N):
src = list(map(lambda x:int(x)-1,input().split()))
for j in src[1:]:
unite(i,N+j)
for i in range(1,N):
if not same(0,i):
print('NO')
exit()
print('YES')
```
No
| 63,894 | [
0.406982421875,
0.1646728515625,
-0.337646484375,
0.18310546875,
-0.250732421875,
-0.404052734375,
-0.332275390625,
0.1495361328125,
0.0738525390625,
0.8369140625,
0.431640625,
0.1085205078125,
-0.01137542724609375,
-0.83642578125,
-0.4736328125,
0.10028076171875,
-0.8173828125,
-0... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.
For CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.
The i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.
Two participants A and B can communicate with each other if and only if one of the following conditions is satisfied:
* There exists a language that both A and B can speak.
* There exists a participant X that both A and B can communicate with.
Determine whether all N participants can communicate with all other participants.
Constraints
* 2≦N≦10^5
* 1≦M≦10^5
* 1≦K_i≦M
* (The sum of all K_i)≦10^5
* 1≦L_{i,j}≦M
* L_{i,1}, L_{i,2}, ..., L_{i,{}K_i} are pairwise distinct.
Input
The input is given from Standard Input in the following format:
N M
K_1 L_{1,1} L_{1,2} ... L_{1,{}K_1}
K_2 L_{2,1} L_{2,2} ... L_{2,{}K_2}
:
K_N L_{N,1} L_{N,2} ... L_{N,{}K_N}
Output
If all N participants can communicate with all other participants, print `YES`. Otherwise, print `NO`.
Examples
Input
4 6
3 1 2 3
2 4 2
2 4 6
1 6
Output
YES
Input
4 4
2 1 2
2 1 2
1 3
2 4 3
Output
NO
Submitted Solution:
```
import sys
sys.setrecursionlimit(100000)
n, m = map(int, input().split())
people = []
lang = [[] for _ in range(m)]
for i in range(n):
kl = list(map(int, input().split()))
k = kl[0]
people.append(kl[1:])
for l in kl[1:]:
lang[l-1].append(i)
print(people, lang)
visited = [False for _ in range(n)]
def dfs(i):
if visited[i]:
return
else:
visited[i] = True
for l in people[i]:
for nexp in lang[l-1]:
dfs(nexp)
dfs(0)
if all(visited):
print('YES')
else:
print('NO')
```
No
| 63,895 | [
0.365234375,
0.26025390625,
-0.282470703125,
0.305419921875,
-0.329833984375,
-0.42431640625,
-0.337646484375,
0.153564453125,
0.03509521484375,
0.8095703125,
0.298583984375,
0.0316162109375,
0.0199127197265625,
-0.78564453125,
-0.52587890625,
0.1107177734375,
-0.8466796875,
-0.791... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
Welcome to PC Koshien, players. At PC Koshien, competitions are currently being held in a total of three categories: programming category, mobile category, and Ichimai's picture CG category.
Given the number of participants in each department, create a program that calculates the total number of participants.
Input
The input is given in the following format.
p m c
The input is one line, the number of participants in the programming department p (0 ≤ p ≤ 10000), the number of participants in the mobile department m (0 ≤ m ≤ 10000), the number of participants in the Ichimai picture CG department c (0) ≤ c ≤ 10000) is given.
Output
Output the total number of participants on one line.
Examples
Input
10 10 20
Output
40
Input
100 0 0
Output
100
Input
1000 1000 1000
Output
3000
"Correct Solution:
```
#coding:utf-8
#Your code here
a,b,c=map(int,input().split())
print(a+b+c)
```
| 63,913 | [
0.3779296875,
0.14697265625,
-0.5185546875,
-0.09771728515625,
-0.428466796875,
-0.587890625,
0.1676025390625,
0.318115234375,
0.046417236328125,
0.4267578125,
0.32080078125,
0.1761474609375,
-0.08831787109375,
-0.568359375,
-0.37158203125,
-0.2783203125,
-0.188232421875,
-0.627929... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
Welcome to PC Koshien, players. At PC Koshien, competitions are currently being held in a total of three categories: programming category, mobile category, and Ichimai's picture CG category.
Given the number of participants in each department, create a program that calculates the total number of participants.
Input
The input is given in the following format.
p m c
The input is one line, the number of participants in the programming department p (0 ≤ p ≤ 10000), the number of participants in the mobile department m (0 ≤ m ≤ 10000), the number of participants in the Ichimai picture CG department c (0) ≤ c ≤ 10000) is given.
Output
Output the total number of participants on one line.
Examples
Input
10 10 20
Output
40
Input
100 0 0
Output
100
Input
1000 1000 1000
Output
3000
"Correct Solution:
```
a = input().split()
b=int(a[0])+int(a[1])+int(a[2])
print(b)
```
| 63,914 | [
0.40234375,
0.11541748046875,
-0.453857421875,
-0.06378173828125,
-0.5029296875,
-0.62548828125,
0.0791015625,
0.34033203125,
0.06341552734375,
0.45166015625,
0.339111328125,
0.1041259765625,
-0.205322265625,
-0.6279296875,
-0.432373046875,
-0.202392578125,
-0.2218017578125,
-0.648... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
Welcome to PC Koshien, players. At PC Koshien, competitions are currently being held in a total of three categories: programming category, mobile category, and Ichimai's picture CG category.
Given the number of participants in each department, create a program that calculates the total number of participants.
Input
The input is given in the following format.
p m c
The input is one line, the number of participants in the programming department p (0 ≤ p ≤ 10000), the number of participants in the mobile department m (0 ≤ m ≤ 10000), the number of participants in the Ichimai picture CG department c (0) ≤ c ≤ 10000) is given.
Output
Output the total number of participants on one line.
Examples
Input
10 10 20
Output
40
Input
100 0 0
Output
100
Input
1000 1000 1000
Output
3000
"Correct Solution:
```
# coding: utf-8
# Your code here!
p,m,c= map(int,input().split())
print(p+m+c)
```
| 63,915 | [
0.37744140625,
0.15673828125,
-0.493408203125,
-0.08477783203125,
-0.44091796875,
-0.5732421875,
0.1776123046875,
0.298095703125,
0.046478271484375,
0.39794921875,
0.350341796875,
0.1817626953125,
-0.0836181640625,
-0.5830078125,
-0.40478515625,
-0.264892578125,
-0.1597900390625,
-... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
Welcome to PC Koshien, players. At PC Koshien, competitions are currently being held in a total of three categories: programming category, mobile category, and Ichimai's picture CG category.
Given the number of participants in each department, create a program that calculates the total number of participants.
Input
The input is given in the following format.
p m c
The input is one line, the number of participants in the programming department p (0 ≤ p ≤ 10000), the number of participants in the mobile department m (0 ≤ m ≤ 10000), the number of participants in the Ichimai picture CG department c (0) ≤ c ≤ 10000) is given.
Output
Output the total number of participants on one line.
Examples
Input
10 10 20
Output
40
Input
100 0 0
Output
100
Input
1000 1000 1000
Output
3000
"Correct Solution:
```
# 10 10 20 => 分割して、数値に変換する
p, m, c = map(int, input().split())
print(p + m + c)
```
| 63,916 | [
0.3857421875,
0.1644287109375,
-0.419189453125,
-0.064208984375,
-0.4658203125,
-0.533203125,
0.0404052734375,
0.378662109375,
0.028961181640625,
0.37646484375,
0.419921875,
0.12493896484375,
-0.0435791015625,
-0.61376953125,
-0.44775390625,
-0.1875,
-0.2042236328125,
-0.6186523437... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
Welcome to PC Koshien, players. At PC Koshien, competitions are currently being held in a total of three categories: programming category, mobile category, and Ichimai's picture CG category.
Given the number of participants in each department, create a program that calculates the total number of participants.
Input
The input is given in the following format.
p m c
The input is one line, the number of participants in the programming department p (0 ≤ p ≤ 10000), the number of participants in the mobile department m (0 ≤ m ≤ 10000), the number of participants in the Ichimai picture CG department c (0) ≤ c ≤ 10000) is given.
Output
Output the total number of participants on one line.
Examples
Input
10 10 20
Output
40
Input
100 0 0
Output
100
Input
1000 1000 1000
Output
3000
"Correct Solution:
```
import math
a,b,c,=map(int,input().split())
print(a+b+c)
```
| 63,917 | [
0.452392578125,
0.1834716796875,
-0.477294921875,
-0.09686279296875,
-0.4658203125,
-0.52685546875,
0.042236328125,
0.35693359375,
0.0633544921875,
0.46923828125,
0.392333984375,
0.10870361328125,
-0.1036376953125,
-0.603515625,
-0.375732421875,
-0.1981201171875,
-0.23828125,
-0.59... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
Welcome to PC Koshien, players. At PC Koshien, competitions are currently being held in a total of three categories: programming category, mobile category, and Ichimai's picture CG category.
Given the number of participants in each department, create a program that calculates the total number of participants.
Input
The input is given in the following format.
p m c
The input is one line, the number of participants in the programming department p (0 ≤ p ≤ 10000), the number of participants in the mobile department m (0 ≤ m ≤ 10000), the number of participants in the Ichimai picture CG department c (0) ≤ c ≤ 10000) is given.
Output
Output the total number of participants on one line.
Examples
Input
10 10 20
Output
40
Input
100 0 0
Output
100
Input
1000 1000 1000
Output
3000
"Correct Solution:
```
import sys
import math
p,m,c=map(int,input().split())
total=p+m+c
print(total)
```
| 63,918 | [
0.436279296875,
0.2052001953125,
-0.368896484375,
-0.075927734375,
-0.48681640625,
-0.48779296875,
0.0335693359375,
0.32275390625,
0.0679931640625,
0.451904296875,
0.35595703125,
0.107666015625,
-0.08477783203125,
-0.5546875,
-0.452880859375,
-0.150634765625,
-0.1951904296875,
-0.5... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
Welcome to PC Koshien, players. At PC Koshien, competitions are currently being held in a total of three categories: programming category, mobile category, and Ichimai's picture CG category.
Given the number of participants in each department, create a program that calculates the total number of participants.
Input
The input is given in the following format.
p m c
The input is one line, the number of participants in the programming department p (0 ≤ p ≤ 10000), the number of participants in the mobile department m (0 ≤ m ≤ 10000), the number of participants in the Ichimai picture CG department c (0) ≤ c ≤ 10000) is given.
Output
Output the total number of participants on one line.
Examples
Input
10 10 20
Output
40
Input
100 0 0
Output
100
Input
1000 1000 1000
Output
3000
"Correct Solution:
```
while True:
try:
a,b,c=map(int,input().split())
print(a+b+c)
except:break
```
| 63,919 | [
0.425537109375,
0.1734619140625,
-0.478515625,
-0.031829833984375,
-0.443359375,
-0.59521484375,
-0.0222625732421875,
0.300537109375,
0.065185546875,
0.473388671875,
0.392822265625,
0.09710693359375,
-0.08831787109375,
-0.59619140625,
-0.33447265625,
-0.272216796875,
-0.2440185546875... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
Welcome to PC Koshien, players. At PC Koshien, competitions are currently being held in a total of three categories: programming category, mobile category, and Ichimai's picture CG category.
Given the number of participants in each department, create a program that calculates the total number of participants.
Input
The input is given in the following format.
p m c
The input is one line, the number of participants in the programming department p (0 ≤ p ≤ 10000), the number of participants in the mobile department m (0 ≤ m ≤ 10000), the number of participants in the Ichimai picture CG department c (0) ≤ c ≤ 10000) is given.
Output
Output the total number of participants on one line.
Examples
Input
10 10 20
Output
40
Input
100 0 0
Output
100
Input
1000 1000 1000
Output
3000
"Correct Solution:
```
p, m, c = map(int, input().split())
all = p+m+c
print(all)
```
| 63,920 | [
0.427490234375,
0.184814453125,
-0.4052734375,
-0.04522705078125,
-0.438720703125,
-0.58251953125,
0.04718017578125,
0.33642578125,
0.03875732421875,
0.41748046875,
0.419677734375,
0.108154296875,
-0.09210205078125,
-0.650390625,
-0.4423828125,
-0.2078857421875,
-0.2091064453125,
-... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Welcome to PC Koshien, players. At PC Koshien, competitions are currently being held in a total of three categories: programming category, mobile category, and Ichimai's picture CG category.
Given the number of participants in each department, create a program that calculates the total number of participants.
Input
The input is given in the following format.
p m c
The input is one line, the number of participants in the programming department p (0 ≤ p ≤ 10000), the number of participants in the mobile department m (0 ≤ m ≤ 10000), the number of participants in the Ichimai picture CG department c (0) ≤ c ≤ 10000) is given.
Output
Output the total number of participants on one line.
Examples
Input
10 10 20
Output
40
Input
100 0 0
Output
100
Input
1000 1000 1000
Output
3000
Submitted Solution:
```
a,b,c=map(int,input().split())
x=a+b+c
print(x)
```
Yes
| 63,921 | [
0.494873046875,
0.1746826171875,
-0.389892578125,
-0.00014972686767578125,
-0.515625,
-0.5029296875,
-0.0499267578125,
0.33837890625,
0.03167724609375,
0.48388671875,
0.366943359375,
0.1639404296875,
-0.161376953125,
-0.59619140625,
-0.37109375,
-0.265625,
-0.2197265625,
-0.6738281... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Welcome to PC Koshien, players. At PC Koshien, competitions are currently being held in a total of three categories: programming category, mobile category, and Ichimai's picture CG category.
Given the number of participants in each department, create a program that calculates the total number of participants.
Input
The input is given in the following format.
p m c
The input is one line, the number of participants in the programming department p (0 ≤ p ≤ 10000), the number of participants in the mobile department m (0 ≤ m ≤ 10000), the number of participants in the Ichimai picture CG department c (0) ≤ c ≤ 10000) is given.
Output
Output the total number of participants on one line.
Examples
Input
10 10 20
Output
40
Input
100 0 0
Output
100
Input
1000 1000 1000
Output
3000
Submitted Solution:
```
p,m,c=(int(x) for x in input().split())
print(p+m+c)
```
Yes
| 63,922 | [
0.501953125,
0.1622314453125,
-0.30322265625,
0.00400543212890625,
-0.5068359375,
-0.478271484375,
-0.0072479248046875,
0.287109375,
0.07196044921875,
0.4091796875,
0.419189453125,
0.1302490234375,
-0.1982421875,
-0.638671875,
-0.453125,
-0.185791015625,
-0.1953125,
-0.69580078125,... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Welcome to PC Koshien, players. At PC Koshien, competitions are currently being held in a total of three categories: programming category, mobile category, and Ichimai's picture CG category.
Given the number of participants in each department, create a program that calculates the total number of participants.
Input
The input is given in the following format.
p m c
The input is one line, the number of participants in the programming department p (0 ≤ p ≤ 10000), the number of participants in the mobile department m (0 ≤ m ≤ 10000), the number of participants in the Ichimai picture CG department c (0) ≤ c ≤ 10000) is given.
Output
Output the total number of participants on one line.
Examples
Input
10 10 20
Output
40
Input
100 0 0
Output
100
Input
1000 1000 1000
Output
3000
Submitted Solution:
```
p,m,c=map(int,input().split());print(p+m+c)
```
Yes
| 63,923 | [
0.481201171875,
0.1715087890625,
-0.383056640625,
-0.0044403076171875,
-0.51171875,
-0.50439453125,
-0.040435791015625,
0.312255859375,
0.035675048828125,
0.4453125,
0.384765625,
0.1505126953125,
-0.1497802734375,
-0.6181640625,
-0.412841796875,
-0.231689453125,
-0.2027587890625,
-... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Welcome to PC Koshien, players. At PC Koshien, competitions are currently being held in a total of three categories: programming category, mobile category, and Ichimai's picture CG category.
Given the number of participants in each department, create a program that calculates the total number of participants.
Input
The input is given in the following format.
p m c
The input is one line, the number of participants in the programming department p (0 ≤ p ≤ 10000), the number of participants in the mobile department m (0 ≤ m ≤ 10000), the number of participants in the Ichimai picture CG department c (0) ≤ c ≤ 10000) is given.
Output
Output the total number of participants on one line.
Examples
Input
10 10 20
Output
40
Input
100 0 0
Output
100
Input
1000 1000 1000
Output
3000
Submitted Solution:
```
print(sum(list(map(int, input().split()))))
```
Yes
| 63,924 | [
0.45556640625,
0.137939453125,
-0.405029296875,
0.0594482421875,
-0.5263671875,
-0.54736328125,
-0.0264434814453125,
0.359619140625,
0.060302734375,
0.401611328125,
0.3603515625,
0.12139892578125,
-0.1385498046875,
-0.54833984375,
-0.457763671875,
-0.255126953125,
-0.21435546875,
-... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Welcome to PC Koshien, players. At PC Koshien, competitions are currently being held in a total of three categories: programming category, mobile category, and Ichimai's picture CG category.
Given the number of participants in each department, create a program that calculates the total number of participants.
Input
The input is given in the following format.
p m c
The input is one line, the number of participants in the programming department p (0 ≤ p ≤ 10000), the number of participants in the mobile department m (0 ≤ m ≤ 10000), the number of participants in the Ichimai picture CG department c (0) ≤ c ≤ 10000) is given.
Output
Output the total number of participants on one line.
Examples
Input
10 10 20
Output
40
Input
100 0 0
Output
100
Input
1000 1000 1000
Output
3000
Submitted Solution:
```
print(sum(map(int, input().split()))
```
No
| 63,925 | [
0.465087890625,
0.1724853515625,
-0.43310546875,
0.04718017578125,
-0.509765625,
-0.58056640625,
-0.03662109375,
0.3662109375,
0.03948974609375,
0.427001953125,
0.37451171875,
0.1451416015625,
-0.1455078125,
-0.55810546875,
-0.4453125,
-0.2734375,
-0.2021484375,
-0.69140625,
-0.2... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Welcome to PC Koshien, players. At PC Koshien, competitions are currently being held in a total of three categories: programming category, mobile category, and Ichimai's picture CG category.
Given the number of participants in each department, create a program that calculates the total number of participants.
Input
The input is given in the following format.
p m c
The input is one line, the number of participants in the programming department p (0 ≤ p ≤ 10000), the number of participants in the mobile department m (0 ≤ m ≤ 10000), the number of participants in the Ichimai picture CG department c (0) ≤ c ≤ 10000) is given.
Output
Output the total number of participants on one line.
Examples
Input
10 10 20
Output
40
Input
100 0 0
Output
100
Input
1000 1000 1000
Output
3000
Submitted Solution:
```
while True:
try:
a,b,c=map(int,input().split)
print(a+b+c)
except:break
```
No
| 63,926 | [
0.4775390625,
0.1676025390625,
-0.4287109375,
0.021392822265625,
-0.488525390625,
-0.52197265625,
-0.046600341796875,
0.30078125,
0.04296875,
0.463134765625,
0.381591796875,
0.1396484375,
-0.152587890625,
-0.6064453125,
-0.359375,
-0.3017578125,
-0.210693359375,
-0.64794921875,
-... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
Example
Input
2 2 7
3 4
3 2
1 3
1 1
2 2
1 2
2 1
1 2
2 2
1 1
Output
5
"Correct Solution:
```
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
P, R, T = map(int, readline().split())
*L, = map(int, readline().split())
RS = [list(map(int, readline().split())) for i in range(P)]
LG = [list(map(int, input().split())) for i in range(T)]
prv = -1
K = [[0]*R for i in range(P)]
def check(t):
nonlocal prv
if prv < t:
for i in range(prv+1, t+1):
p, r = LG[i]
K[p-1][r-1] += 1
L[r-1] -= 1
else:
for i in range(t+1, prv+1):
p, r = LG[i]
K[p-1][r-1] -= 1
L[r-1] += 1
S = L[:]; U = [0]*P
updated = 1
while updated:
updated = 0
for i in range(P):
if U[i]:
continue
for j in range(R):
if RS[i][j] - K[i][j] > max(S[j], 0):
break
else:
U[i] = 1
for j in range(R):
S[j] += K[i][j]
updated = 1
prv = t
return sum(U) == P
left = 0; right = T
while left+1 < right:
mid = (left + right) >> 1
if check(mid):
left = mid
else:
right = mid
if right == T:
write("-1\n")
else:
write("%d\n" % (right+1))
solve()
```
| 63,944 | [
0.17041015625,
0.302734375,
-0.15478515625,
0.11029052734375,
-0.5869140625,
-0.60498046875,
-0.2003173828125,
0.0660400390625,
-0.134033203125,
0.9169921875,
0.1837158203125,
0.1295166015625,
0.029571533203125,
-0.5,
-0.7255859375,
-0.10308837890625,
-0.45458984375,
-0.90966796875... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya used to be an accountant before the war began and he is one of the few who knows how to operate a computer, so he was assigned as the programmer.
We all know that programs often store sets of integers. For example, if we have a problem about a weighted directed graph, its edge can be represented by three integers: the number of the starting vertex, the number of the final vertex and the edge's weight. So, as Vasya was trying to represent characteristics of a recently invented robot in his program, he faced the following problem.
Vasya is not a programmer, so he asked his friend Gena, what the convenient way to store n integers is. Gena used to code in language X-- and so he can use only the types that occur in this language. Let's define, what a "type" is in language X--:
* First, a type is a string "int".
* Second, a type is a string that starts with "pair", then followed by angle brackets listing exactly two comma-separated other types of language X--. This record contains no spaces.
* No other strings can be regarded as types.
More formally: type := int | pair<type,type>. For example, Gena uses the following type for graph edges: pair<int,pair<int,int>>.
Gena was pleased to help Vasya, he dictated to Vasya a type of language X--, that stores n integers. Unfortunately, Gena was in a hurry, so he omitted the punctuation. Now Gena has already left and Vasya can't find the correct punctuation, resulting in a type of language X--, however hard he tries.
Help Vasya and add the punctuation marks so as to receive the valid type of language X--. Otherwise say that the task is impossible to perform.
Input
The first line contains a single integer n (1 ≤ n ≤ 105), showing how many numbers the type dictated by Gena contains.
The second line contains space-separated words, said by Gena. Each of them is either "pair" or "int" (without the quotes).
It is guaranteed that the total number of words does not exceed 105 and that among all the words that Gena said, there are exactly n words "int".
Output
If it is possible to add the punctuation marks so as to get a correct type of language X-- as a result, print a single line that represents the resulting type. Otherwise, print "Error occurred" (without the quotes). Inside the record of a type should not be any extra spaces and other characters.
It is guaranteed that if such type exists, then it is unique.
Note that you should print the type dictated by Gena (if such type exists) and not any type that can contain n values.
Examples
Input
3
pair pair int int int
Output
pair<pair<int,int>,int>
Input
1
pair int
Output
Error occurred
Submitted Solution:
```
n = input()
p = ''
s = []
for q in input().split():
t = q < 'p'
p += q
while t and s and s[-1]:
p += '>'
s.pop()
if s:
s.pop()
s.append(t)
p += "<," [t]
if p.count('<') == p.count('>'):
print(p[: -1])
else:
print("Error occurred")
```
Yes
| 64,263 | [
0.583984375,
-0.19384765625,
-0.11224365234375,
-0.0826416015625,
-0.5693359375,
-0.47802734375,
0.1722412109375,
0.299560546875,
-0.0005841255187988281,
0.55810546875,
0.384033203125,
-0.06732177734375,
-0.018951416015625,
-0.5947265625,
-0.367431640625,
0.04736328125,
-0.4323730468... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya used to be an accountant before the war began and he is one of the few who knows how to operate a computer, so he was assigned as the programmer.
We all know that programs often store sets of integers. For example, if we have a problem about a weighted directed graph, its edge can be represented by three integers: the number of the starting vertex, the number of the final vertex and the edge's weight. So, as Vasya was trying to represent characteristics of a recently invented robot in his program, he faced the following problem.
Vasya is not a programmer, so he asked his friend Gena, what the convenient way to store n integers is. Gena used to code in language X-- and so he can use only the types that occur in this language. Let's define, what a "type" is in language X--:
* First, a type is a string "int".
* Second, a type is a string that starts with "pair", then followed by angle brackets listing exactly two comma-separated other types of language X--. This record contains no spaces.
* No other strings can be regarded as types.
More formally: type := int | pair<type,type>. For example, Gena uses the following type for graph edges: pair<int,pair<int,int>>.
Gena was pleased to help Vasya, he dictated to Vasya a type of language X--, that stores n integers. Unfortunately, Gena was in a hurry, so he omitted the punctuation. Now Gena has already left and Vasya can't find the correct punctuation, resulting in a type of language X--, however hard he tries.
Help Vasya and add the punctuation marks so as to receive the valid type of language X--. Otherwise say that the task is impossible to perform.
Input
The first line contains a single integer n (1 ≤ n ≤ 105), showing how many numbers the type dictated by Gena contains.
The second line contains space-separated words, said by Gena. Each of them is either "pair" or "int" (without the quotes).
It is guaranteed that the total number of words does not exceed 105 and that among all the words that Gena said, there are exactly n words "int".
Output
If it is possible to add the punctuation marks so as to get a correct type of language X-- as a result, print a single line that represents the resulting type. Otherwise, print "Error occurred" (without the quotes). Inside the record of a type should not be any extra spaces and other characters.
It is guaranteed that if such type exists, then it is unique.
Note that you should print the type dictated by Gena (if such type exists) and not any type that can contain n values.
Examples
Input
3
pair pair int int int
Output
pair<pair<int,int>,int>
Input
1
pair int
Output
Error occurred
Submitted Solution:
```
input()
p = ''
s = []
for q in input().split():
t = q < 'p'
p += q
while t and s and s[-1]:
p += '>'
s.pop()
if s: s.pop()
s.append(t)
p += '<,'[t]
print(p[:-1] if p.count('<') == p.count('>') else 'Error occurred')
```
Yes
| 64,264 | [
0.583984375,
-0.19384765625,
-0.11224365234375,
-0.0826416015625,
-0.5693359375,
-0.47802734375,
0.1722412109375,
0.299560546875,
-0.0005841255187988281,
0.55810546875,
0.384033203125,
-0.06732177734375,
-0.018951416015625,
-0.5947265625,
-0.367431640625,
0.04736328125,
-0.4323730468... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya used to be an accountant before the war began and he is one of the few who knows how to operate a computer, so he was assigned as the programmer.
We all know that programs often store sets of integers. For example, if we have a problem about a weighted directed graph, its edge can be represented by three integers: the number of the starting vertex, the number of the final vertex and the edge's weight. So, as Vasya was trying to represent characteristics of a recently invented robot in his program, he faced the following problem.
Vasya is not a programmer, so he asked his friend Gena, what the convenient way to store n integers is. Gena used to code in language X-- and so he can use only the types that occur in this language. Let's define, what a "type" is in language X--:
* First, a type is a string "int".
* Second, a type is a string that starts with "pair", then followed by angle brackets listing exactly two comma-separated other types of language X--. This record contains no spaces.
* No other strings can be regarded as types.
More formally: type := int | pair<type,type>. For example, Gena uses the following type for graph edges: pair<int,pair<int,int>>.
Gena was pleased to help Vasya, he dictated to Vasya a type of language X--, that stores n integers. Unfortunately, Gena was in a hurry, so he omitted the punctuation. Now Gena has already left and Vasya can't find the correct punctuation, resulting in a type of language X--, however hard he tries.
Help Vasya and add the punctuation marks so as to receive the valid type of language X--. Otherwise say that the task is impossible to perform.
Input
The first line contains a single integer n (1 ≤ n ≤ 105), showing how many numbers the type dictated by Gena contains.
The second line contains space-separated words, said by Gena. Each of them is either "pair" or "int" (without the quotes).
It is guaranteed that the total number of words does not exceed 105 and that among all the words that Gena said, there are exactly n words "int".
Output
If it is possible to add the punctuation marks so as to get a correct type of language X-- as a result, print a single line that represents the resulting type. Otherwise, print "Error occurred" (without the quotes). Inside the record of a type should not be any extra spaces and other characters.
It is guaranteed that if such type exists, then it is unique.
Note that you should print the type dictated by Gena (if such type exists) and not any type that can contain n values.
Examples
Input
3
pair pair int int int
Output
pair<pair<int,int>,int>
Input
1
pair int
Output
Error occurred
Submitted Solution:
```
n=int(input())
words=[str(i) for i in input().split()]
pair=[]
curr=-1
ni=0
np=0
for i in range(len(words)):
if words[i]=='int':
ni+=1
else:
np+=1
if words[-1]!='int' or (ni!=np+1) or (not (ni==np+1 and words[-1]=='int')) or words[0]=='int':
print('Error occurred')
else:
for i in range(len(words)):
if(words[i]=='pair'):
#print('he')
np+=1
pair.append(1)
curr+=1
print('pair<',end='')
elif(words[i]=='int'):
ni+=1
'''if(len(pair)==0 or ni+1==np):
print('Error Occured')
break'''
if(1):
pair[curr]+=1
if(pair[curr]==2):
if(i!=len(words)-1):
print('int,',end='')
else:
print('int>',end='')
elif(pair[curr]==3):
print('int>,',end='')
curr-=1
pair.pop()
```
No
| 64,265 | [
0.583984375,
-0.19384765625,
-0.11224365234375,
-0.0826416015625,
-0.5693359375,
-0.47802734375,
0.1722412109375,
0.299560546875,
-0.0005841255187988281,
0.55810546875,
0.384033203125,
-0.06732177734375,
-0.018951416015625,
-0.5947265625,
-0.367431640625,
0.04736328125,
-0.4323730468... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya used to be an accountant before the war began and he is one of the few who knows how to operate a computer, so he was assigned as the programmer.
We all know that programs often store sets of integers. For example, if we have a problem about a weighted directed graph, its edge can be represented by three integers: the number of the starting vertex, the number of the final vertex and the edge's weight. So, as Vasya was trying to represent characteristics of a recently invented robot in his program, he faced the following problem.
Vasya is not a programmer, so he asked his friend Gena, what the convenient way to store n integers is. Gena used to code in language X-- and so he can use only the types that occur in this language. Let's define, what a "type" is in language X--:
* First, a type is a string "int".
* Second, a type is a string that starts with "pair", then followed by angle brackets listing exactly two comma-separated other types of language X--. This record contains no spaces.
* No other strings can be regarded as types.
More formally: type := int | pair<type,type>. For example, Gena uses the following type for graph edges: pair<int,pair<int,int>>.
Gena was pleased to help Vasya, he dictated to Vasya a type of language X--, that stores n integers. Unfortunately, Gena was in a hurry, so he omitted the punctuation. Now Gena has already left and Vasya can't find the correct punctuation, resulting in a type of language X--, however hard he tries.
Help Vasya and add the punctuation marks so as to receive the valid type of language X--. Otherwise say that the task is impossible to perform.
Input
The first line contains a single integer n (1 ≤ n ≤ 105), showing how many numbers the type dictated by Gena contains.
The second line contains space-separated words, said by Gena. Each of them is either "pair" or "int" (without the quotes).
It is guaranteed that the total number of words does not exceed 105 and that among all the words that Gena said, there are exactly n words "int".
Output
If it is possible to add the punctuation marks so as to get a correct type of language X-- as a result, print a single line that represents the resulting type. Otherwise, print "Error occurred" (without the quotes). Inside the record of a type should not be any extra spaces and other characters.
It is guaranteed that if such type exists, then it is unique.
Note that you should print the type dictated by Gena (if such type exists) and not any type that can contain n values.
Examples
Input
3
pair pair int int int
Output
pair<pair<int,int>,int>
Input
1
pair int
Output
Error occurred
Submitted Solution:
```
n=int(input())
a=list(input().split())
c=[]
c.extend(a)
l=c.count('pair')
r=c.count('int')
if(l==r or l>r):
print('Error occurred')
else:
k=l
m=r
while(l>0 and r>0):
for i in range(k):
print('pair<',end="")
l-=1
for j in range(m):
if(m==r):
print('int,',end="")
r-=1
else:
print('int>',end="")
r-=1
```
No
| 64,266 | [
0.583984375,
-0.19384765625,
-0.11224365234375,
-0.0826416015625,
-0.5693359375,
-0.47802734375,
0.1722412109375,
0.299560546875,
-0.0005841255187988281,
0.55810546875,
0.384033203125,
-0.06732177734375,
-0.018951416015625,
-0.5947265625,
-0.367431640625,
0.04736328125,
-0.4323730468... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya used to be an accountant before the war began and he is one of the few who knows how to operate a computer, so he was assigned as the programmer.
We all know that programs often store sets of integers. For example, if we have a problem about a weighted directed graph, its edge can be represented by three integers: the number of the starting vertex, the number of the final vertex and the edge's weight. So, as Vasya was trying to represent characteristics of a recently invented robot in his program, he faced the following problem.
Vasya is not a programmer, so he asked his friend Gena, what the convenient way to store n integers is. Gena used to code in language X-- and so he can use only the types that occur in this language. Let's define, what a "type" is in language X--:
* First, a type is a string "int".
* Second, a type is a string that starts with "pair", then followed by angle brackets listing exactly two comma-separated other types of language X--. This record contains no spaces.
* No other strings can be regarded as types.
More formally: type := int | pair<type,type>. For example, Gena uses the following type for graph edges: pair<int,pair<int,int>>.
Gena was pleased to help Vasya, he dictated to Vasya a type of language X--, that stores n integers. Unfortunately, Gena was in a hurry, so he omitted the punctuation. Now Gena has already left and Vasya can't find the correct punctuation, resulting in a type of language X--, however hard he tries.
Help Vasya and add the punctuation marks so as to receive the valid type of language X--. Otherwise say that the task is impossible to perform.
Input
The first line contains a single integer n (1 ≤ n ≤ 105), showing how many numbers the type dictated by Gena contains.
The second line contains space-separated words, said by Gena. Each of them is either "pair" or "int" (without the quotes).
It is guaranteed that the total number of words does not exceed 105 and that among all the words that Gena said, there are exactly n words "int".
Output
If it is possible to add the punctuation marks so as to get a correct type of language X-- as a result, print a single line that represents the resulting type. Otherwise, print "Error occurred" (without the quotes). Inside the record of a type should not be any extra spaces and other characters.
It is guaranteed that if such type exists, then it is unique.
Note that you should print the type dictated by Gena (if such type exists) and not any type that can contain n values.
Examples
Input
3
pair pair int int int
Output
pair<pair<int,int>,int>
Input
1
pair int
Output
Error occurred
Submitted Solution:
```
n = int(input())
s = list(input().split())
c = s.count('pair')
co,p,i=0,0,0
if c!=n-1:
print('Error occurred')
elif s[0]=='int' and c>0:
print('Error occurred')
elif s[len(s)-1]=='pair':
print('Error occurred')
else:
for j in range(len(s)):
if s[j]=='pair': p+=1
elif s[j]=='int': i+=1
if i>p+1:
print('Error occurred')
exit()
print(s[0]+'<',end='')
for i in range(1,len(s)-1):
if (s[i-1]=='pair' or s[i-1]=='int') and s[i]=='pair':
print(s[i]+'<',end='')
elif s[i-1]=='pair' and s[i]=='int':
print(s[i]+',',end='')
elif s[i-1]=='int' and s[i]=='int':
print(s[i]+'>,',end='')
co+=1
print(s[len(s)-1]+'>',end='')
print('>'*(n-co-2))
```
No
| 64,267 | [
0.583984375,
-0.19384765625,
-0.11224365234375,
-0.0826416015625,
-0.5693359375,
-0.47802734375,
0.1722412109375,
0.299560546875,
-0.0005841255187988281,
0.55810546875,
0.384033203125,
-0.06732177734375,
-0.018951416015625,
-0.5947265625,
-0.367431640625,
0.04736328125,
-0.4323730468... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya used to be an accountant before the war began and he is one of the few who knows how to operate a computer, so he was assigned as the programmer.
We all know that programs often store sets of integers. For example, if we have a problem about a weighted directed graph, its edge can be represented by three integers: the number of the starting vertex, the number of the final vertex and the edge's weight. So, as Vasya was trying to represent characteristics of a recently invented robot in his program, he faced the following problem.
Vasya is not a programmer, so he asked his friend Gena, what the convenient way to store n integers is. Gena used to code in language X-- and so he can use only the types that occur in this language. Let's define, what a "type" is in language X--:
* First, a type is a string "int".
* Second, a type is a string that starts with "pair", then followed by angle brackets listing exactly two comma-separated other types of language X--. This record contains no spaces.
* No other strings can be regarded as types.
More formally: type := int | pair<type,type>. For example, Gena uses the following type for graph edges: pair<int,pair<int,int>>.
Gena was pleased to help Vasya, he dictated to Vasya a type of language X--, that stores n integers. Unfortunately, Gena was in a hurry, so he omitted the punctuation. Now Gena has already left and Vasya can't find the correct punctuation, resulting in a type of language X--, however hard he tries.
Help Vasya and add the punctuation marks so as to receive the valid type of language X--. Otherwise say that the task is impossible to perform.
Input
The first line contains a single integer n (1 ≤ n ≤ 105), showing how many numbers the type dictated by Gena contains.
The second line contains space-separated words, said by Gena. Each of them is either "pair" or "int" (without the quotes).
It is guaranteed that the total number of words does not exceed 105 and that among all the words that Gena said, there are exactly n words "int".
Output
If it is possible to add the punctuation marks so as to get a correct type of language X-- as a result, print a single line that represents the resulting type. Otherwise, print "Error occurred" (without the quotes). Inside the record of a type should not be any extra spaces and other characters.
It is guaranteed that if such type exists, then it is unique.
Note that you should print the type dictated by Gena (if such type exists) and not any type that can contain n values.
Examples
Input
3
pair pair int int int
Output
pair<pair<int,int>,int>
Input
1
pair int
Output
Error occurred
Submitted Solution:
```
t = int(input())
inp = input()
inp_li = inp.split(" ")
if(len(inp_li) > 1 and inp_li[0] == 'int'):
print("Error occurred")
else:
record = []
record.append(inp_li[0])
curr = 0
for i in range(1,len(inp_li)):
if inp_li[i] == 'pair':
curr +=1
record.append(inp_li[i])
else:
record.append(inp_li[i])
if(len(record)-curr-1) == 2:
record[curr] = record[curr] + '<' + record[curr+1] + ',' + record[curr+2] + '>'
record.pop()
record.pop()
curr-=1
if(len(record)>1):
print("Error occurred")
else:
res = record[0]
li = res.split(',')
if(len(li) == t):
print(res)
else:
print("Error occurred")
```
No
| 64,268 | [
0.583984375,
-0.19384765625,
-0.11224365234375,
-0.0826416015625,
-0.5693359375,
-0.47802734375,
0.1722412109375,
0.299560546875,
-0.0005841255187988281,
0.55810546875,
0.384033203125,
-0.06732177734375,
-0.018951416015625,
-0.5947265625,
-0.367431640625,
0.04736328125,
-0.4323730468... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sereja is a coder and he likes to take part in Codesorfes rounds. However, Uzhland doesn't have good internet connection, so Sereja sometimes skips rounds.
Codesorfes has rounds of two types: Div1 (for advanced coders) and Div2 (for beginner coders). Two rounds, Div1 and Div2, can go simultaneously, (Div1 round cannot be held without Div2) in all other cases the rounds don't overlap in time. Each round has a unique identifier — a positive integer. The rounds are sequentially (without gaps) numbered with identifiers by the starting time of the round. The identifiers of rounds that are run simultaneously are different by one, also the identifier of the Div1 round is always greater.
Sereja is a beginner coder, so he can take part only in rounds of Div2 type. At the moment he is taking part in a Div2 round, its identifier equals to x. Sereja remembers very well that he has taken part in exactly k rounds before this round. Also, he remembers all identifiers of the rounds he has taken part in and all identifiers of the rounds that went simultaneously with them. Sereja doesn't remember anything about the rounds he missed.
Sereja is wondering: what minimum and what maximum number of Div2 rounds could he have missed? Help him find these two numbers.
Input
The first line contains two integers: x (1 ≤ x ≤ 4000) — the round Sereja is taking part in today, and k (0 ≤ k < 4000) — the number of rounds he took part in.
Next k lines contain the descriptions of the rounds that Sereja took part in before. If Sereja took part in one of two simultaneous rounds, the corresponding line looks like: "1 num2 num1" (where num2 is the identifier of this Div2 round, num1 is the identifier of the Div1 round). It is guaranteed that num1 - num2 = 1. If Sereja took part in a usual Div2 round, then the corresponding line looks like: "2 num" (where num is the identifier of this Div2 round). It is guaranteed that the identifiers of all given rounds are less than x.
Output
Print in a single line two integers — the minimum and the maximum number of rounds that Sereja could have missed.
Examples
Input
3 2
2 1
2 2
Output
0 0
Input
9 3
1 2 3
2 8
1 4 5
Output
2 3
Input
10 0
Output
5 9
Note
In the second sample we have unused identifiers of rounds 1, 6, 7. The minimum number of rounds Sereja could have missed equals to 2. In this case, the round with the identifier 1 will be a usual Div2 round and the round with identifier 6 will be synchronous with the Div1 round.
The maximum number of rounds equals 3. In this case all unused identifiers belong to usual Div2 rounds.
Submitted Solution:
```
x, k = map(int, input().split())
a = [0] * x
q = x - 1
for i in range(k):
s = list(map(int, input().split()))
a[s[1] - 1] = 1
if len(s) == 3:
a[s[2] - 1] = 1
q-= len(s) - 1
p = 0
for i in range(x - 1):
if a[i] == 0:
p += 1
if a[i + 1] == 0:
a[i + 1] = 1
print(p, q)
```
Yes
| 64,347 | [
0.341796875,
0.17529296875,
-0.1859130859375,
0.338134765625,
-0.496826171875,
-0.2279052734375,
-0.382568359375,
-0.062347412109375,
0.03643798828125,
1.0966796875,
0.76904296875,
0.2548828125,
-0.0628662109375,
-0.76611328125,
-0.121826171875,
0.327392578125,
-0.71533203125,
-0.6... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sereja is a coder and he likes to take part in Codesorfes rounds. However, Uzhland doesn't have good internet connection, so Sereja sometimes skips rounds.
Codesorfes has rounds of two types: Div1 (for advanced coders) and Div2 (for beginner coders). Two rounds, Div1 and Div2, can go simultaneously, (Div1 round cannot be held without Div2) in all other cases the rounds don't overlap in time. Each round has a unique identifier — a positive integer. The rounds are sequentially (without gaps) numbered with identifiers by the starting time of the round. The identifiers of rounds that are run simultaneously are different by one, also the identifier of the Div1 round is always greater.
Sereja is a beginner coder, so he can take part only in rounds of Div2 type. At the moment he is taking part in a Div2 round, its identifier equals to x. Sereja remembers very well that he has taken part in exactly k rounds before this round. Also, he remembers all identifiers of the rounds he has taken part in and all identifiers of the rounds that went simultaneously with them. Sereja doesn't remember anything about the rounds he missed.
Sereja is wondering: what minimum and what maximum number of Div2 rounds could he have missed? Help him find these two numbers.
Input
The first line contains two integers: x (1 ≤ x ≤ 4000) — the round Sereja is taking part in today, and k (0 ≤ k < 4000) — the number of rounds he took part in.
Next k lines contain the descriptions of the rounds that Sereja took part in before. If Sereja took part in one of two simultaneous rounds, the corresponding line looks like: "1 num2 num1" (where num2 is the identifier of this Div2 round, num1 is the identifier of the Div1 round). It is guaranteed that num1 - num2 = 1. If Sereja took part in a usual Div2 round, then the corresponding line looks like: "2 num" (where num is the identifier of this Div2 round). It is guaranteed that the identifiers of all given rounds are less than x.
Output
Print in a single line two integers — the minimum and the maximum number of rounds that Sereja could have missed.
Examples
Input
3 2
2 1
2 2
Output
0 0
Input
9 3
1 2 3
2 8
1 4 5
Output
2 3
Input
10 0
Output
5 9
Note
In the second sample we have unused identifiers of rounds 1, 6, 7. The minimum number of rounds Sereja could have missed equals to 2. In this case, the round with the identifier 1 will be a usual Div2 round and the round with identifier 6 will be synchronous with the Div1 round.
The maximum number of rounds equals 3. In this case all unused identifiers belong to usual Div2 rounds.
Submitted Solution:
```
def main():
x, k = map(int, input().split())
l1, l2 = [], [0]
for _ in range(k):
tmp = list(map(int, input().split()))
l1.append(tmp[1])
l2.append(tmp[-1])
l1.sort()
l2.sort()
l1.append(x)
mi = ma = 0
for a, b in zip(l1, l2):
x = a - b
mi += x // 2
ma += x - 1
print(mi, ma)
if __name__ == '__main__':
main()
```
Yes
| 64,348 | [
0.341796875,
0.17529296875,
-0.1859130859375,
0.338134765625,
-0.496826171875,
-0.2279052734375,
-0.382568359375,
-0.062347412109375,
0.03643798828125,
1.0966796875,
0.76904296875,
0.2548828125,
-0.0628662109375,
-0.76611328125,
-0.121826171875,
0.327392578125,
-0.71533203125,
-0.6... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sereja is a coder and he likes to take part in Codesorfes rounds. However, Uzhland doesn't have good internet connection, so Sereja sometimes skips rounds.
Codesorfes has rounds of two types: Div1 (for advanced coders) and Div2 (for beginner coders). Two rounds, Div1 and Div2, can go simultaneously, (Div1 round cannot be held without Div2) in all other cases the rounds don't overlap in time. Each round has a unique identifier — a positive integer. The rounds are sequentially (without gaps) numbered with identifiers by the starting time of the round. The identifiers of rounds that are run simultaneously are different by one, also the identifier of the Div1 round is always greater.
Sereja is a beginner coder, so he can take part only in rounds of Div2 type. At the moment he is taking part in a Div2 round, its identifier equals to x. Sereja remembers very well that he has taken part in exactly k rounds before this round. Also, he remembers all identifiers of the rounds he has taken part in and all identifiers of the rounds that went simultaneously with them. Sereja doesn't remember anything about the rounds he missed.
Sereja is wondering: what minimum and what maximum number of Div2 rounds could he have missed? Help him find these two numbers.
Input
The first line contains two integers: x (1 ≤ x ≤ 4000) — the round Sereja is taking part in today, and k (0 ≤ k < 4000) — the number of rounds he took part in.
Next k lines contain the descriptions of the rounds that Sereja took part in before. If Sereja took part in one of two simultaneous rounds, the corresponding line looks like: "1 num2 num1" (where num2 is the identifier of this Div2 round, num1 is the identifier of the Div1 round). It is guaranteed that num1 - num2 = 1. If Sereja took part in a usual Div2 round, then the corresponding line looks like: "2 num" (where num is the identifier of this Div2 round). It is guaranteed that the identifiers of all given rounds are less than x.
Output
Print in a single line two integers — the minimum and the maximum number of rounds that Sereja could have missed.
Examples
Input
3 2
2 1
2 2
Output
0 0
Input
9 3
1 2 3
2 8
1 4 5
Output
2 3
Input
10 0
Output
5 9
Note
In the second sample we have unused identifiers of rounds 1, 6, 7. The minimum number of rounds Sereja could have missed equals to 2. In this case, the round with the identifier 1 will be a usual Div2 round and the round with identifier 6 will be synchronous with the Div1 round.
The maximum number of rounds equals 3. In this case all unused identifiers belong to usual Div2 rounds.
Submitted Solution:
```
I = lambda: map(int, input().split())
x, k = I()
R = [0, x]
for _ in range(k):
_, *r = I()
R += r
R.sort()
max_ = min_ = 0
for i in range(len(R)-1):
min_ += (R[i+1]-R[i]) // 2
max_ += R[i+1]-R[i]-1
print(min_, max_)
```
Yes
| 64,349 | [
0.341796875,
0.17529296875,
-0.1859130859375,
0.338134765625,
-0.496826171875,
-0.2279052734375,
-0.382568359375,
-0.062347412109375,
0.03643798828125,
1.0966796875,
0.76904296875,
0.2548828125,
-0.0628662109375,
-0.76611328125,
-0.121826171875,
0.327392578125,
-0.71533203125,
-0.6... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sereja is a coder and he likes to take part in Codesorfes rounds. However, Uzhland doesn't have good internet connection, so Sereja sometimes skips rounds.
Codesorfes has rounds of two types: Div1 (for advanced coders) and Div2 (for beginner coders). Two rounds, Div1 and Div2, can go simultaneously, (Div1 round cannot be held without Div2) in all other cases the rounds don't overlap in time. Each round has a unique identifier — a positive integer. The rounds are sequentially (without gaps) numbered with identifiers by the starting time of the round. The identifiers of rounds that are run simultaneously are different by one, also the identifier of the Div1 round is always greater.
Sereja is a beginner coder, so he can take part only in rounds of Div2 type. At the moment he is taking part in a Div2 round, its identifier equals to x. Sereja remembers very well that he has taken part in exactly k rounds before this round. Also, he remembers all identifiers of the rounds he has taken part in and all identifiers of the rounds that went simultaneously with them. Sereja doesn't remember anything about the rounds he missed.
Sereja is wondering: what minimum and what maximum number of Div2 rounds could he have missed? Help him find these two numbers.
Input
The first line contains two integers: x (1 ≤ x ≤ 4000) — the round Sereja is taking part in today, and k (0 ≤ k < 4000) — the number of rounds he took part in.
Next k lines contain the descriptions of the rounds that Sereja took part in before. If Sereja took part in one of two simultaneous rounds, the corresponding line looks like: "1 num2 num1" (where num2 is the identifier of this Div2 round, num1 is the identifier of the Div1 round). It is guaranteed that num1 - num2 = 1. If Sereja took part in a usual Div2 round, then the corresponding line looks like: "2 num" (where num is the identifier of this Div2 round). It is guaranteed that the identifiers of all given rounds are less than x.
Output
Print in a single line two integers — the minimum and the maximum number of rounds that Sereja could have missed.
Examples
Input
3 2
2 1
2 2
Output
0 0
Input
9 3
1 2 3
2 8
1 4 5
Output
2 3
Input
10 0
Output
5 9
Note
In the second sample we have unused identifiers of rounds 1, 6, 7. The minimum number of rounds Sereja could have missed equals to 2. In this case, the round with the identifier 1 will be a usual Div2 round and the round with identifier 6 will be synchronous with the Div1 round.
The maximum number of rounds equals 3. In this case all unused identifiers belong to usual Div2 rounds.
Submitted Solution:
```
#! /usr/bin/env python3.3
x, k=map(int, input().split())
a=[False]*x
for i in range(k):
o=list(map(int, input().split()))
a[o[1]]=True
if o[0]==1: a[o[2]]=True
cnt1=cnt2=d=0
for i in range(1,x):
if a[i]:
d=0
else:
d^=1
cnt1+=d
cnt2+=1
print(cnt1, cnt2)
```
Yes
| 64,350 | [
0.341796875,
0.17529296875,
-0.1859130859375,
0.338134765625,
-0.496826171875,
-0.2279052734375,
-0.382568359375,
-0.062347412109375,
0.03643798828125,
1.0966796875,
0.76904296875,
0.2548828125,
-0.0628662109375,
-0.76611328125,
-0.121826171875,
0.327392578125,
-0.71533203125,
-0.6... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sereja is a coder and he likes to take part in Codesorfes rounds. However, Uzhland doesn't have good internet connection, so Sereja sometimes skips rounds.
Codesorfes has rounds of two types: Div1 (for advanced coders) and Div2 (for beginner coders). Two rounds, Div1 and Div2, can go simultaneously, (Div1 round cannot be held without Div2) in all other cases the rounds don't overlap in time. Each round has a unique identifier — a positive integer. The rounds are sequentially (without gaps) numbered with identifiers by the starting time of the round. The identifiers of rounds that are run simultaneously are different by one, also the identifier of the Div1 round is always greater.
Sereja is a beginner coder, so he can take part only in rounds of Div2 type. At the moment he is taking part in a Div2 round, its identifier equals to x. Sereja remembers very well that he has taken part in exactly k rounds before this round. Also, he remembers all identifiers of the rounds he has taken part in and all identifiers of the rounds that went simultaneously with them. Sereja doesn't remember anything about the rounds he missed.
Sereja is wondering: what minimum and what maximum number of Div2 rounds could he have missed? Help him find these two numbers.
Input
The first line contains two integers: x (1 ≤ x ≤ 4000) — the round Sereja is taking part in today, and k (0 ≤ k < 4000) — the number of rounds he took part in.
Next k lines contain the descriptions of the rounds that Sereja took part in before. If Sereja took part in one of two simultaneous rounds, the corresponding line looks like: "1 num2 num1" (where num2 is the identifier of this Div2 round, num1 is the identifier of the Div1 round). It is guaranteed that num1 - num2 = 1. If Sereja took part in a usual Div2 round, then the corresponding line looks like: "2 num" (where num is the identifier of this Div2 round). It is guaranteed that the identifiers of all given rounds are less than x.
Output
Print in a single line two integers — the minimum and the maximum number of rounds that Sereja could have missed.
Examples
Input
3 2
2 1
2 2
Output
0 0
Input
9 3
1 2 3
2 8
1 4 5
Output
2 3
Input
10 0
Output
5 9
Note
In the second sample we have unused identifiers of rounds 1, 6, 7. The minimum number of rounds Sereja could have missed equals to 2. In this case, the round with the identifier 1 will be a usual Div2 round and the round with identifier 6 will be synchronous with the Div1 round.
The maximum number of rounds equals 3. In this case all unused identifiers belong to usual Div2 rounds.
Submitted Solution:
```
n,k=list(map(int,input().split()))
f=[0]*n
f[n-1]=1
for _ in range(k):
w=input().split()
if(w[0]=='1'):
f[int(w[1])-1]=1
f[int(w[2])-1]=1
else:
f[int(w[1])-1]=1
cnt=0
nu=[]
for i in range(n):
if(f[i]==0):
cnt+=1
else:
nu.append(cnt)
cnt=1
nu.append(cnt)
#print((nu))
c=0
for i in range(len(nu)):
if(nu[i]>1):
c+=(nu[i]-nu[i]%2)//2
#print(c)
c+=nu[i]%2
print(c,f.count(0))
```
No
| 64,351 | [
0.341796875,
0.17529296875,
-0.1859130859375,
0.338134765625,
-0.496826171875,
-0.2279052734375,
-0.382568359375,
-0.062347412109375,
0.03643798828125,
1.0966796875,
0.76904296875,
0.2548828125,
-0.0628662109375,
-0.76611328125,
-0.121826171875,
0.327392578125,
-0.71533203125,
-0.6... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sereja is a coder and he likes to take part in Codesorfes rounds. However, Uzhland doesn't have good internet connection, so Sereja sometimes skips rounds.
Codesorfes has rounds of two types: Div1 (for advanced coders) and Div2 (for beginner coders). Two rounds, Div1 and Div2, can go simultaneously, (Div1 round cannot be held without Div2) in all other cases the rounds don't overlap in time. Each round has a unique identifier — a positive integer. The rounds are sequentially (without gaps) numbered with identifiers by the starting time of the round. The identifiers of rounds that are run simultaneously are different by one, also the identifier of the Div1 round is always greater.
Sereja is a beginner coder, so he can take part only in rounds of Div2 type. At the moment he is taking part in a Div2 round, its identifier equals to x. Sereja remembers very well that he has taken part in exactly k rounds before this round. Also, he remembers all identifiers of the rounds he has taken part in and all identifiers of the rounds that went simultaneously with them. Sereja doesn't remember anything about the rounds he missed.
Sereja is wondering: what minimum and what maximum number of Div2 rounds could he have missed? Help him find these two numbers.
Input
The first line contains two integers: x (1 ≤ x ≤ 4000) — the round Sereja is taking part in today, and k (0 ≤ k < 4000) — the number of rounds he took part in.
Next k lines contain the descriptions of the rounds that Sereja took part in before. If Sereja took part in one of two simultaneous rounds, the corresponding line looks like: "1 num2 num1" (where num2 is the identifier of this Div2 round, num1 is the identifier of the Div1 round). It is guaranteed that num1 - num2 = 1. If Sereja took part in a usual Div2 round, then the corresponding line looks like: "2 num" (where num is the identifier of this Div2 round). It is guaranteed that the identifiers of all given rounds are less than x.
Output
Print in a single line two integers — the minimum and the maximum number of rounds that Sereja could have missed.
Examples
Input
3 2
2 1
2 2
Output
0 0
Input
9 3
1 2 3
2 8
1 4 5
Output
2 3
Input
10 0
Output
5 9
Note
In the second sample we have unused identifiers of rounds 1, 6, 7. The minimum number of rounds Sereja could have missed equals to 2. In this case, the round with the identifier 1 will be a usual Div2 round and the round with identifier 6 will be synchronous with the Div1 round.
The maximum number of rounds equals 3. In this case all unused identifiers belong to usual Div2 rounds.
Submitted Solution:
```
import math
x,k=map(int,input().split())
a=[0]*x
for i in range(k):
c=list(map(int,input().split()))
if(len(c)==2):
a[c[1]]=1
else:
a[c[1]] = 1
a[c[2]] = 1
max=0
min=0
for i in range(x):
if a[i]==0:
max+=1
max-=1
min=max
print(a)
i=1
while i<(x-1):
if a[i]==0 and a[i+1]==0:
min-=1
i+=1
i+=1
print(min,max)
```
No
| 64,352 | [
0.341796875,
0.17529296875,
-0.1859130859375,
0.338134765625,
-0.496826171875,
-0.2279052734375,
-0.382568359375,
-0.062347412109375,
0.03643798828125,
1.0966796875,
0.76904296875,
0.2548828125,
-0.0628662109375,
-0.76611328125,
-0.121826171875,
0.327392578125,
-0.71533203125,
-0.6... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sereja is a coder and he likes to take part in Codesorfes rounds. However, Uzhland doesn't have good internet connection, so Sereja sometimes skips rounds.
Codesorfes has rounds of two types: Div1 (for advanced coders) and Div2 (for beginner coders). Two rounds, Div1 and Div2, can go simultaneously, (Div1 round cannot be held without Div2) in all other cases the rounds don't overlap in time. Each round has a unique identifier — a positive integer. The rounds are sequentially (without gaps) numbered with identifiers by the starting time of the round. The identifiers of rounds that are run simultaneously are different by one, also the identifier of the Div1 round is always greater.
Sereja is a beginner coder, so he can take part only in rounds of Div2 type. At the moment he is taking part in a Div2 round, its identifier equals to x. Sereja remembers very well that he has taken part in exactly k rounds before this round. Also, he remembers all identifiers of the rounds he has taken part in and all identifiers of the rounds that went simultaneously with them. Sereja doesn't remember anything about the rounds he missed.
Sereja is wondering: what minimum and what maximum number of Div2 rounds could he have missed? Help him find these two numbers.
Input
The first line contains two integers: x (1 ≤ x ≤ 4000) — the round Sereja is taking part in today, and k (0 ≤ k < 4000) — the number of rounds he took part in.
Next k lines contain the descriptions of the rounds that Sereja took part in before. If Sereja took part in one of two simultaneous rounds, the corresponding line looks like: "1 num2 num1" (where num2 is the identifier of this Div2 round, num1 is the identifier of the Div1 round). It is guaranteed that num1 - num2 = 1. If Sereja took part in a usual Div2 round, then the corresponding line looks like: "2 num" (where num is the identifier of this Div2 round). It is guaranteed that the identifiers of all given rounds are less than x.
Output
Print in a single line two integers — the minimum and the maximum number of rounds that Sereja could have missed.
Examples
Input
3 2
2 1
2 2
Output
0 0
Input
9 3
1 2 3
2 8
1 4 5
Output
2 3
Input
10 0
Output
5 9
Note
In the second sample we have unused identifiers of rounds 1, 6, 7. The minimum number of rounds Sereja could have missed equals to 2. In this case, the round with the identifier 1 will be a usual Div2 round and the round with identifier 6 will be synchronous with the Div1 round.
The maximum number of rounds equals 3. In this case all unused identifiers belong to usual Div2 rounds.
Submitted Solution:
```
import math
x,k=map(int,input().split())
a=[0]*x
for i in range(k):
c=list(map(int,input().split()))
if(len(c)==2):
a[c[1]]=1
else:
a[c[1]] = 1
a[c[2]] = 1
count=0
for i in range(x):
if a[i]==0:
count+=1
print(math.ceil((count-1)/2),count-1)
```
No
| 64,353 | [
0.341796875,
0.17529296875,
-0.1859130859375,
0.338134765625,
-0.496826171875,
-0.2279052734375,
-0.382568359375,
-0.062347412109375,
0.03643798828125,
1.0966796875,
0.76904296875,
0.2548828125,
-0.0628662109375,
-0.76611328125,
-0.121826171875,
0.327392578125,
-0.71533203125,
-0.6... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sereja is a coder and he likes to take part in Codesorfes rounds. However, Uzhland doesn't have good internet connection, so Sereja sometimes skips rounds.
Codesorfes has rounds of two types: Div1 (for advanced coders) and Div2 (for beginner coders). Two rounds, Div1 and Div2, can go simultaneously, (Div1 round cannot be held without Div2) in all other cases the rounds don't overlap in time. Each round has a unique identifier — a positive integer. The rounds are sequentially (without gaps) numbered with identifiers by the starting time of the round. The identifiers of rounds that are run simultaneously are different by one, also the identifier of the Div1 round is always greater.
Sereja is a beginner coder, so he can take part only in rounds of Div2 type. At the moment he is taking part in a Div2 round, its identifier equals to x. Sereja remembers very well that he has taken part in exactly k rounds before this round. Also, he remembers all identifiers of the rounds he has taken part in and all identifiers of the rounds that went simultaneously with them. Sereja doesn't remember anything about the rounds he missed.
Sereja is wondering: what minimum and what maximum number of Div2 rounds could he have missed? Help him find these two numbers.
Input
The first line contains two integers: x (1 ≤ x ≤ 4000) — the round Sereja is taking part in today, and k (0 ≤ k < 4000) — the number of rounds he took part in.
Next k lines contain the descriptions of the rounds that Sereja took part in before. If Sereja took part in one of two simultaneous rounds, the corresponding line looks like: "1 num2 num1" (where num2 is the identifier of this Div2 round, num1 is the identifier of the Div1 round). It is guaranteed that num1 - num2 = 1. If Sereja took part in a usual Div2 round, then the corresponding line looks like: "2 num" (where num is the identifier of this Div2 round). It is guaranteed that the identifiers of all given rounds are less than x.
Output
Print in a single line two integers — the minimum and the maximum number of rounds that Sereja could have missed.
Examples
Input
3 2
2 1
2 2
Output
0 0
Input
9 3
1 2 3
2 8
1 4 5
Output
2 3
Input
10 0
Output
5 9
Note
In the second sample we have unused identifiers of rounds 1, 6, 7. The minimum number of rounds Sereja could have missed equals to 2. In this case, the round with the identifier 1 will be a usual Div2 round and the round with identifier 6 will be synchronous with the Div1 round.
The maximum number of rounds equals 3. In this case all unused identifiers belong to usual Div2 rounds.
Submitted Solution:
```
x, k = map(int, input().split())
v = [0]*(x+1)
v[0] = 1
v[x] += 1
for i in range(k):
p = [int(i) for i in input().split()]
v[p[1]]+=1
if p[0] == 1:
v[p[2]]+=1
mini, maxi = 10e4,-10e4
flag = False
for i in range(x):
if v[i] == 0:
maxi+=1
if v[i+1] == 0 and not flag:
mini += 1
flag = True
else:
flag = False
print(maxi-mini, maxi)
```
No
| 64,354 | [
0.341796875,
0.17529296875,
-0.1859130859375,
0.338134765625,
-0.496826171875,
-0.2279052734375,
-0.382568359375,
-0.062347412109375,
0.03643798828125,
1.0966796875,
0.76904296875,
0.2548828125,
-0.0628662109375,
-0.76611328125,
-0.121826171875,
0.327392578125,
-0.71533203125,
-0.6... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Iahub and Iahubina went to a picnic in a forest full of trees. Less than 5 minutes passed before Iahub remembered of trees from programming. Moreover, he invented a new problem and Iahubina has to solve it, otherwise Iahub won't give her the food.
Iahub asks Iahubina: can you build a rooted tree, such that
* each internal node (a node with at least one son) has at least two sons;
* node i has ci nodes in its subtree?
Iahubina has to guess the tree. Being a smart girl, she realized that it's possible no tree can follow Iahub's restrictions. In this way, Iahub will eat all the food. You need to help Iahubina: determine if there's at least one tree following Iahub's restrictions. The required tree must contain n nodes.
Input
The first line of the input contains integer n (1 ≤ n ≤ 24). Next line contains n positive integers: the i-th number represents ci (1 ≤ ci ≤ n).
Output
Output on the first line "YES" (without quotes) if there exist at least one tree following Iahub's restrictions, otherwise output "NO" (without quotes).
Examples
Input
4
1 1 1 4
Output
YES
Input
5
1 1 5 2 1
Output
NO
Submitted Solution:
```
def DFS(x):
for i in range(x):
if(Seen[i]):
continue
if(Rem[i]>=C[x]):
Rem[i]-=C[x]
Parent[x]=i
Children[i].append(x)
return True
for i in range(x):
if(Seen[i]):
continue
Y=[]
Seen[i]=True
for j in range(len(Children[i])):
child=Children[i][j]
Parent[child]=-1
Rem[i]+=C[child]
if(DFS(child)):
continue
Parent[child]=i
Rem[i]-=C[child]
Y.append(child)
Seen[i]=False
Children[i]=list(Y)
if(Rem[i]>=C[x]):
Rem[i]-=C[x]
Children[i].append(x)
Parent[x]=i
return True
return False
n=int(input())
C=list(map(int,input().split()))
Rem=[-1]*n
Parent=[-1]*n
Children=[]
Seen=[False]*n
C.sort(reverse=True)
if(C[0]!=n or C.count(2)>0):
print("NO")
else:
for i in range(n):
Rem[i]=C[i]-1
Children.append([])
Parent[0]=0
Ans="YES"
for i in range(1,n):
if(DFS(i)==False):
Ans="NO"
break
for i in range(n):
if(Rem[i]!=0 and C[i]!=1):
Ans="NO"
break
print(Ans)
```
No
| 64,358 | [
0.388427734375,
0.268798828125,
-0.03472900390625,
-0.179931640625,
-0.1998291015625,
0.021575927734375,
-0.38330078125,
0.73388671875,
0.439697265625,
0.75341796875,
0.496826171875,
-0.11932373046875,
0.29345703125,
-0.638671875,
-0.442626953125,
0.0146331787109375,
-0.48583984375,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Iahub and Iahubina went to a picnic in a forest full of trees. Less than 5 minutes passed before Iahub remembered of trees from programming. Moreover, he invented a new problem and Iahubina has to solve it, otherwise Iahub won't give her the food.
Iahub asks Iahubina: can you build a rooted tree, such that
* each internal node (a node with at least one son) has at least two sons;
* node i has ci nodes in its subtree?
Iahubina has to guess the tree. Being a smart girl, she realized that it's possible no tree can follow Iahub's restrictions. In this way, Iahub will eat all the food. You need to help Iahubina: determine if there's at least one tree following Iahub's restrictions. The required tree must contain n nodes.
Input
The first line of the input contains integer n (1 ≤ n ≤ 24). Next line contains n positive integers: the i-th number represents ci (1 ≤ ci ≤ n).
Output
Output on the first line "YES" (without quotes) if there exist at least one tree following Iahub's restrictions, otherwise output "NO" (without quotes).
Examples
Input
4
1 1 1 4
Output
YES
Input
5
1 1 5 2 1
Output
NO
Submitted Solution:
```
def DFS(x):
for i in range(x):
if(Seen[i]):
continue
if(Rem[i]>=C[x]):
if(Rem[i]==C[x] and len(Children[i])==0):
continue
Rem[i]-=C[x]
Parent[x]=i
Children[i].append(x)
return True
for i in range(x):
if(Seen[i]):
continue
Y=[]
Seen[i]=True
for j in range(len(Children[i])):
child=Children[i][j]
Parent[child]=-1
Rem[i]+=C[child]
if(DFS(child)):
continue
Parent[child]=i
Rem[i]-=C[child]
Y.append(child)
Seen[i]=False
Children[i]=list(Y)
if(Rem[i]>=C[x]):
if(Rem[i]==C[x] and len(Children[i])==0):
continue
Rem[i]-=C[x]
Children[i].append(x)
Parent[x]=i
return True
return False
n=int(input())
C=list(map(int,input().split()))
Rem=[-1]*n
Parent=[-1]*n
Children=[]
Seen=[False]*n
C.sort(reverse=True)
if(C[0]!=n or C.count(2)>0):
print("NO")
else:
for i in range(n):
Rem[i]=C[i]-1
Children.append([])
Parent[0]=0
Ans="YES"
for i in range(1,n):
if(DFS(i)==False):
Ans="NO"
break
for i in range(n):
if(Rem[i]!=0 and C[i]!=1):
Ans="NO"
break
print(Ans)
```
No
| 64,359 | [
0.401611328125,
0.27392578125,
-0.05194091796875,
-0.16162109375,
-0.189208984375,
0.0271148681640625,
-0.374755859375,
0.7490234375,
0.420166015625,
0.7529296875,
0.489501953125,
-0.110107421875,
0.281982421875,
-0.63818359375,
-0.432861328125,
0.0279998779296875,
-0.487060546875,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a simple way to create hard tasks: take one simple problem as the query, and try to find an algorithm that can solve it faster than bruteforce. This kind of tasks usually appears in OI contest, and usually involves data structures.
Let's try to create a task, for example, we take the "Hamming distance problem": for two binary strings s and t with the same length, the Hamming distance between them is the number of positions at which the corresponding symbols are different. For example, the Hamming distance between "00111" and "10101" is 2 (the different symbols are marked with bold).
We use the Hamming distance problem as a query in the following way: you are given two strings a and b and several queries. Each query will be: what is the Hamming distance between two strings ap1ap1 + 1...ap1 + len - 1 and bp2bp2 + 1...bp2 + len - 1?
Note, that in this problem the strings are zero-based, that is s = s0s1... s|s| - 1.
Input
The first line contains a string a (1 ≤ |a| ≤ 200000). The second line contains a string b (1 ≤ |b| ≤ 200000). Each character of both strings is either "0" or "1".
The third line contains an integer q (1 ≤ q ≤ 400000) — the number of queries. Each of the following q lines contains three integers: p1, p2 and len (0 ≤ p1 ≤ |a| - len; 0 ≤ p2 ≤ |b| - len), these numbers denote the parameters of the current query.
Output
Output q integers — the answers for the queries.
Examples
Input
101010
11110000
3
0 0 3
2 3 4
5 7 1
Output
1
1
0
Input
10001010101011001010100101010011010
101010100101001010100100101010
5
0 0 12
3 9 7
6 4 15
12 15 10
13 3 20
Output
5
4
3
5
13
Submitted Solution:
```
string1 = input()
string2 = input()
q = input()
q = int(q)
while q > 0:
c = input()
c = c.split(' ')
start1 = int(c[0])
start2 = int(c[1])
length = int(c[2])
n = int(string1[start1: start1 + length]) ^ int(string2[start2: start2 + length])
print(bin(n).count('1'))
q -= 1
```
No
| 64,376 | [
0.34521484375,
-0.1727294921875,
-0.06805419921875,
0.09619140625,
-0.6005859375,
-0.4052734375,
0.097412109375,
-0.04217529296875,
-0.01065826416015625,
0.9345703125,
0.44140625,
0.11077880859375,
-0.275390625,
-0.76708984375,
-0.322509765625,
-0.209228515625,
-0.2421875,
-0.53710... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.
First, each actor has a certain voice range and there are some parts that he cannot sing. Formally, there are two integers for each actor, ci and di (ci ≤ di) — the pitch of the lowest and the highest note that the actor can sing. There also are two integers for each part — aj and bj (aj ≤ bj) — the pitch of the lowest and the highest notes that are present in the part. The i-th actor can perform the j-th part if and only if ci ≤ aj ≤ bj ≤ di, i.e. each note of the part is in the actor's voice range.
According to the contract, the i-th actor can perform at most ki parts. Besides, you are allowed not to give any part to some actors (then they take part in crowd scenes).
The rehearsal starts in two hours and you need to do the assignment quickly!
Input
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105).
Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109).
The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105).
Next m lines contain three space-separated integers each, ci, di and ki — the range of the i-th actor and the number of parts that he can perform (1 ≤ ci ≤ di ≤ 109, 1 ≤ ki ≤ 109).
Output
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line.
In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of them.
If there is no correct assignment, print a single word "NO" (without the quotes).
Examples
Input
3
1 3
2 4
3 5
2
1 4 2
2 5 1
Output
YES
1 1 2
Input
3
1 3
2 4
3 5
2
1 3 2
2 5 1
Output
NO
Submitted Solution:
```
from itertools import *
def main(n,m,a,b,c,d,k, info=False):
if info:
print(n,m)
print(a,b,c,d,k)
global p,s, parts, singers
p = parts = [list(x) for x in sorted(zip(a,b,range(n),[0]*n))]
s = singers = [list (x) for x in sorted(zip(c,d,k,range(m)))]
for j,p in enumerate(parts):
s = dropwhile(lambda x: x[1]<=p[0], singers)
s = list(takewhile(lambda x: x[0]<=p[0], s))
mn,ind = 1e9, -1
for i,x in enumerate(s):
if x[1]>=p[1] and x[2]>0 and x[1]<mn:
mn = x[1]
ind = i
if s == [] or ind == -1:
print("NO")
return
singers[s[ind][3]][2] -= 1 # reduce number of parts
parts[j][3] = s[ind][3]+1
print("YES")
print(*[p[3] for p in parts])
def main_input():
global a,b,c,d,k,n,m
n = int(input())
a, b = [0]*n, [0]*n
for i in range(n):
a[i], b[i] = [int(x) for x in input().split()]
m = int(input())
c,d,k = [0]*m, [0]*m, [0]*m
for i in range(m):
c[i], d[i], k[i] = [int(x) for x in input().split()]
main(n,m,a,b,c,d,k)
if __name__ == "__main__":
main_input()
```
No
| 64,377 | [
0.204345703125,
-0.0787353515625,
-0.24658203125,
-0.25927734375,
-0.42626953125,
-0.310302734375,
0.06182861328125,
-0.1353759765625,
0.187255859375,
0.86962890625,
0.603515625,
-0.2347412109375,
0.41259765625,
-1.0439453125,
-0.395263671875,
0.37841796875,
-0.76513671875,
-0.7124... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.
First, each actor has a certain voice range and there are some parts that he cannot sing. Formally, there are two integers for each actor, ci and di (ci ≤ di) — the pitch of the lowest and the highest note that the actor can sing. There also are two integers for each part — aj and bj (aj ≤ bj) — the pitch of the lowest and the highest notes that are present in the part. The i-th actor can perform the j-th part if and only if ci ≤ aj ≤ bj ≤ di, i.e. each note of the part is in the actor's voice range.
According to the contract, the i-th actor can perform at most ki parts. Besides, you are allowed not to give any part to some actors (then they take part in crowd scenes).
The rehearsal starts in two hours and you need to do the assignment quickly!
Input
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105).
Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109).
The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105).
Next m lines contain three space-separated integers each, ci, di and ki — the range of the i-th actor and the number of parts that he can perform (1 ≤ ci ≤ di ≤ 109, 1 ≤ ki ≤ 109).
Output
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line.
In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of them.
If there is no correct assignment, print a single word "NO" (without the quotes).
Examples
Input
3
1 3
2 4
3 5
2
1 4 2
2 5 1
Output
YES
1 1 2
Input
3
1 3
2 4
3 5
2
1 3 2
2 5 1
Output
NO
Submitted Solution:
```
n = int(input())
a = []
b = []
for i in range(n):
l,r = map(int,input().split())
a.append([l,r,i])
m = int(input())
for i in range(m):
l,r,x = map(int,input().split())
b.append([l,r,x,i])
a.sort()
b.sort()
f = 0
c2 = 0
c = [0] * (n)
for i in range(len(a)):
c1 = 0
for j in range(len(b)):
if ((a[i][0] >= b[j][0]) and (a[i][1] <= b[j][1]) and (b[j][2] != 0)):
b[j][2] = b[j][2] - 1
c1 = -1
f = b[j][3]
break
if (c1 != -1):
print('NO')
c2 = -1
break
else:
c[i] = [a[i][2],f + 1]
if (c2 != -1):
c.sort()
print('YES')
for i in range(len(c)):
print(c[i][1],end = ' ')
```
No
| 64,378 | [
0.204345703125,
-0.0787353515625,
-0.24658203125,
-0.25927734375,
-0.42626953125,
-0.310302734375,
0.06182861328125,
-0.1353759765625,
0.187255859375,
0.86962890625,
0.603515625,
-0.2347412109375,
0.41259765625,
-1.0439453125,
-0.395263671875,
0.37841796875,
-0.76513671875,
-0.7124... | 11 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.