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.
A dragon symbolizes wisdom, power and wealth. On Lunar New Year's Day, people model a dragon with bamboo strips and clothes, raise them with rods, and hold the rods high and low to resemble a flying dragon.
A performer holding the rod low i... | instruction | 0 | 76,430 | 14 | 152,860 |
Tags: dp
Correct Solution:
```
def solve():
n=int(input())
arr=list(map(int,input().split()))
ones = 0
ones2s = 0
ones2s1s = 0
ones2s1s2s = 0
for value in arr:
if value==1:
ones+=1
ones2s1s = max(ones2s1s+1,ones2s+1)
if value==2:
ones2s = m... | output | 1 | 76,430 | 14 | 152,861 |
Provide tags and a correct Python 2 solution for this coding contest problem.
A dragon symbolizes wisdom, power and wealth. On Lunar New Year's Day, people model a dragon with bamboo strips and clothes, raise them with rods, and hold the rods high and low to resemble a flying dragon.
A performer holding the rod low i... | instruction | 0 | 76,431 | 14 | 152,862 |
Tags: dp
Correct Solution:
```
from sys import stdin, stdout
from collections import Counter, defaultdict
from itertools import permutations, combinations
raw_input = stdin.readline
pr = stdout.write
def in_num():
return int(raw_input())
def in_arr():
return map(int,raw_input().split())
def pr_num(n):
... | output | 1 | 76,431 | 14 | 152,863 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A dragon symbolizes wisdom, power and wealth. On Lunar New Year's Day, people model a dragon with bamboo strips and clothes, raise them with rods, and hold the rods high and low to resemble a fl... | instruction | 0 | 76,432 | 14 | 152,864 |
Yes | output | 1 | 76,432 | 14 | 152,865 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A dragon symbolizes wisdom, power and wealth. On Lunar New Year's Day, people model a dragon with bamboo strips and clothes, raise them with rods, and hold the rods high and low to resemble a fl... | instruction | 0 | 76,433 | 14 | 152,866 |
Yes | output | 1 | 76,433 | 14 | 152,867 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A dragon symbolizes wisdom, power and wealth. On Lunar New Year's Day, people model a dragon with bamboo strips and clothes, raise them with rods, and hold the rods high and low to resemble a fl... | instruction | 0 | 76,434 | 14 | 152,868 |
Yes | output | 1 | 76,434 | 14 | 152,869 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A dragon symbolizes wisdom, power and wealth. On Lunar New Year's Day, people model a dragon with bamboo strips and clothes, raise them with rods, and hold the rods high and low to resemble a fl... | instruction | 0 | 76,435 | 14 | 152,870 |
Yes | output | 1 | 76,435 | 14 | 152,871 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A dragon symbolizes wisdom, power and wealth. On Lunar New Year's Day, people model a dragon with bamboo strips and clothes, raise them with rods, and hold the rods high and low to resemble a fl... | instruction | 0 | 76,436 | 14 | 152,872 |
No | output | 1 | 76,436 | 14 | 152,873 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A dragon symbolizes wisdom, power and wealth. On Lunar New Year's Day, people model a dragon with bamboo strips and clothes, raise them with rods, and hold the rods high and low to resemble a fl... | instruction | 0 | 76,437 | 14 | 152,874 |
No | output | 1 | 76,437 | 14 | 152,875 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A dragon symbolizes wisdom, power and wealth. On Lunar New Year's Day, people model a dragon with bamboo strips and clothes, raise them with rods, and hold the rods high and low to resemble a fl... | instruction | 0 | 76,438 | 14 | 152,876 |
No | output | 1 | 76,438 | 14 | 152,877 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A dragon symbolizes wisdom, power and wealth. On Lunar New Year's Day, people model a dragon with bamboo strips and clothes, raise them with rods, and hold the rods high and low to resemble a fl... | instruction | 0 | 76,439 | 14 | 152,878 |
No | output | 1 | 76,439 | 14 | 152,879 |
Provide a correct Python 3 solution for this coding contest problem.
"Fukusekiken" is a popular ramen shop where you can line up. But recently, I've heard some customers say, "I can't afford to have vacant seats when I enter the store, even though I have a long waiting time." I'd like to find out why such dissatisfact... | instruction | 0 | 76,608 | 14 | 153,216 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0147
"""
import sys
from sys import stdin
from heapq import heappop, heappush
from collections import deque
input = stdin.readline
class Seat():
def __init__(self, n):
self.seat = '_' * n
def ... | output | 1 | 76,608 | 14 | 153,217 |
Provide a correct Python 3 solution for this coding contest problem.
"Fukusekiken" is a popular ramen shop where you can line up. But recently, I've heard some customers say, "I can't afford to have vacant seats when I enter the store, even though I have a long waiting time." I'd like to find out why such dissatisfact... | instruction | 0 | 76,609 | 14 | 153,218 |
"Correct Solution:
```
from collections import deque
from heapq import heappush, heappop
que = deque()
q = []
N = 100
for i in range(N):
heappush(q, (5*i, 0, i))
M = 17
S = [-1]*M
T = [0]*N
while q:
t = None
while q and (t is None or q[0][0] == t):
t, c, i = heappop(q)
if c == 0:
... | output | 1 | 76,609 | 14 | 153,219 |
Provide a correct Python 3 solution for this coding contest problem.
"Fukusekiken" is a popular ramen shop where you can line up. But recently, I've heard some customers say, "I can't afford to have vacant seats when I enter the store, even though I have a long waiting time." I'd like to find out why such dissatisfact... | instruction | 0 | 76,610 | 14 | 153,220 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0147
"""
import sys
from sys import stdin
from heapq import heappop, heappush
from collections import deque
input = stdin.readline
class Seat():
# ??????????????¶???????????????????????????
# '_'??????... | output | 1 | 76,610 | 14 | 153,221 |
Provide a correct Python 3 solution for this coding contest problem.
"Fukusekiken" is a popular ramen shop where you can line up. But recently, I've heard some customers say, "I can't afford to have vacant seats when I enter the store, even though I have a long waiting time." I'd like to find out why such dissatisfact... | instruction | 0 | 76,611 | 14 | 153,222 |
"Correct Solution:
```
# AOJ 0147 Fukushimaken
# Python3 2018.6.23 bal4u
# キューで待ち行列
S = 17
seat = [[0 for t in range(27)] for id in range(27)]
ans = [0]*105
id = 0
Q = []
for i in range(S): seat[i][0] = -1
t = -1
while ans[99] == 0:
t += 1
# グループ到着
if t % 5 == 0 and id <= 99:
n = 5 if (id % 5) == 1 else 2
Q.app... | output | 1 | 76,611 | 14 | 153,223 |
Provide a correct Python 3 solution for this coding contest problem.
"Fukusekiken" is a popular ramen shop where you can line up. But recently, I've heard some customers say, "I can't afford to have vacant seats when I enter the store, even though I have a long waiting time." I'd like to find out why such dissatisfact... | instruction | 0 | 76,612 | 14 | 153,224 |
"Correct Solution:
```
from collections import deque
que = deque()
t = 0
seat = [0] * 17
score = []
while que or t < 500:
if t % 5 == 0 and t < 500:
i = t // 5
que.append([t, 5 if i % 5 == 1 else 2, 17 * (i % 2) + 3 * (i % 3) + 19])
for i in range(17):
if seat[i]:
seat[i] -= 1
while que:
... | output | 1 | 76,612 | 14 | 153,225 |
Provide a correct Python 3 solution for this coding contest problem.
problem
You decide to invite your friends of the school and your friends of a friend to the Christmas party. The number of students in your school is n, and each student is assigned a number from 1 to n. Your number is 1. You have a list of who and ... | instruction | 0 | 76,619 | 14 | 153,238 |
"Correct Solution:
```
# AOJ 0545: Party
# Python3 2018.7.1 bal4u
import sys
from sys import stdin
input = stdin.readline
while True:
n, m = int(input()), int(input())
if n == 0: break
n += 1
f, tbl = [0]*n, []
for i in range(m):
a, b = map(int, input().split())
if a == 1 or b == 1: f[a] = f[b] = 1
else: t... | output | 1 | 76,619 | 14 | 153,239 |
Provide a correct Python 3 solution for this coding contest problem.
problem
You decide to invite your friends of the school and your friends of a friend to the Christmas party. The number of students in your school is n, and each student is assigned a number from 1 to n. Your number is 1. You have a list of who and ... | instruction | 0 | 76,620 | 14 | 153,240 |
"Correct Solution:
```
while True:
n = int(input())
if not n:
break
m = int(input())
li = [[] for _ in range(n + 1)]
for _ in range(m):
a, b = [int(i) for i in input().split()]
li[a].append(b)
li[b].append(a)
ans = set()
for i in li[1]:
ans.add(i)
... | output | 1 | 76,620 | 14 | 153,241 |
Provide a correct Python 3 solution for this coding contest problem.
problem
You decide to invite your friends of the school and your friends of a friend to the Christmas party. The number of students in your school is n, and each student is assigned a number from 1 to n. Your number is 1. You have a list of who and ... | instruction | 0 | 76,621 | 14 | 153,242 |
"Correct Solution:
```
def s():
import sys
r=sys.stdin.readline
for e in iter(r,'0\n'):
R=[[]for _ in[0]*-~int(e)]
for _ in[0]*int(r()):
a,b=map(int,r().split())
R[a]+=[b];R[b]+=[a]
for m in R[1][:]:R[1]+=R[m]
print(len({*R[1]}-{1}))
s()
``` | output | 1 | 76,621 | 14 | 153,243 |
Provide a correct Python 3 solution for this coding contest problem.
problem
You decide to invite your friends of the school and your friends of a friend to the Christmas party. The number of students in your school is n, and each student is assigned a number from 1 to n. Your number is 1. You have a list of who and ... | instruction | 0 | 76,622 | 14 | 153,244 |
"Correct Solution:
```
while True:
n = int(input())
m = int(input())
if n==0: break
tab = [[] for _ in range(n)]
for _ in range(m):
a,b = map(int,input().split())
a -= 1
b -= 1
tab[a].append(b)
tab[b].append(a)
ans = set(tab[0])
foff = set()
for i ... | output | 1 | 76,622 | 14 | 153,245 |
Provide a correct Python 3 solution for this coding contest problem.
problem
You decide to invite your friends of the school and your friends of a friend to the Christmas party. The number of students in your school is n, and each student is assigned a number from 1 to n. Your number is 1. You have a list of who and ... | instruction | 0 | 76,623 | 14 | 153,246 |
"Correct Solution:
```
while 1:
n = int(input())
m = int(input())
if n == m == 0:
break
a = []
for i in range(m):
x, y = map(int,input().split())
a.append([x, y])
a.sort(key = lambda x: x[0])
f1 = []
f2 = []
for i in range(m):
if a[i][0] == 1:
... | output | 1 | 76,623 | 14 | 153,247 |
Provide a correct Python 3 solution for this coding contest problem.
problem
You decide to invite your friends of the school and your friends of a friend to the Christmas party. The number of students in your school is n, and each student is assigned a number from 1 to n. Your number is 1. You have a list of who and ... | instruction | 0 | 76,624 | 14 | 153,248 |
"Correct Solution:
```
for e in iter(input,'0'):
R=[set()for _ in[0]*-~int(e)]
for _ in[0]*int(input()):
a,b=map(int,input().split())
R[a]|={b}
if a-1:R[b]|={a}
for m in set(R[1]):
R[1]|=R[m]
print(len(R[1]))
``` | output | 1 | 76,624 | 14 | 153,249 |
Provide a correct Python 3 solution for this coding contest problem.
problem
You decide to invite your friends of the school and your friends of a friend to the Christmas party. The number of students in your school is n, and each student is assigned a number from 1 to n. Your number is 1. You have a list of who and ... | instruction | 0 | 76,625 | 14 | 153,250 |
"Correct Solution:
```
while True:
n = int(input())
m = int(input())
if m == 0:
break
dataset = [input().split() for _ in range(m)]
list_ = {i+1: [] for i in range(n)}
for data in dataset:
idx_x, idx_y = map(int, data)
list_[idx_x].append(idx_y)
list_[idx_y].appen... | output | 1 | 76,625 | 14 | 153,251 |
Provide a correct Python 3 solution for this coding contest problem.
problem
You decide to invite your friends of the school and your friends of a friend to the Christmas party. The number of students in your school is n, and each student is assigned a number from 1 to n. Your number is 1. You have a list of who and ... | instruction | 0 | 76,626 | 14 | 153,252 |
"Correct Solution:
```
def solve():
while True:
n = int(input())
if not n:
break
m = int(input())
edge = [[0 for i in range(n + 1)] for j in range(n + 1)]
for i in range(m):
a,b = map(int,input().split())
edge[a][b] = 1
edge[b][a] = 1
friends1 = [i for i in range(n + 1)... | output | 1 | 76,626 | 14 | 153,253 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
You decide to invite your friends of the school and your friends of a friend to the Christmas party. The number of students in your school is n, and each student is assigned a number fr... | instruction | 0 | 76,627 | 14 | 153,254 |
Yes | output | 1 | 76,627 | 14 | 153,255 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
You decide to invite your friends of the school and your friends of a friend to the Christmas party. The number of students in your school is n, and each student is assigned a number fr... | instruction | 0 | 76,628 | 14 | 153,256 |
Yes | output | 1 | 76,628 | 14 | 153,257 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
You decide to invite your friends of the school and your friends of a friend to the Christmas party. The number of students in your school is n, and each student is assigned a number fr... | instruction | 0 | 76,629 | 14 | 153,258 |
Yes | output | 1 | 76,629 | 14 | 153,259 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
You decide to invite your friends of the school and your friends of a friend to the Christmas party. The number of students in your school is n, and each student is assigned a number fr... | instruction | 0 | 76,630 | 14 | 153,260 |
Yes | output | 1 | 76,630 | 14 | 153,261 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
You decide to invite your friends of the school and your friends of a friend to the Christmas party. The number of students in your school is n, and each student is assigned a number fr... | instruction | 0 | 76,631 | 14 | 153,262 |
No | output | 1 | 76,631 | 14 | 153,263 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
You decide to invite your friends of the school and your friends of a friend to the Christmas party. The number of students in your school is n, and each student is assigned a number fr... | instruction | 0 | 76,632 | 14 | 153,264 |
No | output | 1 | 76,632 | 14 | 153,265 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
You decide to invite your friends of the school and your friends of a friend to the Christmas party. The number of students in your school is n, and each student is assigned a number fr... | instruction | 0 | 76,633 | 14 | 153,266 |
No | output | 1 | 76,633 | 14 | 153,267 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
You decide to invite your friends of the school and your friends of a friend to the Christmas party. The number of students in your school is n, and each student is assigned a number fr... | instruction | 0 | 76,634 | 14 | 153,268 |
No | output | 1 | 76,634 | 14 | 153,269 |
Provide a correct Python 3 solution for this coding contest problem.
Problem
Gaccho loses motivation as the final exam approaches and often misses school.
There are N days left until the final exam.
Gaccho's motivation on day i is Xi, and the motivation needed to go to school on day i is Yi.
Gaccho goes to school onl... | instruction | 0 | 76,651 | 14 | 153,302 |
"Correct Solution:
```
N,P=map(int,input().split())
xs=[]
ys=[]
dp=[[[1e9 for i in range(N+1)] for j in range(N+1)] for k in range(N+1)]
memo=[[0 for i in range(N+1)] for j in range(N+1)]
for i in range(N):
x,y=map(int,input().split())
xs.append(x)
ys.append(y)
for start in range(N):
preuse=0
for n... | output | 1 | 76,651 | 14 | 153,303 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Given a positive integer m, we say that a sequence x_1, x_2, ..., x_n of positive integers is m-cute if for every index i such that 2 ≤ i ≤ n it holds that x_i = x_{i - 1} + x_{i - 2} + ... + x_1 + r_i for some positive integer r_i satisfyin... | instruction | 0 | 76,768 | 14 | 153,536 |
Tags: binary search, brute force, greedy, math
Correct Solution:
```
import sys
input = sys.stdin.readline
q=int(input())
Q=[list(map(int,input().split())) for i in range(q)]
for a,b,m in Q:
MIN=[a]
MAX=[a]
SUMMIN=a
SUMMAX=a
flag=1
for k in range(51):
if MIN[-1]<=b<=MAX[-1]:
... | output | 1 | 76,768 | 14 | 153,537 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Given a positive integer m, we say that a sequence x_1, x_2, ..., x_n of positive integers is m-cute if for every index i such that 2 ≤ i ≤ n it holds that x_i = x_{i - 1} + x_{i - 2} + ... + x_1 + r_i for some positive integer r_i satisfyin... | instruction | 0 | 76,769 | 14 | 153,538 |
Tags: binary search, brute force, greedy, math
Correct Solution:
```
for _ in range(int(input())):
a,b,m=map(int,input().split())
if a==b:
print(1,a)
continue
for k in range(2,51):
pw=1<<(k-2)
mn=pw*(a+1)
mx=pw*(a+m)
if mn<=b<=mx:
r=[0]*(k+1)
... | output | 1 | 76,769 | 14 | 153,539 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Given a positive integer m, we say that a sequence x_1, x_2, ..., x_n of positive integers is m-cute if for every index i such that 2 ≤ i ≤ n it holds that x_i = x_{i - 1} + x_{i - 2} + ... + x_1 + r_i for some positive integer r_i satisfyin... | instruction | 0 | 76,770 | 14 | 153,540 |
Tags: binary search, brute force, greedy, math
Correct Solution:
```
# https://codeforces.com/contest/1166/problem/D
def creat_r(X, k, m, p):
q = X // p[k]
r = X % p[k]
R = []
for _ in range(k+1):
R.append(q)
s = bin(r)[2:]
for i in range(1, len(s)+1):
if s[-i] == ... | output | 1 | 76,770 | 14 | 153,541 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Given a positive integer m, we say that a sequence x_1, x_2, ..., x_n of positive integers is m-cute if for every index i such that 2 ≤ i ≤ n it holds that x_i = x_{i - 1} + x_{i - 2} + ... + x_1 + r_i for some positive integer r_i satisfyin... | instruction | 0 | 76,771 | 14 | 153,542 |
Tags: binary search, brute force, greedy, math
Correct Solution:
```
q = int(input())
def prepare_sequence(a, b, curr_two_pow, m):
sequence = [a]
curr_pow = 1
diff = b-curr_two_pow*a
while curr_two_pow > 1:
m_candidate = 1
diff -= m_candidate
while diff > curr_two_pow//2:
m_candidate*=2
... | output | 1 | 76,771 | 14 | 153,543 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Given a positive integer m, we say that a sequence x_1, x_2, ..., x_n of positive integers is m-cute if for every index i such that 2 ≤ i ≤ n it holds that x_i = x_{i - 1} + x_{i - 2} + ... + x_1 + r_i for some positive integer r_i satisfyin... | instruction | 0 | 76,772 | 14 | 153,544 |
Tags: binary search, brute force, greedy, math
Correct Solution:
```
def solve():
a, b, m = (int(x) for x in input().split())
if a == b:
print(1, a)
return
curr = a
curr_const = 1
steps_nr = 0
while b - curr > curr_const * m:
curr *= 2
curr_const *= 2
step... | output | 1 | 76,772 | 14 | 153,545 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Given a positive integer m, we say that a sequence x_1, x_2, ..., x_n of positive integers is m-cute if for every index i such that 2 ≤ i ≤ n it holds that x_i = x_{i - 1} + x_{i - 2} + ... + x_1 + r_i for some positive integer r_i satisfyin... | instruction | 0 | 76,773 | 14 | 153,546 |
Tags: binary search, brute force, greedy, math
Correct Solution:
```
for _ in range(int(input())):
a, b, m = [int(i) for i in input().split()]
if a == b:
print("1 " + str(a))
continue
l = a + 1
r = a + m
cnt = 1
while r < b:
l += l
r += r
cnt += 1
i... | output | 1 | 76,773 | 14 | 153,547 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Given a positive integer m, we say that a sequence x_1, x_2, ..., x_n of positive integers is m-cute if for every index i such that 2 ≤ i ≤ n it holds that x_i = x_{i - 1} + x_{i - 2} + ... + x_1 + r_i for some positive integer r_i satisfyin... | instruction | 0 | 76,774 | 14 | 153,548 |
Tags: binary search, brute force, greedy, math
Correct Solution:
```
# ========= /\ /| |====/|
# | / \ | | / |
# | /____\ | | / |
# | / \ | | / |
# ========= / \ ===== |/====|
# code
if __name__ == "__main__":
q = int(i... | output | 1 | 76,774 | 14 | 153,549 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Given a positive integer m, we say that a sequence x_1, x_2, ..., x_n of positive integers is m-cute if for every index i such that 2 ≤ i ≤ n it holds that x_i = x_{i - 1} + x_{i - 2} + ... + x_1 + r_i for some positive integer r_i satisfyin... | instruction | 0 | 76,775 | 14 | 153,550 |
Tags: binary search, brute force, greedy, math
Correct Solution:
```
from sys import stdin, stdout
n = int(stdin.readline())
for nn in range(n):
a, b, m = map(int,stdin.readline().split())
if a == b:
stdout.write('{} {}\n'.format(1,a))
else:
for j in range(2,51):
if (a+1)<<(j-2... | output | 1 | 76,775 | 14 | 153,551 |
Provide tags and a correct Python 3 solution for this coding contest problem.
n soldiers stand in a circle. For each soldier his height ai is known. A reconnaissance unit can be made of such two neighbouring soldiers, whose heights difference is minimal, i.e. |ai - aj| is minimal. So each of them will be less noticeab... | instruction | 0 | 77,049 | 14 | 154,098 |
Tags: implementation
Correct Solution:
```
n = int(input())
li = tuple((map(int, input().split())))
li1 = []
diff = []
i = 0
flag = 0
flag1 = 0
for i in range(len(li)):
try:
diff.append(abs(li[i] - li[i + 1]))
li1.append([li[i], li[i + 1]])
except IndexError:
diff.append(abs(li[i] - li[0... | output | 1 | 77,049 | 14 | 154,099 |
Provide tags and a correct Python 3 solution for this coding contest problem.
n soldiers stand in a circle. For each soldier his height ai is known. A reconnaissance unit can be made of such two neighbouring soldiers, whose heights difference is minimal, i.e. |ai - aj| is minimal. So each of them will be less noticeab... | instruction | 0 | 77,050 | 14 | 154,100 |
Tags: implementation
Correct Solution:
```
n = int(input())
a = list(int(b) for b in input().split())
mi = n-1
md = abs(a[0]-a[mi])
for i in range(n-1):
td = abs(a[i]-a[i+1])
if td < md:
md = td
mi = i
if md == 0:
break
print(mi+1, (mi+1)%n+1)
``` | output | 1 | 77,050 | 14 | 154,101 |
Provide tags and a correct Python 3 solution for this coding contest problem.
n soldiers stand in a circle. For each soldier his height ai is known. A reconnaissance unit can be made of such two neighbouring soldiers, whose heights difference is minimal, i.e. |ai - aj| is minimal. So each of them will be less noticeab... | instruction | 0 | 77,051 | 14 | 154,102 |
Tags: implementation
Correct Solution:
```
n=int(input())
a=list(map(int,input().split()))
ab=max(a)
ind=-1
for i in range(1,n):
if abs(a[i]-a[i-1]) < ab:
ab=abs(a[i]-a[i-1])
ind=i
if ab<abs(a[-1]-a[0]):
print(ind+1,ind)
else:
print(n,1)
``` | output | 1 | 77,051 | 14 | 154,103 |
Provide tags and a correct Python 3 solution for this coding contest problem.
n soldiers stand in a circle. For each soldier his height ai is known. A reconnaissance unit can be made of such two neighbouring soldiers, whose heights difference is minimal, i.e. |ai - aj| is minimal. So each of them will be less noticeab... | instruction | 0 | 77,052 | 14 | 154,104 |
Tags: implementation
Correct Solution:
```
n = int(input())
heights = [int(x) for x in input().split(' ')]
mn = abs(heights[len(heights)-1] - heights[0])
ans = [len(heights), 1]
for i in range(len(heights)-1):
if abs(heights[i+1] - heights[i]) < mn:
mn = abs(heights[i+1] - heights[i])
ans = [i+1, i... | output | 1 | 77,052 | 14 | 154,105 |
Provide tags and a correct Python 3 solution for this coding contest problem.
n soldiers stand in a circle. For each soldier his height ai is known. A reconnaissance unit can be made of such two neighbouring soldiers, whose heights difference is minimal, i.e. |ai - aj| is minimal. So each of them will be less noticeab... | instruction | 0 | 77,053 | 14 | 154,106 |
Tags: implementation
Correct Solution:
```
n = int(input())
lst = list(map(int, input().split()))
mn = abs(lst[1] - lst[0])
sol = [1, 2]
for i in range(2, len(lst)):
tmp = abs(lst[i] - lst[i-1])
if tmp < mn:
sol[0] = i
sol[1] = i + 1
mn = tmp
if abs(lst[-1] - lst[0]) < mn:
sol[0] = n... | output | 1 | 77,053 | 14 | 154,107 |
Provide tags and a correct Python 3 solution for this coding contest problem.
n soldiers stand in a circle. For each soldier his height ai is known. A reconnaissance unit can be made of such two neighbouring soldiers, whose heights difference is minimal, i.e. |ai - aj| is minimal. So each of them will be less noticeab... | instruction | 0 | 77,054 | 14 | 154,108 |
Tags: implementation
Correct Solution:
```
n = int(input())
s = list(map(int,input().strip().split()))[:n]
in1,in2,h=0,0,1000
for i in range(n):
k = abs(s[i] - s[(i+1)%n])
if k<h:
h=k
in1= i+1
in2 = ((i+1)%n) + 1
print(in1,in2)
``` | output | 1 | 77,054 | 14 | 154,109 |
Provide tags and a correct Python 3 solution for this coding contest problem.
n soldiers stand in a circle. For each soldier his height ai is known. A reconnaissance unit can be made of such two neighbouring soldiers, whose heights difference is minimal, i.e. |ai - aj| is minimal. So each of them will be less noticeab... | instruction | 0 | 77,055 | 14 | 154,110 |
Tags: implementation
Correct Solution:
```
n=int(input())
l=list(map(int,input().split()))
ans=abs(l[-1]-l[0])
x,y=0,n-1
for i in range(n-1):
if(ans>abs(l[i]-l[i+1])):
ans=abs(l[i]-l[i+1])
x,y=i,i+1
print(x+1,y+1)
``` | output | 1 | 77,055 | 14 | 154,111 |
Provide tags and a correct Python 3 solution for this coding contest problem.
n soldiers stand in a circle. For each soldier his height ai is known. A reconnaissance unit can be made of such two neighbouring soldiers, whose heights difference is minimal, i.e. |ai - aj| is minimal. So each of them will be less noticeab... | instruction | 0 | 77,056 | 14 | 154,112 |
Tags: implementation
Correct Solution:
```
N=int(input())
ara=list(map(int,input().split()))
min=abs(ara[-1]-ara[0])
x=N
y=1
for i in range(1,N):
if(abs(ara[i]-ara[i-1])<min):
min=abs(ara[i]-ara[i-1])
x=i
y=i+1
print(x,y)
``` | output | 1 | 77,056 | 14 | 154,113 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of the collected works of Berland leaders, the library has a reading room.
Today was the pilot launch of an automated r... | instruction | 0 | 77,119 | 14 | 154,238 |
Tags: implementation
Correct Solution:
```
ins = []
sumi = []
ous = []
n = int(input())
l = []
for i in range(n):
l.append(str(input()))
sumi.append(0)
sumi.append(0)
for i in range(n):
if l[i][0] == "+":
ins.append(l[i][2:len(l[i])])
for j in range(i+1, n+1):
sumi[j]+=1
e... | output | 1 | 77,119 | 14 | 154,239 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of the collected works of Berland leaders, the library has a reading room.
Today was the pilot launch of an automated r... | instruction | 0 | 77,120 | 14 | 154,240 |
Tags: implementation
Correct Solution:
```
n = int(input())
people = []
current = 0
num = [0]
for i in range(n):
x, y = input().split()
if x == "+":
people.append(y)
current += 1
num.append(current)
else:
try:
people.remove(y)
current -= 1
exce... | output | 1 | 77,120 | 14 | 154,241 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.