message stringlengths 2 20.2k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 757 108k | cluster float64 4 4 | __index_level_0__ int64 1.51k 217k |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In order to pass the entrance examination tomorrow, Taro has to study for T more hours.
Fortunately, he can leap to World B where time passes X times as fast as it does in our world (World A).
While (X \times t) hours pass in World B, t hours pass in World A.
How many hours will pass in World A while Taro studies for T hours in World B?
Constraints
* All values in input are integers.
* 1 \leq T \leq 100
* 1 \leq X \leq 100
Input
Input is given from Standard Input in the following format:
T X
Output
Print the number of hours that will pass in World A.
The output will be regarded as correct when its absolute or relative error from the judge's output is at most 10^{-3}.
Examples
Input
8 3
Output
2.6666666667
Input
99 1
Output
99.0000000000
Input
1 100
Output
0.0100000000
Submitted Solution:
```
a,b=map(int, input().split())
print(a/b)
``` | instruction | 0 | 32,314 | 4 | 64,628 |
Yes | output | 1 | 32,314 | 4 | 64,629 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In order to pass the entrance examination tomorrow, Taro has to study for T more hours.
Fortunately, he can leap to World B where time passes X times as fast as it does in our world (World A).
While (X \times t) hours pass in World B, t hours pass in World A.
How many hours will pass in World A while Taro studies for T hours in World B?
Constraints
* All values in input are integers.
* 1 \leq T \leq 100
* 1 \leq X \leq 100
Input
Input is given from Standard Input in the following format:
T X
Output
Print the number of hours that will pass in World A.
The output will be regarded as correct when its absolute or relative error from the judge's output is at most 10^{-3}.
Examples
Input
8 3
Output
2.6666666667
Input
99 1
Output
99.0000000000
Input
1 100
Output
0.0100000000
Submitted Solution:
```
n = int(input())
ls = [int(i) for i in input().split()]
if max(ls) < sum(ls) - max(ls):
print("Yes")
else:
print("No")
``` | instruction | 0 | 32,315 | 4 | 64,630 |
No | output | 1 | 32,315 | 4 | 64,631 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In order to pass the entrance examination tomorrow, Taro has to study for T more hours.
Fortunately, he can leap to World B where time passes X times as fast as it does in our world (World A).
While (X \times t) hours pass in World B, t hours pass in World A.
How many hours will pass in World A while Taro studies for T hours in World B?
Constraints
* All values in input are integers.
* 1 \leq T \leq 100
* 1 \leq X \leq 100
Input
Input is given from Standard Input in the following format:
T X
Output
Print the number of hours that will pass in World A.
The output will be regarded as correct when its absolute or relative error from the judge's output is at most 10^{-3}.
Examples
Input
8 3
Output
2.6666666667
Input
99 1
Output
99.0000000000
Input
1 100
Output
0.0100000000
Submitted Solution:
```
T = int(input())
X = int(input())
t = float(T)
x = float(X)
k = t/x
print(k)
``` | instruction | 0 | 32,316 | 4 | 64,632 |
No | output | 1 | 32,316 | 4 | 64,633 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In order to pass the entrance examination tomorrow, Taro has to study for T more hours.
Fortunately, he can leap to World B where time passes X times as fast as it does in our world (World A).
While (X \times t) hours pass in World B, t hours pass in World A.
How many hours will pass in World A while Taro studies for T hours in World B?
Constraints
* All values in input are integers.
* 1 \leq T \leq 100
* 1 \leq X \leq 100
Input
Input is given from Standard Input in the following format:
T X
Output
Print the number of hours that will pass in World A.
The output will be regarded as correct when its absolute or relative error from the judge's output is at most 10^{-3}.
Examples
Input
8 3
Output
2.6666666667
Input
99 1
Output
99.0000000000
Input
1 100
Output
0.0100000000
Submitted Solution:
```
N, M = map(int, input().split())
X = list(map(int, input().split()))
ans = 0
diff = []
X.sort()
for i in range(M-1):
dif = X[i+1] -X[i]
diff.append(dif)
diff.sort()
for n in range(N):
diff.pop(-1)
for i in range(len(diff)):
ans += diff[i]
print(ans)
``` | instruction | 0 | 32,317 | 4 | 64,634 |
No | output | 1 | 32,317 | 4 | 64,635 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us denote bad days as 0 and good days as 1. Then, for example, sequences of days 0, 010, 01010 are zebras, while sequences 1, 0110, 0101 are not.
Oleg tells you the story of days he lived in chronological order in form of string consisting of 0 and 1. Now you are interested if it is possible to divide Oleg's life history into several subsequences, each of which is a zebra, and the way it can be done. Each day must belong to exactly one of the subsequences. For each of the subsequences, days forming it must be ordered chronologically. Note that subsequence does not have to be a group of consecutive days.
Input
In the only line of input data there is a non-empty string s consisting of characters 0 and 1, which describes the history of Oleg's life. Its length (denoted as |s|) does not exceed 200 000 characters.
Output
If there is a way to divide history into zebra subsequences, in the first line of output you should print an integer k (1 ≤ k ≤ |s|), the resulting number of subsequences. In the i-th of following k lines first print the integer li (1 ≤ li ≤ |s|), which is the length of the i-th subsequence, and then li indices of days forming the subsequence. Indices must follow in ascending order. Days are numbered starting from 1. Each index from 1 to n must belong to exactly one subsequence. If there is no way to divide day history into zebra subsequences, print -1.
Subsequences may be printed in any order. If there are several solutions, you may print any of them. You do not have to minimize nor maximize the value of k.
Examples
Input
0010100
Output
3
3 1 3 4
3 2 5 6
1 7
Input
111
Output
-1 | instruction | 0 | 33,093 | 4 | 66,186 |
Tags: greedy
Correct Solution:
```
import configparser
import math
import sys
input = sys.stdin.readline
def main():
s = input().strip()
one = []
zero = []
adj = [[] for i in range(len(s))]
for i in range(len(s)):
if s[i] == '0':
if len(one) == 0:
zero.append(i)
else:
adj[one.pop()].append(i)
zero.append(i)
else:
if len(zero) == 0:
print(-1)
return
else:
adj[zero.pop()].append(i)
one.append(i)
if len(one) != 0:
print(-1)
return
groups = []
vis = [False for i in range(len(s))]
for i in range(len(vis)):
if not vis[i]:
cur_node = i
cur_g = [cur_node]
vis[cur_node] = True
while True:
if len(adj[cur_node]) == 0:
break
else:
cur_node = adj[cur_node][0]
cur_g.append(cur_node)
vis[cur_node] = True
groups.append(cur_g)
print(len(groups))
for i in groups:
print(len(i), end=' ')
for j in i:
print((j+1), end=' ')
print()
if __name__ == '__main__':
main()
``` | output | 1 | 33,093 | 4 | 66,187 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us denote bad days as 0 and good days as 1. Then, for example, sequences of days 0, 010, 01010 are zebras, while sequences 1, 0110, 0101 are not.
Oleg tells you the story of days he lived in chronological order in form of string consisting of 0 and 1. Now you are interested if it is possible to divide Oleg's life history into several subsequences, each of which is a zebra, and the way it can be done. Each day must belong to exactly one of the subsequences. For each of the subsequences, days forming it must be ordered chronologically. Note that subsequence does not have to be a group of consecutive days.
Input
In the only line of input data there is a non-empty string s consisting of characters 0 and 1, which describes the history of Oleg's life. Its length (denoted as |s|) does not exceed 200 000 characters.
Output
If there is a way to divide history into zebra subsequences, in the first line of output you should print an integer k (1 ≤ k ≤ |s|), the resulting number of subsequences. In the i-th of following k lines first print the integer li (1 ≤ li ≤ |s|), which is the length of the i-th subsequence, and then li indices of days forming the subsequence. Indices must follow in ascending order. Days are numbered starting from 1. Each index from 1 to n must belong to exactly one subsequence. If there is no way to divide day history into zebra subsequences, print -1.
Subsequences may be printed in any order. If there are several solutions, you may print any of them. You do not have to minimize nor maximize the value of k.
Examples
Input
0010100
Output
3
3 1 3 4
3 2 5 6
1 7
Input
111
Output
-1 | instruction | 0 | 33,094 | 4 | 66,188 |
Tags: greedy
Correct Solution:
```
life_log = input()
result = list()
def possible():
ones = 0
zeros = 0
for k in life_log:
if k == '0':
if ones > 0:
ones -= 1
zeros += 1
else:
zeros -= 1
ones += 1
if zeros < 0:
return False
if ones > 0:
return False
return True
def compute():
ones = 0
for k in range(len(life_log)):
char = life_log[k]
if char == '0':
if ones == 0:
result.append([k + 1])
else:
result[ones - 1].append(k+1)
ones -= 1
else:
result[ones].append(k + 1)
ones += 1
if possible():
compute()
print(len(result))
print("\n".join([str(len(sub)) + " " + " ".join(map(str, sub)) for sub in result]))
else:
print(-1)
``` | output | 1 | 33,094 | 4 | 66,189 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us denote bad days as 0 and good days as 1. Then, for example, sequences of days 0, 010, 01010 are zebras, while sequences 1, 0110, 0101 are not.
Oleg tells you the story of days he lived in chronological order in form of string consisting of 0 and 1. Now you are interested if it is possible to divide Oleg's life history into several subsequences, each of which is a zebra, and the way it can be done. Each day must belong to exactly one of the subsequences. For each of the subsequences, days forming it must be ordered chronologically. Note that subsequence does not have to be a group of consecutive days.
Input
In the only line of input data there is a non-empty string s consisting of characters 0 and 1, which describes the history of Oleg's life. Its length (denoted as |s|) does not exceed 200 000 characters.
Output
If there is a way to divide history into zebra subsequences, in the first line of output you should print an integer k (1 ≤ k ≤ |s|), the resulting number of subsequences. In the i-th of following k lines first print the integer li (1 ≤ li ≤ |s|), which is the length of the i-th subsequence, and then li indices of days forming the subsequence. Indices must follow in ascending order. Days are numbered starting from 1. Each index from 1 to n must belong to exactly one subsequence. If there is no way to divide day history into zebra subsequences, print -1.
Subsequences may be printed in any order. If there are several solutions, you may print any of them. You do not have to minimize nor maximize the value of k.
Examples
Input
0010100
Output
3
3 1 3 4
3 2 5 6
1 7
Input
111
Output
-1 | instruction | 0 | 33,095 | 4 | 66,190 |
Tags: greedy
Correct Solution:
```
import io,os
# input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
s = input()
n = len(s)
err = 0
f = []
l = [set(), set()]
cnt = 0
par = 0
for i in range(n):
if(s[i] == "0"):
if(len(l[0]) == 0):
l[1].add(cnt)
cnt+=1
f.append([])
f[-1].append(i+1)
else:
a = l[0].pop()
l[1].add(a)
f[a].append(i+1)
elif(s[i] == "1"):
if(len(l[1]) == 0):
err = 1
break
else:
a = l[1].pop()
l[0].add(a)
f[a].append(i+1)
if(err):
print(-1)
else:
if(len(l[0]) == 0):
print(len(f))
for i in f:
print(len(i), *i)
else:
print(-1)
``` | output | 1 | 33,095 | 4 | 66,191 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us denote bad days as 0 and good days as 1. Then, for example, sequences of days 0, 010, 01010 are zebras, while sequences 1, 0110, 0101 are not.
Oleg tells you the story of days he lived in chronological order in form of string consisting of 0 and 1. Now you are interested if it is possible to divide Oleg's life history into several subsequences, each of which is a zebra, and the way it can be done. Each day must belong to exactly one of the subsequences. For each of the subsequences, days forming it must be ordered chronologically. Note that subsequence does not have to be a group of consecutive days.
Input
In the only line of input data there is a non-empty string s consisting of characters 0 and 1, which describes the history of Oleg's life. Its length (denoted as |s|) does not exceed 200 000 characters.
Output
If there is a way to divide history into zebra subsequences, in the first line of output you should print an integer k (1 ≤ k ≤ |s|), the resulting number of subsequences. In the i-th of following k lines first print the integer li (1 ≤ li ≤ |s|), which is the length of the i-th subsequence, and then li indices of days forming the subsequence. Indices must follow in ascending order. Days are numbered starting from 1. Each index from 1 to n must belong to exactly one subsequence. If there is no way to divide day history into zebra subsequences, print -1.
Subsequences may be printed in any order. If there are several solutions, you may print any of them. You do not have to minimize nor maximize the value of k.
Examples
Input
0010100
Output
3
3 1 3 4
3 2 5 6
1 7
Input
111
Output
-1 | instruction | 0 | 33,096 | 4 | 66,192 |
Tags: greedy
Correct Solution:
```
#Code by Sounak, IIESTS
#------------------------------warmup----------------------------
import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
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")
#-------------------game starts now-----------------------------------------------------
s = input()
res, p = [], -1
for i in range(len(s)):
j = i + 1
if s[i] == '0':
if p > -1:
res[p].append(j)
p -= 1
else:
res.append([j])
else:
p += 1
if p >= len(res):
print(-1)
exit()
res[p].append(j)
if p != -1:
print(-1)
exit()
print(len(res))
for x in res:
print(len(x), *x)
``` | output | 1 | 33,096 | 4 | 66,193 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us denote bad days as 0 and good days as 1. Then, for example, sequences of days 0, 010, 01010 are zebras, while sequences 1, 0110, 0101 are not.
Oleg tells you the story of days he lived in chronological order in form of string consisting of 0 and 1. Now you are interested if it is possible to divide Oleg's life history into several subsequences, each of which is a zebra, and the way it can be done. Each day must belong to exactly one of the subsequences. For each of the subsequences, days forming it must be ordered chronologically. Note that subsequence does not have to be a group of consecutive days.
Input
In the only line of input data there is a non-empty string s consisting of characters 0 and 1, which describes the history of Oleg's life. Its length (denoted as |s|) does not exceed 200 000 characters.
Output
If there is a way to divide history into zebra subsequences, in the first line of output you should print an integer k (1 ≤ k ≤ |s|), the resulting number of subsequences. In the i-th of following k lines first print the integer li (1 ≤ li ≤ |s|), which is the length of the i-th subsequence, and then li indices of days forming the subsequence. Indices must follow in ascending order. Days are numbered starting from 1. Each index from 1 to n must belong to exactly one subsequence. If there is no way to divide day history into zebra subsequences, print -1.
Subsequences may be printed in any order. If there are several solutions, you may print any of them. You do not have to minimize nor maximize the value of k.
Examples
Input
0010100
Output
3
3 1 3 4
3 2 5 6
1 7
Input
111
Output
-1 | instruction | 0 | 33,097 | 4 | 66,194 |
Tags: greedy
Correct Solution:
```
def solve(s):
lists = [[] for _ in range(len(s))]
cid = 0
waitSet = set()
doneSet = set()
zeros = set()
for i, c in enumerate(s):
i += 1
if c == '1':
if not doneSet and not zeros:
print(-1)
return
elif doneSet:
aid = doneSet.pop()
lists[aid].append(i)
waitSet.add(aid)
else:
aid, idx = zeros.pop()
lists[aid].append(idx) # '0'
lists[aid].append(i) # '1'
waitSet.add(aid)
else:
if waitSet:
aid = waitSet.pop()
lists[aid].append(i)
doneSet.add(aid)
else:
# lists[cid].append(i)
# lists.append([i])
# doneSet.add(cid)
zeros.add((cid, i))
cid += 1
if waitSet:
print(-1)
return
k = len(doneSet) + len(zeros)
print(k)
for i in doneSet:
zebra = lists[i]
print("%d %s" % (len(zebra), " ".join(map(str, zebra))))
for aid, idx in zeros:
print("1 %d" % idx)
s = input()
solve(s)
``` | output | 1 | 33,097 | 4 | 66,195 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us denote bad days as 0 and good days as 1. Then, for example, sequences of days 0, 010, 01010 are zebras, while sequences 1, 0110, 0101 are not.
Oleg tells you the story of days he lived in chronological order in form of string consisting of 0 and 1. Now you are interested if it is possible to divide Oleg's life history into several subsequences, each of which is a zebra, and the way it can be done. Each day must belong to exactly one of the subsequences. For each of the subsequences, days forming it must be ordered chronologically. Note that subsequence does not have to be a group of consecutive days.
Input
In the only line of input data there is a non-empty string s consisting of characters 0 and 1, which describes the history of Oleg's life. Its length (denoted as |s|) does not exceed 200 000 characters.
Output
If there is a way to divide history into zebra subsequences, in the first line of output you should print an integer k (1 ≤ k ≤ |s|), the resulting number of subsequences. In the i-th of following k lines first print the integer li (1 ≤ li ≤ |s|), which is the length of the i-th subsequence, and then li indices of days forming the subsequence. Indices must follow in ascending order. Days are numbered starting from 1. Each index from 1 to n must belong to exactly one subsequence. If there is no way to divide day history into zebra subsequences, print -1.
Subsequences may be printed in any order. If there are several solutions, you may print any of them. You do not have to minimize nor maximize the value of k.
Examples
Input
0010100
Output
3
3 1 3 4
3 2 5 6
1 7
Input
111
Output
-1 | instruction | 0 | 33,098 | 4 | 66,196 |
Tags: greedy
Correct Solution:
```
s = input()
arr, zero, one = [], [], []
for i in range(len(s)):
if s[i] == '0':
if one:
idx = one.pop()
arr[idx].append(i + 1)
zero.append(idx)
else:
zero.append(len(arr))
arr.append([i + 1])
else:
if not zero:break
idx = zero.pop()
one.append(idx)
arr[idx].append(i + 1)
if arr and zero and not one:
print(len(arr))
for x in zero:
print(len(arr[x]), end=' ')
print(*arr[x])
else:print(-1)
``` | output | 1 | 33,098 | 4 | 66,197 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us denote bad days as 0 and good days as 1. Then, for example, sequences of days 0, 010, 01010 are zebras, while sequences 1, 0110, 0101 are not.
Oleg tells you the story of days he lived in chronological order in form of string consisting of 0 and 1. Now you are interested if it is possible to divide Oleg's life history into several subsequences, each of which is a zebra, and the way it can be done. Each day must belong to exactly one of the subsequences. For each of the subsequences, days forming it must be ordered chronologically. Note that subsequence does not have to be a group of consecutive days.
Input
In the only line of input data there is a non-empty string s consisting of characters 0 and 1, which describes the history of Oleg's life. Its length (denoted as |s|) does not exceed 200 000 characters.
Output
If there is a way to divide history into zebra subsequences, in the first line of output you should print an integer k (1 ≤ k ≤ |s|), the resulting number of subsequences. In the i-th of following k lines first print the integer li (1 ≤ li ≤ |s|), which is the length of the i-th subsequence, and then li indices of days forming the subsequence. Indices must follow in ascending order. Days are numbered starting from 1. Each index from 1 to n must belong to exactly one subsequence. If there is no way to divide day history into zebra subsequences, print -1.
Subsequences may be printed in any order. If there are several solutions, you may print any of them. You do not have to minimize nor maximize the value of k.
Examples
Input
0010100
Output
3
3 1 3 4
3 2 5 6
1 7
Input
111
Output
-1 | instruction | 0 | 33,099 | 4 | 66,198 |
Tags: greedy
Correct Solution:
```
s = input()
zero = set() # 前面的一个以0结尾的串的索引
one = set() # 前面的一个以1结尾的串的索引
ans = [] # 结果的串
for i in range(0,len(s)):
if(s[i] == '0'):
if one:
k = one.pop()
zero.add(k)
ans[k].append(i+1)
else:
zero.add(len(ans))
ans.append([i+1])
else:
if not zero:
print(-1)
exit()
k = zero.pop()
one.add(k)
ans[k].append(i+1)
if(one):
print(-1)
exit()
print(len(ans))
print('\n'.join([str(len(x))+' '+' '.join(map(str,x)) for x in ans]))
``` | output | 1 | 33,099 | 4 | 66,199 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us denote bad days as 0 and good days as 1. Then, for example, sequences of days 0, 010, 01010 are zebras, while sequences 1, 0110, 0101 are not.
Oleg tells you the story of days he lived in chronological order in form of string consisting of 0 and 1. Now you are interested if it is possible to divide Oleg's life history into several subsequences, each of which is a zebra, and the way it can be done. Each day must belong to exactly one of the subsequences. For each of the subsequences, days forming it must be ordered chronologically. Note that subsequence does not have to be a group of consecutive days.
Input
In the only line of input data there is a non-empty string s consisting of characters 0 and 1, which describes the history of Oleg's life. Its length (denoted as |s|) does not exceed 200 000 characters.
Output
If there is a way to divide history into zebra subsequences, in the first line of output you should print an integer k (1 ≤ k ≤ |s|), the resulting number of subsequences. In the i-th of following k lines first print the integer li (1 ≤ li ≤ |s|), which is the length of the i-th subsequence, and then li indices of days forming the subsequence. Indices must follow in ascending order. Days are numbered starting from 1. Each index from 1 to n must belong to exactly one subsequence. If there is no way to divide day history into zebra subsequences, print -1.
Subsequences may be printed in any order. If there are several solutions, you may print any of them. You do not have to minimize nor maximize the value of k.
Examples
Input
0010100
Output
3
3 1 3 4
3 2 5 6
1 7
Input
111
Output
-1 | instruction | 0 | 33,100 | 4 | 66,200 |
Tags: greedy
Correct Solution:
```
from collections import deque
l=input()
az=deque([])
z=deque([])
f=0
for i in range(len(l)):
if l[i]=='0':
if len(az)==0:
z.append([i+1])
else:
az[0].append(i+1)
z.append(az[0])
az.popleft()
else:
#print(f)
if len(z)==0:
f=1
break
else:
z[0].append(i+1)
az.append(z[0])
z.popleft()
if f==1 or len(az)!=0:
print(-1)
else:
print(len(z))
for i in range(len(z)):
print(len(z[i]),*z[i],sep=" ")
``` | output | 1 | 33,100 | 4 | 66,201 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us denote bad days as 0 and good days as 1. Then, for example, sequences of days 0, 010, 01010 are zebras, while sequences 1, 0110, 0101 are not.
Oleg tells you the story of days he lived in chronological order in form of string consisting of 0 and 1. Now you are interested if it is possible to divide Oleg's life history into several subsequences, each of which is a zebra, and the way it can be done. Each day must belong to exactly one of the subsequences. For each of the subsequences, days forming it must be ordered chronologically. Note that subsequence does not have to be a group of consecutive days.
Input
In the only line of input data there is a non-empty string s consisting of characters 0 and 1, which describes the history of Oleg's life. Its length (denoted as |s|) does not exceed 200 000 characters.
Output
If there is a way to divide history into zebra subsequences, in the first line of output you should print an integer k (1 ≤ k ≤ |s|), the resulting number of subsequences. In the i-th of following k lines first print the integer li (1 ≤ li ≤ |s|), which is the length of the i-th subsequence, and then li indices of days forming the subsequence. Indices must follow in ascending order. Days are numbered starting from 1. Each index from 1 to n must belong to exactly one subsequence. If there is no way to divide day history into zebra subsequences, print -1.
Subsequences may be printed in any order. If there are several solutions, you may print any of them. You do not have to minimize nor maximize the value of k.
Examples
Input
0010100
Output
3
3 1 3 4
3 2 5 6
1 7
Input
111
Output
-1
Submitted Solution:
```
s = input()
one = -1
ans=[]
p = True
for i in range(0,len(s)):
if s[i]=='0':
if one == -1:
ans.append([i+1])
else:
ans[one].append(i+1)
one-=1
else:
one+=1
if one == len(ans):
p = False
break
else:
ans[one].append(i+1)
#print(ans)
if p==False or one !=-1:
print("-1")
else:
print(len(ans))
print("\n".join([str(len(sub)) + " " + " ".join(map(str, sub)) for sub in ans]))
``` | instruction | 0 | 33,101 | 4 | 66,202 |
Yes | output | 1 | 33,101 | 4 | 66,203 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us denote bad days as 0 and good days as 1. Then, for example, sequences of days 0, 010, 01010 are zebras, while sequences 1, 0110, 0101 are not.
Oleg tells you the story of days he lived in chronological order in form of string consisting of 0 and 1. Now you are interested if it is possible to divide Oleg's life history into several subsequences, each of which is a zebra, and the way it can be done. Each day must belong to exactly one of the subsequences. For each of the subsequences, days forming it must be ordered chronologically. Note that subsequence does not have to be a group of consecutive days.
Input
In the only line of input data there is a non-empty string s consisting of characters 0 and 1, which describes the history of Oleg's life. Its length (denoted as |s|) does not exceed 200 000 characters.
Output
If there is a way to divide history into zebra subsequences, in the first line of output you should print an integer k (1 ≤ k ≤ |s|), the resulting number of subsequences. In the i-th of following k lines first print the integer li (1 ≤ li ≤ |s|), which is the length of the i-th subsequence, and then li indices of days forming the subsequence. Indices must follow in ascending order. Days are numbered starting from 1. Each index from 1 to n must belong to exactly one subsequence. If there is no way to divide day history into zebra subsequences, print -1.
Subsequences may be printed in any order. If there are several solutions, you may print any of them. You do not have to minimize nor maximize the value of k.
Examples
Input
0010100
Output
3
3 1 3 4
3 2 5 6
1 7
Input
111
Output
-1
Submitted Solution:
```
import sys
def solve(days):
zebras = []
azebras = []
for i in range(len(days)):
if days[i] == 1:
if not zebras:
return (False, [])
seq = zebras.pop()
seq.append(i)
azebras.append(seq)
else:
if not azebras:
zebras.append([i])
else:
seq = azebras.pop()
seq.append(i)
zebras.append(seq)
if azebras:
return (False, [])
return (True, zebras)
def main():
days = [int(i) for i in sys.stdin.readline().strip()]
ok, seqs = solve(days)
if not ok:
print(-1)
else:
print(len(seqs))
for seq in seqs:
print(len(seq), " ".join([str(i+1) for i in seq]))
if __name__ == '__main__':
main()
``` | instruction | 0 | 33,102 | 4 | 66,204 |
Yes | output | 1 | 33,102 | 4 | 66,205 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us denote bad days as 0 and good days as 1. Then, for example, sequences of days 0, 010, 01010 are zebras, while sequences 1, 0110, 0101 are not.
Oleg tells you the story of days he lived in chronological order in form of string consisting of 0 and 1. Now you are interested if it is possible to divide Oleg's life history into several subsequences, each of which is a zebra, and the way it can be done. Each day must belong to exactly one of the subsequences. For each of the subsequences, days forming it must be ordered chronologically. Note that subsequence does not have to be a group of consecutive days.
Input
In the only line of input data there is a non-empty string s consisting of characters 0 and 1, which describes the history of Oleg's life. Its length (denoted as |s|) does not exceed 200 000 characters.
Output
If there is a way to divide history into zebra subsequences, in the first line of output you should print an integer k (1 ≤ k ≤ |s|), the resulting number of subsequences. In the i-th of following k lines first print the integer li (1 ≤ li ≤ |s|), which is the length of the i-th subsequence, and then li indices of days forming the subsequence. Indices must follow in ascending order. Days are numbered starting from 1. Each index from 1 to n must belong to exactly one subsequence. If there is no way to divide day history into zebra subsequences, print -1.
Subsequences may be printed in any order. If there are several solutions, you may print any of them. You do not have to minimize nor maximize the value of k.
Examples
Input
0010100
Output
3
3 1 3 4
3 2 5 6
1 7
Input
111
Output
-1
Submitted Solution:
```
temp = [int(x) for x in list(input())]
#a = [] # ending with 1
b = [] # ending with 0
cnt = -1
skip = False
for i in range(len(temp)):
if temp[i] == 0:
if cnt == -1:
b.append([i+1])
else:
b[cnt] += [i+1]
cnt -= 1
else:
cnt += 1
if cnt == len(b):
skip = True
break
else:
b[cnt].append(i+1)
if skip or cnt != -1:
print(-1)
else:
print(len(b))
for i in b:
print(str(len(i))+' '+' '.join([str(x) for x in i]))
``` | instruction | 0 | 33,103 | 4 | 66,206 |
Yes | output | 1 | 33,103 | 4 | 66,207 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us denote bad days as 0 and good days as 1. Then, for example, sequences of days 0, 010, 01010 are zebras, while sequences 1, 0110, 0101 are not.
Oleg tells you the story of days he lived in chronological order in form of string consisting of 0 and 1. Now you are interested if it is possible to divide Oleg's life history into several subsequences, each of which is a zebra, and the way it can be done. Each day must belong to exactly one of the subsequences. For each of the subsequences, days forming it must be ordered chronologically. Note that subsequence does not have to be a group of consecutive days.
Input
In the only line of input data there is a non-empty string s consisting of characters 0 and 1, which describes the history of Oleg's life. Its length (denoted as |s|) does not exceed 200 000 characters.
Output
If there is a way to divide history into zebra subsequences, in the first line of output you should print an integer k (1 ≤ k ≤ |s|), the resulting number of subsequences. In the i-th of following k lines first print the integer li (1 ≤ li ≤ |s|), which is the length of the i-th subsequence, and then li indices of days forming the subsequence. Indices must follow in ascending order. Days are numbered starting from 1. Each index from 1 to n must belong to exactly one subsequence. If there is no way to divide day history into zebra subsequences, print -1.
Subsequences may be printed in any order. If there are several solutions, you may print any of them. You do not have to minimize nor maximize the value of k.
Examples
Input
0010100
Output
3
3 1 3 4
3 2 5 6
1 7
Input
111
Output
-1
Submitted Solution:
```
s = input()
o = -1
sol=[]
p = True
for i in range(0,len(s)):
if s[i]=='0':
if o == -1:
sol.append([i+1])
else:
sol[o].append(i+1)
o-=1
else:
o+=1
if o == len(sol):
p = False
break
else:
sol[o].append(i+1)
if p==False or o !=-1:
print("-1")
else:
print(len(sol))
print("\n".join([str(len(sub)) + " " + " ".join(map(str, sub)) for sub in sol]))
# Made By Mostafa_Khaled
``` | instruction | 0 | 33,104 | 4 | 66,208 |
Yes | output | 1 | 33,104 | 4 | 66,209 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us denote bad days as 0 and good days as 1. Then, for example, sequences of days 0, 010, 01010 are zebras, while sequences 1, 0110, 0101 are not.
Oleg tells you the story of days he lived in chronological order in form of string consisting of 0 and 1. Now you are interested if it is possible to divide Oleg's life history into several subsequences, each of which is a zebra, and the way it can be done. Each day must belong to exactly one of the subsequences. For each of the subsequences, days forming it must be ordered chronologically. Note that subsequence does not have to be a group of consecutive days.
Input
In the only line of input data there is a non-empty string s consisting of characters 0 and 1, which describes the history of Oleg's life. Its length (denoted as |s|) does not exceed 200 000 characters.
Output
If there is a way to divide history into zebra subsequences, in the first line of output you should print an integer k (1 ≤ k ≤ |s|), the resulting number of subsequences. In the i-th of following k lines first print the integer li (1 ≤ li ≤ |s|), which is the length of the i-th subsequence, and then li indices of days forming the subsequence. Indices must follow in ascending order. Days are numbered starting from 1. Each index from 1 to n must belong to exactly one subsequence. If there is no way to divide day history into zebra subsequences, print -1.
Subsequences may be printed in any order. If there are several solutions, you may print any of them. You do not have to minimize nor maximize the value of k.
Examples
Input
0010100
Output
3
3 1 3 4
3 2 5 6
1 7
Input
111
Output
-1
Submitted Solution:
```
s = input()
zero = []
one = []
for i in range(0,len(s)):
if(s[i] == '0'):
zero.append(i+1)
else:
one.append(i+1)
if(len(zero) < len(one)):
print('-1')
else:
print(len(zero)-len(one))
zero_item = 0
one_item = 0
for i in range(len(one)):
print(zero[zero_item],end=' '); zero_item+=1
print(one[one_item],end=' '); one_item+=1
print(zero[zero_item]); zero_item+=1
for x in range(zero_item,len(zero)):
print(1,zero[x])
``` | instruction | 0 | 33,105 | 4 | 66,210 |
No | output | 1 | 33,105 | 4 | 66,211 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us denote bad days as 0 and good days as 1. Then, for example, sequences of days 0, 010, 01010 are zebras, while sequences 1, 0110, 0101 are not.
Oleg tells you the story of days he lived in chronological order in form of string consisting of 0 and 1. Now you are interested if it is possible to divide Oleg's life history into several subsequences, each of which is a zebra, and the way it can be done. Each day must belong to exactly one of the subsequences. For each of the subsequences, days forming it must be ordered chronologically. Note that subsequence does not have to be a group of consecutive days.
Input
In the only line of input data there is a non-empty string s consisting of characters 0 and 1, which describes the history of Oleg's life. Its length (denoted as |s|) does not exceed 200 000 characters.
Output
If there is a way to divide history into zebra subsequences, in the first line of output you should print an integer k (1 ≤ k ≤ |s|), the resulting number of subsequences. In the i-th of following k lines first print the integer li (1 ≤ li ≤ |s|), which is the length of the i-th subsequence, and then li indices of days forming the subsequence. Indices must follow in ascending order. Days are numbered starting from 1. Each index from 1 to n must belong to exactly one subsequence. If there is no way to divide day history into zebra subsequences, print -1.
Subsequences may be printed in any order. If there are several solutions, you may print any of them. You do not have to minimize nor maximize the value of k.
Examples
Input
0010100
Output
3
3 1 3 4
3 2 5 6
1 7
Input
111
Output
-1
Submitted Solution:
```
def read_data():
a = list(map(int, list(input().strip())))
return a
def solve():
sol = []
solp = []
nextp = []
queue = []
used = []
i = 0
while i < len(a):
if a[i] != 0:
break
i += 1
if i >60000:
print("66666")
for i in range(0,66665):
print("3", i+1, i+66667, i+133333)
exit(0)
for i in range(0,len(a)):
if a[i] == 0:
new = [0]
newp = [i]
sol.append(new)
solp.append(newp)
nextp.append(i+1)
used.append(False)
queue.append(len(sol)-1)
else:
if queue == []:
return [], []
else:
sol[queue[0]].append(1)
solp[queue[0]].append(i)
nextp[queue[0]] = i + 1
del queue[0]
i = 0
while i < len(sol):
if sol[i][-1] == 1:
j = nextp[i] - 1
while j < len(sol):
if solp[j][0] > solp[i][-1] and not used[j]:
sol[i] += sol[j]
solp[i] += solp[j]
used[j] = True
j -= 1
if sol[i][-1] == 0:
break
j += 1
if sol[i][-1] == 1:
return [], []
i += 1
return solp, used
def print_sol(sol, used):
if len(sol) > 0:
print(len(sol) - used.count(True))
i = 0
for c in sol:
if not used[i]:
line = str(len(c))
for v in c:
line += " " + str(v+1)
print(line)
i += 1
else:
print("-1")
a = read_data()
# a = []
# for i in range(0,6666):
# a.append(0)
# for i in range(0,6666):
# a.append(1)
# for i in range(0,6666):
# a.append(0)
sol, used = solve()
print_sol(sol, used)
``` | instruction | 0 | 33,106 | 4 | 66,212 |
No | output | 1 | 33,106 | 4 | 66,213 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us denote bad days as 0 and good days as 1. Then, for example, sequences of days 0, 010, 01010 are zebras, while sequences 1, 0110, 0101 are not.
Oleg tells you the story of days he lived in chronological order in form of string consisting of 0 and 1. Now you are interested if it is possible to divide Oleg's life history into several subsequences, each of which is a zebra, and the way it can be done. Each day must belong to exactly one of the subsequences. For each of the subsequences, days forming it must be ordered chronologically. Note that subsequence does not have to be a group of consecutive days.
Input
In the only line of input data there is a non-empty string s consisting of characters 0 and 1, which describes the history of Oleg's life. Its length (denoted as |s|) does not exceed 200 000 characters.
Output
If there is a way to divide history into zebra subsequences, in the first line of output you should print an integer k (1 ≤ k ≤ |s|), the resulting number of subsequences. In the i-th of following k lines first print the integer li (1 ≤ li ≤ |s|), which is the length of the i-th subsequence, and then li indices of days forming the subsequence. Indices must follow in ascending order. Days are numbered starting from 1. Each index from 1 to n must belong to exactly one subsequence. If there is no way to divide day history into zebra subsequences, print -1.
Subsequences may be printed in any order. If there are several solutions, you may print any of them. You do not have to minimize nor maximize the value of k.
Examples
Input
0010100
Output
3
3 1 3 4
3 2 5 6
1 7
Input
111
Output
-1
Submitted Solution:
```
from collections import deque
st='a'+input()
n=len(st)
z_queue=deque()
o_queue=deque()
lst=[[] for i in range(n)]
flag=1
curr=-1
for i in range(1,n):
if st[i] =="1" and not z_queue:
flag=-1
break
if st[i] =='0' and not o_queue:
curr +=1
z_queue.append(curr)
lst[curr].append(i)
continue
if st[i] =='0':
q=o_queue.pop()
lst[q] .append(i)
z_queue.append(q)
continue
if st[i] =='1':
q=z_queue.pop()
lst[q].append(i)
o_queue.append(q)
if flag ==-1:
print(-1)
exit(0)
ans=[]
for i in range(n):
if len(lst[i]) >0:
ans.append(lst[i])
continue
break
print(len(ans))
for i in ans:
print(len(i),*i)
``` | instruction | 0 | 33,107 | 4 | 66,214 |
No | output | 1 | 33,107 | 4 | 66,215 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us denote bad days as 0 and good days as 1. Then, for example, sequences of days 0, 010, 01010 are zebras, while sequences 1, 0110, 0101 are not.
Oleg tells you the story of days he lived in chronological order in form of string consisting of 0 and 1. Now you are interested if it is possible to divide Oleg's life history into several subsequences, each of which is a zebra, and the way it can be done. Each day must belong to exactly one of the subsequences. For each of the subsequences, days forming it must be ordered chronologically. Note that subsequence does not have to be a group of consecutive days.
Input
In the only line of input data there is a non-empty string s consisting of characters 0 and 1, which describes the history of Oleg's life. Its length (denoted as |s|) does not exceed 200 000 characters.
Output
If there is a way to divide history into zebra subsequences, in the first line of output you should print an integer k (1 ≤ k ≤ |s|), the resulting number of subsequences. In the i-th of following k lines first print the integer li (1 ≤ li ≤ |s|), which is the length of the i-th subsequence, and then li indices of days forming the subsequence. Indices must follow in ascending order. Days are numbered starting from 1. Each index from 1 to n must belong to exactly one subsequence. If there is no way to divide day history into zebra subsequences, print -1.
Subsequences may be printed in any order. If there are several solutions, you may print any of them. You do not have to minimize nor maximize the value of k.
Examples
Input
0010100
Output
3
3 1 3 4
3 2 5 6
1 7
Input
111
Output
-1
Submitted Solution:
```
if __name__ == '__main__':
s = input()
zero = []
one = []
for i in range(0,len(s)):
if(s[i] == '0'):
zero.append(i+1)
else:
one.append(i+1)
if(len(zero) < len(one)):
print('-1')
else:
print(len(zero)-len(one))
zero_item = 0
one_item = 0
print(len(one)*2+1)
for i in range(len(one)):
print(zero[zero_item],end=' '); zero_item+=1
print(one[one_item],end=' '); one_item+=1
print(zero[zero_item]); zero_item+=1
for x in range(zero_item,len(zero)):
print(1,zero[x])
``` | instruction | 0 | 33,108 | 4 | 66,216 |
No | output | 1 | 33,108 | 4 | 66,217 |
Provide a correct Python 3 solution for this coding contest problem.
Create a program that takes two dates as input and outputs the number of days between the two dates.
Date 1 (y1, m1, d1) is the same as or earlier than date 2 (y2, m2, d2). Date 1 is included in the number of days, not date 2. Also, take the leap year into account when calculating. The leap year conditions are as follows.
* The year is divisible by 4.
* However, a year divisible by 100 is not a leap year.
* However, a year divisible by 400 is a leap year.
Input
Given multiple datasets. The format of each dataset is as follows:
y1 m1 d1 y2 m2 d2
When any of y1, m1, d1, y2, m2, and d2 is a negative number, the input ends.
The number of datasets does not exceed 50.
Output
Output the number of days on one line for each dataset.
Example
Input
2006 9 2 2006 9 3
2006 9 2 2006 11 11
2004 1 1 2005 1 1
2000 1 1 2006 1 1
2000 1 1 2101 1 1
-1 -1 -1 -1 -1 -1
Output
1
70
366
2192
36890 | instruction | 0 | 34,162 | 4 | 68,324 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
import sys
import os
import math
from datetime import date
for s in sys.stdin:
y1, m1, d1, y2, m2, d2 = map(int, s.split())
if y1 == m1 == d1 == y2 == m2 == d2 == -1:
break
day1 = date(y1, m1, d1)
day2 = date(y2, m2, d2)
delta = day2 - day1
print(delta.days)
``` | output | 1 | 34,162 | 4 | 68,325 |
Provide a correct Python 3 solution for this coding contest problem.
Create a program that takes two dates as input and outputs the number of days between the two dates.
Date 1 (y1, m1, d1) is the same as or earlier than date 2 (y2, m2, d2). Date 1 is included in the number of days, not date 2. Also, take the leap year into account when calculating. The leap year conditions are as follows.
* The year is divisible by 4.
* However, a year divisible by 100 is not a leap year.
* However, a year divisible by 400 is a leap year.
Input
Given multiple datasets. The format of each dataset is as follows:
y1 m1 d1 y2 m2 d2
When any of y1, m1, d1, y2, m2, and d2 is a negative number, the input ends.
The number of datasets does not exceed 50.
Output
Output the number of days on one line for each dataset.
Example
Input
2006 9 2 2006 9 3
2006 9 2 2006 11 11
2004 1 1 2005 1 1
2000 1 1 2006 1 1
2000 1 1 2101 1 1
-1 -1 -1 -1 -1 -1
Output
1
70
366
2192
36890 | instruction | 0 | 34,163 | 4 | 68,326 |
"Correct Solution:
```
# AOJ 0125 Day Count
# Python3 2018.6.18 bal4u
def ut2jd(year, month, day):
if month <= 2:
year -= 1
month += 12
s = 3 + year//4 - year//100 + year//400
s += 1720994 + year*365 + (month+1)*30 + (month+1)*3//5 + day;
return s
while True:
y1, m1, d1, y2, m2, d2 = list(map(int, input().split()))
if y1 < 0 or m1 < 0 or d1 < 0 or y2 < 0 or m2 < 0 or d2 < 0: break
print(ut2jd(y2, m2, d2)-ut2jd(y1, m1, d1))
``` | output | 1 | 34,163 | 4 | 68,327 |
Provide a correct Python 3 solution for this coding contest problem.
Create a program that takes two dates as input and outputs the number of days between the two dates.
Date 1 (y1, m1, d1) is the same as or earlier than date 2 (y2, m2, d2). Date 1 is included in the number of days, not date 2. Also, take the leap year into account when calculating. The leap year conditions are as follows.
* The year is divisible by 4.
* However, a year divisible by 100 is not a leap year.
* However, a year divisible by 400 is a leap year.
Input
Given multiple datasets. The format of each dataset is as follows:
y1 m1 d1 y2 m2 d2
When any of y1, m1, d1, y2, m2, and d2 is a negative number, the input ends.
The number of datasets does not exceed 50.
Output
Output the number of days on one line for each dataset.
Example
Input
2006 9 2 2006 9 3
2006 9 2 2006 11 11
2004 1 1 2005 1 1
2000 1 1 2006 1 1
2000 1 1 2101 1 1
-1 -1 -1 -1 -1 -1
Output
1
70
366
2192
36890 | instruction | 0 | 34,164 | 4 | 68,328 |
"Correct Solution:
```
import datetime
while True:
y1,m1,d1,y2,m2,d2=[int(i) for i in input().split(" ")]
if y1==-1:
break
d1=datetime.datetime(y1,m1,d1)
d2=datetime.datetime(y2,m2,d2)
print((d2-d1).days)
``` | output | 1 | 34,164 | 4 | 68,329 |
Provide a correct Python 3 solution for this coding contest problem.
Create a program that takes two dates as input and outputs the number of days between the two dates.
Date 1 (y1, m1, d1) is the same as or earlier than date 2 (y2, m2, d2). Date 1 is included in the number of days, not date 2. Also, take the leap year into account when calculating. The leap year conditions are as follows.
* The year is divisible by 4.
* However, a year divisible by 100 is not a leap year.
* However, a year divisible by 400 is a leap year.
Input
Given multiple datasets. The format of each dataset is as follows:
y1 m1 d1 y2 m2 d2
When any of y1, m1, d1, y2, m2, and d2 is a negative number, the input ends.
The number of datasets does not exceed 50.
Output
Output the number of days on one line for each dataset.
Example
Input
2006 9 2 2006 9 3
2006 9 2 2006 11 11
2004 1 1 2005 1 1
2000 1 1 2006 1 1
2000 1 1 2101 1 1
-1 -1 -1 -1 -1 -1
Output
1
70
366
2192
36890 | instruction | 0 | 34,165 | 4 | 68,330 |
"Correct Solution:
```
import datetime
while 1:
y1,m1,d1,y2,m2,d2=map(int,input().split())
if y1==-1:break
d1 = datetime.date(y1, m1, d1)
d2 = datetime.date(y2, m2, d2)
print((d2-d1).days)
``` | output | 1 | 34,165 | 4 | 68,331 |
Provide a correct Python 3 solution for this coding contest problem.
Create a program that takes two dates as input and outputs the number of days between the two dates.
Date 1 (y1, m1, d1) is the same as or earlier than date 2 (y2, m2, d2). Date 1 is included in the number of days, not date 2. Also, take the leap year into account when calculating. The leap year conditions are as follows.
* The year is divisible by 4.
* However, a year divisible by 100 is not a leap year.
* However, a year divisible by 400 is a leap year.
Input
Given multiple datasets. The format of each dataset is as follows:
y1 m1 d1 y2 m2 d2
When any of y1, m1, d1, y2, m2, and d2 is a negative number, the input ends.
The number of datasets does not exceed 50.
Output
Output the number of days on one line for each dataset.
Example
Input
2006 9 2 2006 9 3
2006 9 2 2006 11 11
2004 1 1 2005 1 1
2000 1 1 2006 1 1
2000 1 1 2101 1 1
-1 -1 -1 -1 -1 -1
Output
1
70
366
2192
36890 | instruction | 0 | 34,166 | 4 | 68,332 |
"Correct Solution:
```
def convert(y, m, d):
if m <= 2:
m += 12
y -= 1
mjd = int(365.25*y) + (y//400) - (y//100) + int(30.59*(m-2)) + d - 678912
return mjd
while 1:
y1, m1, d1, y2, m2, d2 = map(int, input().split())
if y1 == -1:
break
print(convert(y2, m2, d2) - convert(y1, m1, d1))
``` | output | 1 | 34,166 | 4 | 68,333 |
Provide a correct Python 3 solution for this coding contest problem.
Create a program that takes two dates as input and outputs the number of days between the two dates.
Date 1 (y1, m1, d1) is the same as or earlier than date 2 (y2, m2, d2). Date 1 is included in the number of days, not date 2. Also, take the leap year into account when calculating. The leap year conditions are as follows.
* The year is divisible by 4.
* However, a year divisible by 100 is not a leap year.
* However, a year divisible by 400 is a leap year.
Input
Given multiple datasets. The format of each dataset is as follows:
y1 m1 d1 y2 m2 d2
When any of y1, m1, d1, y2, m2, and d2 is a negative number, the input ends.
The number of datasets does not exceed 50.
Output
Output the number of days on one line for each dataset.
Example
Input
2006 9 2 2006 9 3
2006 9 2 2006 11 11
2004 1 1 2005 1 1
2000 1 1 2006 1 1
2000 1 1 2101 1 1
-1 -1 -1 -1 -1 -1
Output
1
70
366
2192
36890 | instruction | 0 | 34,167 | 4 | 68,334 |
"Correct Solution:
```
import datetime
while 1:
y1,m1,d1,y2,m2,d2 = (int(x) for x in input().split())
if y1 < 0:break
start = datetime.date(y1,m1,d1)
end = datetime.date(y2,m2,d2)
print((end - start).days)
``` | output | 1 | 34,167 | 4 | 68,335 |
Provide a correct Python 3 solution for this coding contest problem.
Create a program that takes two dates as input and outputs the number of days between the two dates.
Date 1 (y1, m1, d1) is the same as or earlier than date 2 (y2, m2, d2). Date 1 is included in the number of days, not date 2. Also, take the leap year into account when calculating. The leap year conditions are as follows.
* The year is divisible by 4.
* However, a year divisible by 100 is not a leap year.
* However, a year divisible by 400 is a leap year.
Input
Given multiple datasets. The format of each dataset is as follows:
y1 m1 d1 y2 m2 d2
When any of y1, m1, d1, y2, m2, and d2 is a negative number, the input ends.
The number of datasets does not exceed 50.
Output
Output the number of days on one line for each dataset.
Example
Input
2006 9 2 2006 9 3
2006 9 2 2006 11 11
2004 1 1 2005 1 1
2000 1 1 2006 1 1
2000 1 1 2101 1 1
-1 -1 -1 -1 -1 -1
Output
1
70
366
2192
36890 | instruction | 0 | 34,168 | 4 | 68,336 |
"Correct Solution:
```
# Aizu Problem 00125: Day Count
#
import sys, math, os, datetime
# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
sys.stdin = open("sample-input.txt", "rt")
for line in sys.stdin:
y1, m1, d1, y2, m2, d2 = [int(_) for _ in line.split()]
if y1 == m1 == d1 == y2 == m2 == d2 == -1:
break
date1 = datetime.date(y1, m1, d1)
date2 = datetime.date(y2, m2, d2)
print((date2 - date1).days)
``` | output | 1 | 34,168 | 4 | 68,337 |
Provide a correct Python 3 solution for this coding contest problem.
Create a program that takes two dates as input and outputs the number of days between the two dates.
Date 1 (y1, m1, d1) is the same as or earlier than date 2 (y2, m2, d2). Date 1 is included in the number of days, not date 2. Also, take the leap year into account when calculating. The leap year conditions are as follows.
* The year is divisible by 4.
* However, a year divisible by 100 is not a leap year.
* However, a year divisible by 400 is a leap year.
Input
Given multiple datasets. The format of each dataset is as follows:
y1 m1 d1 y2 m2 d2
When any of y1, m1, d1, y2, m2, and d2 is a negative number, the input ends.
The number of datasets does not exceed 50.
Output
Output the number of days on one line for each dataset.
Example
Input
2006 9 2 2006 9 3
2006 9 2 2006 11 11
2004 1 1 2005 1 1
2000 1 1 2006 1 1
2000 1 1 2101 1 1
-1 -1 -1 -1 -1 -1
Output
1
70
366
2192
36890 | instruction | 0 | 34,169 | 4 | 68,338 |
"Correct Solution:
```
ans_list = []
days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
while True:
y1, m1, d1, y2, m2, d2 = map(int, input().split())
if y1+y2+m1+m2+d1+d2 == -6:
break
else:
ans = 0
dis_m = m2 - m1
dis_y = y2 - y1
leap = 0
if dis_y == 0:
leap = 0
if y1 % 4 == 0:
if y1 % 100 == 0:
if y1 % 400 != 0:
leap = 1
else:
leap = 1
if dis_m == 0:
ans = d2 - d1
else:
ans += sum(days[m1:m2-1]) + days[m1-1] - d1 + d2
if leap == 1 and m1 < 3 and 2 < m2:
ans += 1
ans_list.append(ans)
else:
for y in range(y1, y2+1):
leap = 0
if y % 4 == 0:
if y % 100 == 0 and y % 400 != 0:
leap = 0
else:
leap = 1
if y == y1:
ans += sum(days[m1:]) + days[m1-1] - d1
if leap == 1 and m1 < 3:
ans += 1
elif y == y2:
ans += sum(days[:m2-1]) + d2
if leap == 1 and m2 > 2:
ans += 1
else:
if leap == 0:
ans += 365
else:
ans += 366
ans_list.append(ans)
for a in ans_list:
print(a)
``` | output | 1 | 34,169 | 4 | 68,339 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Create a program that takes two dates as input and outputs the number of days between the two dates.
Date 1 (y1, m1, d1) is the same as or earlier than date 2 (y2, m2, d2). Date 1 is included in the number of days, not date 2. Also, take the leap year into account when calculating. The leap year conditions are as follows.
* The year is divisible by 4.
* However, a year divisible by 100 is not a leap year.
* However, a year divisible by 400 is a leap year.
Input
Given multiple datasets. The format of each dataset is as follows:
y1 m1 d1 y2 m2 d2
When any of y1, m1, d1, y2, m2, and d2 is a negative number, the input ends.
The number of datasets does not exceed 50.
Output
Output the number of days on one line for each dataset.
Example
Input
2006 9 2 2006 9 3
2006 9 2 2006 11 11
2004 1 1 2005 1 1
2000 1 1 2006 1 1
2000 1 1 2101 1 1
-1 -1 -1 -1 -1 -1
Output
1
70
366
2192
36890
Submitted Solution:
```
import datetime
while True:
year1, month1, day1, year2, month2, day2 = [int(item) for item in input().split(" ")]
if any([item < 0 for item in [year1, month1, day1, year2, month2, day2]]):
break
date1 = datetime.date(year1, month1, day1)
date2 = datetime.date(year2, month2, day2)
subtract = date2 - date1
print(subtract.days)
``` | instruction | 0 | 34,170 | 4 | 68,340 |
Yes | output | 1 | 34,170 | 4 | 68,341 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Create a program that takes two dates as input and outputs the number of days between the two dates.
Date 1 (y1, m1, d1) is the same as or earlier than date 2 (y2, m2, d2). Date 1 is included in the number of days, not date 2. Also, take the leap year into account when calculating. The leap year conditions are as follows.
* The year is divisible by 4.
* However, a year divisible by 100 is not a leap year.
* However, a year divisible by 400 is a leap year.
Input
Given multiple datasets. The format of each dataset is as follows:
y1 m1 d1 y2 m2 d2
When any of y1, m1, d1, y2, m2, and d2 is a negative number, the input ends.
The number of datasets does not exceed 50.
Output
Output the number of days on one line for each dataset.
Example
Input
2006 9 2 2006 9 3
2006 9 2 2006 11 11
2004 1 1 2005 1 1
2000 1 1 2006 1 1
2000 1 1 2101 1 1
-1 -1 -1 -1 -1 -1
Output
1
70
366
2192
36890
Submitted Solution:
```
from datetime import date
while 1:
t=list(map(int,input().split()))
if t[0]<0:break
print((date(*t[3:])-date(*t[:3])).days)
``` | instruction | 0 | 34,171 | 4 | 68,342 |
Yes | output | 1 | 34,171 | 4 | 68,343 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Create a program that takes two dates as input and outputs the number of days between the two dates.
Date 1 (y1, m1, d1) is the same as or earlier than date 2 (y2, m2, d2). Date 1 is included in the number of days, not date 2. Also, take the leap year into account when calculating. The leap year conditions are as follows.
* The year is divisible by 4.
* However, a year divisible by 100 is not a leap year.
* However, a year divisible by 400 is a leap year.
Input
Given multiple datasets. The format of each dataset is as follows:
y1 m1 d1 y2 m2 d2
When any of y1, m1, d1, y2, m2, and d2 is a negative number, the input ends.
The number of datasets does not exceed 50.
Output
Output the number of days on one line for each dataset.
Example
Input
2006 9 2 2006 9 3
2006 9 2 2006 11 11
2004 1 1 2005 1 1
2000 1 1 2006 1 1
2000 1 1 2101 1 1
-1 -1 -1 -1 -1 -1
Output
1
70
366
2192
36890
Submitted Solution:
```
import datetime
while 1:
t=list(map(int,input().split()))
if t[0]<0:break
s=datetime.date(t[0],t[1],t[2])
e=datetime.date(t[3],t[4],t[5])
print((e-s).days)
``` | instruction | 0 | 34,172 | 4 | 68,344 |
Yes | output | 1 | 34,172 | 4 | 68,345 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Create a program that takes two dates as input and outputs the number of days between the two dates.
Date 1 (y1, m1, d1) is the same as or earlier than date 2 (y2, m2, d2). Date 1 is included in the number of days, not date 2. Also, take the leap year into account when calculating. The leap year conditions are as follows.
* The year is divisible by 4.
* However, a year divisible by 100 is not a leap year.
* However, a year divisible by 400 is a leap year.
Input
Given multiple datasets. The format of each dataset is as follows:
y1 m1 d1 y2 m2 d2
When any of y1, m1, d1, y2, m2, and d2 is a negative number, the input ends.
The number of datasets does not exceed 50.
Output
Output the number of days on one line for each dataset.
Example
Input
2006 9 2 2006 9 3
2006 9 2 2006 11 11
2004 1 1 2005 1 1
2000 1 1 2006 1 1
2000 1 1 2101 1 1
-1 -1 -1 -1 -1 -1
Output
1
70
366
2192
36890
Submitted Solution:
```
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0125
"""
import sys
from datetime import timedelta, date
def solve(data):
y1, m1, d1, y2, m2, d2 = data
date1 = date(y1, m1, d1)
date2 = date(y2, m2, d2)
delta = date2 - date1
return delta.days
def main(args):
while True:
data = [int(x) for x in input().split()]
try:
result = solve(data)
print(result)
except ValueError:
break
if __name__ == '__main__':
main(sys.argv[1:])
``` | instruction | 0 | 34,173 | 4 | 68,346 |
Yes | output | 1 | 34,173 | 4 | 68,347 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Create a program that takes two dates as input and outputs the number of days between the two dates.
Date 1 (y1, m1, d1) is the same as or earlier than date 2 (y2, m2, d2). Date 1 is included in the number of days, not date 2. Also, take the leap year into account when calculating. The leap year conditions are as follows.
* The year is divisible by 4.
* However, a year divisible by 100 is not a leap year.
* However, a year divisible by 400 is a leap year.
Input
Given multiple datasets. The format of each dataset is as follows:
y1 m1 d1 y2 m2 d2
When any of y1, m1, d1, y2, m2, and d2 is a negative number, the input ends.
The number of datasets does not exceed 50.
Output
Output the number of days on one line for each dataset.
Example
Input
2006 9 2 2006 9 3
2006 9 2 2006 11 11
2004 1 1 2005 1 1
2000 1 1 2006 1 1
2000 1 1 2101 1 1
-1 -1 -1 -1 -1 -1
Output
1
70
366
2192
36890
Submitted Solution:
```
def y_to_d(y):
y -= 1
ret = 365 * y
ret += y // 4
ret -= y // 100
ret += y // 400
return ret
month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
def m_to_d(y, m):
m -= 1
ret = 0
for i in range(m-1):
ret += month[i]
if m > 2 and (y % 4 == 0 and y % 100 != 0 or y % 400 == 0):
ret += 1
return ret
while True:
y1, m1, d1, y2, m2, d2 = map(int, input().split())
if y1 == m1 == d1 == y2 == m2 == d2 == -1:
quit()
ymd1 = y_to_d(y1) + m_to_d(y1, m1) + d1
ymd2 = y_to_d(y2) + m_to_d(y2, m2) + d2
print(ymd2 - ymd1)
``` | instruction | 0 | 34,174 | 4 | 68,348 |
No | output | 1 | 34,174 | 4 | 68,349 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Create a program that takes two dates as input and outputs the number of days between the two dates.
Date 1 (y1, m1, d1) is the same as or earlier than date 2 (y2, m2, d2). Date 1 is included in the number of days, not date 2. Also, take the leap year into account when calculating. The leap year conditions are as follows.
* The year is divisible by 4.
* However, a year divisible by 100 is not a leap year.
* However, a year divisible by 400 is a leap year.
Input
Given multiple datasets. The format of each dataset is as follows:
y1 m1 d1 y2 m2 d2
When any of y1, m1, d1, y2, m2, and d2 is a negative number, the input ends.
The number of datasets does not exceed 50.
Output
Output the number of days on one line for each dataset.
Example
Input
2006 9 2 2006 9 3
2006 9 2 2006 11 11
2004 1 1 2005 1 1
2000 1 1 2006 1 1
2000 1 1 2101 1 1
-1 -1 -1 -1 -1 -1
Output
1
70
366
2192
36890
Submitted Solution:
```
def y_to_d(y):
y = y-1
ret = 365 * y
ret += y // 4
ret -= y // 100
ret += y // 400
return ret
month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
def m_to_d(y, m):
ret = 0
for i in range(m-1-1):
ret += month[i]
if m > 2 and (y % 4 == 0 and y % 100 != 0 or y % 400 == 0):
ret -= 1
return ret
while True:
y1, m1, d1, y2, m2, d2 = map(int, input().split())
if y1 == m1 == d1 == y2 == m2 == d2 == -1:
quit()
ymd1 = y_to_d(y1) + m_to_d(y1, m1) + d1
ymd2 = y_to_d(y2) + m_to_d(y2, m2) + d2
print(ymd2 - ymd1)
``` | instruction | 0 | 34,175 | 4 | 68,350 |
No | output | 1 | 34,175 | 4 | 68,351 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Create a program that takes two dates as input and outputs the number of days between the two dates.
Date 1 (y1, m1, d1) is the same as or earlier than date 2 (y2, m2, d2). Date 1 is included in the number of days, not date 2. Also, take the leap year into account when calculating. The leap year conditions are as follows.
* The year is divisible by 4.
* However, a year divisible by 100 is not a leap year.
* However, a year divisible by 400 is a leap year.
Input
Given multiple datasets. The format of each dataset is as follows:
y1 m1 d1 y2 m2 d2
When any of y1, m1, d1, y2, m2, and d2 is a negative number, the input ends.
The number of datasets does not exceed 50.
Output
Output the number of days on one line for each dataset.
Example
Input
2006 9 2 2006 9 3
2006 9 2 2006 11 11
2004 1 1 2005 1 1
2000 1 1 2006 1 1
2000 1 1 2101 1 1
-1 -1 -1 -1 -1 -1
Output
1
70
366
2192
36890
Submitted Solution:
```
def uru(y):
return y % 4 == 0 and y % 100 != 0 or y % 400 == 0
def y_to_d(y):
ret = 0
for i in range(y):
if uru(i):
ret += 366
else:
ret += 365
return ret
month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
def m_to_d(y, m):
m -= 1
ret = 0
for i in range(m-1):
ret += month[i]
if m > 2 and uru:
ret += 1
return ret
while True:
y1, m1, d1, y2, m2, d2 = map(int, input().split())
if min(y1, m1, d1, y2, m2, d2) < 0:
quit()
ymd1 = y_to_d(y1) + m_to_d(y1, m1) + d1
ymd2 = y_to_d(y2) + m_to_d(y2, m2) + d2
print(ymd2 - ymd1)
``` | instruction | 0 | 34,176 | 4 | 68,352 |
No | output | 1 | 34,176 | 4 | 68,353 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Create a program that takes two dates as input and outputs the number of days between the two dates.
Date 1 (y1, m1, d1) is the same as or earlier than date 2 (y2, m2, d2). Date 1 is included in the number of days, not date 2. Also, take the leap year into account when calculating. The leap year conditions are as follows.
* The year is divisible by 4.
* However, a year divisible by 100 is not a leap year.
* However, a year divisible by 400 is a leap year.
Input
Given multiple datasets. The format of each dataset is as follows:
y1 m1 d1 y2 m2 d2
When any of y1, m1, d1, y2, m2, and d2 is a negative number, the input ends.
The number of datasets does not exceed 50.
Output
Output the number of days on one line for each dataset.
Example
Input
2006 9 2 2006 9 3
2006 9 2 2006 11 11
2004 1 1 2005 1 1
2000 1 1 2006 1 1
2000 1 1 2101 1 1
-1 -1 -1 -1 -1 -1
Output
1
70
366
2192
36890
Submitted Solution:
```
def y_to_d(y):
y -= 1
ret = 365 * y
ret += y // 4
ret -= y // 100
ret += y // 400
return ret
month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
def m_to_d(y, m):
m -= 1
ret = 0
for i in range(m-1):
ret += month[i]
if m > 2 and (y % 4 == 0 and y % 100 != 0 or y % 400 == 0):
ret -= 1
return ret
while True:
y1, m1, d1, y2, m2, d2 = map(int, input().split())
if y1 == m1 == d1 == y2 == m2 == d2 == -1:
quit()
ymd1 = y_to_d(y1) + m_to_d(y1, m1) + d1
ymd2 = y_to_d(y2) + m_to_d(y2, m2) + d2
print(ymd2 - ymd1)
``` | instruction | 0 | 34,177 | 4 | 68,354 |
No | output | 1 | 34,177 | 4 | 68,355 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alena has successfully passed the entrance exams to the university and is now looking forward to start studying.
One two-hour lesson at the Russian university is traditionally called a pair, it lasts for two academic hours (an academic hour is equal to 45 minutes).
The University works in such a way that every day it holds exactly n lessons. Depending on the schedule of a particular group of students, on a given day, some pairs may actually contain classes, but some may be empty (such pairs are called breaks).
The official website of the university has already published the schedule for tomorrow for Alena's group. Thus, for each of the n pairs she knows if there will be a class at that time or not.
Alena's House is far from the university, so if there are breaks, she doesn't always go home. Alena has time to go home only if the break consists of at least two free pairs in a row, otherwise she waits for the next pair at the university.
Of course, Alena does not want to be sleepy during pairs, so she will sleep as long as possible, and will only come to the first pair that is presented in her schedule. Similarly, if there are no more pairs, then Alena immediately goes home.
Alena appreciates the time spent at home, so she always goes home when it is possible, and returns to the university only at the beginning of the next pair. Help Alena determine for how many pairs she will stay at the university. Note that during some pairs Alena may be at the university waiting for the upcoming pair.
Input
The first line of the input contains a positive integer n (1 ≤ n ≤ 100) — the number of lessons at the university.
The second line contains n numbers ai (0 ≤ ai ≤ 1). Number ai equals 0, if Alena doesn't have the i-th pairs, otherwise it is equal to 1. Numbers a1, a2, ..., an are separated by spaces.
Output
Print a single number — the number of pairs during which Alena stays at the university.
Examples
Input
5
0 1 0 1 1
Output
4
Input
7
1 0 1 0 0 1 0
Output
4
Input
1
0
Output
0
Note
In the first sample Alena stays at the university from the second to the fifth pair, inclusive, during the third pair she will be it the university waiting for the next pair.
In the last sample Alena doesn't have a single pair, so she spends all the time at home.
Submitted Solution:
```
input()
l = list(map(int, input().split()))
while l and l[0] == 0:
l = l[1:]
while l and l[-1] == 0:
l = l[:-1]
for i in range(1, len(l) - 1):
if l[i-1] == 1 and l[i] == 0 and l[i+1] == 1:
l[i] = 1
print(l.count(1))
``` | instruction | 0 | 34,724 | 4 | 69,448 |
Yes | output | 1 | 34,724 | 4 | 69,449 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alena has successfully passed the entrance exams to the university and is now looking forward to start studying.
One two-hour lesson at the Russian university is traditionally called a pair, it lasts for two academic hours (an academic hour is equal to 45 minutes).
The University works in such a way that every day it holds exactly n lessons. Depending on the schedule of a particular group of students, on a given day, some pairs may actually contain classes, but some may be empty (such pairs are called breaks).
The official website of the university has already published the schedule for tomorrow for Alena's group. Thus, for each of the n pairs she knows if there will be a class at that time or not.
Alena's House is far from the university, so if there are breaks, she doesn't always go home. Alena has time to go home only if the break consists of at least two free pairs in a row, otherwise she waits for the next pair at the university.
Of course, Alena does not want to be sleepy during pairs, so she will sleep as long as possible, and will only come to the first pair that is presented in her schedule. Similarly, if there are no more pairs, then Alena immediately goes home.
Alena appreciates the time spent at home, so she always goes home when it is possible, and returns to the university only at the beginning of the next pair. Help Alena determine for how many pairs she will stay at the university. Note that during some pairs Alena may be at the university waiting for the upcoming pair.
Input
The first line of the input contains a positive integer n (1 ≤ n ≤ 100) — the number of lessons at the university.
The second line contains n numbers ai (0 ≤ ai ≤ 1). Number ai equals 0, if Alena doesn't have the i-th pairs, otherwise it is equal to 1. Numbers a1, a2, ..., an are separated by spaces.
Output
Print a single number — the number of pairs during which Alena stays at the university.
Examples
Input
5
0 1 0 1 1
Output
4
Input
7
1 0 1 0 0 1 0
Output
4
Input
1
0
Output
0
Note
In the first sample Alena stays at the university from the second to the fifth pair, inclusive, during the third pair she will be it the university waiting for the next pair.
In the last sample Alena doesn't have a single pair, so she spends all the time at home.
Submitted Solution:
```
__author__ = 'yarsanich'
n = int(input(''))
a = list(map(int, input('').split()))
ans = 0
for i in range(n):
if (a[i] == 1):
ans+=1
a.append(1)
start = a.index(1)
if (start!=n):
for i in range(start,n-1):
if (a[i] == 0) and (a[i+1] != 0) and (a[i-1]!=0):
ans+=1
print(ans)
else:
print(0)
``` | instruction | 0 | 34,725 | 4 | 69,450 |
Yes | output | 1 | 34,725 | 4 | 69,451 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alena has successfully passed the entrance exams to the university and is now looking forward to start studying.
One two-hour lesson at the Russian university is traditionally called a pair, it lasts for two academic hours (an academic hour is equal to 45 minutes).
The University works in such a way that every day it holds exactly n lessons. Depending on the schedule of a particular group of students, on a given day, some pairs may actually contain classes, but some may be empty (such pairs are called breaks).
The official website of the university has already published the schedule for tomorrow for Alena's group. Thus, for each of the n pairs she knows if there will be a class at that time or not.
Alena's House is far from the university, so if there are breaks, she doesn't always go home. Alena has time to go home only if the break consists of at least two free pairs in a row, otherwise she waits for the next pair at the university.
Of course, Alena does not want to be sleepy during pairs, so she will sleep as long as possible, and will only come to the first pair that is presented in her schedule. Similarly, if there are no more pairs, then Alena immediately goes home.
Alena appreciates the time spent at home, so she always goes home when it is possible, and returns to the university only at the beginning of the next pair. Help Alena determine for how many pairs she will stay at the university. Note that during some pairs Alena may be at the university waiting for the upcoming pair.
Input
The first line of the input contains a positive integer n (1 ≤ n ≤ 100) — the number of lessons at the university.
The second line contains n numbers ai (0 ≤ ai ≤ 1). Number ai equals 0, if Alena doesn't have the i-th pairs, otherwise it is equal to 1. Numbers a1, a2, ..., an are separated by spaces.
Output
Print a single number — the number of pairs during which Alena stays at the university.
Examples
Input
5
0 1 0 1 1
Output
4
Input
7
1 0 1 0 0 1 0
Output
4
Input
1
0
Output
0
Note
In the first sample Alena stays at the university from the second to the fifth pair, inclusive, during the third pair she will be it the university waiting for the next pair.
In the last sample Alena doesn't have a single pair, so she spends all the time at home.
Submitted Solution:
```
input()
a = list(map(int, input().split()))
for i in range(1, len(a) - 1):
if a[i - 1] and a[i + 1]:
a[i] = 1
print(sum(a))
``` | instruction | 0 | 34,726 | 4 | 69,452 |
Yes | output | 1 | 34,726 | 4 | 69,453 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alena has successfully passed the entrance exams to the university and is now looking forward to start studying.
One two-hour lesson at the Russian university is traditionally called a pair, it lasts for two academic hours (an academic hour is equal to 45 minutes).
The University works in such a way that every day it holds exactly n lessons. Depending on the schedule of a particular group of students, on a given day, some pairs may actually contain classes, but some may be empty (such pairs are called breaks).
The official website of the university has already published the schedule for tomorrow for Alena's group. Thus, for each of the n pairs she knows if there will be a class at that time or not.
Alena's House is far from the university, so if there are breaks, she doesn't always go home. Alena has time to go home only if the break consists of at least two free pairs in a row, otherwise she waits for the next pair at the university.
Of course, Alena does not want to be sleepy during pairs, so she will sleep as long as possible, and will only come to the first pair that is presented in her schedule. Similarly, if there are no more pairs, then Alena immediately goes home.
Alena appreciates the time spent at home, so she always goes home when it is possible, and returns to the university only at the beginning of the next pair. Help Alena determine for how many pairs she will stay at the university. Note that during some pairs Alena may be at the university waiting for the upcoming pair.
Input
The first line of the input contains a positive integer n (1 ≤ n ≤ 100) — the number of lessons at the university.
The second line contains n numbers ai (0 ≤ ai ≤ 1). Number ai equals 0, if Alena doesn't have the i-th pairs, otherwise it is equal to 1. Numbers a1, a2, ..., an are separated by spaces.
Output
Print a single number — the number of pairs during which Alena stays at the university.
Examples
Input
5
0 1 0 1 1
Output
4
Input
7
1 0 1 0 0 1 0
Output
4
Input
1
0
Output
0
Note
In the first sample Alena stays at the university from the second to the fifth pair, inclusive, during the third pair she will be it the university waiting for the next pair.
In the last sample Alena doesn't have a single pair, so she spends all the time at home.
Submitted Solution:
```
n = input()
lessons = input().split()
prev = '0'
home = True
cnt = 0
for l in lessons:
if l == '0' and prev == '0':
home = True
elif l == '1':
cnt += 1
if prev == '0' and not home:
cnt += 1
home = False
prev = l
print(cnt)
``` | instruction | 0 | 34,727 | 4 | 69,454 |
Yes | output | 1 | 34,727 | 4 | 69,455 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alena has successfully passed the entrance exams to the university and is now looking forward to start studying.
One two-hour lesson at the Russian university is traditionally called a pair, it lasts for two academic hours (an academic hour is equal to 45 minutes).
The University works in such a way that every day it holds exactly n lessons. Depending on the schedule of a particular group of students, on a given day, some pairs may actually contain classes, but some may be empty (such pairs are called breaks).
The official website of the university has already published the schedule for tomorrow for Alena's group. Thus, for each of the n pairs she knows if there will be a class at that time or not.
Alena's House is far from the university, so if there are breaks, she doesn't always go home. Alena has time to go home only if the break consists of at least two free pairs in a row, otherwise she waits for the next pair at the university.
Of course, Alena does not want to be sleepy during pairs, so she will sleep as long as possible, and will only come to the first pair that is presented in her schedule. Similarly, if there are no more pairs, then Alena immediately goes home.
Alena appreciates the time spent at home, so she always goes home when it is possible, and returns to the university only at the beginning of the next pair. Help Alena determine for how many pairs she will stay at the university. Note that during some pairs Alena may be at the university waiting for the upcoming pair.
Input
The first line of the input contains a positive integer n (1 ≤ n ≤ 100) — the number of lessons at the university.
The second line contains n numbers ai (0 ≤ ai ≤ 1). Number ai equals 0, if Alena doesn't have the i-th pairs, otherwise it is equal to 1. Numbers a1, a2, ..., an are separated by spaces.
Output
Print a single number — the number of pairs during which Alena stays at the university.
Examples
Input
5
0 1 0 1 1
Output
4
Input
7
1 0 1 0 0 1 0
Output
4
Input
1
0
Output
0
Note
In the first sample Alena stays at the university from the second to the fifth pair, inclusive, during the third pair she will be it the university waiting for the next pair.
In the last sample Alena doesn't have a single pair, so she spends all the time at home.
Submitted Solution:
```
__author__ = 'yarsanich'
n = int(input(''))
a = list(map(int, input('').split()))
cur_time = 1
for i in range(n):
if (a[i] == 1):
cur_time = i
break
last_pair = 0
b = list(reversed(a))
for i in range(n):
if (b[i] == 1):
last_pair = i
break
ans = n - cur_time - last_pair
if (n != 1):
while cur_time != n - 1:
if (a[cur_time] == 0) and (a[cur_time + 1] == 0):
ans -= 2
cur_time += 2
else:
cur_time += 1
if (n == 1):
print(a[0])
else:
print(ans)
``` | instruction | 0 | 34,728 | 4 | 69,456 |
No | output | 1 | 34,728 | 4 | 69,457 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alena has successfully passed the entrance exams to the university and is now looking forward to start studying.
One two-hour lesson at the Russian university is traditionally called a pair, it lasts for two academic hours (an academic hour is equal to 45 minutes).
The University works in such a way that every day it holds exactly n lessons. Depending on the schedule of a particular group of students, on a given day, some pairs may actually contain classes, but some may be empty (such pairs are called breaks).
The official website of the university has already published the schedule for tomorrow for Alena's group. Thus, for each of the n pairs she knows if there will be a class at that time or not.
Alena's House is far from the university, so if there are breaks, she doesn't always go home. Alena has time to go home only if the break consists of at least two free pairs in a row, otherwise she waits for the next pair at the university.
Of course, Alena does not want to be sleepy during pairs, so she will sleep as long as possible, and will only come to the first pair that is presented in her schedule. Similarly, if there are no more pairs, then Alena immediately goes home.
Alena appreciates the time spent at home, so she always goes home when it is possible, and returns to the university only at the beginning of the next pair. Help Alena determine for how many pairs she will stay at the university. Note that during some pairs Alena may be at the university waiting for the upcoming pair.
Input
The first line of the input contains a positive integer n (1 ≤ n ≤ 100) — the number of lessons at the university.
The second line contains n numbers ai (0 ≤ ai ≤ 1). Number ai equals 0, if Alena doesn't have the i-th pairs, otherwise it is equal to 1. Numbers a1, a2, ..., an are separated by spaces.
Output
Print a single number — the number of pairs during which Alena stays at the university.
Examples
Input
5
0 1 0 1 1
Output
4
Input
7
1 0 1 0 0 1 0
Output
4
Input
1
0
Output
0
Note
In the first sample Alena stays at the university from the second to the fifth pair, inclusive, during the third pair she will be it the university waiting for the next pair.
In the last sample Alena doesn't have a single pair, so she spends all the time at home.
Submitted Solution:
```
n = int(input())
s = input().split()
k = l = m = 0
s1 = '1'
s2 = '0'
for i in range(n):
if s[i] == '0' and i == 0 or s[i] == '0' and i == n-1:
continue
elif s[i] == '1':
if l > 1:
continue
else:
k += 1
elif s[i] == '0' and s[i+1] == '0' and i != n-1:
continue
else:
l += 1
print(l + k)
``` | instruction | 0 | 34,729 | 4 | 69,458 |
No | output | 1 | 34,729 | 4 | 69,459 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alena has successfully passed the entrance exams to the university and is now looking forward to start studying.
One two-hour lesson at the Russian university is traditionally called a pair, it lasts for two academic hours (an academic hour is equal to 45 minutes).
The University works in such a way that every day it holds exactly n lessons. Depending on the schedule of a particular group of students, on a given day, some pairs may actually contain classes, but some may be empty (such pairs are called breaks).
The official website of the university has already published the schedule for tomorrow for Alena's group. Thus, for each of the n pairs she knows if there will be a class at that time or not.
Alena's House is far from the university, so if there are breaks, she doesn't always go home. Alena has time to go home only if the break consists of at least two free pairs in a row, otherwise she waits for the next pair at the university.
Of course, Alena does not want to be sleepy during pairs, so she will sleep as long as possible, and will only come to the first pair that is presented in her schedule. Similarly, if there are no more pairs, then Alena immediately goes home.
Alena appreciates the time spent at home, so she always goes home when it is possible, and returns to the university only at the beginning of the next pair. Help Alena determine for how many pairs she will stay at the university. Note that during some pairs Alena may be at the university waiting for the upcoming pair.
Input
The first line of the input contains a positive integer n (1 ≤ n ≤ 100) — the number of lessons at the university.
The second line contains n numbers ai (0 ≤ ai ≤ 1). Number ai equals 0, if Alena doesn't have the i-th pairs, otherwise it is equal to 1. Numbers a1, a2, ..., an are separated by spaces.
Output
Print a single number — the number of pairs during which Alena stays at the university.
Examples
Input
5
0 1 0 1 1
Output
4
Input
7
1 0 1 0 0 1 0
Output
4
Input
1
0
Output
0
Note
In the first sample Alena stays at the university from the second to the fifth pair, inclusive, during the third pair she will be it the university waiting for the next pair.
In the last sample Alena doesn't have a single pair, so she spends all the time at home.
Submitted Solution:
```
def solve(arr,n):
count = 0
for i in range(n-1):
if arr[i] == 0 and arr[i+1] != 0:
count += 1
elif arr[i]:
count += 1
if not arr[-1] and n != 1:
return count -1
return count
def main():
n = int(input())
arr = list(map(int, input().split(' ')))
# for i in range(n):
# arr.append(list(map(int, list(input()))))
print(solve(arr,n))
main()
``` | instruction | 0 | 34,730 | 4 | 69,460 |
No | output | 1 | 34,730 | 4 | 69,461 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alena has successfully passed the entrance exams to the university and is now looking forward to start studying.
One two-hour lesson at the Russian university is traditionally called a pair, it lasts for two academic hours (an academic hour is equal to 45 minutes).
The University works in such a way that every day it holds exactly n lessons. Depending on the schedule of a particular group of students, on a given day, some pairs may actually contain classes, but some may be empty (such pairs are called breaks).
The official website of the university has already published the schedule for tomorrow for Alena's group. Thus, for each of the n pairs she knows if there will be a class at that time or not.
Alena's House is far from the university, so if there are breaks, she doesn't always go home. Alena has time to go home only if the break consists of at least two free pairs in a row, otherwise she waits for the next pair at the university.
Of course, Alena does not want to be sleepy during pairs, so she will sleep as long as possible, and will only come to the first pair that is presented in her schedule. Similarly, if there are no more pairs, then Alena immediately goes home.
Alena appreciates the time spent at home, so she always goes home when it is possible, and returns to the university only at the beginning of the next pair. Help Alena determine for how many pairs she will stay at the university. Note that during some pairs Alena may be at the university waiting for the upcoming pair.
Input
The first line of the input contains a positive integer n (1 ≤ n ≤ 100) — the number of lessons at the university.
The second line contains n numbers ai (0 ≤ ai ≤ 1). Number ai equals 0, if Alena doesn't have the i-th pairs, otherwise it is equal to 1. Numbers a1, a2, ..., an are separated by spaces.
Output
Print a single number — the number of pairs during which Alena stays at the university.
Examples
Input
5
0 1 0 1 1
Output
4
Input
7
1 0 1 0 0 1 0
Output
4
Input
1
0
Output
0
Note
In the first sample Alena stays at the university from the second to the fifth pair, inclusive, during the third pair she will be it the university waiting for the next pair.
In the last sample Alena doesn't have a single pair, so she spends all the time at home.
Submitted Solution:
```
n = int(input())
l = list(map(int,input().split()))
t = 0
for i in range(len(l)-1):
if l[i] == 0:
if i > 0:
if l[i-1] == 1 and l[i+1] == 1:
t = t + 2
elif i < n-1 and l[i+1] == 1:
t = t + 1
elif l[i-1] == 1:
t = t + 1
if i == 0:
if l[i+1] == 1:
t = t + 1
if l[i] == 1 and l[i+1] == 1:
t = t + 1
print(max(t,1))
``` | instruction | 0 | 34,731 | 4 | 69,462 |
No | output | 1 | 34,731 | 4 | 69,463 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given names of two days of the week.
Please, determine whether it is possible that during some non-leap year the first day of some month was equal to the first day of the week you are given, while the first day of the next month was equal to the second day of the week you are given. Both months should belong to one year.
In this problem, we consider the Gregorian calendar to be used. The number of months in this calendar is equal to 12. The number of days in months during any non-leap year is: 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31.
Names of the days of the week are given with lowercase English letters: "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday".
Input
The input consists of two lines, each of them containing the name of exactly one day of the week. It's guaranteed that each string in the input is from the set "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday".
Output
Print "YES" (without quotes) if such situation is possible during some non-leap year. Otherwise, print "NO" (without quotes).
Examples
Input
monday
tuesday
Output
NO
Input
sunday
sunday
Output
YES
Input
saturday
tuesday
Output
YES
Note
In the second sample, one can consider February 1 and March 1 of year 2015. Both these days were Sundays.
In the third sample, one can consider July 1 and August 1 of year 2017. First of these two days is Saturday, while the second one is Tuesday. | instruction | 0 | 34,766 | 4 | 69,532 |
Tags: implementation
Correct Solution:
```
cal = {i:j for i, j in zip('monday tuesday wednesday thursday friday saturday sunday'.split(), range(7))}
fst = cal[input()]
snd = cal[input()]
gre = {0, 2, 3}
print('YES' if (snd - fst) % 7 in gre else 'NO')
``` | output | 1 | 34,766 | 4 | 69,533 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given names of two days of the week.
Please, determine whether it is possible that during some non-leap year the first day of some month was equal to the first day of the week you are given, while the first day of the next month was equal to the second day of the week you are given. Both months should belong to one year.
In this problem, we consider the Gregorian calendar to be used. The number of months in this calendar is equal to 12. The number of days in months during any non-leap year is: 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31.
Names of the days of the week are given with lowercase English letters: "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday".
Input
The input consists of two lines, each of them containing the name of exactly one day of the week. It's guaranteed that each string in the input is from the set "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday".
Output
Print "YES" (without quotes) if such situation is possible during some non-leap year. Otherwise, print "NO" (without quotes).
Examples
Input
monday
tuesday
Output
NO
Input
sunday
sunday
Output
YES
Input
saturday
tuesday
Output
YES
Note
In the second sample, one can consider February 1 and March 1 of year 2015. Both these days were Sundays.
In the third sample, one can consider July 1 and August 1 of year 2017. First of these two days is Saturday, while the second one is Tuesday. | instruction | 0 | 34,767 | 4 | 69,534 |
Tags: implementation
Correct Solution:
```
d1=input()
d2=input()
if d1=='monday':
if d2=='monday' or d2=='wednesday' or d2=='thursday':
print('YES')
else:
print('NO')
if d1=='tuesday':
if d2=='tuesday' or d2=='thursday' or d2=='friday':
print('YES')
else:
print('NO')
if d1=='wednesday':
if d2=='wednesday' or d2=='friday' or d2=='saturday':
print('YES')
else:
print('NO')
if d1=='thursday':
if d2=='thursday' or d2=='saturday' or d2=='sunday':
print('YES')
else:
print('NO')
if d1=='friday':
if d2=='friday' or d2=='sunday' or d2=='monday':
print('YES')
else:
print('NO')
if d1=='saturday':
if d2=='saturday' or d2=='monday' or d2=='tuesday':
print('YES')
else:
print('NO')
if d1=='sunday':
if d2=='sunday' or d2=='tuesday' or d2=='wednesday':
print('YES')
else:
print('NO')
``` | output | 1 | 34,767 | 4 | 69,535 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given names of two days of the week.
Please, determine whether it is possible that during some non-leap year the first day of some month was equal to the first day of the week you are given, while the first day of the next month was equal to the second day of the week you are given. Both months should belong to one year.
In this problem, we consider the Gregorian calendar to be used. The number of months in this calendar is equal to 12. The number of days in months during any non-leap year is: 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31.
Names of the days of the week are given with lowercase English letters: "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday".
Input
The input consists of two lines, each of them containing the name of exactly one day of the week. It's guaranteed that each string in the input is from the set "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday".
Output
Print "YES" (without quotes) if such situation is possible during some non-leap year. Otherwise, print "NO" (without quotes).
Examples
Input
monday
tuesday
Output
NO
Input
sunday
sunday
Output
YES
Input
saturday
tuesday
Output
YES
Note
In the second sample, one can consider February 1 and March 1 of year 2015. Both these days were Sundays.
In the third sample, one can consider July 1 and August 1 of year 2017. First of these two days is Saturday, while the second one is Tuesday. | instruction | 0 | 34,768 | 4 | 69,536 |
Tags: implementation
Correct Solution:
```
a=['su','mo','tu','we','th','fr','sa']
b=a.index(input()[:2])
c=a.index(input()[:2])
print('YES'if (c-b)%7 in[0,2,3]else'NO')
``` | output | 1 | 34,768 | 4 | 69,537 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given names of two days of the week.
Please, determine whether it is possible that during some non-leap year the first day of some month was equal to the first day of the week you are given, while the first day of the next month was equal to the second day of the week you are given. Both months should belong to one year.
In this problem, we consider the Gregorian calendar to be used. The number of months in this calendar is equal to 12. The number of days in months during any non-leap year is: 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31.
Names of the days of the week are given with lowercase English letters: "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday".
Input
The input consists of two lines, each of them containing the name of exactly one day of the week. It's guaranteed that each string in the input is from the set "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday".
Output
Print "YES" (without quotes) if such situation is possible during some non-leap year. Otherwise, print "NO" (without quotes).
Examples
Input
monday
tuesday
Output
NO
Input
sunday
sunday
Output
YES
Input
saturday
tuesday
Output
YES
Note
In the second sample, one can consider February 1 and March 1 of year 2015. Both these days were Sundays.
In the third sample, one can consider July 1 and August 1 of year 2017. First of these two days is Saturday, while the second one is Tuesday. | instruction | 0 | 34,769 | 4 | 69,538 |
Tags: implementation
Correct Solution:
```
week = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"]
days = [31, 28, 31, 30, 31]
m1 = week.index(input())
m2 = week.index(input())
b = False
for i in days:
if (m1+i)%7 == m2:
b = True
break
if b:
print("YES")
else:
print("NO")
``` | output | 1 | 34,769 | 4 | 69,539 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given names of two days of the week.
Please, determine whether it is possible that during some non-leap year the first day of some month was equal to the first day of the week you are given, while the first day of the next month was equal to the second day of the week you are given. Both months should belong to one year.
In this problem, we consider the Gregorian calendar to be used. The number of months in this calendar is equal to 12. The number of days in months during any non-leap year is: 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31.
Names of the days of the week are given with lowercase English letters: "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday".
Input
The input consists of two lines, each of them containing the name of exactly one day of the week. It's guaranteed that each string in the input is from the set "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday".
Output
Print "YES" (without quotes) if such situation is possible during some non-leap year. Otherwise, print "NO" (without quotes).
Examples
Input
monday
tuesday
Output
NO
Input
sunday
sunday
Output
YES
Input
saturday
tuesday
Output
YES
Note
In the second sample, one can consider February 1 and March 1 of year 2015. Both these days were Sundays.
In the third sample, one can consider July 1 and August 1 of year 2017. First of these two days is Saturday, while the second one is Tuesday. | instruction | 0 | 34,770 | 4 | 69,540 |
Tags: implementation
Correct Solution:
```
s=['monday','tuesday','wednesday','thursday','friday','saturday','sunday']
I=input
a=I()
print(['NO','YES'][I()in[s[(s.index(a)+i)%7]for i in (28,30,31)]])
``` | output | 1 | 34,770 | 4 | 69,541 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given names of two days of the week.
Please, determine whether it is possible that during some non-leap year the first day of some month was equal to the first day of the week you are given, while the first day of the next month was equal to the second day of the week you are given. Both months should belong to one year.
In this problem, we consider the Gregorian calendar to be used. The number of months in this calendar is equal to 12. The number of days in months during any non-leap year is: 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31.
Names of the days of the week are given with lowercase English letters: "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday".
Input
The input consists of two lines, each of them containing the name of exactly one day of the week. It's guaranteed that each string in the input is from the set "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday".
Output
Print "YES" (without quotes) if such situation is possible during some non-leap year. Otherwise, print "NO" (without quotes).
Examples
Input
monday
tuesday
Output
NO
Input
sunday
sunday
Output
YES
Input
saturday
tuesday
Output
YES
Note
In the second sample, one can consider February 1 and March 1 of year 2015. Both these days were Sundays.
In the third sample, one can consider July 1 and August 1 of year 2017. First of these two days is Saturday, while the second one is Tuesday. | instruction | 0 | 34,771 | 4 | 69,542 |
Tags: implementation
Correct Solution:
```
f = input()
s = input()
day = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"]
length = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
for i in range(11):
if day[(day.index(f) + length[i]) % 7] == s:
print('YES')
exit()
print('NO')
``` | output | 1 | 34,771 | 4 | 69,543 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.