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 |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the ... | instruction | 0 | 69,291 | 14 | 138,582 |
Yes | output | 1 | 69,291 | 14 | 138,583 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the ... | instruction | 0 | 69,292 | 14 | 138,584 |
Yes | output | 1 | 69,292 | 14 | 138,585 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the ... | instruction | 0 | 69,293 | 14 | 138,586 |
No | output | 1 | 69,293 | 14 | 138,587 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the ... | instruction | 0 | 69,294 | 14 | 138,588 |
No | output | 1 | 69,294 | 14 | 138,589 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the ... | instruction | 0 | 69,295 | 14 | 138,590 |
No | output | 1 | 69,295 | 14 | 138,591 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the ... | instruction | 0 | 69,296 | 14 | 138,592 |
No | output | 1 | 69,296 | 14 | 138,593 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one couple of a boy and a girl in the line, the fol... | instruction | 0 | 69,345 | 14 | 138,690 |
Tags: data structures
Correct Solution:
```
import heapq, sys
q = []
cnt = 0
n = int(input())
sex = input()
a = list(map(int, input().split()))
l = [i-1 for i in range(n)]
r = [i+1 for i in range(n)]
for i in range(n-1):
if sex[i] != sex[i+1]:
heapq.heappush(q, (abs(a[i] - a[i+1]), i, i+1))
cnt += 1
ans = []
while... | output | 1 | 69,345 | 14 | 138,691 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one couple of a boy and a girl in the line, the fol... | instruction | 0 | 69,346 | 14 | 138,692 |
Tags: data structures
Correct Solution:
```
__author__ = 'Utena'
from heapq import heappushpop, heapify,heappop,heappush
n=int(input())
danced=[0]*(n+1)
gender=[0]+list(input())
skill=[0]+list(map(int,input().split()))
next=[0]+[i+1 for i in range(1,n)]+[0]
prev=[0]+[i for i in range(n)]
ans=[]
line=[]
total=0
for i in... | output | 1 | 69,346 | 14 | 138,693 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one couple of a boy and a girl in the line, the fol... | instruction | 0 | 69,347 | 14 | 138,694 |
Tags: data structures
Correct Solution:
```
from heapq import heappushpop, heapify,heappop,heappush
n=int(input())
li = input()
a = list(map(int, input().split()))
h,seq = [],[]
dan = [0]*(n+1)
for i in range(n+1)[2:n]:
#dan[i]=(Node(li[i-1],i-1,i+1))
dan[i]=[i-1,i+1]
#dan[1]=(Node(li[0],None,2))
dan[1] = [None... | output | 1 | 69,347 | 14 | 138,695 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one couple of a boy and a girl in the line, the fol... | instruction | 0 | 69,348 | 14 | 138,696 |
Tags: data structures
Correct Solution:
```
#Again testing the condition of the server, code by Yijie Xia
import heapq as hq
n=int(input())
s=input()
a=list(map(int,input().split()))
pre=[i-1 for i in range(n)]
nxt=[i+1 for i in range(n)]
free=[1 for i in range(n)]
line=[(abs(a[i]-a[i+1]),i,i+1) for i in range(n-1) if ... | output | 1 | 69,348 | 14 | 138,697 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one couple of a boy and a girl in the line, the fol... | instruction | 0 | 69,349 | 14 | 138,698 |
Tags: data structures
Correct Solution:
```
from heapq import heapify,heappush,heappop
n = int(input())
sex = input()
a = [int(i) for i in input().split()]
cp = []
r = []
b = sex.count('B')
N = min(n-b,b)
for i in range(1,len(a)):
if sex[i] != sex[i-1]:
cp.append((abs(a[i]-a[i-1]),i-1,i))
heapify(cp)
prev ... | output | 1 | 69,349 | 14 | 138,699 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one couple of a boy and a girl in the line, the fol... | instruction | 0 | 69,350 | 14 | 138,700 |
Tags: data structures
Correct Solution:
```
import heapq as hq
n=int(input())
s=input()
a=list(map(int,input().split()))
pre=[i-1 for i in range(n)]
nxt=[i+1 for i in range(n)]
free=[1 for i in range(n)]
line=[(abs(a[i]-a[i+1]),i,i+1) for i in range(n-1) if s[i]!=s[i+1]]
#print(line)
hq.heapify(line)
ans=[]
while line... | output | 1 | 69,350 | 14 | 138,701 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one couple of a boy and a girl in the line, the fol... | instruction | 0 | 69,351 | 14 | 138,702 |
Tags: data structures
Correct Solution:
```
import heapq,sys
q=[]
c=0
n=int(input())
s=input()
a=list(map(int,input().split()))
l=[i-1 for i in range(n)]
r=[i+1 for i in range(n)]
for i in range(n-1):
if s[i]!=s[i+1]:
heapq.heappush(q,(abs(a[i]-a[i+1]),i,i+1))
c+=1
ans=[]
while c>0:
t,i,j=heapq.heappop(q)
c-=1
... | output | 1 | 69,351 | 14 | 138,703 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one couple of a boy and a girl in the line, the fol... | instruction | 0 | 69,352 | 14 | 138,704 |
Tags: data structures
Correct Solution:
```
from heapq import heappush, heappop,heapify
n = int(input())
b = list(input())
a = [int(i)for i in input().split()]
c = []
d = [0]*n
e = []
ahead = [0]+[i for i in range(n)]
after = [i+1 for i in range(n)]+[0]
num = 0
fo... | output | 1 | 69,352 | 14 | 138,705 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one ... | instruction | 0 | 69,353 | 14 | 138,706 |
Yes | output | 1 | 69,353 | 14 | 138,707 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one ... | instruction | 0 | 69,354 | 14 | 138,708 |
Yes | output | 1 | 69,354 | 14 | 138,709 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one ... | instruction | 0 | 69,355 | 14 | 138,710 |
Yes | output | 1 | 69,355 | 14 | 138,711 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one ... | instruction | 0 | 69,356 | 14 | 138,712 |
Yes | output | 1 | 69,356 | 14 | 138,713 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one ... | instruction | 0 | 69,357 | 14 | 138,714 |
No | output | 1 | 69,357 | 14 | 138,715 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one ... | instruction | 0 | 69,358 | 14 | 138,716 |
No | output | 1 | 69,358 | 14 | 138,717 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one ... | instruction | 0 | 69,359 | 14 | 138,718 |
No | output | 1 | 69,359 | 14 | 138,719 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one ... | instruction | 0 | 69,360 | 14 | 138,720 |
No | output | 1 | 69,360 | 14 | 138,721 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worri... | instruction | 0 | 69,491 | 14 | 138,982 |
Tags: dp, two pointers
Correct Solution:
```
def main():
n = int(input())
a = list(map(int, input().split()))
b = [abs(a[i] - a[i + 1]) for i in range(len(a) - 1)]
ansmx = [0] * len(b)
ansmn = [0] * len(b)
ansmx[-1] = b[-1]
ansmn[-1] = 0
for i in range(1, len(b)):
j = i - 1
... | output | 1 | 69,491 | 14 | 138,983 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worri... | instruction | 0 | 69,492 | 14 | 138,984 |
Tags: dp, two pointers
Correct Solution:
```
n=int(input())
a=list(map(int,input().split()))
ans=-10**9-1
mini=0
temp=0
for i in range(n-1):
if(i%2==0):temp+=abs(a[i]-a[i+1])
else:temp-=abs(a[i]-a[i+1])
mini=min(mini,temp)
ans=max(ans,temp-mini)
mini=0
temp=0
for i in range(1,n-1):
if(i%2==0):temp-=abs(a[i]-a[i+1]... | output | 1 | 69,492 | 14 | 138,985 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worri... | instruction | 0 | 69,493 | 14 | 138,986 |
Tags: dp, two pointers
Correct Solution:
```
from sys import stdin
input=lambda : stdin.readline().strip()
from math import ceil,sqrt,factorial,gcd
from collections import deque
from bisect import bisect_left,bisect_right
n=int(input())
l=list(map(int,input().split()))
z=[]
for i in range(n-1):
z.append(abs(l[i]-l[i+1... | output | 1 | 69,493 | 14 | 138,987 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worri... | instruction | 0 | 69,495 | 14 | 138,990 |
Tags: dp, two pointers
Correct Solution:
```
def mp(): return map(int,input().split())
def lt(): return list(map(int,input().split()))
def pt(x): print(x)
def ip(): return input()
def it(): return int(input())
def sl(x): return [t for t in x]
def spl(x): return x.split()
def aj(liste, item): liste.append(item)
d... | output | 1 | 69,495 | 14 | 138,991 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worri... | instruction | 0 | 69,496 | 14 | 138,992 |
Tags: dp, two pointers
Correct Solution:
```
from collections import defaultdict
from sys import stdin
def fun(ar):
if(len(ar)) < 2:
return 0
ans, cur = 0, 0
for i in range(len(ar)-1):
if (i & 1) == 0 and cur < 0:
cur = 0
cur += abs(ar[i+1]-ar[i])*(-1 if i & 1 else 1)
ans = max(ans, cur)
return ans
de... | output | 1 | 69,496 | 14 | 138,993 |
Provide a correct Python 3 solution for this coding contest problem.
There are N people (with different names) and K clubs. For each club you know the list of members (so you have K unordered lists). Each person can be a member of many clubs (and also 0 clubs) and two different clubs might have exactly the same member... | instruction | 0 | 69,592 | 14 | 139,184 |
"Correct Solution:
```
#
# File : F.py
# Author : Kazune Takahashi
# Created : 5/24/2020, 3:07:25 AM
# Powered by Visual Studio Code
#
dic = {
1: 1,
2: 1,
3: 1,
4: 7,
5: 4,
6: 1,
7: 336,
8: 384,
9: 334,
10: 220,
11: 108,
12: 36,
13: 6,
27: 976,
28: 108,
... | output | 1 | 69,592 | 14 | 139,185 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N people (with different names) and K clubs. For each club you know the list of members (so you have K unordered lists). Each person can be a member of many clubs (and also 0 clubs) an... | instruction | 0 | 69,593 | 14 | 139,186 |
No | output | 1 | 69,593 | 14 | 139,187 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N people (with different names) and K clubs. For each club you know the list of members (so you have K unordered lists). Each person can be a member of many clubs (and also 0 clubs) an... | instruction | 0 | 69,594 | 14 | 139,188 |
No | output | 1 | 69,594 | 14 | 139,189 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N people (with different names) and K clubs. For each club you know the list of members (so you have K unordered lists). Each person can be a member of many clubs (and also 0 clubs) an... | instruction | 0 | 69,595 | 14 | 139,190 |
No | output | 1 | 69,595 | 14 | 139,191 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N people (with different names) and K clubs. For each club you know the list of members (so you have K unordered lists). Each person can be a member of many clubs (and also 0 clubs) an... | instruction | 0 | 69,596 | 14 | 139,192 |
No | output | 1 | 69,596 | 14 | 139,193 |
Provide tags and a correct Python 3 solution for this coding contest problem.
As meticulous Gerald sets the table, Alexander finished another post on Codeforces and begins to respond to New Year greetings from friends. Alexander has n friends, and each of them sends to Alexander exactly one e-card. Let us number his f... | instruction | 0 | 70,037 | 14 | 140,074 |
Tags: brute force, greedy, implementation
Correct Solution:
```
n = int(input())
arr = [list(map(int, input().split())) for _ in range(n+1)]
res = [0] * n
for i in range(n):
p = [0] * (n+1)
for j in range(n):
p[arr[i][j]] = j
u, t, b = 0, int(1e5), int(1e5)
for x in arr[n]:
if x != i+1 ... | output | 1 | 70,037 | 14 | 140,075 |
Provide tags and a correct Python 3 solution for this coding contest problem.
As meticulous Gerald sets the table, Alexander finished another post on Codeforces and begins to respond to New Year greetings from friends. Alexander has n friends, and each of them sends to Alexander exactly one e-card. Let us number his f... | instruction | 0 | 70,038 | 14 | 140,076 |
Tags: brute force, greedy, implementation
Correct Solution:
```
def f():
t = [0] * n
for i, j in enumerate(input().split()): t[int(j) - 1] = i
return t
n = int(input())
p = [f() for i in range(n)]
s = f()
for x, t in enumerate(p):
i = j = x < 1
for y in range(n):
if x != y and s[y] < s[i]: i... | output | 1 | 70,038 | 14 | 140,077 |
Provide tags and a correct Python 3 solution for this coding contest problem.
As meticulous Gerald sets the table, Alexander finished another post on Codeforces and begins to respond to New Year greetings from friends. Alexander has n friends, and each of them sends to Alexander exactly one e-card. Let us number his f... | instruction | 0 | 70,039 | 14 | 140,078 |
Tags: brute force, greedy, implementation
Correct Solution:
```
import sys
from itertools import *
from math import *
def solve():
n = int(input())
tab = [list(map(int, input().split())) for _ in range(n)]
alex = list(map(int, input().split()))
willget = [[0]*n for _ in range(n)]
has = list()
fo... | output | 1 | 70,039 | 14 | 140,079 |
Provide tags and a correct Python 3 solution for this coding contest problem.
As meticulous Gerald sets the table, Alexander finished another post on Codeforces and begins to respond to New Year greetings from friends. Alexander has n friends, and each of them sends to Alexander exactly one e-card. Let us number his f... | instruction | 0 | 70,040 | 14 | 140,080 |
Tags: brute force, greedy, implementation
Correct Solution:
```
n = int(input())
frnd = [list(map(int, input().split() )) for _ in range(n)]
ara = list(map(int, input().split() ))
pref = [0]*(n+1)
ans = [0] * n
for i in range(n):
pref[ara[i]] = i
def ok(val, row):
for x in ara:
if x-1 == row:
continue
if ... | output | 1 | 70,040 | 14 | 140,081 |
Provide tags and a correct Python 3 solution for this coding contest problem.
As meticulous Gerald sets the table, Alexander finished another post on Codeforces and begins to respond to New Year greetings from friends. Alexander has n friends, and each of them sends to Alexander exactly one e-card. Let us number his f... | instruction | 0 | 70,041 | 14 | 140,082 |
Tags: brute force, greedy, implementation
Correct Solution:
```
import sys
from itertools import *
from math import *
def solve():
n = int(input())
tab = [list(map(int, input().split())) for _ in range(n)]
alex = list(map(int, input().split()))
has = list()
for row in range(n):
hasrow = list... | output | 1 | 70,041 | 14 | 140,083 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
As meticulous Gerald sets the table, Alexander finished another post on Codeforces and begins to respond to New Year greetings from friends. Alexander has n friends, and each of them sends to Al... | instruction | 0 | 70,042 | 14 | 140,084 |
No | output | 1 | 70,042 | 14 | 140,085 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
As meticulous Gerald sets the table, Alexander finished another post on Codeforces and begins to respond to New Year greetings from friends. Alexander has n friends, and each of them sends to Al... | instruction | 0 | 70,043 | 14 | 140,086 |
No | output | 1 | 70,043 | 14 | 140,087 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
As meticulous Gerald sets the table, Alexander finished another post on Codeforces and begins to respond to New Year greetings from friends. Alexander has n friends, and each of them sends to Al... | instruction | 0 | 70,044 | 14 | 140,088 |
No | output | 1 | 70,044 | 14 | 140,089 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
As meticulous Gerald sets the table, Alexander finished another post on Codeforces and begins to respond to New Year greetings from friends. Alexander has n friends, and each of them sends to Al... | instruction | 0 | 70,045 | 14 | 140,090 |
No | output | 1 | 70,045 | 14 | 140,091 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Once n people simultaneously signed in to the reception at the recently opened, but already thoroughly bureaucratic organization (abbreviated TBO). As the organization is thoroughly bureaucratic, it can accept and cater for exactly one perso... | instruction | 0 | 70,112 | 14 | 140,224 |
Tags: binary search, combinatorics
Correct Solution:
```
def go(m, k):
rem, ans, binom = m*k, 0, 1
ones = 0
while ones <= k:
take = min(1 if ones == 0 else rem//ones, binom)
if take == 0:
break
ans += take
rem -= ones * take
binom = binom*(k-ones)//(ones+1)
ones += 1
return ans
def solve():
n, m =... | output | 1 | 70,112 | 14 | 140,225 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya has k matches, placed in n matchboxes lying in a line from left to right. We know that k is divisible by n. Petya wants all boxes to have the same number of matches inside. For that, he can move a match from its box to the adjacent one... | instruction | 0 | 70,175 | 14 | 140,350 |
Tags: greedy, implementation
Correct Solution:
```
n=int(input())
a=list(map(int,input().split()))
t=0
for i in range(n):
t+=a[i]
t=t//n
cnt=0
for i in range(n):
if a[i]>t:
a[i+1]+=abs(a[i]-t)
cnt+=(abs(a[i]-t))
elif a[i]<t:
a[i+1]-=abs(a[i]-t)
cnt+=(abs(a[i]-t))
print(c... | output | 1 | 70,175 | 14 | 140,351 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya has k matches, placed in n matchboxes lying in a line from left to right. We know that k is divisible by n. Petya wants all boxes to have the same number of matches inside. For that, he can move a match from its box to the adjacent one... | instruction | 0 | 70,179 | 14 | 140,358 |
Tags: greedy, implementation
Correct Solution:
```
n=int(input())
lst=[*map(int,input().split())]
item=sum(lst)//n
from sys import exit
if n==1:print(0);exit()
less,more,leng1,leng2=[],[],0,0
for i,x in enumerate(lst):
if x<item:less.append(i);leng1+=1
if x>item:more.append(i);leng2+=1
if leng1==0 and leng2==0:... | output | 1 | 70,179 | 14 | 140,359 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya has k matches, placed in n matchboxes lying in a line from left to right. We know that k is divisible by n. Petya wants all boxes to have the same number of matches inside. For that, he can move a match from its box to the adjacent one... | instruction | 0 | 70,180 | 14 | 140,360 |
Tags: greedy, implementation
Correct Solution:
```
n = int(input())
a = [int(i) for i in input().split()]
av = sum(a) // len(a)
ans = 0
s = 0
for i in a:
s += i - av
ans += abs(s)
print(ans)
# Made By Mostafa_Khaled
``` | output | 1 | 70,180 | 14 | 140,361 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya has k matches, placed in n matchboxes lying in a line from left to right. We know that k is divisible by n. Petya wants all boxes to have the same number of matches inside. For that, he can move a match from its box to the adjacent one... | instruction | 0 | 70,181 | 14 | 140,362 |
Tags: greedy, implementation
Correct Solution:
```
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode... | output | 1 | 70,181 | 14 | 140,363 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya has k matches, placed in n matchboxes lying in a line from left to right. We know that k is divisible by n. Petya wants all boxes to have the same number of matches inside. For that, he can move a match from its box to the adjacent one... | instruction | 0 | 70,182 | 14 | 140,364 |
Tags: greedy, implementation
Correct Solution:
```
n = int(input())
a = [int(i) for i in input().split()]
av = sum(a) // len(a)
ans = 0
s = 0
for i in a:
s += i - av
ans += abs(s)
print(ans)
``` | output | 1 | 70,182 | 14 | 140,365 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Sagheer is working at a kindergarten. There are n children and m different toys. These children use well-defined protocols for playing with the toys:
* Each child has a lovely set of toys that he loves to play with. He requests the toys o... | instruction | 0 | 70,393 | 14 | 140,786 |
Tags: dfs and similar, graphs, implementation, trees
Correct Solution:
```
from sys import stdin
from sys import stdout
n, m, k, q = map(int, stdin.readline().split())
d = [None for i in range(m)]
roots = set(range(n))
matrix = [[] for i in range(n)]
for i in range(k):
x, y = map(int, stdin.readline().split())
... | output | 1 | 70,393 | 14 | 140,787 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sagheer is working at a kindergarten. There are n children and m different toys. These children use well-defined protocols for playing with the toys:
* Each child has a lovely set of toys tha... | instruction | 0 | 70,394 | 14 | 140,788 |
No | output | 1 | 70,394 | 14 | 140,789 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sagheer is working at a kindergarten. There are n children and m different toys. These children use well-defined protocols for playing with the toys:
* Each child has a lovely set of toys tha... | instruction | 0 | 70,395 | 14 | 140,790 |
No | output | 1 | 70,395 | 14 | 140,791 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.