message stringlengths 2 65.1k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 0 108k | cluster float64 14 14 | __index_level_0__ int64 0 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of languages, which he k... | instruction | 0 | 33,667 | 14 | 67,334 |
Tags: dfs and similar, dsu
Correct Solution:
```
n,m=map(int,input().split())
languages=[ [list(map(int,input().split()))[1:]]+[False] for i in range(n) ]
c=0
w=0
for i in range(len(languages)):
g=languages[i-w][0]
if not g:
c+=1
languages.pop(i-w)
w+=1
def connected(languages,lang):
... | output | 1 | 33,667 | 14 | 67,335 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of languages, which he k... | instruction | 0 | 33,668 | 14 | 67,336 |
Tags: dfs and similar, dsu
Correct Solution:
```
n, m = map(int, input().split())
languages = []
for i in range(n):
languages.append(list(map(int, input().split()))[1:])
languages.insert(0, [])
# print(languages)
neighbors = [[] for i in range( 1 + n)]
# Function to check if employees speak same language
def Spe... | output | 1 | 33,668 | 14 | 67,337 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of languages, which he k... | instruction | 0 | 33,669 | 14 | 67,338 |
Tags: dfs and similar, dsu
Correct Solution:
```
n,m = map(int,input().split())
lang = [set(list(map(int,input().split()))[1:]) for _ in range(n)]
g = {}
count = 0
for i,e in enumerate(lang):
if len(e)!=0:
g[i] = []
for j,o in enumerate(lang):
if i!=j and len(o)!=0:
if le... | output | 1 | 33,669 | 14 | 67,339 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel is participating in a party in Prime Kingdom. There are n foxes there (include Fox Ciel). The i-th fox is ai years old.
They will have dinner around some round tables. You want to distribute foxes such that:
1. Each fox is sitti... | instruction | 0 | 33,781 | 14 | 67,562 |
Tags: flows
Correct Solution:
```
#E
def main():
sieve = [False, True] * 10001
for i in range(3, 140, 2):
if sieve[i]:
j, k = i * 2, i * i
le = (20001 - k) // j + 1
sieve[k::j] = [False] * le
n = int(input())
aa = list(map(int, input().split()))
pp = [-1] ... | output | 1 | 33,781 | 14 | 67,563 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel is participating in a party in Prime Kingdom. There are n foxes there (include Fox Ciel). The i-th fox is ai years old.
They will have dinner around some round tables. You want to distribute foxes such that:
1. Each fox is sitti... | instruction | 0 | 33,782 | 14 | 67,564 |
Tags: flows
Correct Solution:
```
from collections import deque
class Dinic():
def __init__(self, listEdge, s, t):
self.s = s
self.t = t
self.graph = {}
self.maxCap = 1000000
# dict các node lân cận
# e[0]: from, e[1]: to, e[2]: dung luong
fo... | output | 1 | 33,782 | 14 | 67,565 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel is participating in a party in Prime Kingdom. There are n foxes there (include Fox Ciel). The i-th fox is ai years old.
They will have dinner around some round tables. You want to distribute foxes such that:
1. Each fox is sitti... | instruction | 0 | 33,783 | 14 | 67,566 |
Tags: flows
Correct Solution:
```
def main():
sieve = [False, True] * 10001
for i in range(3, 140, 2):
if sieve[i]:
j, k = i * 2, i * i
le = (20001 - k) // j + 1
sieve[k::j] = [False] * le
n = int(input())
aa = list(map(int, input().split()))
pp = [-1] * ... | output | 1 | 33,783 | 14 | 67,567 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Fox Ciel is participating in a party in Prime Kingdom. There are n foxes there (include Fox Ciel). The i-th fox is ai years old.
They will have dinner around some round tables. You want to dist... | instruction | 0 | 33,784 | 14 | 67,568 |
No | output | 1 | 33,784 | 14 | 67,569 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Fox Ciel is participating in a party in Prime Kingdom. There are n foxes there (include Fox Ciel). The i-th fox is ai years old.
They will have dinner around some round tables. You want to dist... | instruction | 0 | 33,785 | 14 | 67,570 |
No | output | 1 | 33,785 | 14 | 67,571 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Innokentiy likes tea very much and today he wants to drink exactly n cups of tea. He would be happy to drink more but he had exactly n tea bags, a of them are green and b are black.
Innokentiy doesn't like to drink the same tea (green or bl... | instruction | 0 | 33,891 | 14 | 67,782 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
from math import ceil
n, k, g, b = map(int, input().split())
if (min(g, b) + 1) * k < max(g, b):
print("NO")
exit()
if g > b:
m = ceil(g / k)
left = b
for i in range(m - 1):
print("G" * k, end="")
if left - k >= (m - i... | output | 1 | 33,891 | 14 | 67,783 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Innokentiy likes tea very much and today he wants to drink exactly n cups of tea. He would be happy to drink more but he had exactly n tea bags, a of them are green and b are black.
Innokentiy doesn't like to drink the same tea (green or bl... | instruction | 0 | 33,892 | 14 | 67,784 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
n,k,a,b = map(int,input().split())
s = 'GB'*min(a,b)
a-=len(s)//2
b-=len(s)//2
if(a!=0):
s+='G'
a-=1
elif b!=0:
s='B'+s
b-=1
cur = 0
m = 1
while(cur!= len(s)):
if(m!=k):
if(s[cur]=='G' and a!=0):
s = s[:cur+1]+'G'+... | output | 1 | 33,892 | 14 | 67,785 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Innokentiy likes tea very much and today he wants to drink exactly n cups of tea. He would be happy to drink more but he had exactly n tea bags, a of them are green and b are black.
Innokentiy doesn't like to drink the same tea (green or bl... | instruction | 0 | 33,893 | 14 | 67,786 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
#PY
n,k,a,b = map(int,input().split())
m1=max(a,b)
m2=min(a,b)
if m1 - (k * m2) > k:
print("NO")
elif a == b:
while a != 0:
print("G",end='')
print("B",end='')
a-=1
elif a > b:
while b!=0 or a!=0:
for i in ran... | output | 1 | 33,893 | 14 | 67,787 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Innokentiy likes tea very much and today he wants to drink exactly n cups of tea. He would be happy to drink more but he had exactly n tea bags, a of them are green and b are black.
Innokentiy doesn't like to drink the same tea (green or bl... | instruction | 0 | 33,894 | 14 | 67,788 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
n, k, a, b = [int(x) for x in input().split()]
if (int(n / (k+1)) > min(a, b)):
print("NO")
else:
actual = (a >= b)
s = ""
letter = ""
m = 0
while(n > 0):
v = int(n / (k+1))
if (v < min(a, b)):
if actu... | output | 1 | 33,894 | 14 | 67,789 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Innokentiy likes tea very much and today he wants to drink exactly n cups of tea. He would be happy to drink more but he had exactly n tea bags, a of them are green and b are black.
Innokentiy doesn't like to drink the same tea (green or bl... | instruction | 0 | 33,895 | 14 | 67,790 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
n, k, a, b = [int(x) for x in input().split()]
s = ""
if (int(n / (k+1)) > min(a, b)):
s = "NO"
else:
actual = (a >= b)
m = 0
while(n > 0):
v = int(n / (k+1))
if (a != b):
if (actual):
m = max(... | output | 1 | 33,895 | 14 | 67,791 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Innokentiy likes tea very much and today he wants to drink exactly n cups of tea. He would be happy to drink more but he had exactly n tea bags, a of them are green and b are black.
Innokentiy doesn't like to drink the same tea (green or bl... | instruction | 0 | 33,896 | 14 | 67,792 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
n, k, a, b = [int(v) for v in input().split()]
# n, k, a, b = 5,1,3,2
# n, k, a, b = 7,2,2,5
# n, k, a, b = 4,3,4,0
G = 'G'
B = 'B'
if a > b:
a, b = b, a
G, B = B, G
ans = []
while b - a > 1 and a >= 1:
take_b = min(k, b - a)
ans.append(B * take_... | output | 1 | 33,896 | 14 | 67,793 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Innokentiy likes tea very much and today he wants to drink exactly n cups of tea. He would be happy to drink more but he had exactly n tea bags, a of them are green and b are black.
Innokentiy doesn't like to drink the same tea (green or bl... | instruction | 0 | 33,897 | 14 | 67,794 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
from collections import *
d = defaultdict()
n,k,a,b = map(int,input().split())
ch = 1
if(a == b):
ch = 2
mx,mn = max(a,b),min(a,b)
if(a>b):
d[mx] = 'G'
d[mn] = 'B'
else:
d[mx] = 'B'
d[mn] = 'G'
o = -((-mx)//(mn+1))
if(o>k):
c... | output | 1 | 33,897 | 14 | 67,795 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Innokentiy likes tea very much and today he wants to drink exactly n cups of tea. He would be happy to drink more but he had exactly n tea bags, a of them are green and b are black.
Innokentiy doesn't like to drink the same tea (green or bl... | instruction | 0 | 33,898 | 14 | 67,796 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
n,k,a,b=map(int,input().split())
acol='G'
bcol='B'
if a>b:
a,b=b,a
acol,bcol=bcol,acol
if b>(a+1)*k:
print("NO")
else:
s=""
num=0
for i in range(n):
if b>a and num<k:
print(bcol,end="")
b-=1
... | output | 1 | 33,898 | 14 | 67,797 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In an embassy of a well-known kingdom an electronic queue is organised. Every person who comes to the embassy, needs to make the following three actions: show the ID, pay money to the cashier and be fingerprinted. Besides, the actions should... | instruction | 0 | 33,950 | 14 | 67,900 |
Tags: data structures, greedy
Correct Solution:
```
from heapq import heappush,heappop
k=list(map(int,input().split()))
t=list(map(int,input().split()))
ans=0
n=int(input())
l=sorted(list(map(int,input().split())))
X=list(l)
for i in range(3):
for j in range(n):
if j>=k[i] and X[j-k[i]]>X[j]:
X[... | output | 1 | 33,950 | 14 | 67,901 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In an embassy of a well-known kingdom an electronic queue is organised. Every person who comes to the embassy, needs to make the following three actions: show the ID, pay money to the cashier and be fingerprinted. Besides, the actions should... | instruction | 0 | 33,951 | 14 | 67,902 |
Tags: data structures, greedy
Correct Solution:
```
q = zip(map(int, input().split()), map(int, input().split()))
n = int(input())
c = list(map(int, input().split()))
d = c[:]
for k, t in q:
for i in range(min(k, n)): c[i] += t
for i in range(k, n): c[i] = max(c[i], c[i - k]) + t
print(max(c[i] - d[i] for i in ... | output | 1 | 33,951 | 14 | 67,903 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Melody Pond was stolen from her parents as a newborn baby by Madame Kovarian, to become a weapon of the Silence in their crusade against the Doctor. Madame Kovarian changed Melody's name to River Song, giving her a new identity that allowed ... | instruction | 0 | 34,335 | 14 | 68,670 |
Tags: brute force, math, number theory
Correct Solution:
```
ans = int(input())
flag = 0
if ans > 1000000000000:
print("NO")
else:
if ans > 3:
x = 1
y = (ans - 3) // 2
if (x ** 2 + 2 * x * y + x + 1) == ans:
print(str(x)+' '+str(y))
flag = 1
if flag == 0:
prin... | output | 1 | 34,335 | 14 | 68,671 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Melody Pond was stolen from her parents as a newborn baby by Madame Kovarian, to become a weapon of the Silence in their crusade against the Doctor. Madame Kovarian changed Melody's name to River Song, giving her a new identity that allowed ... | instruction | 0 | 34,336 | 14 | 68,672 |
Tags: brute force, math, number theory
Correct Solution:
```
r=int(input())
if r&1==0 or r<5:
print ("NO")
else:
print(1,(r-3)//2)
``` | output | 1 | 34,336 | 14 | 68,673 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Melody Pond was stolen from her parents as a newborn baby by Madame Kovarian, to become a weapon of the Silence in their crusade against the Doctor. Madame Kovarian changed Melody's name to River Song, giving her a new identity that allowed ... | instruction | 0 | 34,337 | 14 | 68,674 |
Tags: brute force, math, number theory
Correct Solution:
```
from math import *
r = int(input())
r -= 1
e = False
xx = 0
yy = 0
for i in range(1, int(sqrt(r)) + 1):
i1 = i
r1 = r
if r1 % i1 == 0:
r1 = r1/i1
if ((r1 - i1 - 1) > 0) and ((r1 - i1 - 1) % 2 == 0):
xx = i1
... | output | 1 | 34,337 | 14 | 68,675 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Melody Pond was stolen from her parents as a newborn baby by Madame Kovarian, to become a weapon of the Silence in their crusade against the Doctor. Madame Kovarian changed Melody's name to River Song, giving her a new identity that allowed ... | instruction | 0 | 34,338 | 14 | 68,676 |
Tags: brute force, math, number theory
Correct Solution:
```
n = int(input())
if(n % 2 == 1):
if(n <= 3):
print("NO")
else:
print("1 " + str((n - 3) // 2))
else:
print("NO")
``` | output | 1 | 34,338 | 14 | 68,677 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Melody Pond was stolen from her parents as a newborn baby by Madame Kovarian, to become a weapon of the Silence in their crusade against the Doctor. Madame Kovarian changed Melody's name to River Song, giving her a new identity that allowed ... | instruction | 0 | 34,339 | 14 | 68,678 |
Tags: brute force, math, number theory
Correct Solution:
```
r=int(input())
y=0
x=1
cnt=0
while True:
y=(r-1-x-x*x)/(2*x)
s=int(y)
if y<=0:
break
if y==s:
cnt=1
break
else:
x+=1
if cnt==1:
print(x,s)
else :
print("NO")
``` | output | 1 | 34,339 | 14 | 68,679 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Melody Pond was stolen from her parents as a newborn baby by Madame Kovarian, to become a weapon of the Silence in their crusade against the Doctor. Madame Kovarian changed Melody's name to River Song, giving her a new identity that allowed ... | instruction | 0 | 34,340 | 14 | 68,680 |
Tags: brute force, math, number theory
Correct Solution:
```
def prime_factors(n):
i = 2
factors = []
while i * i <= n:
if n % i:
i += 1
else:
n //= i
factors.append(i)
if n > 1:
factors.append(n)
return factors
def factors(n):
super=[... | output | 1 | 34,340 | 14 | 68,681 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Melody Pond was stolen from her parents as a newborn baby by Madame Kovarian, to become a weapon of the Silence in their crusade against the Doctor. Madame Kovarian changed Melody's name to River Song, giving her a new identity that allowed ... | instruction | 0 | 34,341 | 14 | 68,682 |
Tags: brute force, math, number theory
Correct Solution:
```
from math import sqrt
def get_int():
from sys import stdin
return int(stdin.readline().replace('\n', ''))
def is_even(n):
return n%2 == 0
def heidi_hash(r):
k = r-1
rt = int(sqrt(k))
for x in range(1, rt+2):
if k % x == 0:
... | output | 1 | 34,341 | 14 | 68,683 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Melody Pond was stolen from her parents as a newborn baby by Madame Kovarian, to become a weapon of the Silence in their crusade against the Doctor. Madame Kovarian changed Melody's name to Rive... | instruction | 0 | 34,342 | 14 | 68,684 |
Yes | output | 1 | 34,342 | 14 | 68,685 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Melody Pond was stolen from her parents as a newborn baby by Madame Kovarian, to become a weapon of the Silence in their crusade against the Doctor. Madame Kovarian changed Melody's name to Rive... | instruction | 0 | 34,343 | 14 | 68,686 |
Yes | output | 1 | 34,343 | 14 | 68,687 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Melody Pond was stolen from her parents as a newborn baby by Madame Kovarian, to become a weapon of the Silence in their crusade against the Doctor. Madame Kovarian changed Melody's name to Rive... | instruction | 0 | 34,344 | 14 | 68,688 |
Yes | output | 1 | 34,344 | 14 | 68,689 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Melody Pond was stolen from her parents as a newborn baby by Madame Kovarian, to become a weapon of the Silence in their crusade against the Doctor. Madame Kovarian changed Melody's name to Rive... | instruction | 0 | 34,345 | 14 | 68,690 |
Yes | output | 1 | 34,345 | 14 | 68,691 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Melody Pond was stolen from her parents as a newborn baby by Madame Kovarian, to become a weapon of the Silence in their crusade against the Doctor. Madame Kovarian changed Melody's name to Rive... | instruction | 0 | 34,346 | 14 | 68,692 |
No | output | 1 | 34,346 | 14 | 68,693 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Melody Pond was stolen from her parents as a newborn baby by Madame Kovarian, to become a weapon of the Silence in their crusade against the Doctor. Madame Kovarian changed Melody's name to Rive... | instruction | 0 | 34,347 | 14 | 68,694 |
No | output | 1 | 34,347 | 14 | 68,695 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Melody Pond was stolen from her parents as a newborn baby by Madame Kovarian, to become a weapon of the Silence in their crusade against the Doctor. Madame Kovarian changed Melody's name to Rive... | instruction | 0 | 34,348 | 14 | 68,696 |
No | output | 1 | 34,348 | 14 | 68,697 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Melody Pond was stolen from her parents as a newborn baby by Madame Kovarian, to become a weapon of the Silence in their crusade against the Doctor. Madame Kovarian changed Melody's name to Rive... | instruction | 0 | 34,349 | 14 | 68,698 |
No | output | 1 | 34,349 | 14 | 68,699 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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... | instruction | 0 | 34,716 | 14 | 69,432 |
Tags: implementation
Correct Solution:
```
n = int(input())
a = list(map(int, input().split()))
count = 0
i = 0
while i < n and a[i] == 0:
i += 1
while i < n:
if a[i] == 1:
i += 1
count += 1
else:
tmp = 0
while i < n and a[i] == 0:
tmp += 1
i += 1
... | output | 1 | 34,716 | 14 | 69,433 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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... | instruction | 0 | 34,717 | 14 | 69,434 |
Tags: implementation
Correct Solution:
```
import re
input()
print(len("".join(re.split('00+', input().replace(' ', '').strip('0')))))
``` | output | 1 | 34,717 | 14 | 69,435 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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... | instruction | 0 | 34,718 | 14 | 69,436 |
Tags: implementation
Correct Solution:
```
import sys
def solve(v, n):
start = n
for i in range(n):
if(v[i] == 1):
start = i
break
end = -1
for i in range(n-1, -1, -1):
if(v[i] == 1):
end = i+1
break
resp = end-start
# print(start, end, resp)
if(resp > 1):
zeros = 0
... | output | 1 | 34,718 | 14 | 69,437 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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... | instruction | 0 | 34,719 | 14 | 69,438 |
Tags: implementation
Correct Solution:
```
import sys
n = int(input())
v = list(map(int, input().split()))
for i in range(2, n):
if v[i] + v[i - 2] == 2: v[i - 1] = 1
print(sum(v))
``` | output | 1 | 34,719 | 14 | 69,439 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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... | instruction | 0 | 34,720 | 14 | 69,440 |
Tags: implementation
Correct Solution:
```
# ===================================
# (c) MidAndFeed aka ASilentVoice
# ===================================
# import math, fractions, collections
# ===================================
n = int(input())
q = [int(x) for x in input().split()]
go = 0
ans = 0
for i in range(n):
i... | output | 1 | 34,720 | 14 | 69,441 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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... | instruction | 0 | 34,721 | 14 | 69,442 |
Tags: implementation
Correct Solution:
```
def main():
n = int(input())
a = list(map(int, input().split()))
cnt = 0
ans = 0
i = 0
while i < n:
if a[i] == 1:
break
i += 1
while i < n:
cnt = 0
if a[i] == 0:
while i < n and a[i] == 0:
... | output | 1 | 34,721 | 14 | 69,443 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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... | instruction | 0 | 34,722 | 14 | 69,444 |
Tags: implementation
Correct Solution:
```
#!/usr/bin/python3.5
n=int(input())
s=[int(x) for x in input().split()]
p,o,=0,0
for i in range(n):
if s[i]:
p+=1
o=1
elif not(o):
continue
elif i<n-1:
if s[i+1] and s[i-1]:
p+=1
print(p)
``` | output | 1 | 34,722 | 14 | 69,445 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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... | instruction | 0 | 34,723 | 14 | 69,446 |
Tags: implementation
Correct Solution:
```
n = int(input())
a = [int(x) for x in input().split()]
time = 0
try:
start = a.index(1)
except:
print(0)
exit()
current = a[start]
zero_in_row = 0
f = lambda x: 1 if x == 1 else 0
for i in range(start, n):
if a[i] == 1:
time += f(zero_in_row)
z... | output | 1 | 34,723 | 14 | 69,447 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Statistics claims that students sleep no more than three hours a day. But even in the world of their dreams, while they are snoring peacefully, the sense of impending doom is still upon them.
A poor student is dreaming that he is sitting th... | instruction | 0 | 34,748 | 14 | 69,496 |
Tags: greedy, math
Correct Solution:
```
al, ar = map(int, input().split())
bl, br = map(int, input().split())
if al-1<=br<=2*al+2 or ar-1<=bl<=2*ar+2:
print("YES")
else:
print("NO")
``` | output | 1 | 34,748 | 14 | 69,497 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Statistics claims that students sleep no more than three hours a day. But even in the world of their dreams, while they are snoring peacefully, the sense of impending doom is still upon them.
A poor student is dreaming that he is sitting th... | instruction | 0 | 34,749 | 14 | 69,498 |
Tags: greedy, math
Correct Solution:
```
girl = list(map(int, input().split()))
boy = list(map(int, input().split()))
def compatible(b, g):
return (g - 1) <= b <= (g + 1) * 2
if compatible(boy[0], girl[1]) or compatible(boy[1], girl[0]):
print('YES')
else:
print('NO')
``` | output | 1 | 34,749 | 14 | 69,499 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Statistics claims that students sleep no more than three hours a day. But even in the world of their dreams, while they are snoring peacefully, the sense of impending doom is still upon them.
A poor student is dreaming that he is sitting th... | instruction | 0 | 34,750 | 14 | 69,500 |
Tags: greedy, math
Correct Solution:
```
f=lambda:map(int,input().split())
dl,dr=f()
ml,mr=f()
def chk(d,m):
return d-2<m and m<2*d+3
if chk(dl,mr) or chk(dr,ml):
print("YES")
else:
print("NO")
``` | output | 1 | 34,750 | 14 | 69,501 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Statistics claims that students sleep no more than three hours a day. But even in the world of their dreams, while they are snoring peacefully, the sense of impending doom is still upon them.
A poor student is dreaming that he is sitting th... | instruction | 0 | 34,751 | 14 | 69,502 |
Tags: greedy, math
Correct Solution:
```
def fun(x,y):
if y>=x-1:
s=1
else:
s=0
if y%2==0:
t=(y/2)-1
else:
t=int(y/2)
if x>=t:
w=1
else:
w=0
if w*s==1:
return 1
else:
return 0
a,b=map(int,input().split())
c,d=map(int,input()... | output | 1 | 34,751 | 14 | 69,503 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Statistics claims that students sleep no more than three hours a day. But even in the world of their dreams, while they are snoring peacefully, the sense of impending doom is still upon them.
A poor student is dreaming that he is sitting th... | instruction | 0 | 34,752 | 14 | 69,504 |
Tags: greedy, math
Correct Solution:
```
import sys
import math
import collections
import heapq
import decimal
input=sys.stdin.readline
a,b=(int(i) for i in input().split())
c,d=(int(i) for i in input().split())
def check(i,j):
if((j>=i-1 and j<=(i+1)*2) or (i>=(j-1)//2 and i<=j+1)):
return True
else:
... | output | 1 | 34,752 | 14 | 69,505 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Statistics claims that students sleep no more than three hours a day. But even in the world of their dreams, while they are snoring peacefully, the sense of impending doom is still upon them.
A poor student is dreaming that he is sitting th... | instruction | 0 | 34,753 | 14 | 69,506 |
Tags: greedy, math
Correct Solution:
```
r=lambda g,b: g-1<=b<=2*(g+1)
a,b=map(int,input().split())
c,d=map(int,input().split())
if r(a,d) or r(b,c):print("YES")
else:print("NO")
``` | output | 1 | 34,753 | 14 | 69,507 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Statistics claims that students sleep no more than three hours a day. But even in the world of their dreams, while they are snoring peacefully, the sense of impending doom is still upon them.
A poor student is dreaming that he is sitting th... | instruction | 0 | 34,754 | 14 | 69,508 |
Tags: greedy, math
Correct Solution:
```
l_g, r_g = [int(x) for x in input().split()]
l_b, r_b = [int(x) for x in input().split()]
def is_okay(g, b):
if g >= (b + 2):
return False
if b >= (((g + 1) * 2) + 1):
return False
return True
if any([is_okay(l_g, r_b), is_okay(r_g, l_b)]):
prin... | output | 1 | 34,754 | 14 | 69,509 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Statistics claims that students sleep no more than three hours a day. But even in the world of their dreams, while they are snoring peacefully, the sense of impending doom is still upon them.
A poor student is dreaming that he is sitting th... | instruction | 0 | 34,755 | 14 | 69,510 |
Tags: greedy, math
Correct Solution:
```
gl, gr = map(int, input().split())
bl, br = map(int, input().split())
if (br >= gl-1 and br <= (gl+1)*2) or (bl >= gr-1 and bl <= (gr+1)*2):
print('YES')
else:
print('NO')
``` | output | 1 | 34,755 | 14 | 69,511 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Statistics claims that students sleep no more than three hours a day. But even in the world of their dreams, while they are snoring peacefully, the sense of impending doom is still upon them.
A... | instruction | 0 | 34,761 | 14 | 69,522 |
No | output | 1 | 34,761 | 14 | 69,523 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.