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.
There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type ai.
Let's call a sequence of consecutive pearls a segment. Let's call a segment good if it contains two ... | instruction | 0 | 13,728 | 14 | 27,456 |
Tags: greedy
Correct Solution:
```
n = int(input())
data = list(map(int, input().split()))
a = 0
answer = []
start = 1
finish = 1
help_set = set()
for i in range(n):
if data[i] in help_set:
answer.append([start, finish])
help_set = set()
start = finish + 1
finish += 1
else:
... | output | 1 | 13,728 | 14 | 27,457 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type ai.
Let's call a sequence of consecutive pearls a segment. Let's call a segment good if it contains two ... | instruction | 0 | 13,729 | 14 | 27,458 |
Tags: greedy
Correct Solution:
```
n = int(input())
index = 1
memory = set()
counter = 0
segments = [[0, 0]]
for number in input().split():
if number not in memory:
memory.add(number)
else:
counter += 1
segments.append([segments[-1][1] + 1, index])
memory = set()
index += 1
s... | output | 1 | 13,729 | 14 | 27,459 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type ai.
Let's call a sequence of consecutive pearls a segment... | instruction | 0 | 13,730 | 14 | 27,460 |
Yes | output | 1 | 13,730 | 14 | 27,461 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type ai.
Let's call a sequence of consecutive pearls a segment... | instruction | 0 | 13,731 | 14 | 27,462 |
Yes | output | 1 | 13,731 | 14 | 27,463 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type ai.
Let's call a sequence of consecutive pearls a segment... | instruction | 0 | 13,732 | 14 | 27,464 |
Yes | output | 1 | 13,732 | 14 | 27,465 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type ai.
Let's call a sequence of consecutive pearls a segment... | instruction | 0 | 13,733 | 14 | 27,466 |
Yes | output | 1 | 13,733 | 14 | 27,467 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type ai.
Let's call a sequence of consecutive pearls a segment... | instruction | 0 | 13,734 | 14 | 27,468 |
No | output | 1 | 13,734 | 14 | 27,469 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type ai.
Let's call a sequence of consecutive pearls a segment... | instruction | 0 | 13,735 | 14 | 27,470 |
No | output | 1 | 13,735 | 14 | 27,471 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type ai.
Let's call a sequence of consecutive pearls a segment... | instruction | 0 | 13,736 | 14 | 27,472 |
No | output | 1 | 13,736 | 14 | 27,473 |
Provide a correct Python 3 solution for this coding contest problem.
Nathan O. Davis has been running an electronic bulletin board system named JAG-channel. He is now having hard time to add a new feature there --- threaded view.
Like many other bulletin board systems, JAG-channel is thread-based. Here a thread (also... | instruction | 0 | 14,097 | 14 | 28,194 |
"Correct Solution:
```
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.rea... | output | 1 | 14,097 | 14 | 28,195 |
Provide a correct Python 3 solution for this coding contest problem.
Nathan O. Davis has been running an electronic bulletin board system named JAG-channel. He is now having hard time to add a new feature there --- threaded view.
Like many other bulletin board systems, JAG-channel is thread-based. Here a thread (also... | instruction | 0 | 14,098 | 14 | 28,196 |
"Correct Solution:
```
import sys
sys.setrecursionlimit(10000)
n=int(input())
a=[]
b=[[]for _ in [0]*n]
def f(i,x):
print('.'*x+a[i])
for j in b[i]:
f(j,x+1)
for i in range(n):
c=int(input())
a+=[input()]
if c!=0:b[c-1]+=[i]
f(0,0)
``` | output | 1 | 14,098 | 14 | 28,197 |
Provide a correct Python 3 solution for this coding contest problem.
Nathan O. Davis has been running an electronic bulletin board system named JAG-channel. He is now having hard time to add a new feature there --- threaded view.
Like many other bulletin board systems, JAG-channel is thread-based. Here a thread (also... | instruction | 0 | 14,099 | 14 | 28,198 |
"Correct Solution:
```
import sys
sys.setrecursionlimit(1010)
N = int(input())
src = []
for i in range(N):
k = int(input())
s = input()
src.append((s,[]))
if i == 0: continue
src[k-1][1].append(i)
def dfs(i,depth):
s,ch = src[i]
print('.'*depth + s)
for c in ch:
dfs(c,depth+1)
... | output | 1 | 14,099 | 14 | 28,199 |
Provide a correct Python 3 solution for this coding contest problem.
Nathan O. Davis has been running an electronic bulletin board system named JAG-channel. He is now having hard time to add a new feature there --- threaded view.
Like many other bulletin board systems, JAG-channel is thread-based. Here a thread (also... | instruction | 0 | 14,100 | 14 | 28,200 |
"Correct Solution:
```
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return li... | output | 1 | 14,100 | 14 | 28,201 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya is choosing a laptop. The shop has n laptops to all tastes.
Vasya is interested in the following properties: processor speed, ram and hdd. Vasya is a programmer and not a gamer which is why he is not interested in all other properties... | instruction | 0 | 14,154 | 14 | 28,308 |
Tags: brute force, implementation
Correct Solution:
```
n = int(input())
main = []
for i in range(n):
arr = list(map(int, input().split()))
main.append(arr)
outdated = set()
for i in range(len(main) - 1):
for j in range(i + 1, len(main)):
if main[i][0] < main[j][0] and main[i][1] < main[j][1] and m... | output | 1 | 14,154 | 14 | 28,309 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya is choosing a laptop. The shop has n laptops to all tastes.
Vasya is interested in the following properties: processor speed, ram and hdd. Vasya is a programmer and not a gamer which is why he is not interested in all other properties... | instruction | 0 | 14,155 | 14 | 28,310 |
Tags: brute force, implementation
Correct Solution:
```
import sys
n = int(sys.stdin.readline().strip())
t = []
for i in range(n):
c = [int(x) for x in sys.stdin.readline().strip().split()]
c[3] = -c[3]
t.append(c)
#print(c)
#print(t)
id = -1
best = 1e9
for i, c in enumerate(t):
ok = True
for... | output | 1 | 14,155 | 14 | 28,311 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya is choosing a laptop. The shop has n laptops to all tastes.
Vasya is interested in the following properties: processor speed, ram and hdd. Vasya is a programmer and not a gamer which is why he is not interested in all other properties... | instruction | 0 | 14,156 | 14 | 28,312 |
Tags: brute force, implementation
Correct Solution:
```
n = int(input())
s = [[int(i) for i in input().split()]+[1] for i in range(n)]
speed,ram,hdd=0,0,0
num = 1001
for i in range(n):
for j in range(n):
if s[i][0]>s[j][0] and s[i][1]>s[j][1] and s[i][2]>s[j][2]:
s[j][4]=0
for i in range(n):
if s[i][4]:
if s[i... | output | 1 | 14,156 | 14 | 28,313 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya is choosing a laptop. The shop has n laptops to all tastes.
Vasya is interested in the following properties: processor speed, ram and hdd. Vasya is a programmer and not a gamer which is why he is not interested in all other properties... | instruction | 0 | 14,157 | 14 | 28,314 |
Tags: brute force, implementation
Correct Solution:
```
a=[]
n=int(input())
for i in range(n):
s,r,h,c=map(int,input().split())
a.append([s,r,h,c])
ans=-1
for i in range(n):
flag=True
for j in range(n):
if a[i][0]<a[j][0] and a[i][1]<a[j][1] and a[i][2]<a[j][2]:
flag=False
... | output | 1 | 14,157 | 14 | 28,315 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya is choosing a laptop. The shop has n laptops to all tastes.
Vasya is interested in the following properties: processor speed, ram and hdd. Vasya is a programmer and not a gamer which is why he is not interested in all other properties... | instruction | 0 | 14,158 | 14 | 28,316 |
Tags: brute force, implementation
Correct Solution:
```
n=int(input())
a=0
b=0
c=0
g=[]
v=[0]*n
for _ in range(n):
l=list(map(int,input().split()))
g.append(l)
l=[]
for i in range(n):
f=0
for j in range(n):
if(g[i][1]<g[j][1] and g[i][2]<g[j][2] and g[i][0]<g[j][0]):
f=1
... | output | 1 | 14,158 | 14 | 28,317 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya is choosing a laptop. The shop has n laptops to all tastes.
Vasya is interested in the following properties: processor speed, ram and hdd. Vasya is a programmer and not a gamer which is why he is not interested in all other properties... | instruction | 0 | 14,159 | 14 | 28,318 |
Tags: brute force, implementation
Correct Solution:
```
n = int(input())
t = [0] * n
for i in range(n):
t[i] = list(map(int, input().split()))
ans = [1] * n
for i in range(n):
for j in range(n):
if all(t[i][k] < t[j][k] for k in range(3)):
ans[i] = 0
break
k, p = 0, 1001
for i i... | output | 1 | 14,159 | 14 | 28,319 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya is choosing a laptop. The shop has n laptops to all tastes.
Vasya is interested in the following properties: processor speed, ram and hdd. Vasya is a programmer and not a gamer which is why he is not interested in all other properties... | instruction | 0 | 14,160 | 14 | 28,320 |
Tags: brute force, implementation
Correct Solution:
```
def choosing_laptop(n,specs):
index = 0
length = n
not_outdated = []
while index < length :
sub_index = 0
assign = 1
speed , ram , hdd, cost = specs[index]
for speed2,ram2,hdd2, cost2 in specs :
if speed ... | output | 1 | 14,160 | 14 | 28,321 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya is choosing a laptop. The shop has n laptops to all tastes.
Vasya is interested in the following properties: processor speed, ram and hdd. Vasya is a programmer and not a gamer which is why he is not interested in all other properties... | instruction | 0 | 14,161 | 14 | 28,322 |
Tags: brute force, implementation
Correct Solution:
```
from sys import*
input= stdin.readline
t=int(input())
l=[]
cost=[]
for i in range(t):
a,b,c,d=map(int,input().split())
l.append([a,b,c])
cost.append(d)
for i in range(t):
for j in range(t):
if(i!=j):
if(l[i][0]<l[j][0] and l[i][... | output | 1 | 14,161 | 14 | 28,323 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day Vasya the Hipster decided to count how many socks he had. It turned out that he had a red socks and b blue socks.
According to the latest fashion, hipsters should wear the socks of different colors: a red one on the left foot, a blu... | instruction | 0 | 14,624 | 14 | 29,248 |
Tags: implementation, math
Correct Solution:
```
def Swap(a,b):
return (b,a)
a,b = map(int,input().split())
if a > b:
a,b = Swap(a,b)
print("%d %d" %(a,(b - a) //2))
``` | output | 1 | 14,624 | 14 | 29,249 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day Vasya the Hipster decided to count how many socks he had. It turned out that he had a red socks and b blue socks.
According to the latest fashion, hipsters should wear the socks of different colors: a red one on the left foot, a blu... | instruction | 0 | 14,625 | 14 | 29,250 |
Tags: implementation, math
Correct Solution:
```
import math
n,m=map(int,input().split())
if n>m:
print(m,int((n-m)/2))
elif m>n:
print(n,int((m-n)/2))
else:
print(n,0)
``` | output | 1 | 14,625 | 14 | 29,251 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day Vasya the Hipster decided to count how many socks he had. It turned out that he had a red socks and b blue socks.
According to the latest fashion, hipsters should wear the socks of different colors: a red one on the left foot, a blu... | instruction | 0 | 14,626 | 14 | 29,252 |
Tags: implementation, math
Correct Solution:
```
z = [int(s) for s in input().split()]
a, b = z[0], z[1]
if a > b:
print(b, (a - b) // 2)
elif a<b:
print(a, (b - a) // 2)
elif a == b:
print(a, 0)
``` | output | 1 | 14,626 | 14 | 29,253 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day Vasya the Hipster decided to count how many socks he had. It turned out that he had a red socks and b blue socks.
According to the latest fashion, hipsters should wear the socks of different colors: a red one on the left foot, a blu... | instruction | 0 | 14,627 | 14 | 29,254 |
Tags: implementation, math
Correct Solution:
```
n,m=map(int,input().split(" "))
a=0
if n>=m:
a=m
else:
a=n
b=(max(n,m)-a)//2
print(f"{a} {b}")
``` | output | 1 | 14,627 | 14 | 29,255 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day Vasya the Hipster decided to count how many socks he had. It turned out that he had a red socks and b blue socks.
According to the latest fashion, hipsters should wear the socks of different colors: a red one on the left foot, a blu... | instruction | 0 | 14,628 | 14 | 29,256 |
Tags: implementation, math
Correct Solution:
```
a, b = map(int, input().split())
first = min(a, b)
second = max((a-first)//2, (b-first)//2)
print(first, second)
``` | output | 1 | 14,628 | 14 | 29,257 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day Vasya the Hipster decided to count how many socks he had. It turned out that he had a red socks and b blue socks.
According to the latest fashion, hipsters should wear the socks of different colors: a red one on the left foot, a blu... | instruction | 0 | 14,629 | 14 | 29,258 |
Tags: implementation, math
Correct Solution:
```
n, m = map(int, input().split())
print(min(n, m), end = ' ')
print((max(n, m) - min(n, m)) // 2)
``` | output | 1 | 14,629 | 14 | 29,259 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day Vasya the Hipster decided to count how many socks he had. It turned out that he had a red socks and b blue socks.
According to the latest fashion, hipsters should wear the socks of different colors: a red one on the left foot, a blu... | instruction | 0 | 14,630 | 14 | 29,260 |
Tags: implementation, math
Correct Solution:
```
a = input().split()
b = int(a[1])
a = int(a[0])
print(min(a,b),abs(a-b)//2)
``` | output | 1 | 14,630 | 14 | 29,261 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day Vasya the Hipster decided to count how many socks he had. It turned out that he had a red socks and b blue socks.
According to the latest fashion, hipsters should wear the socks of different colors: a red one on the left foot, a blu... | instruction | 0 | 14,631 | 14 | 29,262 |
Tags: implementation, math
Correct Solution:
```
def main(b, r):
minim = min([b,r])
maxim = max([b,r])
if(b!=r):
if ((maxim - minim) % 2 != 0):
cols = int((maxim - minim - 1) / 2)
else:
cols = int((maxim - minim) /2)
return ' '.join([str(minim), str(cols)])
... | output | 1 | 14,631 | 14 | 29,263 |
Provide tags and a correct Python 3 solution for this coding contest problem.
People do many crazy things to stand out in a crowd. Some of them dance, some learn by heart rules of Russian language, some try to become an outstanding competitive programmers, while others collect funny math objects.
Alis is among these ... | instruction | 0 | 14,640 | 14 | 29,280 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n, k = map(int, input().split())
print(int((((n * (k - 1) + 1)) + ((n - 1) * (n - k + 1)) / 2) * n))
for i in range(n):
curr = []
for j in range(n):
if j + 1 == k:
curr.append((n * (k - 1) + 1) + i * (n - k + 1))
eli... | output | 1 | 14,640 | 14 | 29,281 |
Provide tags and a correct Python 3 solution for this coding contest problem.
People do many crazy things to stand out in a crowd. Some of them dance, some learn by heart rules of Russian language, some try to become an outstanding competitive programmers, while others collect funny math objects.
Alis is among these ... | instruction | 0 | 14,641 | 14 | 29,282 |
Tags: constructive algorithms, implementation
Correct Solution:
```
sLine = input()
sSplit = sLine.split()
n = int(sSplit[0])
k = int(sSplit[1])
v = []
for i in range(n) :
v.append([])
for j in range(n) :
v[i].append(0)
x1 = n * n
x2 = 1
for i in range(n) :
for j in range(n-1, (k-1)-1, -1) :
v[i][j] = x1
x1 -=... | output | 1 | 14,641 | 14 | 29,283 |
Provide tags and a correct Python 3 solution for this coding contest problem.
People do many crazy things to stand out in a crowd. Some of them dance, some learn by heart rules of Russian language, some try to become an outstanding competitive programmers, while others collect funny math objects.
Alis is among these ... | instruction | 0 | 14,642 | 14 | 29,284 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n, k = map(int, input().split())
k -= 1
answer = [[0] * n for i in range(n)]
cur = 1
for i in range(n):
for j in range(k):
answer[i][j] = cur
cur += 1
for i in range(n):
for j in range(k, n):
answer[i][j] = cur
c... | output | 1 | 14,642 | 14 | 29,285 |
Provide tags and a correct Python 3 solution for this coding contest problem.
People do many crazy things to stand out in a crowd. Some of them dance, some learn by heart rules of Russian language, some try to become an outstanding competitive programmers, while others collect funny math objects.
Alis is among these ... | instruction | 0 | 14,643 | 14 | 29,286 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n, k = map(int, input().split())
a = []
for i in range(1, (n*(k-1)) + 1):
a.append(i)
a = a[::-1]
lst = []
for i in range((n*(k-1)) + 1, (n*n) + 1):
lst.append(i)
lst = lst[::-1]
s = 0
ans = ""
for i in range(1, n + 1):
for j in range(1, n ... | output | 1 | 14,643 | 14 | 29,287 |
Provide tags and a correct Python 3 solution for this coding contest problem.
People do many crazy things to stand out in a crowd. Some of them dance, some learn by heart rules of Russian language, some try to become an outstanding competitive programmers, while others collect funny math objects.
Alis is among these ... | instruction | 0 | 14,645 | 14 | 29,290 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n, m = map(int, input().split())
n1, n2 = 1, (m - 1) * n + 1
ans = 0
print(n * (n - 1) // 2 * (n - m + 1) + n2 * n)
for i in range(n):
j = 0
while j < m - 1:
print(n1, end=' ')
n1 += 1
j += 1
while j < n:
pri... | output | 1 | 14,645 | 14 | 29,291 |
Provide tags and a correct Python 3 solution for this coding contest problem.
People do many crazy things to stand out in a crowd. Some of them dance, some learn by heart rules of Russian language, some try to become an outstanding competitive programmers, while others collect funny math objects.
Alis is among these ... | instruction | 0 | 14,646 | 14 | 29,292 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n,k=map(int,input().split())
ans=((n*n)-(n-k))
test=ans
op=[n*n-(n-k)]
op2=[]
count=[]
for i in range(1,n):
ans+=test-i*(n-k+1)
op.append(test-i*(n-k+1))
print(ans)
for i in range(n):
count.append(k+i*n)
pos=1
j=1
op=sorted(op)
#print(op)
i... | output | 1 | 14,646 | 14 | 29,293 |
Provide tags and a correct Python 3 solution for this coding contest problem.
People do many crazy things to stand out in a crowd. Some of them dance, some learn by heart rules of Russian language, some try to become an outstanding competitive programmers, while others collect funny math objects.
Alis is among these ... | instruction | 0 | 14,647 | 14 | 29,294 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n, k = map(int, input().split())
a=[]
for i in range(n):
a.append([])
for j in range(n):
a[i].append(0)
c = 1
for i in range(n):
for j in range(k - 1):
a[i][j] = c
c += 1
for i in range(n):
for j in range(k - 1, ... | output | 1 | 14,647 | 14 | 29,295 |
Provide tags and a correct Python 3 solution for this coding contest problem.
It seems that Borya is seriously sick. He is going visit n doctors to find out the exact diagnosis. Each of the doctors needs the information about all previous visits, so Borya has to visit them in the prescribed order (i.e. Borya should fi... | instruction | 0 | 14,708 | 14 | 29,416 |
Tags: implementation
Correct Solution:
```
#!/bin/python
import collections
import random
import sys
n = int(input())
day = 0
for i in range(n):
s, d = map(int, input().split())
day = max(day + 1, s)
if (day - s) % d != 0:
day += d - (day - s) % d
print(day)
``` | output | 1 | 14,708 | 14 | 29,417 |
Provide tags and a correct Python 3 solution for this coding contest problem.
It seems that Borya is seriously sick. He is going visit n doctors to find out the exact diagnosis. Each of the doctors needs the information about all previous visits, so Borya has to visit them in the prescribed order (i.e. Borya should fi... | instruction | 0 | 14,709 | 14 | 29,418 |
Tags: implementation
Correct Solution:
```
r=0
for _ in[0]*int(input()):
s,d=map(int,input().split())
r=[(r-s+d)//d*d+s,s][r<s]
print(r)
``` | output | 1 | 14,709 | 14 | 29,419 |
Provide tags and a correct Python 3 solution for this coding contest problem.
It seems that Borya is seriously sick. He is going visit n doctors to find out the exact diagnosis. Each of the doctors needs the information about all previous visits, so Borya has to visit them in the prescribed order (i.e. Borya should fi... | instruction | 0 | 14,710 | 14 | 29,420 |
Tags: implementation
Correct Solution:
```
n = int(input())
s, d = map(int, input().split())
t = s + 1;
for i in range(n - 1):
s, d = map(int, input().split())
if s >= t:
t = s + 1;
elif (t - s) % d == 0:
t += 1;
else:
t += d - (t - s) % d + 1;
print(t - 1)
``` | output | 1 | 14,710 | 14 | 29,421 |
Provide tags and a correct Python 3 solution for this coding contest problem.
It seems that Borya is seriously sick. He is going visit n doctors to find out the exact diagnosis. Each of the doctors needs the information about all previous visits, so Borya has to visit them in the prescribed order (i.e. Borya should fi... | instruction | 0 | 14,711 | 14 | 29,422 |
Tags: implementation
Correct Solution:
```
n = int(input())
for i in range(n):
si, di = list(map(int, input().split()))
if i == 0:
sum = si
else:
if si <= sum:
if si + di <= sum:
nd = ((sum - (si + di)) // di) + 1
sum = (si + di) + nd * di
... | output | 1 | 14,711 | 14 | 29,423 |
Provide tags and a correct Python 3 solution for this coding contest problem.
It seems that Borya is seriously sick. He is going visit n doctors to find out the exact diagnosis. Each of the doctors needs the information about all previous visits, so Borya has to visit them in the prescribed order (i.e. Borya should fi... | instruction | 0 | 14,712 | 14 | 29,424 |
Tags: implementation
Correct Solution:
```
def ii():
return int(input())
def mi():
return map(int, input().split())
def li():
return list(mi())
n = ii()
a = [mi() for i in range(n)]
p = 0
for i in range(n):
s, d = a[i]
if s>p:
p = s
else:
q = p - s
p = s + d*(q//d + 1)
p... | output | 1 | 14,712 | 14 | 29,425 |
Provide tags and a correct Python 3 solution for this coding contest problem.
It seems that Borya is seriously sick. He is going visit n doctors to find out the exact diagnosis. Each of the doctors needs the information about all previous visits, so Borya has to visit them in the prescribed order (i.e. Borya should fi... | instruction | 0 | 14,713 | 14 | 29,426 |
Tags: implementation
Correct Solution:
```
#!/usr/bin/python
from math import ceil
n = int(input())
c = 1
for _ in range(n):
s, d = list(map(int, input().split()))
if s >= c:
c = s + 1
else:
i = ceil((c - s) / d)
c = s + i * d + 1
print(c - 1)
``` | output | 1 | 14,713 | 14 | 29,427 |
Provide tags and a correct Python 3 solution for this coding contest problem.
It seems that Borya is seriously sick. He is going visit n doctors to find out the exact diagnosis. Each of the doctors needs the information about all previous visits, so Borya has to visit them in the prescribed order (i.e. Borya should fi... | instruction | 0 | 14,714 | 14 | 29,428 |
Tags: implementation
Correct Solution:
```
count = 0
for _ in range(int(input())):
s,d = map(int,input().split())
if count == 0:
count += s
else:
if s>count:
count = s
else:
if (count-s)%d==0:
count += d
else:
count ... | output | 1 | 14,714 | 14 | 29,429 |
Provide tags and a correct Python 3 solution for this coding contest problem.
It seems that Borya is seriously sick. He is going visit n doctors to find out the exact diagnosis. Each of the doctors needs the information about all previous visits, so Borya has to visit them in the prescribed order (i.e. Borya should fi... | instruction | 0 | 14,715 | 14 | 29,430 |
Tags: implementation
Correct Solution:
```
import math
n = int(input().strip())
day = 0
for _ in range(n):
day += 1
ai, di = map(int, input().strip().split())
if ai <= day:
t = math.ceil((day - ai)/di)
day = ai + t * di
else:
day = ai
print(day)
``` | output | 1 | 14,715 | 14 | 29,431 |
Provide a correct Python 3 solution for this coding contest problem.
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive integer K.
The i-th person from the left is standing on feet if the i-th character of S is `0`, and standing on hands ... | instruction | 0 | 14,812 | 14 | 29,624 |
"Correct Solution:
```
n, k = map(int, input().split())
s = list(input())
L = [0]
R = []
for i, (a, b) in enumerate(zip(s, s[1:])):
if (a, b) == ('0', '1'):
L.append(i+1)
if (a, b) == ('1', '0'):
R.append(i)
else:
R.append(n-1)
ans = R[0]-L[0]+1
if s[0] == '0':
k -= 1
k = min(k, len(... | output | 1 | 14,812 | 14 | 29,625 |
Provide a correct Python 3 solution for this coding contest problem.
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive integer K.
The i-th person from the left is standing on feet if the i-th character of S is `0`, and standing on hands ... | instruction | 0 | 14,813 | 14 | 29,626 |
"Correct Solution:
```
n,k=map(int,input().split())
s='1'+input()
i=0
for j in range(n):k-='10'==s[j:j+2];i+=k<0;k+=k<0and'01'==s[i:i+2]
print(n-i)
``` | output | 1 | 14,813 | 14 | 29,627 |
Provide a correct Python 3 solution for this coding contest problem.
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive integer K.
The i-th person from the left is standing on feet if the i-th character of S is `0`, and standing on hands ... | instruction | 0 | 14,814 | 14 | 29,628 |
"Correct Solution:
```
import sys
def input():
return sys.stdin.readline()[:-1]
N,K=map(int,input().split())
S=input()
l=[0]
t="1"
for i in S:
if t==i:
l[-1]+=1
else:
l.append(1)
if t=="1":
t="0"
else:
t="1"
if t=="0":
l.append(0)
a=sum(l[:2*K+1])
... | output | 1 | 14,814 | 14 | 29,629 |
Provide a correct Python 3 solution for this coding contest problem.
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive integer K.
The i-th person from the left is standing on feet if the i-th character of S is `0`, and standing on hands ... | instruction | 0 | 14,815 | 14 | 29,630 |
"Correct Solution:
```
n,k=map(int,input().split())
s='1'+input()
i=j=0
while j<n:k-='10'==s[j:j+2];i+=k<0;k+=k<0and'01'==s[i:i+2];j+=1
print(n-i)
``` | output | 1 | 14,815 | 14 | 29,631 |
Provide a correct Python 3 solution for this coding contest problem.
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive integer K.
The i-th person from the left is standing on feet if the i-th character of S is `0`, and standing on hands ... | instruction | 0 | 14,816 | 14 | 29,632 |
"Correct Solution:
```
n,k=map(int,input().split())
s=input()
list10 = {'0':[],'1':[]}
pre_c='1'
c_c = 0
cur_sum = 0
cur_max = 0
for c in s:
if c==pre_c:
c_c += 1
else:
list10[pre_c].append(c_c)
cur_sum += c_c
c_c = 1
pre_c = c
if len(list10['1'])== k+1:
cur_... | output | 1 | 14,816 | 14 | 29,633 |
Provide a correct Python 3 solution for this coding contest problem.
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive integer K.
The i-th person from the left is standing on feet if the i-th character of S is `0`, and standing on hands ... | instruction | 0 | 14,817 | 14 | 29,634 |
"Correct Solution:
```
N,K=map(int,input().split())
S=list(input())
l = [0,0] if (S[0] == '0') else [0]
l += [i for i in range(1,N) if S[i-1] != S[i]]
l += [N] if (S[-1] == '1') else [N,N]
ll=len(l)
p=2*K+1
if ll<p:
print(N)
else:
print(max(l[p+i]-l[i] for i in range(0,ll-p+1,2)))
``` | output | 1 | 14,817 | 14 | 29,635 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.