message stringlengths 2 43.5k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 853 107k | cluster float64 24 24 | __index_level_0__ int64 1.71k 214k |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus has a sequence, consisting of n non-negative integers: a1, a2, ..., an.
Let's define function f(l, r) (l, r are integer, 1 β€ l β€ r β€ n) for sequence a as an operation of bitwise OR o... | instruction | 0 | 10,270 | 24 | 20,540 |
Yes | output | 1 | 10,270 | 24 | 20,541 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus has a sequence, consisting of n non-negative integers: a1, a2, ..., an.
Let's define function f(l, r) (l, r are integer, 1 β€ l β€ r β€ n) for sequence a as an operation of bitwise OR o... | instruction | 0 | 10,271 | 24 | 20,542 |
Yes | output | 1 | 10,271 | 24 | 20,543 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus has a sequence, consisting of n non-negative integers: a1, a2, ..., an.
Let's define function f(l, r) (l, r are integer, 1 β€ l β€ r β€ n) for sequence a as an operation of bitwise OR o... | instruction | 0 | 10,272 | 24 | 20,544 |
No | output | 1 | 10,272 | 24 | 20,545 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus has a sequence, consisting of n non-negative integers: a1, a2, ..., an.
Let's define function f(l, r) (l, r are integer, 1 β€ l β€ r β€ n) for sequence a as an operation of bitwise OR o... | instruction | 0 | 10,273 | 24 | 20,546 |
No | output | 1 | 10,273 | 24 | 20,547 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus has a sequence, consisting of n non-negative integers: a1, a2, ..., an.
Let's define function f(l, r) (l, r are integer, 1 β€ l β€ r β€ n) for sequence a as an operation of bitwise OR o... | instruction | 0 | 10,274 | 24 | 20,548 |
No | output | 1 | 10,274 | 24 | 20,549 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus has a sequence, consisting of n non-negative integers: a1, a2, ..., an.
Let's define function f(l, r) (l, r are integer, 1 β€ l β€ r β€ n) for sequence a as an operation of bitwise OR o... | instruction | 0 | 10,275 | 24 | 20,550 |
No | output | 1 | 10,275 | 24 | 20,551 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus is the director of a large corporation. There are n secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that when two people call each other via Spyke, the Spy... | instruction | 0 | 10,276 | 24 | 20,552 |
Tags: *special, implementation, sortings
Correct Solution:
```
n = int(input())
l = list(map(int,input().split()))
l.sort()
r = 0
bad = False
for i in range(n-1):
if l[i] == 0 :
continue
if l[i] == l[i+1]:
r += 1
if i < n-2 and l[i+2] == l[i]:
print(-1)
bad = True
bre... | output | 1 | 10,276 | 24 | 20,553 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus is the director of a large corporation. There are n secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that when two people call each other via Spyke, the Spy... | instruction | 0 | 10,277 | 24 | 20,554 |
Tags: *special, implementation, sortings
Correct Solution:
```
n = map(int, input().split())
a = list(map(int, input().split()))
b = set(a)-{0}
result = 0
for i in b:
if a.count(i)>2:
print(-1)
exit(0)
elif a.count(i)==2:
result+=1
print(result)
``` | output | 1 | 10,277 | 24 | 20,555 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus is the director of a large corporation. There are n secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that when two people call each other via Spyke, the Spy... | instruction | 0 | 10,278 | 24 | 20,556 |
Tags: *special, implementation, sortings
Correct Solution:
```
def shellSort(arr):
gap = n//2
while gap > 0:
for i in range(gap,n):
temp = arr[i]
j = i
while j >= gap and arr[j-gap] >temp:
arr[j] = arr[j-gap]
j -= gap
arr[j... | output | 1 | 10,278 | 24 | 20,557 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus is the director of a large corporation. There are n secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that when two people call each other via Spyke, the Spy... | instruction | 0 | 10,279 | 24 | 20,558 |
Tags: *special, implementation, sortings
Correct Solution:
```
from collections import Counter
N, Answer = int(input()), 0
X = Counter(list(map(int, input().split())))
for key in X:
if key != 0:
if X[key] == 2:
Answer += 1
elif X[key] > 2:
print(-1)
exit()
print(... | output | 1 | 10,279 | 24 | 20,559 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus is the director of a large corporation. There are n secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that when two people call each other via Spyke, the Spy... | instruction | 0 | 10,280 | 24 | 20,560 |
Tags: *special, implementation, sortings
Correct Solution:
```
from collections import *
from sys import *
input=stdin.readline
n=int(input())
ll=list(map(int,input().split()))
l = [i for i in ll if i!=0]
c=Counter(l)
cc=0
d=list(c.values())
for i in d:
if(i==2):
cc=cc+1
elif(i>2):
cc=-1
... | output | 1 | 10,280 | 24 | 20,561 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus is the director of a large corporation. There are n secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that when two people call each other via Spyke, the Spy... | instruction | 0 | 10,281 | 24 | 20,562 |
Tags: *special, implementation, sortings
Correct Solution:
```
def solve():
n = int(input())
id = list(map(int, input().split()))
duplicate_id = set()
unique_id = set()
score = 0
for i in range(len(id)):
if id[i] != 0 and id[i] not in duplicate_id:
if id[i] not in uniqu... | output | 1 | 10,281 | 24 | 20,563 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus is the director of a large corporation. There are n secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that when two people call each other via Spyke, the Spy... | instruction | 0 | 10,282 | 24 | 20,564 |
Tags: *special, implementation, sortings
Correct Solution:
```
n = int(input())
id = sorted(list(map(int, input().split())))
prev = -1
count = 1
output = 0
for i in id[id.count(0):]:
if i == 0:
continue
if prev == i:
count += 1
else:
count = 1
if count == 2:
output += 1
... | output | 1 | 10,282 | 24 | 20,565 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus is the director of a large corporation. There are n secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that when two people call each other via Spyke, the Spy... | instruction | 0 | 10,283 | 24 | 20,566 |
Tags: *special, implementation, sortings
Correct Solution:
```
def cycleSort(array):
writes = 0
for cycleStart in range(0, len(array) - 1):
item = array[cycleStart]
pos = cycleStart
for i in range(cycleStart + 1, len(array)):
if array[i] < item:
pos += 1
if pos == cycleStar... | output | 1 | 10,283 | 24 | 20,567 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus is the director of a large corporation. There are n secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that whe... | instruction | 0 | 10,284 | 24 | 20,568 |
Yes | output | 1 | 10,284 | 24 | 20,569 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus is the director of a large corporation. There are n secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that whe... | instruction | 0 | 10,285 | 24 | 20,570 |
Yes | output | 1 | 10,285 | 24 | 20,571 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus is the director of a large corporation. There are n secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that whe... | instruction | 0 | 10,286 | 24 | 20,572 |
Yes | output | 1 | 10,286 | 24 | 20,573 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus is the director of a large corporation. There are n secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that whe... | instruction | 0 | 10,287 | 24 | 20,574 |
Yes | output | 1 | 10,287 | 24 | 20,575 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus is the director of a large corporation. There are n secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that whe... | instruction | 0 | 10,288 | 24 | 20,576 |
No | output | 1 | 10,288 | 24 | 20,577 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus is the director of a large corporation. There are n secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that whe... | instruction | 0 | 10,289 | 24 | 20,578 |
No | output | 1 | 10,289 | 24 | 20,579 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus is the director of a large corporation. There are n secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that whe... | instruction | 0 | 10,290 | 24 | 20,580 |
No | output | 1 | 10,290 | 24 | 20,581 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus is the director of a large corporation. There are n secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that whe... | instruction | 0 | 10,291 | 24 | 20,582 |
No | output | 1 | 10,291 | 24 | 20,583 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Innocentius has a problem β his computer monitor has broken. Now some of the pixels are "dead", that is, they are always black. As consequence, Innocentius can't play the usual computer games. H... | instruction | 0 | 11,106 | 24 | 22,212 |
No | output | 1 | 11,106 | 24 | 22,213 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Innocentius has a problem β his computer monitor has broken. Now some of the pixels are "dead", that is, they are always black. As consequence, Innocentius can't play the usual computer games. H... | instruction | 0 | 11,107 | 24 | 22,214 |
No | output | 1 | 11,107 | 24 | 22,215 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus has a computer with n processors. Also, his computer has n memory cells. We'll consider the processors numbered by integers from 1 to n and that the memory cells are consecutively numbered by integers from 1 to n.
Polycarpus need... | instruction | 0 | 12,764 | 24 | 25,528 |
Tags: *special, greedy
Correct Solution:
```
n, k = map(int, input().split())
i, j = 1, 2
while n >= i and k > 0:
print((str(n - i) + ' ') * max(0, n - j) + ' '.join(map(str, range(max(i + 1, n - i + 1), n + 1))) + (' ' + str(n)) * i)
i, j, k = j, 2 * j, k - 1
for i in range(k):
print((str(n) + ' ') * n)
``... | output | 1 | 12,764 | 24 | 25,529 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus has a computer with n processors. Also, his computer has n memory cells. We'll consider the processors numbered by integers from 1 to n and that the memory cells are consecutively numbered by integers from 1 to n.
Polycarpus need... | instruction | 0 | 12,765 | 24 | 25,530 |
Tags: *special, greedy
Correct Solution:
```
n, k = map(int, input().split())
a = [1 for i in range(n + 1)]
a[n] = 0
for iter in range(k):
for i in range(1, n - 1):
target = n - i
if a[i + 1] > target - a[i]:
# find right number
target -= a[i]
print(n - target, en... | output | 1 | 12,765 | 24 | 25,531 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus has a computer with n processors. Also, his computer has n memory cells. We'll consider the processors numbered by integers from 1 to n and that the memory cells are consecutively num... | instruction | 0 | 12,766 | 24 | 25,532 |
No | output | 1 | 12,766 | 24 | 25,533 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp has guessed three positive integers a, b and c. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order β their pairwise sums (three numbers) and sum of all three numbers (one number). So, the... | instruction | 0 | 13,375 | 24 | 26,750 |
Tags: math
Correct Solution:
```
a,b,c,d=map(int,input().split())
l=[a,b,c,d]
l.sort()
print(l[-1]-l[0],l[-1]-l[1],l[-1]-l[2])
``` | output | 1 | 13,375 | 24 | 26,751 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp has guessed three positive integers a, b and c. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order β their pairwise sums (three numbers) and sum of all three numbers (one number). So, the... | instruction | 0 | 13,376 | 24 | 26,752 |
Tags: math
Correct Solution:
```
arr = list(map(int,input().split()))
suma = max(arr)
for i in arr:
if(i == suma):
continue
print(suma - i,end = ' ')
``` | output | 1 | 13,376 | 24 | 26,753 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp has guessed three positive integers a, b and c. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order β their pairwise sums (three numbers) and sum of all three numbers (one number). So, the... | instruction | 0 | 13,377 | 24 | 26,754 |
Tags: math
Correct Solution:
```
'''Rajat pal'''
from collections import defaultdict
from sys import stdin
from bisect import bisect_left as bl, bisect_right as br,insort
import heapq
from collections import deque
import math
####### Stay away from negative people. They have problem for every solution.########
a=list(m... | output | 1 | 13,377 | 24 | 26,755 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp has guessed three positive integers a, b and c. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order β their pairwise sums (three numbers) and sum of all three numbers (one number). So, the... | instruction | 0 | 13,378 | 24 | 26,756 |
Tags: math
Correct Solution:
```
abcd=list(map(int,input().split()))
abcd=sorted(abcd)
ans=[]
m=max(abcd)
for i in abcd:
if i!=m:
ans.append(m-i)
print(*ans[::-1])
``` | output | 1 | 13,378 | 24 | 26,757 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp has guessed three positive integers a, b and c. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order β their pairwise sums (three numbers) and sum of all three numbers (one number). So, the... | instruction | 0 | 13,379 | 24 | 26,758 |
Tags: math
Correct Solution:
```
arr = sorted(list(map(int, input().split())))
print(' '.join([str(arr[3] - arr[i]) for i in range(3)]))
``` | output | 1 | 13,379 | 24 | 26,759 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp has guessed three positive integers a, b and c. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order β their pairwise sums (three numbers) and sum of all three numbers (one number). So, the... | instruction | 0 | 13,380 | 24 | 26,760 |
Tags: math
Correct Solution:
```
import math
l=[int(i) for i in input().split()]
l.sort(reverse=True)
p=l[1]
q=l[2]
r=l[3]
a=l[0]-l[1]
b=l[0]-l[2]
c=l[0]-l[3]
print(a,b,c)
``` | output | 1 | 13,380 | 24 | 26,761 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp has guessed three positive integers a, b and c. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order β their pairwise sums (three numbers) and sum of all three numbers (one number). So, the... | instruction | 0 | 13,381 | 24 | 26,762 |
Tags: math
Correct Solution:
```
a, b, c, d = map(int, input().split(' '))
x = int(max(a, b, c, d))
s = ''
if x != a:
s += str(x-a)+' '
if x != b:
s += str(x-b)+' '
if x != c:
s += str(x-c)+' '
if x != d:
s += str(x-d)+' '
print(s.strip())
``` | output | 1 | 13,381 | 24 | 26,763 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp has guessed three positive integers a, b and c. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order β their pairwise sums (three numbers) and sum of all three numbers (one number). So, the... | instruction | 0 | 13,382 | 24 | 26,764 |
Tags: math
Correct Solution:
```
x1,x2,x3,x4 = map(int,input().split())
m = max(x1,x2,x3,x4)
if m == x1:
print(x1 - x2, x1 - x3, x1 - x4)
elif m == x2:
print(x2 - x1, x2 - x3, x2 - x4)
elif m == x3:
print(x3 - x1, x3 - x2, x3 - x4)
elif m == x4:
print(x4 - x1, x4 - x2, x4 - x3)
``` | output | 1 | 13,382 | 24 | 26,765 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp has guessed three positive integers a, b and c. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order β their pairwise sums (three numbers) and... | instruction | 0 | 13,383 | 24 | 26,766 |
Yes | output | 1 | 13,383 | 24 | 26,767 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp has guessed three positive integers a, b and c. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order β their pairwise sums (three numbers) and... | instruction | 0 | 13,384 | 24 | 26,768 |
Yes | output | 1 | 13,384 | 24 | 26,769 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp has guessed three positive integers a, b and c. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order β their pairwise sums (three numbers) and... | instruction | 0 | 13,385 | 24 | 26,770 |
Yes | output | 1 | 13,385 | 24 | 26,771 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp has guessed three positive integers a, b and c. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order β their pairwise sums (three numbers) and... | instruction | 0 | 13,386 | 24 | 26,772 |
Yes | output | 1 | 13,386 | 24 | 26,773 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp has guessed three positive integers a, b and c. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order β their pairwise sums (three numbers) and... | instruction | 0 | 13,387 | 24 | 26,774 |
No | output | 1 | 13,387 | 24 | 26,775 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp has guessed three positive integers a, b and c. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order β their pairwise sums (three numbers) and... | instruction | 0 | 13,388 | 24 | 26,776 |
No | output | 1 | 13,388 | 24 | 26,777 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp has guessed three positive integers a, b and c. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order β their pairwise sums (three numbers) and... | instruction | 0 | 13,389 | 24 | 26,778 |
No | output | 1 | 13,389 | 24 | 26,779 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp has guessed three positive integers a, b and c. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order β their pairwise sums (three numbers) and... | instruction | 0 | 13,390 | 24 | 26,780 |
No | output | 1 | 13,390 | 24 | 26,781 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp plays a (yet another!) strategic computer game. In this game, he leads an army of mercenaries.
Polycarp wants to gather his army for a quest. There are n mercenaries for hire, and the ... | instruction | 0 | 13,480 | 24 | 26,960 |
No | output | 1 | 13,480 | 24 | 26,961 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp plays a (yet another!) strategic computer game. In this game, he leads an army of mercenaries.
Polycarp wants to gather his army for a quest. There are n mercenaries for hire, and the ... | instruction | 0 | 13,481 | 24 | 26,962 |
No | output | 1 | 13,481 | 24 | 26,963 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp plays a (yet another!) strategic computer game. In this game, he leads an army of mercenaries.
Polycarp wants to gather his army for a quest. There are n mercenaries for hire, and the ... | instruction | 0 | 13,482 | 24 | 26,964 |
No | output | 1 | 13,482 | 24 | 26,965 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp plays a (yet another!) strategic computer game. In this game, he leads an army of mercenaries.
Polycarp wants to gather his army for a quest. There are n mercenaries for hire, and the ... | instruction | 0 | 13,483 | 24 | 26,966 |
No | output | 1 | 13,483 | 24 | 26,967 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Monocarp and Bicarp live in Berland, where every bus ticket consists of n digits (n is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been... | instruction | 0 | 14,228 | 24 | 28,456 |
Tags: games, greedy, math
Correct Solution:
```
n = int(input())
s = input()
left_cnt = 0
right_cnt = 0
left_num = 0
right_num = 0
for i in range(n//2):
if s[i] == "?":
left_cnt += 1
else:
left_num += int(s[i])
for i in range(n//2,n):
if s[i] == "?":
right_cnt += 1
else:
... | output | 1 | 14,228 | 24 | 28,457 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Monocarp and Bicarp live in Berland, where every bus ticket consists of n digits (n is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been... | instruction | 0 | 14,229 | 24 | 28,458 |
Tags: games, greedy, math
Correct Solution:
```
n=int(input())
s=input()
s1=0
s2=0
c1=0
c2=0
for i in range(n//2):
if s[i]!="?":
s1+=int(s[i])
else:
c1+=1
if s[-i-1]!="?":
s2+=int(s[-i-1])
else:
c2+=1
if c1>c2:
c1-=c2
# print(c1)
if s1 + 9*(c1//2)>s2 ... | output | 1 | 14,229 | 24 | 28,459 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Monocarp and Bicarp live in Berland, where every bus ticket consists of n digits (n is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been... | instruction | 0 | 14,230 | 24 | 28,460 |
Tags: games, greedy, math
Correct Solution:
```
n = int(input())
word = input()
print(["Monocarp", "Bicarp"][0 == sum([9 * (2 * (i < n//2) - 1) if word[i] == '?' else (4 * (i < n//2) - 2) * int(word[i]) for i in range(n)])])
``` | output | 1 | 14,230 | 24 | 28,461 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.