message stringlengths 2 22.7k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 145 109k | cluster float64 9 9 | __index_level_0__ int64 290 217k |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
12:17 (UTC): The sample input 1 and 2 were swapped. The error is now fixed. We are very sorry for your inconvenience.
There are N children in AtCoder Kindergarten, conveniently numbered 1 throu... | instruction | 0 | 37,644 | 9 | 75,288 |
Yes | output | 1 | 37,644 | 9 | 75,289 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
12:17 (UTC): The sample input 1 and 2 were swapped. The error is now fixed. We are very sorry for your inconvenience.
There are N children in AtCoder Kindergarten, conveniently numbered 1 throu... | instruction | 0 | 37,645 | 9 | 75,290 |
Yes | output | 1 | 37,645 | 9 | 75,291 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
12:17 (UTC): The sample input 1 and 2 were swapped. The error is now fixed. We are very sorry for your inconvenience.
There are N children in AtCoder Kindergarten, conveniently numbered 1 throu... | instruction | 0 | 37,646 | 9 | 75,292 |
Yes | output | 1 | 37,646 | 9 | 75,293 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
12:17 (UTC): The sample input 1 and 2 were swapped. The error is now fixed. We are very sorry for your inconvenience.
There are N children in AtCoder Kindergarten, conveniently numbered 1 throu... | instruction | 0 | 37,647 | 9 | 75,294 |
Yes | output | 1 | 37,647 | 9 | 75,295 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
12:17 (UTC): The sample input 1 and 2 were swapped. The error is now fixed. We are very sorry for your inconvenience.
There are N children in AtCoder Kindergarten, conveniently numbered 1 throu... | instruction | 0 | 37,648 | 9 | 75,296 |
No | output | 1 | 37,648 | 9 | 75,297 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
12:17 (UTC): The sample input 1 and 2 were swapped. The error is now fixed. We are very sorry for your inconvenience.
There are N children in AtCoder Kindergarten, conveniently numbered 1 throu... | instruction | 0 | 37,649 | 9 | 75,298 |
No | output | 1 | 37,649 | 9 | 75,299 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
12:17 (UTC): The sample input 1 and 2 were swapped. The error is now fixed. We are very sorry for your inconvenience.
There are N children in AtCoder Kindergarten, conveniently numbered 1 throu... | instruction | 0 | 37,650 | 9 | 75,300 |
No | output | 1 | 37,650 | 9 | 75,301 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
12:17 (UTC): The sample input 1 and 2 were swapped. The error is now fixed. We are very sorry for your inconvenience.
There are N children in AtCoder Kindergarten, conveniently numbered 1 throu... | instruction | 0 | 37,651 | 9 | 75,302 |
No | output | 1 | 37,651 | 9 | 75,303 |
Provide a correct Python 3 solution for this coding contest problem.
I bought food at the store to make a lunch box to eat at lunch. At the store, I only got an elongated bag to put food in, so I had to stack all the food vertically and put it in the bag. I want to pack the bag with the heavy ones down so that it won'... | instruction | 0 | 38,493 | 9 | 76,986 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0170
"""
import sys
from sys import stdin
input = stdin.readline
from collections import namedtuple
from itertools import permutations
def solve(items):
total_weight = 0
for i in items:
total_w... | output | 1 | 38,493 | 9 | 76,987 |
Provide a correct Python 3 solution for this coding contest problem.
I bought food at the store to make a lunch box to eat at lunch. At the store, I only got an elongated bag to put food in, so I had to stack all the food vertically and put it in the bag. I want to pack the bag with the heavy ones down so that it won'... | instruction | 0 | 38,494 | 9 | 76,988 |
"Correct Solution:
```
from collections import namedtuple
Data = namedtuple("Data", "name weight limit")
def search(food_list, select_list, total_weight):
if len(food_list) == 0:
return select_list
limit = select_list[len(select_list) - 1].limit
for lp, food in enumerate(food_list):
if... | output | 1 | 38,494 | 9 | 76,989 |
Provide a correct Python 3 solution for this coding contest problem.
I bought food at the store to make a lunch box to eat at lunch. At the store, I only got an elongated bag to put food in, so I had to stack all the food vertically and put it in the bag. I want to pack the bag with the heavy ones down so that it won'... | instruction | 0 | 38,495 | 9 | 76,990 |
"Correct Solution:
```
INF = 10 ** 20
while True:
n = int(input())
if n == 0:
break
names = []
weights = []
safes = []
for _ in range(n):
f, w, s = input().split()
names.append(f)
weights.append(int(w))
safes.append(int(s))
all_weight = sum(weights)
dic = [None] * (2 ** n)
def s... | output | 1 | 38,495 | 9 | 76,991 |
Provide a correct Python 3 solution for this coding contest problem.
I bought food at the store to make a lunch box to eat at lunch. At the store, I only got an elongated bag to put food in, so I had to stack all the food vertically and put it in the bag. I want to pack the bag with the heavy ones down so that it won'... | instruction | 0 | 38,496 | 9 | 76,992 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0170
"""
import sys
from sys import stdin
input = stdin.readline
from collections import namedtuple
def solve(items):
from itertools import permutations
total_weight = 0
for i in items:
tot... | output | 1 | 38,496 | 9 | 76,993 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
I bought food at the store to make a lunch box to eat at lunch. At the store, I only got an elongated bag to put food in, so I had to stack all the food vertically and put it in the bag. I want ... | instruction | 0 | 38,497 | 9 | 76,994 |
No | output | 1 | 38,497 | 9 | 76,995 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
I bought food at the store to make a lunch box to eat at lunch. At the store, I only got an elongated bag to put food in, so I had to stack all the food vertically and put it in the bag. I want ... | instruction | 0 | 38,498 | 9 | 76,996 |
No | output | 1 | 38,498 | 9 | 76,997 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Tanya has n candies numbered from 1 to n. The i-th candy has the weight a_i.
She plans to eat exactly n-1 candies and give the remaining candy to her dad. Tanya eats candies in order of increasing their numbers, exactly one candy per day.
... | instruction | 0 | 38,682 | 9 | 77,364 |
Tags: implementation
Correct Solution:
```
n = int(input())
candy = [*map(int, input().split())]
numGood = 0
candyOdd = candy[1::2]
candyEven = candy[2::2]
sumOdd = sum(candyOdd)
sumEven = sum(candyEven)
if sumOdd == sumEven:
numGood += 1
for i in range(1,n):
if i%2:
sumOdd += candy[i-1]-candy[i]
... | output | 1 | 38,682 | 9 | 77,365 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Tanya has n candies numbered from 1 to n. The i-th candy has the weight a_i.
She plans to eat exactly n-1 candies and give the remaining candy to her dad. Tanya eats candies in order of increasing their numbers, exactly one candy per day.
... | instruction | 0 | 38,683 | 9 | 77,366 |
Tags: implementation
Correct Solution:
```
n=int(input())
a=list(map(int,input().split()))
sum=[0]*(n+2)
pre=[0]*(n+2)
for i in range(n-1,-1,-1):
sum[i]=sum[i+2]+a[i]
pre[n-1-i]=a[n-1-i]
if n-2-i>0:
pre[n-1-i]+=pre[n-i-3]
ans=0
for i in range (n):
#removing ith choclate
odd_sum=sum[i+1]
... | output | 1 | 38,683 | 9 | 77,367 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Tanya has n candies numbered from 1 to n. The i-th candy has the weight a_i.
She plans to eat exactly n-1 candies and give the remaining candy to her dad. Tanya eats candies in order of increasing their numbers, exactly one candy per day.
... | instruction | 0 | 38,684 | 9 | 77,368 |
Tags: implementation
Correct Solution:
```
def Num_solution( n, candy):
Odd_sum = Even_sum = num_solution = 0
for i in range(len(candy)):
if i % 2 == 0: #odd number
Odd_sum += candy[i]
else :
Even_sum += candy[i]
#print(Odd_sum)
#print(Even_sum)
Odd_sum_now = Even_sum_now = 0
for i in range(len(candy))... | output | 1 | 38,684 | 9 | 77,369 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Tanya has n candies numbered from 1 to n. The i-th candy has the weight a_i.
She plans to eat exactly n-1 candies and give the remaining candy to her dad. Tanya eats candies in order of increasing their numbers, exactly one candy per day.
... | instruction | 0 | 38,685 | 9 | 77,370 |
Tags: implementation
Correct Solution:
```
from bisect import bisect_right as br
from bisect import bisect_left as bl
from collections import defaultdict
from itertools import *
import functools
import sys
import math
MAX = sys.maxsize
MAXN = 10**6+10
MOD = 10**9+7
def isprime(n):
n = abs(int(n))
if n < 2:
... | output | 1 | 38,685 | 9 | 77,371 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Tanya has n candies numbered from 1 to n. The i-th candy has the weight a_i.
She plans to eat exactly n-1 candies and give the remaining candy to her dad. Tanya eats candies in order of increasing their numbers, exactly one candy per day.
... | instruction | 0 | 38,686 | 9 | 77,372 |
Tags: implementation
Correct Solution:
```
# n=int(input())
# a,b=map(int(input().split()))
n=int(input())
arr=list(map(int,input().split()))
even=[0]*((n+1)//2)
odd =[0]*(n//2)
j,k=0,0
for i in range(n):
if i%2==0:
even[j]=even[j-1]+arr[i]
j+=1
else:
odd[k]=odd[k-1]+arr[i]
k+=1
ans=0
if n==1:
print(1)
e... | output | 1 | 38,686 | 9 | 77,373 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Tanya has n candies numbered from 1 to n. The i-th candy has the weight a_i.
She plans to eat exactly n-1 candies and give the remaining candy to her dad. Tanya eats candies in order of increasing their numbers, exactly one candy per day.
... | instruction | 0 | 38,687 | 9 | 77,374 |
Tags: implementation
Correct Solution:
```
def main():
n = int(input())
aa = [int(i) for i in input().split()]
esuf = osuf = epref = opref = ans = 0
for i in range(n):
if i % 2 == 0:
esuf += aa[i]
else:
osuf += aa[i]
for i in range(n):
x = 1
... | output | 1 | 38,687 | 9 | 77,375 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Tanya has n candies numbered from 1 to n. The i-th candy has the weight a_i.
She plans to eat exactly n-1 candies and give the remaining candy to her dad. Tanya eats candies in order of increasing their numbers, exactly one candy per day.
... | instruction | 0 | 38,688 | 9 | 77,376 |
Tags: implementation
Correct Solution:
```
cnt = lambda s, i: s.count(i)
ii = lambda: int(input())
si = lambda : input()
f = lambda : map(int,input().split())
il = lambda : list(map(int,input().split()))
n=ii()
l=il()
os=sum(l[1::2])
es=sum(l[2::2])
c=int(os==es)
for i in range(2,n+1):
if i&1:
es+=l[i-2]-l[... | output | 1 | 38,688 | 9 | 77,377 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Tanya has n candies numbered from 1 to n. The i-th candy has the weight a_i.
She plans to eat exactly n-1 candies and give the remaining candy to her dad. Tanya eats candies in order of increasing their numbers, exactly one candy per day.
... | instruction | 0 | 38,689 | 9 | 77,378 |
Tags: implementation
Correct Solution:
```
n = int(input())
a = list(map(int, input().split()))
num = 0
odd = a[1::2]
even = a[2::2]
sum_odd = sum(odd)
sum_even = sum(even)
if sum_odd == sum_even:
num += 1
for i in range(1, n):
if i % 2:
sum_odd += a[i-1]-a[i]
else:
sum_even += a[i-1]-a[i]
if sum_od... | output | 1 | 38,689 | 9 | 77,379 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Tanya has n candies numbered from 1 to n. The i-th candy has the weight a_i.
She plans to eat exactly n-1 candies and give the remaining candy to her dad. Tanya eats candies in order of increas... | instruction | 0 | 38,690 | 9 | 77,380 |
Yes | output | 1 | 38,690 | 9 | 77,381 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Tanya has n candies numbered from 1 to n. The i-th candy has the weight a_i.
She plans to eat exactly n-1 candies and give the remaining candy to her dad. Tanya eats candies in order of increas... | instruction | 0 | 38,691 | 9 | 77,382 |
Yes | output | 1 | 38,691 | 9 | 77,383 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Tanya has n candies numbered from 1 to n. The i-th candy has the weight a_i.
She plans to eat exactly n-1 candies and give the remaining candy to her dad. Tanya eats candies in order of increas... | instruction | 0 | 38,692 | 9 | 77,384 |
Yes | output | 1 | 38,692 | 9 | 77,385 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Tanya has n candies numbered from 1 to n. The i-th candy has the weight a_i.
She plans to eat exactly n-1 candies and give the remaining candy to her dad. Tanya eats candies in order of increas... | instruction | 0 | 38,693 | 9 | 77,386 |
Yes | output | 1 | 38,693 | 9 | 77,387 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Tanya has n candies numbered from 1 to n. The i-th candy has the weight a_i.
She plans to eat exactly n-1 candies and give the remaining candy to her dad. Tanya eats candies in order of increas... | instruction | 0 | 38,694 | 9 | 77,388 |
No | output | 1 | 38,694 | 9 | 77,389 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Tanya has n candies numbered from 1 to n. The i-th candy has the weight a_i.
She plans to eat exactly n-1 candies and give the remaining candy to her dad. Tanya eats candies in order of increas... | instruction | 0 | 38,695 | 9 | 77,390 |
No | output | 1 | 38,695 | 9 | 77,391 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Tanya has n candies numbered from 1 to n. The i-th candy has the weight a_i.
She plans to eat exactly n-1 candies and give the remaining candy to her dad. Tanya eats candies in order of increas... | instruction | 0 | 38,696 | 9 | 77,392 |
No | output | 1 | 38,696 | 9 | 77,393 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Tanya has n candies numbered from 1 to n. The i-th candy has the weight a_i.
She plans to eat exactly n-1 candies and give the remaining candy to her dad. Tanya eats candies in order of increas... | instruction | 0 | 38,697 | 9 | 77,394 |
No | output | 1 | 38,697 | 9 | 77,395 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Piegirl has found a monster and a book about monsters and pies. When she is reading the book, she found out that there are n types of monsters, each with an ID between 1 and n. If you feed a pie to a monster, the monster will split into some... | instruction | 0 | 38,997 | 9 | 77,994 |
Tags: dfs and similar, graphs, shortest paths
Correct Solution:
```
import sys
_BLANCO, _GRIS, _NEGRO = 0, 1, 2
_OO = int(1e18)
class Regla:
def __init__(self, id, diamantes, deMonstruo, monstruos):
self.id = id
self.diamantes = diamantes
self.deMonstruo = deMonstruo
self.monstruo... | output | 1 | 38,997 | 9 | 77,995 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Piegirl has found a monster and a book about monsters and pies. When she is reading the book, she found out that there are n types of monsters, each with an ID between 1 and n. If you feed a pie to a monster, the monster will split into some... | instruction | 0 | 38,998 | 9 | 77,996 |
Tags: dfs and similar, graphs, shortest paths
Correct Solution:
```
import sys, heapq
_BLANCO, _GRIS, _NEGRO = 0, 1, 2
_OO = int(1e18)
def esUnaReglaMala(r, adj, d):
for u, diamsOMult in adj[r]:
if d[u] == _OO:
return True
return False
def dfsVisit(u, color, adj, diamMax, d):
color... | output | 1 | 38,998 | 9 | 77,997 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Piegirl has found a monster and a book about monsters and pies. When she is reading the book, she found out that there are n types of monsters, each with an ID between 1 and n. If you feed a pie to a monster, the monster will split into some... | instruction | 0 | 38,999 | 9 | 77,998 |
Tags: dfs and similar, graphs, shortest paths
Correct Solution:
```
import sys, heapq
_BLANCO, _GRIS, _NEGRO = 0, 1, 2
_OO = int(1e18)
class Regla:
def __init__(self, id, diamantes, deMonstruo, monstruos):
self.id = id
self.diamantes = diamantes
self.deMonstruo = deMonstruo
self.m... | output | 1 | 38,999 | 9 | 77,999 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Piegirl has found a monster and a book about monsters and pies. When she is reading the book, she found out that there are n types of monsters, each with an ID between 1 and n. If you feed a pie to a monster, the monster will split into some... | instruction | 0 | 39,000 | 9 | 78,000 |
Tags: dfs and similar, graphs, shortest paths
Correct Solution:
```
import sys, heapq
_BLANCO, _GRIS, _NEGRO = 0, 1, 2
_OO = int(1e18)
def esUnaReglaMala(r, adj, d):
for u, diamsOMult in adj[r]:
if d[u] == _OO:
return True
return False
def dfsVisit(u, color, adj, diamMax, d):
color... | output | 1 | 39,000 | 9 | 78,001 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Piegirl has found a monster and a book about monsters and pies. When she is reading the book, she found out that there are n types of monsters, each with an ID between 1 and n. If you feed a pie... | instruction | 0 | 39,001 | 9 | 78,002 |
No | output | 1 | 39,001 | 9 | 78,003 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Piegirl has found a monster and a book about monsters and pies. When she is reading the book, she found out that there are n types of monsters, each with an ID between 1 and n. If you feed a pie... | instruction | 0 | 39,002 | 9 | 78,004 |
No | output | 1 | 39,002 | 9 | 78,005 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Piegirl has found a monster and a book about monsters and pies. When she is reading the book, she found out that there are n types of monsters, each with an ID between 1 and n. If you feed a pie... | instruction | 0 | 39,003 | 9 | 78,006 |
No | output | 1 | 39,003 | 9 | 78,007 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Piegirl has found a monster and a book about monsters and pies. When she is reading the book, she found out that there are n types of monsters, each with an ID between 1 and n. If you feed a pie... | instruction | 0 | 39,004 | 9 | 78,008 |
No | output | 1 | 39,004 | 9 | 78,009 |
Provide a correct Python 3 solution for this coding contest problem.
Snuke is having another barbeque party.
This time, he will make one serving of Skewer Meal.
He has a stock of N Skewer Meal Packs. The i-th Skewer Meal Pack contains one skewer, A_i pieces of beef and B_i pieces of green pepper. All skewers in thes... | instruction | 0 | 39,515 | 9 | 79,030 |
"Correct Solution:
```
mod = 10**9+7
mod2 = 998244353
rng = 100100
fctr = [1]
finv = [1]
for i in range(1,rng):
fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
if n<0 or k<0:
return 0
else:
return fctr[n]*finv[n-k]*finv[k]%mod
n = int(input())
ab = [l... | output | 1 | 39,515 | 9 | 79,031 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Snuke is having another barbeque party.
This time, he will make one serving of Skewer Meal.
He has a stock of N Skewer Meal Packs. The i-th Skewer Meal Pack contains one skewer, A_i pieces of ... | instruction | 0 | 39,516 | 9 | 79,032 |
No | output | 1 | 39,516 | 9 | 79,033 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Snuke is having another barbeque party.
This time, he will make one serving of Skewer Meal.
He has a stock of N Skewer Meal Packs. The i-th Skewer Meal Pack contains one skewer, A_i pieces of ... | instruction | 0 | 39,517 | 9 | 79,034 |
No | output | 1 | 39,517 | 9 | 79,035 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Snuke is having another barbeque party.
This time, he will make one serving of Skewer Meal.
He has a stock of N Skewer Meal Packs. The i-th Skewer Meal Pack contains one skewer, A_i pieces of ... | instruction | 0 | 39,518 | 9 | 79,036 |
No | output | 1 | 39,518 | 9 | 79,037 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Snuke is having another barbeque party.
This time, he will make one serving of Skewer Meal.
He has a stock of N Skewer Meal Packs. The i-th Skewer Meal Pack contains one skewer, A_i pieces of ... | instruction | 0 | 39,519 | 9 | 79,038 |
No | output | 1 | 39,519 | 9 | 79,039 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Sasha and Dima want to buy two n-tier cakes. Each cake should consist of n different tiers: from the size of 1 to the size of n. Tiers should go in order from the smallest to the biggest (from top to bottom).
They live on the same street, t... | instruction | 0 | 41,268 | 9 | 82,536 |
Tags: greedy
Correct Solution:
```
n=int(input())
a = list(map(int,input().split()))
d = {}
for i in range(2*n):
if a[i] in d:
d[a[i]].append(i)
else:
d[a[i]] = [i]
out = 0
z = a.index(1)
out += z
z+=1
out += z+a[z:].index(1)
for i in range(1,n):
out += min( ( abs(d[i+1][0]-d[i][0]) + abs(d[... | output | 1 | 41,268 | 9 | 82,537 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Sasha and Dima want to buy two n-tier cakes. Each cake should consist of n different tiers: from the size of 1 to the size of n. Tiers should go in order from the smallest to the biggest (from top to bottom).
They live on the same street, t... | instruction | 0 | 41,269 | 9 | 82,538 |
Tags: greedy
Correct Solution:
```
N = int(input())
A = [int(a) for a in input().split()]
L = [-1] * N
R = [0] * N
for i in range(2*N):
a = A[i] - 1
if L[a] < 0:
L[a] = i
else:
R[a] = i
s = L[0]+R[0]
for i in range(N-1):
s += abs(L[i+1] - L[i]) + abs(R[i+1] - R[i])
print(s)
``` | output | 1 | 41,269 | 9 | 82,539 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Sasha and Dima want to buy two n-tier cakes. Each cake should consist of n different tiers: from the size of 1 to the size of n. Tiers should go in order from the smallest to the biggest (from top to bottom).
They live on the same street, t... | instruction | 0 | 41,270 | 9 | 82,540 |
Tags: greedy
Correct Solution:
```
n,a,k,s0,m0,shag=int(input()),dict(),0,1,1,0
for i in input().split():
k+=1
j=int(i)
if j not in a:
a[j]=[k]
else:
a[j].append(k)
for i in range(1,n+1):
s1,s2,m1,m2=abs(a[i][0]-s0),abs(a[i][1]-s0),abs(a[i][0]-m0),abs(a[i][1]-m0)
if s1+m2<=s2+m1:... | output | 1 | 41,270 | 9 | 82,541 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Sasha and Dima want to buy two n-tier cakes. Each cake should consist of n different tiers: from the size of 1 to the size of n. Tiers should go in order from the smallest to the biggest (from top to bottom).
They live on the same street, t... | instruction | 0 | 41,271 | 9 | 82,542 |
Tags: greedy
Correct Solution:
```
n = int(input())
a = list(map(int, input().split()))
d = {}
for i in range(len(a)):
if a[i] in d:
d[a[i]].append(i + 1)
else:
d[a[i]] = [i + 1]
f = 1
s = 1
res = 0
for i in range(1, n + 1):
a, b = d[i]
if abs(f - a) + abs(s - b) > abs(f - b) + abs(... | output | 1 | 41,271 | 9 | 82,543 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Sasha and Dima want to buy two n-tier cakes. Each cake should consist of n different tiers: from the size of 1 to the size of n. Tiers should go in order from the smallest to the biggest (from top to bottom).
They live on the same street, t... | instruction | 0 | 41,272 | 9 | 82,544 |
Tags: greedy
Correct Solution:
```
from sys import stdin,stdout
from itertools import combinations
from collections import defaultdict
import math
def listIn():
return list((map(int,stdin.readline().strip().split())))
def stringListIn():
return([x for x in stdin.readline().split()])
def intIn():
retu... | output | 1 | 41,272 | 9 | 82,545 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Sasha and Dima want to buy two n-tier cakes. Each cake should consist of n different tiers: from the size of 1 to the size of n. Tiers should go in order from the smallest to the biggest (from top to bottom).
They live on the same street, t... | instruction | 0 | 41,273 | 9 | 82,546 |
Tags: greedy
Correct Solution:
```
import math
n=int(input())
a=list(map(int,input().split(' ')))
d={}
count=0
for i in range(2*n):
if a[i] not in d.keys():
d[a[i]]=[i]
else:
d[a[i]].append(i)
d[a[i]].sort()
e,f=0,0
for i in sorted(d.keys()):
count+=abs(d[i][0]-e)+abs(d[i][1]-f)
... | output | 1 | 41,273 | 9 | 82,547 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Sasha and Dima want to buy two n-tier cakes. Each cake should consist of n different tiers: from the size of 1 to the size of n. Tiers should go in order from the smallest to the biggest (from top to bottom).
They live on the same street, t... | instruction | 0 | 41,274 | 9 | 82,548 |
Tags: greedy
Correct Solution:
```
n=int(input())
l=list(map(int,input().split()))
first=[-1]*(n+1)
second=[-1]*(n+1)
ans1=0
ans2=0
for i in range(2*n):
if(first[l[i]]==-1):
first[l[i]]=i+1
else:
second[l[i]]=i+1
cur1=1
cur2=1
for i in range(1,n+1):
ans1+=abs(c... | output | 1 | 41,274 | 9 | 82,549 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.