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.
Taro's summer vacation starts tomorrow, and he has decided to make plans for it now.
The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activit... | instruction | 0 | 41,886 | 4 | 83,772 |
Yes | output | 1 | 41,886 | 4 | 83,773 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Taro's summer vacation starts tomorrow, and he has decided to make plans for it now.
The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activit... | instruction | 0 | 41,887 | 4 | 83,774 |
Yes | output | 1 | 41,887 | 4 | 83,775 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Taro's summer vacation starts tomorrow, and he has decided to make plans for it now.
The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activit... | instruction | 0 | 41,888 | 4 | 83,776 |
Yes | output | 1 | 41,888 | 4 | 83,777 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Taro's summer vacation starts tomorrow, and he has decided to make plans for it now.
The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activit... | instruction | 0 | 41,889 | 4 | 83,778 |
No | output | 1 | 41,889 | 4 | 83,779 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Taro's summer vacation starts tomorrow, and he has decided to make plans for it now.
The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activit... | instruction | 0 | 41,890 | 4 | 83,780 |
No | output | 1 | 41,890 | 4 | 83,781 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Taro's summer vacation starts tomorrow, and he has decided to make plans for it now.
The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activit... | instruction | 0 | 41,891 | 4 | 83,782 |
No | output | 1 | 41,891 | 4 | 83,783 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Taro's summer vacation starts tomorrow, and he has decided to make plans for it now.
The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activit... | instruction | 0 | 41,892 | 4 | 83,784 |
No | output | 1 | 41,892 | 4 | 83,785 |
Provide a correct Python 3 solution for this coding contest problem.
The appearance of the sun is called "sunrise" and the hiding is called "sunset". What is the exact time when the sun is on the horizon?
As shown in the figure below, we will represent the sun as a circle and the horizon as a straight line. At this t... | instruction | 0 | 41,995 | 4 | 83,990 |
"Correct Solution:
```
def f(h,r):
ret = r+h
if ret != 0:
ret //= abs(ret)
return ret
def main():
h,r = map(int,input().split())
print(f(h,r))
if __name__ == '__main__':
main()
``` | output | 1 | 41,995 | 4 | 83,991 |
Provide a correct Python 3 solution for this coding contest problem.
The appearance of the sun is called "sunrise" and the hiding is called "sunset". What is the exact time when the sun is on the horizon?
As shown in the figure below, we will represent the sun as a circle and the horizon as a straight line. At this t... | instruction | 0 | 41,996 | 4 | 83,992 |
"Correct Solution:
```
h, r = map(int, input().split())
if h >= r or h >= 0: print(1)
else: print(0 if h + r == 0 else -1)
``` | output | 1 | 41,996 | 4 | 83,993 |
Provide a correct Python 3 solution for this coding contest problem.
The appearance of the sun is called "sunrise" and the hiding is called "sunset". What is the exact time when the sun is on the horizon?
As shown in the figure below, we will represent the sun as a circle and the horizon as a straight line. At this t... | instruction | 0 | 41,997 | 4 | 83,994 |
"Correct Solution:
```
H,R = map(int,input().split())
if H>=0:
print(1)
elif H<0:
if H+R>0:
print(1)
elif H+R==0:
print(0)
else:
print(-1)
``` | output | 1 | 41,997 | 4 | 83,995 |
Provide a correct Python 3 solution for this coding contest problem.
The appearance of the sun is called "sunrise" and the hiding is called "sunset". What is the exact time when the sun is on the horizon?
As shown in the figure below, we will represent the sun as a circle and the horizon as a straight line. At this t... | instruction | 0 | 41,998 | 4 | 83,996 |
"Correct Solution:
```
h, r = map(int, input().split())
if h + r == 0:
print(0)
elif h + r > 0:
print(1)
else:
print(-1)
``` | output | 1 | 41,998 | 4 | 83,997 |
Provide a correct Python 3 solution for this coding contest problem.
The appearance of the sun is called "sunrise" and the hiding is called "sunset". What is the exact time when the sun is on the horizon?
As shown in the figure below, we will represent the sun as a circle and the horizon as a straight line. At this t... | instruction | 0 | 41,999 | 4 | 83,998 |
"Correct Solution:
```
H, R = map(int, input().split())
if H*(-1) == R: print(0)
elif H*(-1) > R: print(-1)
elif H*(-1) < R: print(1)
``` | output | 1 | 41,999 | 4 | 83,999 |
Provide a correct Python 3 solution for this coding contest problem.
The appearance of the sun is called "sunrise" and the hiding is called "sunset". What is the exact time when the sun is on the horizon?
As shown in the figure below, we will represent the sun as a circle and the horizon as a straight line. At this t... | instruction | 0 | 42,000 | 4 | 84,000 |
"Correct Solution:
```
h,r=map(int, input().split())
if h+r>0:
print(1)
elif h+r==0:
print(0)
else:
print(-1)
``` | output | 1 | 42,000 | 4 | 84,001 |
Provide a correct Python 3 solution for this coding contest problem.
The appearance of the sun is called "sunrise" and the hiding is called "sunset". What is the exact time when the sun is on the horizon?
As shown in the figure below, we will represent the sun as a circle and the horizon as a straight line. At this t... | instruction | 0 | 42,001 | 4 | 84,002 |
"Correct Solution:
```
#標準入力
i = sum(list(map(int,input().split())))
#2数の合計が0なら0負の数なら-1正の数なら1を出力する
if i == 0:print("0")
elif i > 0:print("1")
else:print("-1")
``` | output | 1 | 42,001 | 4 | 84,003 |
Provide a correct Python 3 solution for this coding contest problem.
The appearance of the sun is called "sunrise" and the hiding is called "sunset". What is the exact time when the sun is on the horizon?
As shown in the figure below, we will represent the sun as a circle and the horizon as a straight line. At this t... | instruction | 0 | 42,002 | 4 | 84,004 |
"Correct Solution:
```
H, R = map(int, input().split())
if H + R > 0 :
print(1)
elif H + R == 0 :
print(0)
else :
print(-1)
``` | output | 1 | 42,002 | 4 | 84,005 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The appearance of the sun is called "sunrise" and the hiding is called "sunset". What is the exact time when the sun is on the horizon?
As shown in the figure below, we will represent the sun a... | instruction | 0 | 42,003 | 4 | 84,006 |
Yes | output | 1 | 42,003 | 4 | 84,007 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The appearance of the sun is called "sunrise" and the hiding is called "sunset". What is the exact time when the sun is on the horizon?
As shown in the figure below, we will represent the sun a... | instruction | 0 | 42,004 | 4 | 84,008 |
Yes | output | 1 | 42,004 | 4 | 84,009 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The appearance of the sun is called "sunrise" and the hiding is called "sunset". What is the exact time when the sun is on the horizon?
As shown in the figure below, we will represent the sun a... | instruction | 0 | 42,005 | 4 | 84,010 |
Yes | output | 1 | 42,005 | 4 | 84,011 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The appearance of the sun is called "sunrise" and the hiding is called "sunset". What is the exact time when the sun is on the horizon?
As shown in the figure below, we will represent the sun a... | instruction | 0 | 42,006 | 4 | 84,012 |
Yes | output | 1 | 42,006 | 4 | 84,013 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The appearance of the sun is called "sunrise" and the hiding is called "sunset". What is the exact time when the sun is on the horizon?
As shown in the figure below, we will represent the sun a... | instruction | 0 | 42,007 | 4 | 84,014 |
No | output | 1 | 42,007 | 4 | 84,015 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The appearance of the sun is called "sunrise" and the hiding is called "sunset". What is the exact time when the sun is on the horizon?
As shown in the figure below, we will represent the sun a... | instruction | 0 | 42,008 | 4 | 84,016 |
No | output | 1 | 42,008 | 4 | 84,017 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The appearance of the sun is called "sunrise" and the hiding is called "sunset". What is the exact time when the sun is on the horizon?
As shown in the figure below, we will represent the sun a... | instruction | 0 | 42,009 | 4 | 84,018 |
No | output | 1 | 42,009 | 4 | 84,019 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The appearance of the sun is called "sunrise" and the hiding is called "sunset". What is the exact time when the sun is on the horizon?
As shown in the figure below, we will represent the sun a... | instruction | 0 | 42,010 | 4 | 84,020 |
No | output | 1 | 42,010 | 4 | 84,021 |
Provide a correct Python 3 solution for this coding contest problem.
Generalized leap year
Normally, whether or not the year x is a leap year is defined as follows.
1. If x is a multiple of 400, it is a leap year.
2. Otherwise, if x is a multiple of 100, it is not a leap year.
3. Otherwise, if x is a multiple of 4, ... | instruction | 0 | 42,059 | 4 | 84,118 |
"Correct Solution:
```
while 1:
n,l,r=map(int, input().split())
if n==0:
break
a = []
for i in range(n):
a.append(int(input()))
c = 0
for j in range(l, r+1):
for i in range(n):
if j%a[i]==0:
if i%2==1:
break
... | output | 1 | 42,059 | 4 | 84,119 |
Provide a correct Python 3 solution for this coding contest problem.
Generalized leap year
Normally, whether or not the year x is a leap year is defined as follows.
1. If x is a multiple of 400, it is a leap year.
2. Otherwise, if x is a multiple of 100, it is not a leap year.
3. Otherwise, if x is a multiple of 4, ... | instruction | 0 | 42,060 | 4 | 84,120 |
"Correct Solution:
```
# AOJ 2882: Generalized Leap Years
# Python3 2018.7.10 bal4u
while True:
n, l, r = map(int, input().split())
if n == 0: break
A = [int(input()) for i in range(n)][::-1]
y = [0]*(r+1)
v = 2 - (n&1) # v = 1 if n is odd
for a in A:
for i in range(a, r+1, a): y[i] = v
v = 3-v
ans = k = 0
... | output | 1 | 42,060 | 4 | 84,121 |
Provide a correct Python 3 solution for this coding contest problem.
Generalized leap year
Normally, whether or not the year x is a leap year is defined as follows.
1. If x is a multiple of 400, it is a leap year.
2. Otherwise, if x is a multiple of 100, it is not a leap year.
3. Otherwise, if x is a multiple of 4, ... | instruction | 0 | 42,061 | 4 | 84,122 |
"Correct Solution:
```
import math
for i in range(50):
n,l,r=map(int,input().split())
if n==0 and l==0 and r==0:
break
else:
a=[]
for ii in range(n):
a.append(int(input()))
ans=0
for k in range(l,r+1):
for s in range(math.ceil(n/2)):
if k%a[2*s]==0:
ans+=1
break
elif 2*s+1==n :... | output | 1 | 42,061 | 4 | 84,123 |
Provide a correct Python 3 solution for this coding contest problem.
Generalized leap year
Normally, whether or not the year x is a leap year is defined as follows.
1. If x is a multiple of 400, it is a leap year.
2. Otherwise, if x is a multiple of 100, it is not a leap year.
3. Otherwise, if x is a multiple of 4, ... | instruction | 0 | 42,062 | 4 | 84,124 |
"Correct Solution:
```
while True:
n, r, l = map(int, input().split())
if n == 0:
break
else:
a = []
for i in range(n):
a.append(int(input()))
a.append(1)
count = 0
for i in range(r, l + 1):
for j in range(n + 1):
if i %... | output | 1 | 42,062 | 4 | 84,125 |
Provide a correct Python 3 solution for this coding contest problem.
Generalized leap year
Normally, whether or not the year x is a leap year is defined as follows.
1. If x is a multiple of 400, it is a leap year.
2. Otherwise, if x is a multiple of 100, it is not a leap year.
3. Otherwise, if x is a multiple of 4, ... | instruction | 0 | 42,063 | 4 | 84,126 |
"Correct Solution:
```
while True:
n, l, r = map(int, input().split())
if n == 0 and l == 0 and r == 0:
break
else:
a = [0 for i in range(n)]
for i in range(n):
aa = int(input())
a[i] = aa
cnt = 0
for x in range(l, r + 1):
flag = False
for i in range(n):
if x % ... | output | 1 | 42,063 | 4 | 84,127 |
Provide a correct Python 3 solution for this coding contest problem.
Generalized leap year
Normally, whether or not the year x is a leap year is defined as follows.
1. If x is a multiple of 400, it is a leap year.
2. Otherwise, if x is a multiple of 100, it is not a leap year.
3. Otherwise, if x is a multiple of 4, ... | instruction | 0 | 42,064 | 4 | 84,128 |
"Correct Solution:
```
while True:
n, l, r = map(int, input().split())
if n == 0: break
A = [int(input()) for i in range(n)][::-1]
y = [0]*(r+1)
v = 2 - (n&1) # v = 1 if n is odd
for a in A:
for i in range(a, r+1, a): y[i] = v
v = 3-v
ans = k = 0
for i in range(l, r+1):... | output | 1 | 42,064 | 4 | 84,129 |
Provide a correct Python 3 solution for this coding contest problem.
Generalized leap year
Normally, whether or not the year x is a leap year is defined as follows.
1. If x is a multiple of 400, it is a leap year.
2. Otherwise, if x is a multiple of 100, it is not a leap year.
3. Otherwise, if x is a multiple of 4, ... | instruction | 0 | 42,065 | 4 | 84,130 |
"Correct Solution:
```
while True:
n, l, r = map(int, input().split())
if n == 0:
break
a = []
for i in range(n):
a.append(int(input()))
a.append(1)
cnt = 0
for i in range(l, r+1):
for j in range(n+1):
if i % a[j] == 0:
if j % 2 == 0:
... | output | 1 | 42,065 | 4 | 84,131 |
Provide a correct Python 3 solution for this coding contest problem.
Generalized leap year
Normally, whether or not the year x is a leap year is defined as follows.
1. If x is a multiple of 400, it is a leap year.
2. Otherwise, if x is a multiple of 100, it is not a leap year.
3. Otherwise, if x is a multiple of 4, ... | instruction | 0 | 42,066 | 4 | 84,132 |
"Correct Solution:
```
while 1:
n, l, r = map(int, input().split())
if n == 0:
break
data = []
for _ in range(n):
data.append(int(input()))
cnt = 0
for i in range(l, r+1):
for j, d in enumerate(data):
if i % d == 0:
if j % 2 == 0:
... | output | 1 | 42,066 | 4 | 84,133 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Generalized leap year
Normally, whether or not the year x is a leap year is defined as follows.
1. If x is a multiple of 400, it is a leap year.
2. Otherwise, if x is a multiple of 100, it is ... | instruction | 0 | 42,067 | 4 | 84,134 |
Yes | output | 1 | 42,067 | 4 | 84,135 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Generalized leap year
Normally, whether or not the year x is a leap year is defined as follows.
1. If x is a multiple of 400, it is a leap year.
2. Otherwise, if x is a multiple of 100, it is ... | instruction | 0 | 42,068 | 4 | 84,136 |
Yes | output | 1 | 42,068 | 4 | 84,137 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Generalized leap year
Normally, whether or not the year x is a leap year is defined as follows.
1. If x is a multiple of 400, it is a leap year.
2. Otherwise, if x is a multiple of 100, it is ... | instruction | 0 | 42,069 | 4 | 84,138 |
Yes | output | 1 | 42,069 | 4 | 84,139 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Generalized leap year
Normally, whether or not the year x is a leap year is defined as follows.
1. If x is a multiple of 400, it is a leap year.
2. Otherwise, if x is a multiple of 100, it is ... | instruction | 0 | 42,070 | 4 | 84,140 |
Yes | output | 1 | 42,070 | 4 | 84,141 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Generalized leap year
Normally, whether or not the year x is a leap year is defined as follows.
1. If x is a multiple of 400, it is a leap year.
2. Otherwise, if x is a multiple of 100, it is ... | instruction | 0 | 42,071 | 4 | 84,142 |
No | output | 1 | 42,071 | 4 | 84,143 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Generalized leap year
Normally, whether or not the year x is a leap year is defined as follows.
1. If x is a multiple of 400, it is a leap year.
2. Otherwise, if x is a multiple of 100, it is ... | instruction | 0 | 42,072 | 4 | 84,144 |
No | output | 1 | 42,072 | 4 | 84,145 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Scientists say a lot about the problems of global warming and cooling of the Earth. Indeed, such natural phenomena strongly influence all life on our planet.
Our hero Vasya is quite concerned about the problems. He decided to try a little e... | instruction | 0 | 42,370 | 4 | 84,740 |
Tags: dp, implementation
Correct Solution:
```
'''
Auther: ghoshashis545 Ashis Ghosh
College: jalpaiguri Govt Enggineerin College
Date:07/06/2020
'''
from os import path
import sys
from functools import cmp_to_key as ctk
from collections import deque,defaultdict as dd
from bisect import bisect,bisect_left... | output | 1 | 42,370 | 4 | 84,741 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Scientists say a lot about the problems of global warming and cooling of the Earth. Indeed, such natural phenomena strongly influence all life on our planet.
Our hero Vasya is quite concerned about the problems. He decided to try a little e... | instruction | 0 | 42,371 | 4 | 84,742 |
Tags: dp, implementation
Correct Solution:
```
import sys
import os.path
if os.path.exists('input.txt'):
sys.stdin = open('input.txt','r')
sys.stdout = open('output.txt','w')
n=int(input())
l=list(map(int,input().split()))
neg=[0]*(n)
pos=[0]*(n)
if l[0]>=0:
pos[0]=1
for i in range(1,n):
if l[i]>=0:
... | output | 1 | 42,371 | 4 | 84,743 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Scientists say a lot about the problems of global warming and cooling of the Earth. Indeed, such natural phenomena strongly influence all life on our planet.
Our hero Vasya is quite concerned about the problems. He decided to try a little e... | instruction | 0 | 42,372 | 4 | 84,744 |
Tags: dp, implementation
Correct Solution:
```
# aadiupadhyay
import sys
from collections import *
import os.path
mod = 1000000007
INF = float('inf')
def st(): return list(sys.stdin.readline().strip())
def li(): return list(map(int, sys.stdin.readline().split()))
def mp(): return map(int, sys.stdin.readline().split())
... | output | 1 | 42,372 | 4 | 84,745 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Scientists say a lot about the problems of global warming and cooling of the Earth. Indeed, such natural phenomena strongly influence all life on our planet.
Our hero Vasya is quite concerned a... | instruction | 0 | 42,373 | 4 | 84,746 |
No | output | 1 | 42,373 | 4 | 84,747 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Scientists say a lot about the problems of global warming and cooling of the Earth. Indeed, such natural phenomena strongly influence all life on our planet.
Our hero Vasya is quite concerned a... | instruction | 0 | 42,374 | 4 | 84,748 |
No | output | 1 | 42,374 | 4 | 84,749 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Scientists say a lot about the problems of global warming and cooling of the Earth. Indeed, such natural phenomena strongly influence all life on our planet.
Our hero Vasya is quite concerned a... | instruction | 0 | 42,375 | 4 | 84,750 |
No | output | 1 | 42,375 | 4 | 84,751 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Scientists say a lot about the problems of global warming and cooling of the Earth. Indeed, such natural phenomena strongly influence all life on our planet.
Our hero Vasya is quite concerned a... | instruction | 0 | 42,376 | 4 | 84,752 |
No | output | 1 | 42,376 | 4 | 84,753 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently, you bought a brand new smart lamp with programming features. At first, you set up a schedule to the lamp. Every day it will turn power on at moment 0 and turn power off at moment M. Moreover, the lamp allows you to set a program of... | instruction | 0 | 42,896 | 4 | 85,792 |
Tags: greedy
Correct Solution:
```
f = 1 #switch
n, M = map(int, input().split())
a = [0] + [int(x) for x in input().split()] + [M]
b = [0]*(n+2)
for i in range(1,n+1):
b[i] = b[i-1] + f*(a[i]-a[i-1])
f ^= 1 #0->1 or 1->0
b[n+1] = b[n] + f*(M-a[n])
ans = b[n+1] #untouched
for i in range(1,n+2):
if (... | output | 1 | 42,896 | 4 | 85,793 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently, you bought a brand new smart lamp with programming features. At first, you set up a schedule to the lamp. Every day it will turn power on at moment 0 and turn power off at moment M. Moreover, the lamp allows you to set a program of... | instruction | 0 | 42,897 | 4 | 85,794 |
Tags: greedy
Correct Solution:
```
from itertools import*
R=lambda:map(int,input().split())
n,m=R()
a=[0,*R()]+[m]*(n%2+1)
d=[*map(lambda x,y:x-y,a[1:],a)]
print(sum(d[::2])+max(0,max(accumulate(d[i-1]-d[i]for i
in range(n+n%2,0,-2)))-1))
``` | output | 1 | 42,897 | 4 | 85,795 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently, you bought a brand new smart lamp with programming features. At first, you set up a schedule to the lamp. Every day it will turn power on at moment 0 and turn power off at moment M. Moreover, the lamp allows you to set a program of... | instruction | 0 | 42,898 | 4 | 85,796 |
Tags: greedy
Correct Solution:
```
_, M = input().split()
a = map(int, (input()+' '+M).split())
# Patch defines the start of ON or OFF area
# Since area starts with ON, patch is true
patch = True
max = 0
on_before = off_before = 0
previous = 0
for x in a:
if patch:
# If at the beginning of ON patch,
... | output | 1 | 42,898 | 4 | 85,797 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently, you bought a brand new smart lamp with programming features. At first, you set up a schedule to the lamp. Every day it will turn power on at moment 0 and turn power off at moment M. Moreover, the lamp allows you to set a program of... | instruction | 0 | 42,899 | 4 | 85,798 |
Tags: greedy
Correct Solution:
```
n,m=map(int,input().strip().split())
l=list(map(int,input().strip().split()))
l.insert(0,0)
l.append(m)
lc=[]
lo=[]
on=0
off=0
lo.append([0,0])
for i in range(1,n+2):
if (i%2==1):
on=on+l[i]-l[i-1]
else:
off=off+l[i]-l[i-1]
lo.append([on,off])
max1=on
lc.append([on,off])
for i ... | output | 1 | 42,899 | 4 | 85,799 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently, you bought a brand new smart lamp with programming features. At first, you set up a schedule to the lamp. Every day it will turn power on at moment 0 and turn power off at moment M. Moreover, the lamp allows you to set a program of... | instruction | 0 | 42,900 | 4 | 85,800 |
Tags: greedy
Correct Solution:
```
n, m = map(int, input().split())
tm = [int(i) for i in input().split()]
sum_d = 0
sum_l = 0
is_dark = n & 1
lst = m
tm.reverse()
tm.append(0)
Max = -1
for i in tm:
dis = lst - i
if is_dark:
sum_d += dis
else:
sum_l += dis
lst = i
if dis == 1:... | output | 1 | 42,900 | 4 | 85,801 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently, you bought a brand new smart lamp with programming features. At first, you set up a schedule to the lamp. Every day it will turn power on at moment 0 and turn power off at moment M. Moreover, the lamp allows you to set a program of... | instruction | 0 | 42,901 | 4 | 85,802 |
Tags: greedy
Correct Solution:
```
import copy
n, M = map(int, input().split())
s = list(map(int, input().split()))
lengths =[]
i1 = []
z1 = []
s.append(0)
s.append(M)
s.sort()
l = len(s)
length = 0
for n in range(1, l, 2):
length += s[n] -s[n - 1]
i1.append(s[n] -s[n - 1])
lengths.append(length)
x1 = [2 * i1.i... | output | 1 | 42,901 | 4 | 85,803 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.