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.
It's a walking tour day in SIS.Winter, so t groups of students are visiting Torzhok. Streets of Torzhok are so narrow that students have to go in a row one after another.
Initially, some students are angry. Let's describe a group of student... | instruction | 0 | 46,371 | 14 | 92,742 |
Tags: greedy, implementation
Correct Solution:
```
import sys
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def input(): return sys.stdin.readline().strip()
for _ in range(int(input())):
n = int(input())
... | output | 1 | 46,371 | 14 | 92,743 |
Provide tags and a correct Python 3 solution for this coding contest problem.
It's a walking tour day in SIS.Winter, so t groups of students are visiting Torzhok. Streets of Torzhok are so narrow that students have to go in a row one after another.
Initially, some students are angry. Let's describe a group of student... | instruction | 0 | 46,372 | 14 | 92,744 |
Tags: greedy, implementation
Correct Solution:
```
for _ in range(int(input())):
n=int(input())
l=input()
if 'A' in l:
x=[l.find('A')];d=0
for i in range(x[0]+1,n):
if l[i]=='A':
d=max(d,i-x[-1]-1)
x.append(i)
print(max(d,n-1-x[-1]))
el... | output | 1 | 46,372 | 14 | 92,745 |
Provide tags and a correct Python 3 solution for this coding contest problem.
It's a walking tour day in SIS.Winter, so t groups of students are visiting Torzhok. Streets of Torzhok are so narrow that students have to go in a row one after another.
Initially, some students are angry. Let's describe a group of student... | instruction | 0 | 46,373 | 14 | 92,746 |
Tags: greedy, implementation
Correct Solution:
```
# uses python 3
times = int(input())
arr = []
for i in range(times):
k = int(input())
arr.append(input())
# print(order)
def last_min(order):
count = 0
cp = list(order).copy()
# print(cp)
on = True
while on:
new = cp.copy()
... | output | 1 | 46,373 | 14 | 92,747 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It's a walking tour day in SIS.Winter, so t groups of students are visiting Torzhok. Streets of Torzhok are so narrow that students have to go in a row one after another.
Initially, some studen... | instruction | 0 | 46,374 | 14 | 92,748 |
Yes | output | 1 | 46,374 | 14 | 92,749 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It's a walking tour day in SIS.Winter, so t groups of students are visiting Torzhok. Streets of Torzhok are so narrow that students have to go in a row one after another.
Initially, some studen... | instruction | 0 | 46,375 | 14 | 92,750 |
Yes | output | 1 | 46,375 | 14 | 92,751 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It's a walking tour day in SIS.Winter, so t groups of students are visiting Torzhok. Streets of Torzhok are so narrow that students have to go in a row one after another.
Initially, some studen... | instruction | 0 | 46,376 | 14 | 92,752 |
Yes | output | 1 | 46,376 | 14 | 92,753 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It's a walking tour day in SIS.Winter, so t groups of students are visiting Torzhok. Streets of Torzhok are so narrow that students have to go in a row one after another.
Initially, some studen... | instruction | 0 | 46,377 | 14 | 92,754 |
Yes | output | 1 | 46,377 | 14 | 92,755 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It's a walking tour day in SIS.Winter, so t groups of students are visiting Torzhok. Streets of Torzhok are so narrow that students have to go in a row one after another.
Initially, some studen... | instruction | 0 | 46,378 | 14 | 92,756 |
No | output | 1 | 46,378 | 14 | 92,757 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It's a walking tour day in SIS.Winter, so t groups of students are visiting Torzhok. Streets of Torzhok are so narrow that students have to go in a row one after another.
Initially, some studen... | instruction | 0 | 46,379 | 14 | 92,758 |
No | output | 1 | 46,379 | 14 | 92,759 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It's a walking tour day in SIS.Winter, so t groups of students are visiting Torzhok. Streets of Torzhok are so narrow that students have to go in a row one after another.
Initially, some studen... | instruction | 0 | 46,380 | 14 | 92,760 |
No | output | 1 | 46,380 | 14 | 92,761 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It's a walking tour day in SIS.Winter, so t groups of students are visiting Torzhok. Streets of Torzhok are so narrow that students have to go in a row one after another.
Initially, some studen... | instruction | 0 | 46,381 | 14 | 92,762 |
No | output | 1 | 46,381 | 14 | 92,763 |
Provide tags and a correct Python 3 solution for this coding contest problem.
To learn as soon as possible the latest news about their favourite fundamentally new operating system, BolgenOS community from Nizhni Tagil decided to develop a scheme. According to this scheme a community member, who is the first to learn t... | instruction | 0 | 46,552 | 14 | 93,104 |
Tags: dfs and similar, graphs, trees
Correct Solution:
```
#!/usr/bin/env python3
# Read data
n = int(input())
f = map(int, input().split())
f = [d-1 for d in f] # Make indices 0-based
# Determine in-degree of all the nodes
indegree = [0 for i in range(n)]
for i in range(n):
indegree[f[i]] += 1
# Nodes with indegr... | output | 1 | 46,552 | 14 | 93,105 |
Provide tags and a correct Python 3 solution for this coding contest problem.
To learn as soon as possible the latest news about their favourite fundamentally new operating system, BolgenOS community from Nizhni Tagil decided to develop a scheme. According to this scheme a community member, who is the first to learn t... | instruction | 0 | 46,553 | 14 | 93,106 |
Tags: dfs and similar, graphs, trees
Correct Solution:
```
n = int(input())
g = [int(i) - 1 for i in input().split()]
def solve(n, g):
vertex_id = [-1]*n
current_id = 0
starts_a_cycle = [-1]*n
cycle_vertex_sample = []
start_on_cycle = []
cycle_index_by_ID = []
cycle_count = 0
for v i... | output | 1 | 46,553 | 14 | 93,107 |
Provide tags and a correct Python 3 solution for this coding contest problem.
To learn as soon as possible the latest news about their favourite fundamentally new operating system, BolgenOS community from Nizhni Tagil decided to develop a scheme. According to this scheme a community member, who is the first to learn t... | instruction | 0 | 46,554 | 14 | 93,108 |
Tags: dfs and similar, graphs, trees
Correct Solution:
```
#!/usr/bin/python3
import sys
from collections import Counter
input = lambda: sys.stdin.readline().strip()
n = int(input())
f = [0, *(int(x) for x in input().split())]
c = Counter(f)
component = [0 for i in range(n + 1)]
last = [0 for i in range(n + 1)]
roots =... | output | 1 | 46,554 | 14 | 93,109 |
Provide tags and a correct Python 3 solution for this coding contest problem.
To learn as soon as possible the latest news about their favourite fundamentally new operating system, BolgenOS community from Nizhni Tagil decided to develop a scheme. According to this scheme a community member, who is the first to learn t... | instruction | 0 | 46,555 | 14 | 93,110 |
Tags: dfs and similar, graphs, trees
Correct Solution:
```
import sys
n = int(input())
g = [int(i) - 1 for i in sys.stdin.readline().split()]
def solve(n, g):
vertex_id = [-1]*n
current_id = 0
cycle_starts = []
cycle_starts_by_vertex = [-1]*n
cycle_vertex_sample = []
start_on_cycle = []
... | output | 1 | 46,555 | 14 | 93,111 |
Provide tags and a correct Python 3 solution for this coding contest problem.
To learn as soon as possible the latest news about their favourite fundamentally new operating system, BolgenOS community from Nizhni Tagil decided to develop a scheme. According to this scheme a community member, who is the first to learn t... | instruction | 0 | 46,556 | 14 | 93,112 |
Tags: dfs and similar, graphs, trees
Correct Solution:
```
import sys
from array import array # noqa: F401
def input():
return sys.stdin.buffer.readline().decode('utf-8')
n = int(input())
a = [0] + list(map(int, input().split()))
rev = [[] for _ in range(n + 1)]
indeg = [0] * (n + 1)
for i in range(1, n + 1):... | output | 1 | 46,556 | 14 | 93,113 |
Provide tags and a correct Python 3 solution for this coding contest problem.
To learn as soon as possible the latest news about their favourite fundamentally new operating system, BolgenOS community from Nizhni Tagil decided to develop a scheme. According to this scheme a community member, who is the first to learn t... | instruction | 0 | 46,557 | 14 | 93,114 |
Tags: dfs and similar, graphs, trees
Correct Solution:
```
def dfs_1(graph):
n=len(graph)
stack=[]
recursive_stack=[]
status=[[False,0] for i in range(n)]
for i in range(n):
if not status[i][0]:
recursive_stack.append(i)
status[i][0]=True
__dfs(graph,statu... | output | 1 | 46,557 | 14 | 93,115 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
To learn as soon as possible the latest news about their favourite fundamentally new operating system, BolgenOS community from Nizhni Tagil decided to develop a scheme. According to this scheme ... | instruction | 0 | 46,560 | 14 | 93,120 |
No | output | 1 | 46,560 | 14 | 93,121 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n kangaroos with pockets. Each kangaroo has a size (integer number). A kangaroo can go into another kangaroo's pocket if and only if the size of kangaroo who hold the kangaroo is at least twice as large as the size of kangaroo who ... | instruction | 0 | 46,608 | 14 | 93,216 |
Tags: binary search, greedy, sortings, two pointers
Correct Solution:
```
#------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import*
from io import BytesIO, IOBase
def vsInput():
sys.s... | output | 1 | 46,608 | 14 | 93,217 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n employees working in company "X" (let's number them from 1 to n for convenience). Initially the employees didn't have any relationships among each other. On each of m next days one of the following events took place:
* either ... | instruction | 0 | 46,627 | 14 | 93,254 |
Tags: dfs and similar, dsu, graphs, trees
Correct Solution:
```
import sys
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
n, m = map(int, input().split())
ev = [tuple(map(int, input().split())) for _ in range(m)]
g = [[] for _ in range(n + 1)]
qry = [[] for _ in range(m + 1)]
roots = set(range(1... | output | 1 | 46,627 | 14 | 93,255 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n employees working in company "X" (let's number them from 1 to n for convenience). Initially the employees didn't have any relationships among each other. On each of m next days one of the following events took place:
* either ... | instruction | 0 | 46,628 | 14 | 93,256 |
Tags: dfs and similar, dsu, graphs, trees
Correct Solution:
```
n, m = map(int, input().split())
ev = [tuple(map(int, input().split())) for _ in range(m)]
g = [[] for _ in range(n + 1)]
qry = [[] for _ in range(m + 1)]
roots = set(range(1, n + 1))
qcnt = 0
for e in ev:
if e[0] == 1:
g[e[2]].append(e[1])
roots.rem... | output | 1 | 46,628 | 14 | 93,257 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Xenia is a girl being born a noble. Due to the inflexibility and harshness of her family, Xenia has to find some ways to amuse herself.
<image>
Recently Xenia has bought n_r red gems, n_g green gems and n_b blue gems. Each of the gems has ... | instruction | 0 | 47,141 | 14 | 94,282 |
Tags: binary search, greedy, math, sortings, two pointers
Correct Solution:
```
import bisect
testCases = int(input())
def f1(x, y, z):
global ans
for t1 in y:
x_val = 0
ind1 = bisect.bisect_left(x, t1)
if ind1 == len(x):
x_val = x[ind1 - 1]
elif ind1 == 0:
... | output | 1 | 47,141 | 14 | 94,283 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Xenia is a girl being born a noble. Due to the inflexibility and harshness of her family, Xenia has to find some ways to amuse herself.
<image>
Recently Xenia has bought n_r red gems, n_g green gems and n_b blue gems. Each of the gems has ... | instruction | 0 | 47,142 | 14 | 94,284 |
Tags: binary search, greedy, math, sortings, two pointers
Correct Solution:
```
'''
Yunkai Zhang, 4/16/2020
'''
import sys
input = sys.stdin.readline
def inlt(): # https://codeforces.com/blog/entry/71884
return(list(map(int,input().split())))
def match(a, b, c):
def calculate_result(result, item1, item2, ite... | output | 1 | 47,142 | 14 | 94,285 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Xenia is a girl being born a noble. Due to the inflexibility and harshness of her family, Xenia has to find some ways to amuse herself.
<image>
Recently Xenia has bought n_r red gems, n_g green gems and n_b blue gems. Each of the gems has ... | instruction | 0 | 47,143 | 14 | 94,286 |
Tags: binary search, greedy, math, sortings, two pointers
Correct Solution:
```
from itertools import permutations
#from fractions import Fraction
from collections import defaultdict
from math import*
import os
import sys
from io import BytesIO, IOBase
from heapq import nlargest
from bisect import*
import copy
import i... | output | 1 | 47,143 | 14 | 94,287 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Xenia is a girl being born a noble. Due to the inflexibility and harshness of her family, Xenia has to find some ways to amuse herself.
<image>
Recently Xenia has bought n_r red gems, n_g green gems and n_b blue gems. Each of the gems has ... | instruction | 0 | 47,144 | 14 | 94,288 |
Tags: binary search, greedy, math, sortings, two pointers
Correct Solution:
```
import bisect
def getMin(a, b, c, la, lc):
ans = float('inf')
for i in b:
ia = bisect.bisect_left(a, i)
ic = bisect.bisect_right(c, i)
if ia == la:
ia -= 1
if ic != 0:
ic -= 1
... | output | 1 | 47,144 | 14 | 94,289 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Xenia is a girl being born a noble. Due to the inflexibility and harshness of her family, Xenia has to find some ways to amuse herself.
<image>
Recently Xenia has bought n_r red gems, n_g green gems and n_b blue gems. Each of the gems has ... | instruction | 0 | 47,145 | 14 | 94,290 |
Tags: binary search, greedy, math, sortings, two pointers
Correct Solution:
```
# itne me hi thakk gaye?
from bisect import bisect_left, bisect_right
def getf(a, b, c):
return (a-b)**2 + (b-c)**2 + (a-c)**2
def getcondition(low_arr, mid_arr, high_arr):
s = 10**20
for i in mid_arr:
x_p = bisect_righ... | output | 1 | 47,145 | 14 | 94,291 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Xenia is a girl being born a noble. Due to the inflexibility and harshness of her family, Xenia has to find some ways to amuse herself.
<image>
Recently Xenia has bought n_r red gems, n_g green gems and n_b blue gems. Each of the gems has ... | instruction | 0 | 47,146 | 14 | 94,292 |
Tags: binary search, greedy, math, sortings, two pointers
Correct Solution:
```
#Code by Sounak, IIESTS
#------------------------------warmup----------------------------
import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
from collections import defaultdict
from itertools imp... | output | 1 | 47,146 | 14 | 94,293 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Xenia is a girl being born a noble. Due to the inflexibility and harshness of her family, Xenia has to find some ways to amuse herself.
<image>
Recently Xenia has bought n_r red gems, n_g green gems and n_b blue gems. Each of the gems has ... | instruction | 0 | 47,147 | 14 | 94,294 |
Tags: binary search, greedy, math, sortings, two pointers
Correct Solution:
```
import sys
from array import array # noqa: F401
def input():
return sys.stdin.buffer.readline().decode('utf-8')
def solve(a, b, c):
res = 4 * 10**18
n, m, l = len(a), len(b), len(c)
j, k = 0, 0
for x in a:
... | output | 1 | 47,147 | 14 | 94,295 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Xenia is a girl being born a noble. Due to the inflexibility and harshness of her family, Xenia has to find some ways to amuse herself.
<image>
Recently Xenia has bought n_r red gems, n_g green gems and n_b blue gems. Each of the gems has ... | instruction | 0 | 47,148 | 14 | 94,296 |
Tags: binary search, greedy, math, sortings, two pointers
Correct Solution:
```
import sys
import bisect
input=sys.stdin.readline
def solve(r,g,b):
ans=3*(10**18)
for i in g:
r1=bisect.bisect_right(r,i)
r2=bisect.bisect_left(b,i)
if r1==0 or r2==len(b):
continue
j=r[r... | output | 1 | 47,148 | 14 | 94,297 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Maxim has opened his own restaurant! The restaurant has got a huge table, the table's length is p meters.
Maxim has got a dinner party tonight, n guests will come to him. Let's index the guests of Maxim's restaurant from 1 to n. Maxim knows... | instruction | 0 | 47,349 | 14 | 94,698 |
Tags: dp, math, probabilities
Correct Solution:
```
from pprint import pprint
n = int(input())
a = list(map(int, input().split()))
p = int(input())
fact = [1]
for i in range(1, 51):
fact.append(fact[-1]*i)
if sum(a) <= p:
print(n)
else:
dp = [[0]*56 for _ in range(56)]
dp[0][0] = 1
for i in ran... | output | 1 | 47,349 | 14 | 94,699 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Maxim has opened his own restaurant! The restaurant has got a huge table, the table's length is p meters.
Maxim has got a dinner party tonight, n guests will come to him. Let's index the guests of Maxim's restaurant from 1 to n. Maxim knows... | instruction | 0 | 47,350 | 14 | 94,700 |
Tags: dp, math, probabilities
Correct Solution:
```
n = input()
n = int(n)
arr = [0] * n
fact = [0] * 51
a = input().split()
p = input()
p = int(p)
for i in range(n):
arr[i] = int(a[i])
if n == 1:
if arr[0] <= p:
print(1)
else:
print(0)
exit(0)
def pre():
fact[0] = 1
for i in range(1, 51):
fact[i] = fact... | output | 1 | 47,350 | 14 | 94,701 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Maxim has opened his own restaurant! The restaurant has got a huge table, the table's length is p meters.
Maxim has got a dinner party tonight, n guests will come to him. Let's index the guests of Maxim's restaurant from 1 to n. Maxim knows... | instruction | 0 | 47,351 | 14 | 94,702 |
Tags: dp, math, probabilities
Correct Solution:
```
import math
n = int(input())
a = [int(x) for x in input().split()]
p = int(input())
sum=0;
for x in range(n):
sum+=a[x]
if(sum<=p):
print(n)
else:
ans=0
for i in range(n):
dp = [[[0 for z in range(55)] for y in range(55)] for x in range(55)]
dp[-1][0][0]=1
... | output | 1 | 47,351 | 14 | 94,703 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Maxim has opened his own restaurant! The restaurant has got a huge table, the table's length is p meters.
Maxim has got a dinner party tonight, n guests will come to him. Let's index the guests of Maxim's restaurant from 1 to n. Maxim knows... | instruction | 0 | 47,352 | 14 | 94,704 |
Tags: dp, math, probabilities
Correct Solution:
```
n=int(input())
arr=list(map(int,input().split()))
p=int(input())
dp=[[[0 for k in range(n+1)] for i in range(p+1)] for i in range(n+1)]
for j in range(p+1):
for k in range(n+1):
dp[0][j][k]=1
for i in range(1,n+1):
for j in range(p+1):
for k in... | output | 1 | 47,352 | 14 | 94,705 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Maxim has opened his own restaurant! The restaurant has got a huge table, the table's length is p meters.
Maxim has got a dinner party tonight, n guests will come to him. Let's index the guests of Maxim's restaurant from 1 to n. Maxim knows... | instruction | 0 | 47,353 | 14 | 94,706 |
Tags: dp, math, probabilities
Correct Solution:
```
n = int(input())
a = list(map(int, input().split()))
p = int(input())
fact = [1]
for i in range(1, 51):
fact.append(fact[-1]*i)
if sum(a) <= p:
print(n)
else:
dp = [[0]*56 for _ in range(56)]
dp[0][0] = 1
for i in range(n):
for j in ran... | output | 1 | 47,353 | 14 | 94,707 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Maxim has opened his own restaurant! The restaurant has got a huge table, the table's length is p meters.
Maxim has got a dinner party tonight, n guests will come to him. Let's index the guests... | instruction | 0 | 47,354 | 14 | 94,708 |
No | output | 1 | 47,354 | 14 | 94,709 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Maxim has opened his own restaurant! The restaurant has got a huge table, the table's length is p meters.
Maxim has got a dinner party tonight, n guests will come to him. Let's index the guests... | instruction | 0 | 47,355 | 14 | 94,710 |
No | output | 1 | 47,355 | 14 | 94,711 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Maxim has opened his own restaurant! The restaurant has got a huge table, the table's length is p meters.
Maxim has got a dinner party tonight, n guests will come to him. Let's index the guests... | instruction | 0 | 47,356 | 14 | 94,712 |
No | output | 1 | 47,356 | 14 | 94,713 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Maxim has opened his own restaurant! The restaurant has got a huge table, the table's length is p meters.
Maxim has got a dinner party tonight, n guests will come to him. Let's index the guests... | instruction | 0 | 47,357 | 14 | 94,714 |
No | output | 1 | 47,357 | 14 | 94,715 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Throughout Igor K.'s life he has had many situations worthy of attention. We remember the story with the virus, the story of his mathematical career and of course, his famous programming achievements. However, one does not always adopt new h... | instruction | 0 | 47,643 | 14 | 95,286 |
Tags: implementation
Correct Solution:
```
import sys
sys.setrecursionlimit(10000000)
def solve():
n, m, a, b, = rv()
a -= 1
b -= 1
if a // m == b // m or m == 1:
print(1)
return
first = m - (a - (a // m) * m)
last = b - (b // m) * m + 1
if b + 1 == n: last = m
if first... | output | 1 | 47,643 | 14 | 95,287 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Throughout Igor K.'s life he has had many situations worthy of attention. We remember the story with the virus, the story of his mathematical career and of course, his famous programming achievements. However, one does not always adopt new h... | instruction | 0 | 47,644 | 14 | 95,288 |
Tags: implementation
Correct Solution:
```
n, m, a, b = map(int, input().split())
if m == 1:
print("1")
elif (a - 1) // m == (b - 1) // m:
print("1")
elif abs((a - 1) // m - (b - 1) // m) == 1 and a % m != 1:
print("2")
elif b == n or b % m == 0:
if a % m == 1:
print("1")
else:
p... | output | 1 | 47,644 | 14 | 95,289 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Throughout Igor K.'s life he has had many situations worthy of attention. We remember the story with the virus, the story of his mathematical career and of course, his famous programming achievements. However, one does not always adopt new h... | instruction | 0 | 47,645 | 14 | 95,290 |
Tags: implementation
Correct Solution:
```
#------------------------------warmup----------------------------
# *******************************
# * AUTHOR: RAJDEEP GHOSH *
# * NICK : Rajdeep2k *
# * INSTITUTION: IIEST, SHIBPUR *
# *******************************
import os
import sys
from io import... | output | 1 | 47,645 | 14 | 95,291 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Throughout Igor K.'s life he has had many situations worthy of attention. We remember the story with the virus, the story of his mathematical career and of course, his famous programming achievements. However, one does not always adopt new h... | instruction | 0 | 47,646 | 14 | 95,292 |
Tags: implementation
Correct Solution:
```
import math
n,m,a,b=map(int,input().split())
if (a-1)//m==(b-1)//m:
print(1)
elif (a-1)%m==0 and b%m==0:
print(1)
elif (a-1)%m==0 and b==n or m==1:
print(1)
elif (a-1)%m==0 or b%m==0 or b==n:
print(2)
elif abs((a-1)//m - (b-1)//m)==1 or m==2:
print(2)
elif... | output | 1 | 47,646 | 14 | 95,293 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Throughout Igor K.'s life he has had many situations worthy of attention. We remember the story with the virus, the story of his mathematical career and of course, his famous programming achievements. However, one does not always adopt new h... | instruction | 0 | 47,647 | 14 | 95,294 |
Tags: implementation
Correct Solution:
```
n, m, a, b = map(int, input().split())
r1, r2, c1, c2 = (a - 1) // m, (b - 1) // m, (a - 1) % m, m - 1 if b == n else (b - 1) % m
if r1 == r2 or c1 == 0 and c2 == m - 1:
print(1)
elif r2 == r1 + 1 or c1 == 0 or c2 == m - 1 or c1 == c2 + 1:
print(2)
else:
pri... | output | 1 | 47,647 | 14 | 95,295 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Throughout Igor K.'s life he has had many situations worthy of attention. We remember the story with the virus, the story of his mathematical career and of course, his famous programming achievements. However, one does not always adopt new h... | instruction | 0 | 47,648 | 14 | 95,296 |
Tags: implementation
Correct Solution:
```
import sys
from array import array # noqa: F401
def input():
return sys.stdin.buffer.readline().decode('utf-8')
n, m, a, b = map(int, input().split())
a, b = a - 1, b - 1
if b + 1 == n:
b = (b // m + 1) * m - 1
if a // m == b // m:
print(1)
elif a % m == 0 an... | output | 1 | 47,648 | 14 | 95,297 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Throughout Igor K.'s life he has had many situations worthy of attention. We remember the story with the virus, the story of his mathematical career and of course, his famous programming achievements. However, one does not always adopt new h... | instruction | 0 | 47,649 | 14 | 95,298 |
Tags: implementation
Correct Solution:
```
readints=lambda:map(int, input().strip('\n').split())
n,m,a,b=readints()
a-=1
b-=1 # 0-index
ra=a//m
rb=b//m
ia=a%m
ib=b%m
if (ra==rb) or (ia==0 and b==n-1) or (ia==0 and ib==m-1):
print(1)
elif (ia==0 and ib<m-1 and b!=n-1) or (ia>0 and (ib==m-1 or b==n-1)) or (ra+1... | output | 1 | 47,649 | 14 | 95,299 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Throughout Igor K.'s life he has had many situations worthy of attention. We remember the story with the virus, the story of his mathematical career and of course, his famous programming achievements. However, one does not always adopt new h... | instruction | 0 | 47,650 | 14 | 95,300 |
Tags: implementation
Correct Solution:
```
# ---------------------------iye ha aam zindegi---------------------------------------------
import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import threading
from collections import ... | output | 1 | 47,650 | 14 | 95,301 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A new Berland businessman Vitaly is going to open a household appliances' store. All he's got to do now is to hire the staff.
The store will work seven days a week, but not around the clock. Every day at least k people must work in the stor... | instruction | 0 | 48,187 | 14 | 96,374 |
Tags: greedy
Correct Solution:
```
n, m, k = map(int, input().split())
res, x = [], 1
if k == 1:
while x <= n + m:
res += [str(x)]
x += n - 1
else:
res = ['1']
while x <= n + m:
res += [str(x)]*(k-1)
x += n
if x <= n + m + 1:
res.append(str(x-1))
print(len... | output | 1 | 48,187 | 14 | 96,375 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A new Berland businessman Vitaly is going to open a household appliances' store. All he's got to do now is to hire the staff.
The store will work seven days a week, but not around the clock. Every day at least k people must work in the stor... | instruction | 0 | 48,188 | 14 | 96,376 |
Tags: greedy
Correct Solution:
```
n,m,k = map(int,input().split())
cnt = [0] * 100010
a = []
for day in range(n+m):
while cnt[day] < k or cnt[day + 1] == 0 :
a.append(day + 1)
for i in range(n):
cnt[day+i] += 1
print (len(a))
for i in range(len(a)):
print (a[i],end = " ")
``` | output | 1 | 48,188 | 14 | 96,377 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A new Berland businessman Vitaly is going to open a household appliances' store. All he's got to do now is to hire the staff.
The store will work seven days a week, but not around the clock. Every day at least k people must work in the stor... | instruction | 0 | 48,189 | 14 | 96,378 |
Tags: greedy
Correct Solution:
```
s = input().split()
n = int ( s[0] )
m = int ( s[1] )
k = int ( s[2] )
Restore = []
for i in range(k):
Restore += [1]
if n == m :
Restore += [n]
for i in range(k-1):
Restore += [n+1]
if ( n == 2 ) and ( k == 1 ) :
Restore += [n+1]
Restore += [n+2]
elif n - m... | output | 1 | 48,189 | 14 | 96,379 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A new Berland businessman Vitaly is going to open a household appliances' store. All he's got to do now is to hire the staff.
The store will work seven days a week, but not around the clock. Every day at least k people must work in the stor... | instruction | 0 | 48,190 | 14 | 96,380 |
Tags: greedy
Correct Solution:
```
def readInts(): return map(int, input().split())
def solve():
line0 = []
try: line0 = readInts()
except EOFError: return False
n, m, k = line0
cnt = [0] * 10000
ans = []
keyPos = 1
head = 1
while head <= n+m or keyPos <= n+m:
head = min ( head, keyPos )
... | output | 1 | 48,190 | 14 | 96,381 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.