message stringlengths 2 22.8k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 16 109k | cluster float64 1 1 | __index_level_0__ int64 32 217k |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N towns numbered 1, 2, \cdots, N.
Some roads are planned to be built so that each of them connects two distinct towns bidirectionally. Currently, there are no roads connecting towns.
... | instruction | 0 | 91,477 | 1 | 182,954 |
No | output | 1 | 91,477 | 1 | 182,955 |
Provide a correct Python 3 solution for this coding contest problem.
PCK Taxi in Aizu city, owned by PCK company, has adopted a unique billing system: the user can decide the taxi fare. Today as usual, many people are waiting in a queue at the taxi stand in front of the station.
In front of the station, there are $N$... | instruction | 0 | 91,643 | 1 | 183,286 |
"Correct Solution:
```
from heapq import heappush, heappop
def main():
n = int(input())
que = []
for i in range(n):
lst = sorted(list(map(int, input().split()))[1:], reverse=True)[:i+1]
heappush(que, lst[-1])
for v in lst[:-1]:
heappush(que, v)
heappop(que)
print(sum(que))
main()
``` | output | 1 | 91,643 | 1 | 183,287 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
PCK Taxi in Aizu city, owned by PCK company, has adopted a unique billing system: the user can decide the taxi fare. Today as usual, many people are waiting in a queue at the taxi stand in front... | instruction | 0 | 91,644 | 1 | 183,288 |
No | output | 1 | 91,644 | 1 | 183,289 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
PCK Taxi in Aizu city, owned by PCK company, has adopted a unique billing system: the user can decide the taxi fare. Today as usual, many people are waiting in a queue at the taxi stand in front... | instruction | 0 | 91,645 | 1 | 183,290 |
No | output | 1 | 91,645 | 1 | 183,291 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
PCK Taxi in Aizu city, owned by PCK company, has adopted a unique billing system: the user can decide the taxi fare. Today as usual, many people are waiting in a queue at the taxi stand in front... | instruction | 0 | 91,646 | 1 | 183,292 |
No | output | 1 | 91,646 | 1 | 183,293 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
PCK Taxi in Aizu city, owned by PCK company, has adopted a unique billing system: the user can decide the taxi fare. Today as usual, many people are waiting in a queue at the taxi stand in front... | instruction | 0 | 91,647 | 1 | 183,294 |
No | output | 1 | 91,647 | 1 | 183,295 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|.
Limak is a police officer. He lives in a city a. His job is to catch criminals. It's hard be... | instruction | 0 | 92,203 | 1 | 184,406 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n, a = map(int, input().split())
criminals = list(map(int, input().split()))
current = a - 1
distance = 1
sum = 0
if criminals[current] == 1:
sum = 1
while current + distance < n or current - distance >= 0:
if current + distance >= n:
... | output | 1 | 92,203 | 1 | 184,407 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|.
Limak is a police officer. He lives in a city a. His job is to catch criminals. It's hard be... | instruction | 0 | 92,204 | 1 | 184,408 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n,k=map(int,input().split())
c=list(map(int,input().split()))
tot=0
if c[k-1]==1:
tot+=1
pivot=k-1
left_pointer=k-1
right_pointer=k-1
while left_pointer>0 or right_pointer<n-1:
left_pointer-=1
right_pointer+=1
if left_pointer>=0 and right_pointer... | output | 1 | 92,204 | 1 | 184,409 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|.
Limak is a police officer. He lives in a city a. His job is to catch criminals. It's hard be... | instruction | 0 | 92,205 | 1 | 184,410 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n,a=map(int,input().split())
a-=1
t=list(map(int,input().split()))
ans=0
for i in range(n):
if t[i]:
distance=i-a
j=a-distance
if j<0 or j>=n or t[i]==t[j]:
ans+=1
print(ans)
``` | output | 1 | 92,205 | 1 | 184,411 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|.
Limak is a police officer. He lives in a city a. His job is to catch criminals. It's hard be... | instruction | 0 | 92,206 | 1 | 184,412 |
Tags: constructive algorithms, implementation
Correct Solution:
```
# import sys
# sys.stdin = open("test.in","r")
# sys.stdout = open("test.out","w")
n,a=map(int,input().split())
b=list(map(int,input().split()))
c,d=a-2,a
e=sum(b)
while c>=0 and d<n:
e-=(b[c]+b[d])%2
c-=1
d+=1
print(e)
``` | output | 1 | 92,206 | 1 | 184,413 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|.
Limak is a police officer. He lives in a city a. His job is to catch criminals. It's hard be... | instruction | 0 | 92,207 | 1 | 184,414 |
Tags: constructive algorithms, implementation
Correct Solution:
```
from collections import defaultdict
if __name__ == "__main__":
#n, m = list(map(int, input().split()))
n, a = map(int, input().split())
A = list(map(int, input().split()))
ans, i = sum(A), 1
while a - 1 - i >= 0 and a - 1 + i <= n ... | output | 1 | 92,207 | 1 | 184,415 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|.
Limak is a police officer. He lives in a city a. His job is to catch criminals. It's hard be... | instruction | 0 | 92,208 | 1 | 184,416 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n,a=map(int,input().split());b=[]
t=list(map(int,input().split()))
for i in range(n):
if t[i]==1:
b.append(abs(i+1-a))
r=0
for j in b:
if b.count(j)==2 :
r+=1
elif b.count(j)==1 and (a-1-j<0 or a-1+j>n-1):
r+=1
e... | output | 1 | 92,208 | 1 | 184,417 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|.
Limak is a police officer. He lives in a city a. His job is to catch criminals. It's hard be... | instruction | 0 | 92,209 | 1 | 184,418 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n, a = map(int, input().split())
A = list(map(int, input().split()))
i = 1
cnt = A[a - 1]
while a - 1 - i >= 0 or a - 1 + i <= n - 1:
x = a - 1 - i
y = a - 1 + i
if x >= 0 and y <= n - 1:
if A[x] and A[y]:
cnt += 2
e... | output | 1 | 92,209 | 1 | 184,419 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|.
Limak is a police officer. He lives in a city a. His job is to catch criminals. It's hard be... | instruction | 0 | 92,210 | 1 | 184,420 |
Tags: constructive algorithms, implementation
Correct Solution:
```
import sys
input = sys.stdin.readline
def inp():
return(int(input()))
def inlt():
return(list(map(int,input().split())))
def insr():
s = input()
return(list(s[:len(s) - 1]))
def invr():
return(map(int,input().split()))
x,y=invr()
z... | output | 1 | 92,210 | 1 | 184,421 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|.
Limak is a police officer. He lives in a city... | instruction | 0 | 92,211 | 1 | 184,422 |
Yes | output | 1 | 92,211 | 1 | 184,423 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|.
Limak is a police officer. He lives in a city... | instruction | 0 | 92,212 | 1 | 184,424 |
Yes | output | 1 | 92,212 | 1 | 184,425 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|.
Limak is a police officer. He lives in a city... | instruction | 0 | 92,213 | 1 | 184,426 |
Yes | output | 1 | 92,213 | 1 | 184,427 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|.
Limak is a police officer. He lives in a city... | instruction | 0 | 92,214 | 1 | 184,428 |
Yes | output | 1 | 92,214 | 1 | 184,429 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|.
Limak is a police officer. He lives in a city... | instruction | 0 | 92,215 | 1 | 184,430 |
No | output | 1 | 92,215 | 1 | 184,431 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|.
Limak is a police officer. He lives in a city... | instruction | 0 | 92,216 | 1 | 184,432 |
No | output | 1 | 92,216 | 1 | 184,433 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|.
Limak is a police officer. He lives in a city... | instruction | 0 | 92,217 | 1 | 184,434 |
No | output | 1 | 92,217 | 1 | 184,435 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|.
Limak is a police officer. He lives in a city... | instruction | 0 | 92,218 | 1 | 184,436 |
No | output | 1 | 92,218 | 1 | 184,437 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Those unwilling to return home from a long journey, will be affected by the oddity of the snail and lose their way. Mayoi, the oddity's carrier, wouldn't like this to happen, but there's nothing... | instruction | 0 | 92,299 | 1 | 184,598 |
No | output | 1 | 92,299 | 1 | 184,599 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Those unwilling to return home from a long journey, will be affected by the oddity of the snail and lose their way. Mayoi, the oddity's carrier, wouldn't like this to happen, but there's nothing... | instruction | 0 | 92,300 | 1 | 184,600 |
No | output | 1 | 92,300 | 1 | 184,601 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Those unwilling to return home from a long journey, will be affected by the oddity of the snail and lose their way. Mayoi, the oddity's carrier, wouldn't like this to happen, but there's nothing... | instruction | 0 | 92,301 | 1 | 184,602 |
No | output | 1 | 92,301 | 1 | 184,603 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Those unwilling to return home from a long journey, will be affected by the oddity of the snail and lose their way. Mayoi, the oddity's carrier, wouldn't like this to happen, but there's nothing... | instruction | 0 | 92,302 | 1 | 184,604 |
No | output | 1 | 92,302 | 1 | 184,605 |
Provide a correct Python 3 solution for this coding contest problem.
problem
There are n islands in JOI, and each island is numbered from 1 to n. Currently, the JOI country is developing a route network connecting each island.
You work at a ticket center that handles ship tickets. There are many people in JOI who wa... | instruction | 0 | 92,540 | 1 | 185,080 |
"Correct Solution:
```
import sys
from heapq import*
def g(s,g):
F=[1e7]*-~n;F[s]=0
H=[(0,s)]
while H:
c,u=heappop(H)
if u==g:return c
for f,v in E[u]:
t=c+f
if t<F[v]:
F[v]=t
heappush(H,(t,v))
return-1
for e in iter(input,'0 0'):
n,k=map(int,e.split())
E=[[]for _ in[0]*-~n]
for _ in[0]*k:
... | output | 1 | 92,540 | 1 | 185,081 |
Provide a correct Python 3 solution for this coding contest problem.
problem
There are n islands in JOI, and each island is numbered from 1 to n. Currently, the JOI country is developing a route network connecting each island.
You work at a ticket center that handles ship tickets. There are many people in JOI who wa... | instruction | 0 | 92,541 | 1 | 185,082 |
"Correct Solution:
```
while 1:
INF = 10**9
N, K = map(int, input().split())
if N == K == 0:
break
E = [[INF]*N for i in range(N)]
for i in range(N):
E[i][i] = 0
ans = []
for i in range(K):
q, *c = map(int, input().split())
if q == 0:
a, b = c
... | output | 1 | 92,541 | 1 | 185,083 |
Provide a correct Python 3 solution for this coding contest problem.
problem
There are n islands in JOI, and each island is numbered from 1 to n. Currently, the JOI country is developing a route network connecting each island.
You work at a ticket center that handles ship tickets. There are many people in JOI who wa... | instruction | 0 | 92,542 | 1 | 185,084 |
"Correct Solution:
```
import sys
from heapq import*
r=sys.stdin.readline
def g(E,n,s,g):
F=[1e7]*-~n;F[s]=0
H=[(0,s)]
while H:
c,u=heappop(H)
if u==g:return c
for f,v in E[u]:
t=c+f
if t<F[v]:F[v]=t;heappush(H,(t,v))
return-1
def s():
for e in iter(input,'0 0'):
n,k=map(int,e.split())
E=[[]for _ i... | output | 1 | 92,542 | 1 | 185,085 |
Provide a correct Python 3 solution for this coding contest problem.
problem
There are n islands in JOI, and each island is numbered from 1 to n. Currently, the JOI country is developing a route network connecting each island.
You work at a ticket center that handles ship tickets. There are many people in JOI who wa... | instruction | 0 | 92,543 | 1 | 185,086 |
"Correct Solution:
```
from heapq import*
def g(n,E,s,g):
F=[1e7]*-~n;F[s]=0
H=[(0,s)]
while H:
c,u=heappop(H)
if u==g:return c
for f,v in E[u]:
t=c+f
if t<F[v]:F[v]=t;heappush(H,(t,v))
return-1
def s():
for e in iter(input,'0 0'):
n,k=map(int,e.split())
E=[[]for _ in[0]*-~n]
for _ in[0]*k:
f=... | output | 1 | 92,543 | 1 | 185,087 |
Provide a correct Python 3 solution for this coding contest problem.
problem
There are n islands in JOI, and each island is numbered from 1 to n. Currently, the JOI country is developing a route network connecting each island.
You work at a ticket center that handles ship tickets. There are many people in JOI who wa... | instruction | 0 | 92,544 | 1 | 185,088 |
"Correct Solution:
```
def solve():
max_fare = 99000001
def dijkstra(start, goal):
unvisited = [i for i in range(n)]
fare = [max_fare] * n
fare[start] = 0
while True:
min_fare = max_fare
for i in unvisited:
f = fare[i]
... | output | 1 | 92,544 | 1 | 185,089 |
Provide a correct Python 3 solution for this coding contest problem.
problem
There are n islands in JOI, and each island is numbered from 1 to n. Currently, the JOI country is developing a route network connecting each island.
You work at a ticket center that handles ship tickets. There are many people in JOI who wa... | instruction | 0 | 92,545 | 1 | 185,090 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0526
TLE
"""
import sys
from sys import stdin
from heapq import heappush, heappop
input = stdin.readline
def dijkstra(s, G):
pq = []
d = [float('inf')] * len(G)
d[s] = 0
heappush(pq, (0, s))
... | output | 1 | 92,545 | 1 | 185,091 |
Provide a correct Python 3 solution for this coding contest problem.
problem
There are n islands in JOI, and each island is numbered from 1 to n. Currently, the JOI country is developing a route network connecting each island.
You work at a ticket center that handles ship tickets. There are many people in JOI who wa... | instruction | 0 | 92,546 | 1 | 185,092 |
"Correct Solution:
```
from heapq import heappush, heappop, heapify
def dijkstra(s, t, links):
heap = list(links[s])
heapify(heap)
visited = set()
while heap:
fare, node = heappop(heap)
if node == t:
return fare
if node in visited:
continue
visit... | output | 1 | 92,546 | 1 | 185,093 |
Provide a correct Python 3 solution for this coding contest problem.
problem
There are n islands in JOI, and each island is numbered from 1 to n. Currently, the JOI country is developing a route network connecting each island.
You work at a ticket center that handles ship tickets. There are many people in JOI who wa... | instruction | 0 | 92,547 | 1 | 185,094 |
"Correct Solution:
```
import sys
from heapq import heappush,heappop
r=sys.stdin.readline
def g(s,g):
F=[1e7]*-~n;F[s]=0
H=[(0,s)]
while H:
c,u=heappop(H)
if u==g:return c
for f,v in E[u]:
t=c+f
if t<F[v]:F[v]=t;heappush(H,(t,v))
return-1
for e in iter(input,'0 0'):
n,k=map(int,e.split())
E=[[]for _ i... | output | 1 | 92,547 | 1 | 185,095 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
There are n islands in JOI, and each island is numbered from 1 to n. Currently, the JOI country is developing a route network connecting each island.
You work at a ticket center that h... | instruction | 0 | 92,548 | 1 | 185,096 |
Yes | output | 1 | 92,548 | 1 | 185,097 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
There are n islands in JOI, and each island is numbered from 1 to n. Currently, the JOI country is developing a route network connecting each island.
You work at a ticket center that h... | instruction | 0 | 92,549 | 1 | 185,098 |
Yes | output | 1 | 92,549 | 1 | 185,099 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
There are n islands in JOI, and each island is numbered from 1 to n. Currently, the JOI country is developing a route network connecting each island.
You work at a ticket center that h... | instruction | 0 | 92,550 | 1 | 185,100 |
Yes | output | 1 | 92,550 | 1 | 185,101 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
There are n islands in JOI, and each island is numbered from 1 to n. Currently, the JOI country is developing a route network connecting each island.
You work at a ticket center that h... | instruction | 0 | 92,551 | 1 | 185,102 |
Yes | output | 1 | 92,551 | 1 | 185,103 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
There are n islands in JOI, and each island is numbered from 1 to n. Currently, the JOI country is developing a route network connecting each island.
You work at a ticket center that h... | instruction | 0 | 92,552 | 1 | 185,104 |
No | output | 1 | 92,552 | 1 | 185,105 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
There are n islands in JOI, and each island is numbered from 1 to n. Currently, the JOI country is developing a route network connecting each island.
You work at a ticket center that h... | instruction | 0 | 92,553 | 1 | 185,106 |
No | output | 1 | 92,553 | 1 | 185,107 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
There are n islands in JOI, and each island is numbered from 1 to n. Currently, the JOI country is developing a route network connecting each island.
You work at a ticket center that h... | instruction | 0 | 92,554 | 1 | 185,108 |
No | output | 1 | 92,554 | 1 | 185,109 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
There are n islands in JOI, and each island is numbered from 1 to n. Currently, the JOI country is developing a route network connecting each island.
You work at a ticket center that h... | instruction | 0 | 92,555 | 1 | 185,110 |
No | output | 1 | 92,555 | 1 | 185,111 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from kilometer 0. The n destinations are described ... | instruction | 0 | 92,991 | 1 | 185,982 |
Tags: combinatorics, implementation, math
Correct Solution:
```
from sys import stdin
def c2 (x):
return x * (x - 1)
def gcd (p, q):
if q == 0:
return p
return gcd(q, p % q)
n = int(stdin.readline())
arr = list(map(int, stdin.readline().split()))
arr.sort()
denom = n * (n - 1)
ans = 0
for i in r... | output | 1 | 92,991 | 1 | 185,983 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from kilometer 0. The n destinations are described ... | instruction | 0 | 92,992 | 1 | 185,984 |
Tags: combinatorics, implementation, math
Correct Solution:
```
from fractions import Fraction
n=int(input())
a=[int(i) for i in input().split()]
a=sorted(a)
s=[]
s.append(0)
for i in range(n):
s.append(s[-1]+a[i])
ans=0
for i in range(1,n+1):
ans+=s[n]-s[i-1]-(n-i+1)*a[i-1]
ans=ans*2+sum(a)
ans=Fraction(ans,n)... | output | 1 | 92,992 | 1 | 185,985 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from kilometer 0. The n destinations are described ... | instruction | 0 | 92,993 | 1 | 185,986 |
Tags: combinatorics, implementation, math
Correct Solution:
```
import math
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
k = 0
s1 = 0
s2 = 0
for i in a:
s2 += s1 - k * i
s1 += i
k += 1
s2 *= 2
s2 += sum(a)
gcd = math.gcd(s2, n)
print(s2 // gcd, n // gcd)
... | output | 1 | 92,993 | 1 | 185,987 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from kilometer 0. The n destinations are described ... | instruction | 0 | 92,994 | 1 | 185,988 |
Tags: combinatorics, implementation, math
Correct Solution:
```
import math
def read_int():
return int(input().strip())
def read_ints():
return list(map(int, input().strip().split(' ')))
def solve():
"""
a[i] -> a[j]
(n-1)!*|a[i]-a[j]| for all j
(n-1)!*(for i=1..n, for j=1..n sum(|a[i]-a... | output | 1 | 92,994 | 1 | 185,989 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from kilometer 0. The n destinations are described ... | instruction | 0 | 92,995 | 1 | 185,990 |
Tags: combinatorics, implementation, math
Correct Solution:
```
from math import *
n=int(input())
arr=list(map(int,input().split()))
arr.sort()
S1=sum(arr)
sums=0
sumsi=arr[0]
for i in range(1,n):
sums+=(i)*(arr[i])-sumsi
sumsi+=arr[i]
S2=sums
num=S1+2*S2
den=n
#print(num,den)
while(int(gcd(num,den))!=1):
x=gc... | output | 1 | 92,995 | 1 | 185,991 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from kilometer 0. The n destinations are described ... | instruction | 0 | 92,996 | 1 | 185,992 |
Tags: combinatorics, implementation, math
Correct Solution:
```
#!/usr/bin/env python3
def read_string():
return input()
def read_strings(return_type = iter, split = None, skip = 0):
return return_type(input().split(split)[skip:])
def read_lines(height, return_type = iter):
return return_type(read_string() ... | output | 1 | 92,996 | 1 | 185,993 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from kilometer 0. The n destinations are described ... | instruction | 0 | 92,997 | 1 | 185,994 |
Tags: combinatorics, implementation, math
Correct Solution:
```
from fractions import *
def solve():
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans1 = 0
pres = a[0]
for i in range(1,n):
ans1+=i*a[i] -pres
pres+=a[i]
ans1 *= 2;
tmp = pres+ans1
tmp1 = ... | output | 1 | 92,997 | 1 | 185,995 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from kilometer 0. The n destinations are described ... | instruction | 0 | 92,998 | 1 | 185,996 |
Tags: combinatorics, implementation, math
Correct Solution:
```
from fractions import *
n=int(input());
a=list(map(int,input().split()));
a=sorted(a);
now=a[0];
ans=0;
for i in range(1,n):
ans+=i*a[i]-now;
now=now+a[i];
ans=ans*2+now;
s=Fraction(ans,n);
print(s.numerator,s.denominator);
``` | output | 1 | 92,998 | 1 | 185,997 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.