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.
The only difference between easy and hard versions is constraints.
There are n kids, each of them is reading a unique book. At the end of any day, the i-th kid will give his book to the p_i-th kid (in case of i = p_i the kid will give his b... | instruction | 0 | 63,239 | 14 | 126,478 |
Tags: dfs and similar, dsu, math
Correct Solution:
```
N = []
AA = []
t = int(input())
for i in range(t):
N.append(int(input()))
a = list(map(int,input().split()))
for j in range(len(a)):
a[j] -= 1
AA.append(a)
for i in range(t):
n = N[i]
A = AA[i]
ans = [0] * n
for j in range(n... | output | 1 | 63,239 | 14 | 126,479 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is constraints.
There are n kids, each of them is reading a unique book. At the end of any day, the i-th kid will give his book to the p_i-th kid (in case of i = p_i the kid will give his b... | instruction | 0 | 63,240 | 14 | 126,480 |
Tags: dfs and similar, dsu, math
Correct Solution:
```
for _ in range(int(input())):
kids = int(input())
order = list(map(int, input().split()))
used = set()
re = [None]*kids
for j in range(1,kids+1):
if re[j-1]:
continue
else:
idx = order[j-1]
... | output | 1 | 63,240 | 14 | 126,481 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is constraints.
There are n kids, each of them is reading a unique book. At the end of any day, the i-th kid will give his book to the p_i-th kid (in case of i = p_i the kid will give his b... | instruction | 0 | 63,241 | 14 | 126,482 |
Tags: dfs and similar, dsu, math
Correct Solution:
```
q = int(input())
nums = []
pos =[]
'''for _ in range(q):
nums += [int(input())]
p = input().split()
pos += [[ int(x)-1 for x in p]]'''
for i in range(q):
n = int(input())
p = input().split()
p = [ int(x)-1 for x in p]
list1 =... | output | 1 | 63,241 | 14 | 126,483 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is constraints.
There are n kids, each of them is reading a unique book. At the end of any day, the i-th kid will give his book to the p_i-th kid (in case of i = p_i the kid will give his b... | instruction | 0 | 63,242 | 14 | 126,484 |
Tags: dfs and similar, dsu, math
Correct Solution:
```
#!/usr/bin/env python
import sys
def atoi(line):
line = line.rstrip().split()
return list(map(int, line))
ans = []
q = int(input())
for q_ in range(q):
n = int(input())
p = atoi(sys.stdin.readline())
p.insert(0, 0)
used = [False] * (n + 1... | output | 1 | 63,242 | 14 | 126,485 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is constraints.
There are n kids, each of them is reading a unique book. At the end of any day, the i-th kid will give his book to the p_i-th kid (in case of i = p_i the kid will give his b... | instruction | 0 | 63,243 | 14 | 126,486 |
Tags: dfs and similar, dsu, math
Correct Solution:
```
#_______________________________________________________________#
def fact(x):
if x == 0:
return 1
else:
return x * fact(x-1)
def lower_bound(li, num): #return 0 if all are greater or equal to
answer = -1 #no role though
start = 0
end = len(li)-1
while(s... | output | 1 | 63,243 | 14 | 126,487 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is constraints.
There are n kids, each of them is reading a unique book. At the end of any day, the i-th kid will give his book to the p_i-th kid (in case of i = p_i the kid will give his b... | instruction | 0 | 63,244 | 14 | 126,488 |
Tags: dfs and similar, dsu, math
Correct Solution:
```
for _ in range(int(input())):
n=int(input())
a=[(int(i)-1) for i in input().split()]
c=[1]*n
b=set()
for i in range(n):
if a[i] in b:
continue
if len(b)==n:
break
j=i
a1=set()
s=1
... | output | 1 | 63,244 | 14 | 126,489 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is constraints.
There are n kids, each of them is reading a unique book. At the end of any day, the i-th kid will give his book to the p_i-th ... | instruction | 0 | 63,245 | 14 | 126,490 |
Yes | output | 1 | 63,245 | 14 | 126,491 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is constraints.
There are n kids, each of them is reading a unique book. At the end of any day, the i-th kid will give his book to the p_i-th ... | instruction | 0 | 63,246 | 14 | 126,492 |
Yes | output | 1 | 63,246 | 14 | 126,493 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is constraints.
There are n kids, each of them is reading a unique book. At the end of any day, the i-th kid will give his book to the p_i-th ... | instruction | 0 | 63,247 | 14 | 126,494 |
Yes | output | 1 | 63,247 | 14 | 126,495 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is constraints.
There are n kids, each of them is reading a unique book. At the end of any day, the i-th kid will give his book to the p_i-th ... | instruction | 0 | 63,248 | 14 | 126,496 |
Yes | output | 1 | 63,248 | 14 | 126,497 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is constraints.
There are n kids, each of them is reading a unique book. At the end of any day, the i-th kid will give his book to the p_i-th ... | instruction | 0 | 63,249 | 14 | 126,498 |
No | output | 1 | 63,249 | 14 | 126,499 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is constraints.
There are n kids, each of them is reading a unique book. At the end of any day, the i-th kid will give his book to the p_i-th ... | instruction | 0 | 63,250 | 14 | 126,500 |
No | output | 1 | 63,250 | 14 | 126,501 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is constraints.
There are n kids, each of them is reading a unique book. At the end of any day, the i-th kid will give his book to the p_i-th ... | instruction | 0 | 63,251 | 14 | 126,502 |
No | output | 1 | 63,251 | 14 | 126,503 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is constraints.
There are n kids, each of them is reading a unique book. At the end of any day, the i-th kid will give his book to the p_i-th ... | instruction | 0 | 63,252 | 14 | 126,504 |
No | output | 1 | 63,252 | 14 | 126,505 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days.
In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day.
Du will chat in the grou... | instruction | 0 | 63,314 | 14 | 126,628 |
Tags: dp, greedy, sortings, two pointers
Correct Solution:
```
import sys
import math,bisect
from collections import defaultdict
from itertools import groupby,accumulate
from heapq import heapify,heappop,heappush
from collections import deque,Counter,OrderedDict
#input = iter(sys.stdin.buffer.read().decode().splitlines... | output | 1 | 63,314 | 14 | 126,629 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days.
In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day.
Du will chat in the grou... | instruction | 0 | 63,315 | 14 | 126,630 |
Tags: dp, greedy, sortings, two pointers
Correct Solution:
```
import sys
from array import array # noqa: F401
import typing as Tp # noqa: F401
def input():
return sys.stdin.buffer.readline().decode('utf-8')
def main():
n, d, m = map(int, input().split())
small, big = [], []
for x in map(int, inpu... | output | 1 | 63,315 | 14 | 126,631 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days.
In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day.
Du will chat in the grou... | instruction | 0 | 63,316 | 14 | 126,632 |
Tags: dp, greedy, sortings, two pointers
Correct Solution:
```
n,d,m=map(int,input().split())
a=list(map(int,input().split()))
e,f=[i for i in a if i<=m],[i for i in a if i>m]
e.sort(reverse=True)
f.sort(reverse=True)
c=len(e)
if c==n:
print(sum(a))
exit()
l=1
r=min((n-1)//(d+1)+1,len(f))
#k's range
#e,f 's su... | output | 1 | 63,316 | 14 | 126,633 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days.
In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day.
Du will chat in the grou... | instruction | 0 | 63,317 | 14 | 126,634 |
Tags: dp, greedy, sortings, two pointers
Correct Solution:
```
import sys, collections
n, d, m = map(int, sys.stdin.readline().split())
arr = list(map(int, sys.stdin.readline().split()))
big = []
small = []
for i in arr:
if i > m:
big.append(i)
else:
small.append(i)
big.sort(reverse=True)
small.... | output | 1 | 63,317 | 14 | 126,635 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days.
In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day.
Du will chat in the grou... | instruction | 0 | 63,318 | 14 | 126,636 |
Tags: dp, greedy, sortings, two pointers
Correct Solution:
```
#import sys
#input = sys.stdin.readline
from itertools import accumulate
def main():
n, d, m = map( int, input().split())
A = list( map( int, input().split()))
A_low = []
A_high = []
for a in A:
if a <= m:
A_low.appen... | output | 1 | 63,318 | 14 | 126,637 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days.
In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day.
Du will chat in the grou... | instruction | 0 | 63,319 | 14 | 126,638 |
Tags: dp, greedy, sortings, two pointers
Correct Solution:
```
import sys
input = sys.stdin.readline
n, d, m = map(int, input().split())
vals = sorted([int(i) for i in input().split()], reverse = True)
over, under, over_psa, under_psa, ans = [i for i in vals if i > m], [i for i in vals if i <= m], [0], [0], 0
for i i... | output | 1 | 63,319 | 14 | 126,639 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days.
In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day.
Du will chat in the grou... | instruction | 0 | 63,320 | 14 | 126,640 |
Tags: dp, greedy, sortings, two pointers
Correct Solution:
```
import bisect
n, d, m = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
f = {0:0}
for i in range(n):
f[i+1] = f[i] + arr[i]
k = bisect.bisect_right(arr, m)
ans = 0
for nlo in range(k+1):
nhg = (n-nlo+d)//(d+1)
... | output | 1 | 63,320 | 14 | 126,641 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days.
In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day.
Du will chat in the grou... | instruction | 0 | 63,321 | 14 | 126,642 |
Tags: dp, greedy, sortings, two pointers
Correct Solution:
```
import sys
readline = sys.stdin.buffer.readline
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
def solve():
n, d, m = nm()
a = ... | output | 1 | 63,321 | 14 | 126,643 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days.
In Boboniu's chat group, there's a person called Du Yi who likes to make fun ... | instruction | 0 | 63,322 | 14 | 126,644 |
Yes | output | 1 | 63,322 | 14 | 126,645 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days.
In Boboniu's chat group, there's a person called Du Yi who likes to make fun ... | instruction | 0 | 63,323 | 14 | 126,646 |
Yes | output | 1 | 63,323 | 14 | 126,647 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days.
In Boboniu's chat group, there's a person called Du Yi who likes to make fun ... | instruction | 0 | 63,324 | 14 | 126,648 |
Yes | output | 1 | 63,324 | 14 | 126,649 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days.
In Boboniu's chat group, there's a person called Du Yi who likes to make fun ... | instruction | 0 | 63,325 | 14 | 126,650 |
Yes | output | 1 | 63,325 | 14 | 126,651 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days.
In Boboniu's chat group, there's a person called Du Yi who likes to make fun ... | instruction | 0 | 63,326 | 14 | 126,652 |
No | output | 1 | 63,326 | 14 | 126,653 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days.
In Boboniu's chat group, there's a person called Du Yi who likes to make fun ... | instruction | 0 | 63,327 | 14 | 126,654 |
No | output | 1 | 63,327 | 14 | 126,655 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days.
In Boboniu's chat group, there's a person called Du Yi who likes to make fun ... | instruction | 0 | 63,328 | 14 | 126,656 |
No | output | 1 | 63,328 | 14 | 126,657 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days.
In Boboniu's chat group, there's a person called Du Yi who likes to make fun ... | instruction | 0 | 63,329 | 14 | 126,658 |
No | output | 1 | 63,329 | 14 | 126,659 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya collects coins: he has exactly one coin for every year from 1 to n. Naturally, Vasya keeps all the coins in his collection in the order in which they were released. Once Vasya's younger brother made a change โ he took all the coins who... | instruction | 0 | 63,526 | 14 | 127,052 |
Tags: implementation
Correct Solution:
```
import sys
n=int(input())
l=list(map(int,input().split()))
l1=l.copy()
l1.sort()
if(n<=2):
if(l==l1):
print(0,0)
else:
print(1,2)
sys.exit()
for i in l:
if(i==1):
break
else:
l.remove(i)
l.append(i)
if(l==l1):
pri... | output | 1 | 63,526 | 14 | 127,053 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya collects coins: he has exactly one coin for every year from 1 to n. Naturally, Vasya keeps all the coins in his collection in the order in which they were released. Once Vasya's younger brother made a change โ he took all the coins who... | instruction | 0 | 63,527 | 14 | 127,054 |
Tags: implementation
Correct Solution:
```
r=range
i=input
i()
l=list(map(int,i().split()))
#print(l)
s=0
p=q=-1
for _ in r(len(l)):
if(l[_]!=_+1):
p=_+1
q=l[_]
break
if(p!=-1):
#print(p,q)
l[p-1:q]=sorted(l[p-1:q])
#print(l)
f=1*(p!=-1)
for x in r(len(l)):
if(l[x]!=x+1):f=0
if(f):print("%d %d"%(p,q))
else:pr... | output | 1 | 63,527 | 14 | 127,055 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya collects coins: he has exactly one coin for every year from 1 to n. Naturally, Vasya keeps all the coins in his collection in the order in which they were released. Once Vasya's younger brother made a change โ he took all the coins who... | instruction | 0 | 63,528 | 14 | 127,056 |
Tags: implementation
Correct Solution:
```
n = int(input())
arr = [0] + list(map(int,input().split()))
l = 1
r = n
while l <= n and arr[l] == l:
l += 1
while r >= 0 and arr[r] == r:
r -= 1
if l < n and arr[r:l-1:-1] == list(range(l,r+1)):print(l,r)
else: print(0,0)
``` | output | 1 | 63,528 | 14 | 127,057 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya collects coins: he has exactly one coin for every year from 1 to n. Naturally, Vasya keeps all the coins in his collection in the order in which they were released. Once Vasya's younger brother made a change โ he took all the coins who... | instruction | 0 | 63,529 | 14 | 127,058 |
Tags: implementation
Correct Solution:
```
n=int(input())
L=list(map(int,input().split()))
start=0
end=n-1
while(L[start]==start+1):
start+=1
if(start==n):
break
while(L[end]==end+1):
end-=1
if(end==-1):
break
if(start>end):
print("0 0")
else:
pre=L[:start]
mid=L[start:end+1]... | output | 1 | 63,529 | 14 | 127,059 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya collects coins: he has exactly one coin for every year from 1 to n. Naturally, Vasya keeps all the coins in his collection in the order in which they were released. Once Vasya's younger brother made a change โ he took all the coins who... | instruction | 0 | 63,530 | 14 | 127,060 |
Tags: implementation
Correct Solution:
```
def f():
n=int(input())
L=input().split()
etat=0
debut,fin=0,0
for i in range(n):
num=int(L[i])
if etat==1:
if (1+i+num)!=debut+fin:
return '0 0'
elif i+1==fin:
etat=2
... | output | 1 | 63,530 | 14 | 127,061 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya collects coins: he has exactly one coin for every year from 1 to n. Naturally, Vasya keeps all the coins in his collection in the order in which they were released. Once Vasya's younger brother made a change โ he took all the coins who... | instruction | 0 | 63,531 | 14 | 127,062 |
Tags: implementation
Correct Solution:
```
def spoilt(arr):
if arr==sorted(arr):
print(0,0)
return ""
arr=[0]+arr
ans=["a",0]
cnt=0
temp=0
flag=False
for i in range(1,len(arr)):
if arr[i]!=i and flag==False :
ans[0]=i
temp=i
flag=Tr... | output | 1 | 63,531 | 14 | 127,063 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya collects coins: he has exactly one coin for every year from 1 to n. Naturally, Vasya keeps all the coins in his collection in the order in which they were released. Once Vasya's younger brother made a change โ he took all the coins who... | instruction | 0 | 63,532 | 14 | 127,064 |
Tags: implementation
Correct Solution:
```
#from dust i have come dust i will be
n=int(input())
a=list(map(int,input().split()))
l,r=-1,-1
for i in range(n):
if a[i]!=i+1:
l=i
break
for i in range(n-1,-1,-1):
if a[i]!=i+1:
r=i
break
j=r+1
for i in range(l,r+1):
if a[i]==... | output | 1 | 63,532 | 14 | 127,065 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya collects coins: he has exactly one coin for every year from 1 to n. Naturally, Vasya keeps all the coins in his collection in the order in which they were released. Once Vasya's younger brother made a change โ he took all the coins who... | instruction | 0 | 63,533 | 14 | 127,066 |
Tags: implementation
Correct Solution:
```
n=int(input())
a=list(map(int,input().split()))
l,r=-1,-1
for i in range(n):
if a[i]!=i+1:
l=i
break
for i in range(n-1,-1,-1):
if a[i]!=i+1:
r=i
break
j=r+1
for i in range(l,r+1):
if a[i]==j:
j-=1
continue
... | output | 1 | 63,533 | 14 | 127,067 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Today is birthday of a Little Dasha โ she is now 8 years old! On this occasion, each of her n friends and relatives gave her a ribbon with a greeting written on it, and, as it turned out, all th... | instruction | 0 | 63,542 | 14 | 127,084 |
No | output | 1 | 63,542 | 14 | 127,085 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Pupils decided to go to amusement park. Some of them were with parents. In total, n people came to the park and they all want to get to the most extreme attraction and roll on it exactly once.
Tickets for group of x people are sold on the a... | instruction | 0 | 63,593 | 14 | 127,186 |
Tags: *special, ternary search
Correct Solution:
```
n, c1, c2 = [int(x) for x in input().split(' ')]
s = input()
cnt = s.count('1')
def price(x):
return c1 + c2 * (x - 1) ** 2
prices = []
for i in range(1, cnt + 1):
bigGroupsPeople = n // i + 1
numBigGroups = n % i
smallGroupsPeople = n // i
nu... | output | 1 | 63,593 | 14 | 127,187 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Pupils decided to go to amusement park. Some of them were with parents. In total, n people came to the park and they all want to get to the most extreme attraction and roll on it exactly once.
Tickets for group of x people are sold on the a... | instruction | 0 | 63,594 | 14 | 127,188 |
Tags: *special, ternary search
Correct Solution:
```
t = input()
t = t.split()
n = int(t[0])
c1 = int(t[1])
c2 = int(t[2])
t = input()
d = 0
for i in t:
if(i=="1"):
d = d+1
min = 10**1488
for i in range(1, d+1):
t = c1*i + i*c2*(((n//i)-1)**2) + c2*(n%i)*(2*(n//i)-1)
if t<min:
... | output | 1 | 63,594 | 14 | 127,189 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Pupils decided to go to amusement park. Some of them were with parents. In total, n people came to the park and they all want to get to the most extreme attraction and roll on it exactly once.
Tickets for group of x people are sold on the a... | instruction | 0 | 63,595 | 14 | 127,190 |
Tags: *special, ternary search
Correct Solution:
```
t = input()
t = t.split()
n = int(t[0])
c1 = int(t[1])
c2 = int(t[2])
t = input()
d = 0
for i in t:
if(i=="1"):
d = d+1
min = 10**1488
for i in range(1, d+1):
t = c1*i + i*c2*(((n//i)-1)**2) + c2*(n%i)*(2*(n//i)-1)
if t<min:
min = t
prin... | output | 1 | 63,595 | 14 | 127,191 |
Provide tags and a correct Python 3 solution for this coding contest problem.
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of n high school students numbered from 1 to n. Initially, each student i is on position i. Each student i is characterized by two num... | instruction | 0 | 64,032 | 14 | 128,064 |
Tags: greedy, math, sortings
Correct Solution:
```
n=int(input())
a=[0]*n
b=[0]*n
c=[0]*n
for i in range (0,n):
a[i],b[i]=map(int,input().split())
c[i]=b[i]-a[i]
c=sorted(c)
s=0
for i in range (0,n):
s+=c[i]*(n-1-i)
print(s+(n-1)*sum(a))
``` | output | 1 | 64,032 | 14 | 128,065 |
Provide tags and a correct Python 3 solution for this coding contest problem.
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of n high school students numbered from 1 to n. Initially, each student i is on position i. Each student i is characterized by two num... | instruction | 0 | 64,033 | 14 | 128,066 |
Tags: greedy, math, sortings
Correct Solution:
```
def in_int():
return int(input())
def in_list():
return [int(x) for x in input().split()]
n=int(input())
ns=[]
ans=0
for i in range(n):
x,y=in_list()
ns.append(x-y)
ans+=-x+y*n
ns.sort(reverse=True)
for i in range(n):
c=ns[i]
ans+=c*(i+1)
p... | output | 1 | 64,033 | 14 | 128,067 |
Provide tags and a correct Python 3 solution for this coding contest problem.
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of n high school students numbered from 1 to n. Initially, each student i is on position i. Each student i is characterized by two num... | instruction | 0 | 64,034 | 14 | 128,068 |
Tags: greedy, math, sortings
Correct Solution:
```
n = int(input())
lis = []
for i in range(n):
a, b = map(int, input().split())
c = (a - b)
lis.append([a, b, c])
lis.sort(key = lambda x: x[2])
lis = lis[::-1]
res = 0
for j in range(n):
res += lis[j][0]*j+lis[j][1]*(n-j-1)
print(res)
``` | output | 1 | 64,034 | 14 | 128,069 |
Provide tags and a correct Python 3 solution for this coding contest problem.
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of n high school students numbered from 1 to n. Initially, each student i is on position i. Each student i is characterized by two num... | instruction | 0 | 64,035 | 14 | 128,070 |
Tags: greedy, math, sortings
Correct Solution:
```
n=int(input())
li=[]
ans=0
for i in range(n):
a,b=map(int,input().split())
li.append(b-a)
ans+=(b*n-a)
li.sort()
for i in range(n):
ans-=li[i]*(i+1)
print(ans)
``` | output | 1 | 64,035 | 14 | 128,071 |
Provide tags and a correct Python 3 solution for this coding contest problem.
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of n high school students numbered from 1 to n. Initially, each student i is on position i. Each student i is characterized by two num... | instruction | 0 | 64,036 | 14 | 128,072 |
Tags: greedy, math, sortings
Correct Solution:
```
n, arr, ans= int(input()), list(), 0
for i in range(n):
[a, b] = [int(i) for i in input().split()]
arr += [[b - a, a, b]]
arr = sorted(arr)
for i in range(n):
ans += i * arr[i][1] + (n - i - 1) * arr[i][2]
print(ans)
``` | output | 1 | 64,036 | 14 | 128,073 |
Provide tags and a correct Python 3 solution for this coding contest problem.
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of n high school students numbered from 1 to n. Initially, each student i is on position i. Each student i is characterized by two num... | instruction | 0 | 64,037 | 14 | 128,074 |
Tags: greedy, math, sortings
Correct Solution:
```
n = int(input())
people = list()
for i in range(n):
people.append([int(el) for el in input().split()])
disbal = [(i, el[1]-el[0])for i, el in enumerate(people)]
disbal = sorted(disbal, key=lambda x: x[1])
power = 0
for cur, el in enumerate(disbal):
power += pe... | output | 1 | 64,037 | 14 | 128,075 |
Provide tags and a correct Python 3 solution for this coding contest problem.
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of n high school students numbered from 1 to n. Initially, each student i is on position i. Each student i is characterized by two num... | instruction | 0 | 64,038 | 14 | 128,076 |
Tags: greedy, math, sortings
Correct Solution:
```
import collections as cc
import itertools as it
I=lambda:list(map(int,input().split()))
n,=I()
ans=0
d=[]
for i in range(n):
x,y=I()
ans+=y*(n-1)
d.append(x-y)
d.sort(reverse=True)
for i in range(n):
ans+=d[i]*i
print(ans)
``` | output | 1 | 64,038 | 14 | 128,077 |
Provide tags and a correct Python 3 solution for this coding contest problem.
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of n high school students numbered from 1 to n. Initially, each student i is on position i. Each student i is characterized by two num... | instruction | 0 | 64,039 | 14 | 128,078 |
Tags: greedy, math, sortings
Correct Solution:
```
# cook your dish here
n=int(input())
p1=0
p2=0
l=[]
s=0
for k in range(1,n+1):
x=str(input())
x=x.split(' ')
x=[int(y) for y in x if y !='']
p1=x[0]+p1
p2=p2+x[1]
l.append(x[0]-x[1])
l.sort(reverse=True)
for k in range(1,n+1):
s=s+k*l[k-1]
p... | output | 1 | 64,039 | 14 | 128,079 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.