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.
Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of the collected works of Berland leaders, the library has a reading room.
Today was the pilot launch of an automated r... | instruction | 0 | 77,121 | 14 | 154,242 |
Tags: implementation
Correct Solution:
```
n = int(input())
l = [0] * (10 ** 6 + 1)
capacity = 0
cur = 0
for i in range(n):
s = input().split()
visitor = int(s[1])
if s[0] == "+":
l[visitor] = 1
cur += 1
if cur > capacity:
capacity = cur
else:
if l[visitor] ==... | output | 1 | 77,121 | 14 | 154,243 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of the collected works of Berland leaders, the library has a reading room.
Today was the pilot launch of an automated r... | instruction | 0 | 77,122 | 14 | 154,244 |
Tags: implementation
Correct Solution:
```
d=set()
m=0
for _ in range(int(input())):
x,i=input().split()
if x=="-":
if i in d:d.remove(i)
else:m+=1
else: d.add(i)
m=max(m,len(d))
print(m)
# Made By Mostafa_Khaled
``` | output | 1 | 77,122 | 14 | 154,245 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of the collected works of Berland leaders, the library has a reading room.
Today was the pilot launch of an automated r... | instruction | 0 | 77,123 | 14 | 154,246 |
Tags: implementation
Correct Solution:
```
def main():
n = int(input())
prev = set()
min_cap = 0
cap = 0
for _ in range(n):
cur = input().split()
is_in = cur[0] == '+'
idx = int(cur[1])
if is_in:
cap += 1
prev.add(idx)
min... | output | 1 | 77,123 | 14 | 154,247 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of the collected works of Berland leaders, the library has a reading room.
Today was the pilot launch of an automated r... | instruction | 0 | 77,124 | 14 | 154,248 |
Tags: implementation
Correct Solution:
```
n = int(input())
a = [0] * (n+1)
b = [[0,0]] * (n+1)
for i in range(1,n+1):
s = list(map(str,input().split()))
b[i] = s
if (s[0] == '+'):
a[i] = a[i-1] + 1
else:
j = i
c1 = 0
while (j >= 0):
if ((b[j][0] == '+') and (... | output | 1 | 77,124 | 14 | 154,249 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of the collected works of Berland leaders, the library has a reading room.
Today was the pilot launch of an automated r... | instruction | 0 | 77,125 | 14 | 154,250 |
Tags: implementation
Correct Solution:
```
count = 0
ans = 0
a = set()
n = int(input())
for i in range(n):
reg = input().split()
reg[1] = int(reg[1])
if reg[0] == '+':
a.add(reg[1])
count += 1
else:
if reg[1] in a:
a.remove(reg[1])
count -= 1
else:... | output | 1 | 77,125 | 14 | 154,251 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of the collected works of Berland leaders, the library has a reading room.
Today was the pilot launch of an automated r... | instruction | 0 | 77,126 | 14 | 154,252 |
Tags: implementation
Correct Solution:
```
n = int(input())
# start_count = 0
max_count = 0
lib = []
for i in range(0, n):
sign, key = input().split()
if sign == '+':
lib.append(key)
if len(lib) > max_count:
max_count = len(lib)
else:
if lib.count(key) > 0:
li... | output | 1 | 77,126 | 14 | 154,253 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of the collected works of Berland leaders, the library has a reading room... | instruction | 0 | 77,127 | 14 | 154,254 |
Yes | output | 1 | 77,127 | 14 | 154,255 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of the collected works of Berland leaders, the library has a reading room... | instruction | 0 | 77,128 | 14 | 154,256 |
Yes | output | 1 | 77,128 | 14 | 154,257 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of the collected works of Berland leaders, the library has a reading room... | instruction | 0 | 77,129 | 14 | 154,258 |
Yes | output | 1 | 77,129 | 14 | 154,259 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of the collected works of Berland leaders, the library has a reading room... | instruction | 0 | 77,130 | 14 | 154,260 |
Yes | output | 1 | 77,130 | 14 | 154,261 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of the collected works of Berland leaders, the library has a reading room... | instruction | 0 | 77,131 | 14 | 154,262 |
No | output | 1 | 77,131 | 14 | 154,263 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of the collected works of Berland leaders, the library has a reading room... | instruction | 0 | 77,132 | 14 | 154,264 |
No | output | 1 | 77,132 | 14 | 154,265 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of the collected works of Berland leaders, the library has a reading room... | instruction | 0 | 77,133 | 14 | 154,266 |
No | output | 1 | 77,133 | 14 | 154,267 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of the collected works of Berland leaders, the library has a reading room... | instruction | 0 | 77,134 | 14 | 154,268 |
No | output | 1 | 77,134 | 14 | 154,269 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should share a name (what would happen if they got an order that Bob is a scouter, if the... | instruction | 0 | 77,221 | 14 | 154,442 |
Tags: constructive algorithms, greedy
Correct Solution:
```
names = [chr(ord('A') + i) for i in range(26)]
names += ['A' + chr(ord('a') + i) for i in range(26)]
n, k = map(int, input().split())
a = input().split()
for i, a_i in enumerate(a):
if a_i == 'NO':
names[i+k-1] = names[i]
print(' '.join(names[:n... | output | 1 | 77,221 | 14 | 154,443 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should share a name (what would happen if they got an order that Bob is a scouter, if the... | instruction | 0 | 77,222 | 14 | 154,444 |
Tags: constructive algorithms, greedy
Correct Solution:
```
n, k = map(int, input().split())
names = []
def getNext(a):
if a[1] == 'z':
return chr(ord(a[0]) + 1) + 'a'
else:
return a[0] + chr(ord(a[1]) + 1)
a = list(input().split())
for i in range(len(a)):
a[i] = 1 if a[i] == 'YES' else 0
... | output | 1 | 77,222 | 14 | 154,445 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should share a name (what would happen if they got an order that Bob is a scouter, if the... | instruction | 0 | 77,223 | 14 | 154,446 |
Tags: constructive algorithms, greedy
Correct Solution:
```
from string import ascii_uppercase
n,k=map(int,input().split())
s=list(input().split())
#print(len(s))
names=[]
for i in ascii_uppercase:
names.append(i)
names.append('A'+str(i).lower())
#print(names)
a=[]
if s[0]=='YES':
for i in range(k):
... | output | 1 | 77,223 | 14 | 154,447 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should share a name (what would happen if they got an order that Bob is a scouter, if the... | instruction | 0 | 77,224 | 14 | 154,448 |
Tags: constructive algorithms, greedy
Correct Solution:
```
R= lambda: map(int,input().split())
n,k =R()
l=[]
s,s2= ord('A'),ord('a')
for i in range(k):
if i<26:
l.append(chr(s+i))
else: l.append('A'+chr(s2+(i%26)))
if i<k-1: print(l[i],end=' ')
s=[i for i in range(k-1)]
i,j=k-1,0
c=input().spli... | output | 1 | 77,224 | 14 | 154,449 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should share a name (what would happen if they got an order that Bob is a scouter, if the... | instruction | 0 | 77,225 | 14 | 154,450 |
Tags: constructive algorithms, greedy
Correct Solution:
```
n, k = map(int, input().split())
names = []
for i in range(ord('a'), ord('z') + 1):
names.append('A' + chr(i))
for i in range(ord('a'), ord('z') + 1):
names.append('B' + chr(i))
pos = 0
a = input().split()
ans = []
for i in range(k - 1):
ans.append... | output | 1 | 77,225 | 14 | 154,451 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should share a name (what would happen if they got an order that Bob is a scouter, if the... | instruction | 0 | 77,226 | 14 | 154,452 |
Tags: constructive algorithms, greedy
Correct Solution:
```
def name(n):
return chr(ord('A') + n % 26) + chr(ord('a') + n // 26)
def main():
n, k = map(int, input().split())
arr = list(map(str, input().split()))
if (arr.count("YES") == 0):
for i in range(n):
print("Max ", end = "")
return
ans = ["" for i i... | output | 1 | 77,226 | 14 | 154,453 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should share a name (what would happen if they got an order that Bob is a scouter, if the... | instruction | 0 | 77,227 | 14 | 154,454 |
Tags: constructive algorithms, greedy
Correct Solution:
```
n, k = map(int, input().split()) ##n - k + 1 - всего запросов
names = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'Aa', 'Bb', 'Cc', 'Dd', 'Ee', 'Ff', 'Gg', 'Hh', 'Ii', 'Jj',... | output | 1 | 77,227 | 14 | 154,455 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should share a name (what would happen if they got an order that Bob is a scouter, if the... | instruction | 0 | 77,228 | 14 | 154,456 |
Tags: constructive algorithms, greedy
Correct Solution:
```
n,k=map(int,input().split())
l=list(map(str,input().split()))
A=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','Aa','Ab','Ac','Ad','Ae','Af','Ag','Ah','Ai','Aj','Ak','Al','Am','An','Ao','Ap','Aq','Ar','... | output | 1 | 77,228 | 14 | 154,457 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should share a name (what would happen if ... | instruction | 0 | 77,229 | 14 | 154,458 |
Yes | output | 1 | 77,229 | 14 | 154,459 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should share a name (what would happen if ... | instruction | 0 | 77,230 | 14 | 154,460 |
Yes | output | 1 | 77,230 | 14 | 154,461 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should share a name (what would happen if ... | instruction | 0 | 77,231 | 14 | 154,462 |
Yes | output | 1 | 77,231 | 14 | 154,463 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should share a name (what would happen if ... | instruction | 0 | 77,232 | 14 | 154,464 |
Yes | output | 1 | 77,232 | 14 | 154,465 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should share a name (what would happen if ... | instruction | 0 | 77,233 | 14 | 154,466 |
No | output | 1 | 77,233 | 14 | 154,467 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should share a name (what would happen if ... | instruction | 0 | 77,234 | 14 | 154,468 |
No | output | 1 | 77,234 | 14 | 154,469 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should share a name (what would happen if ... | instruction | 0 | 77,235 | 14 | 154,470 |
No | output | 1 | 77,235 | 14 | 154,471 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should share a name (what would happen if ... | instruction | 0 | 77,236 | 14 | 154,472 |
No | output | 1 | 77,236 | 14 | 154,473 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a team of N people. For a particular task, you can pick any non-empty subset of people. The cost of having x people for the task is xk.
Output the sum of costs over all non-empty subsets of people.
Input
Only line of input conta... | instruction | 0 | 77,321 | 14 | 154,642 |
Tags: combinatorics, dp, math
Correct Solution:
```
n, k = map(int, input().split())
m = 0x3b9aca07
r = 0
p = pow(2, n, m)
a = [1] + [0] * k
for i in range(k):
for j in range(i, -1, -1):
a[j + 1] += a[j]
a[j] = a[j] * j % m
for i in range(k + 1):
r += p * a[i]
p = p * 500000004 * (n - i) % m... | output | 1 | 77,321 | 14 | 154,643 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a team of N people. For a particular task, you can pick any non-empty subset of people. The cost of having x people for the task is xk.
Output the sum of costs over all non-empty subsets of people.
Input
Only line of input conta... | instruction | 0 | 77,322 | 14 | 154,644 |
Tags: combinatorics, dp, math
Correct Solution:
```
n,k = map(int,input().split())
dp = [0 for i in range(k+1)]
mod = 10**9+7
dp[0] = 1
for i in range(k):
for j in range(1,k+1)[::-1]:
dp[j] = (dp[j]*j+dp[j-1]*(n-j+1))%mod
dp[0] = 0
ans = 0
for i in range(k+1):
if n < i:
continue
ans += dp[i]*pow(2,n-i,m... | output | 1 | 77,322 | 14 | 154,645 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a team of N people. For a particular task, you can pick any non-empty subset of people. The cost of having x people for the task is xk.
Output the sum of costs over all non-empty subsets of people.
Input
Only line of input conta... | instruction | 0 | 77,323 | 14 | 154,646 |
Tags: combinatorics, dp, math
Correct Solution:
```
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S()... | output | 1 | 77,323 | 14 | 154,647 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a team of N people. For a particular task, you can pick any non-empty subset of people. The cost of having x people for the task is xk.
Output the sum of costs over all non-empty subsets of people.
Input
Only line of input conta... | instruction | 0 | 77,324 | 14 | 154,648 |
Tags: combinatorics, dp, math
Correct Solution:
```
n, k = map(int, input().split())
m = int(1e9+7)
r = 0
p = pow(2, n, m)
a = [1] + [0] * k
for i in range(k):
for j in range(i, -1, -1):
a[j+1] += a[j]
a[j] = a[j]*j % m
for i in range(k + 1):
r += p*a[i]
p = p*500000004*(n - i) % m
print(r %... | output | 1 | 77,324 | 14 | 154,649 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a team of N people. For a particular task, you can pick any non-empty subset of people. The cost of having x people for the task is xk.
Output the sum of costs over all non-empty subsets of people.
Input
Only line of input conta... | instruction | 0 | 77,325 | 14 | 154,650 |
Tags: combinatorics, dp, math
Correct Solution:
```
# ############################## import
# def stirling2_list(n, mod=10 ** 9 + 7):
# if not n:
# return [0]
# res = [0, 1]
# for i in range(n - 1):
# res = [0, 1] + [(res[j - 1] + j * res[j]) % mod for j in range(2, 2 + i)] + [1]
# retur... | output | 1 | 77,325 | 14 | 154,651 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a team of N people. For a particular task, you can pick any non-empty subset of people. The cost of having x people for the task is xk.
Output the sum of costs over all non-empty subsets of people.
Input
Only line of input conta... | instruction | 0 | 77,326 | 14 | 154,652 |
Tags: combinatorics, dp, math
Correct Solution:
```
n, k = map(int, input().split())
m = 0x3b9aca07
r = 0
p = pow(2, n, m)
a = [1] + [0] * k
for i in range(k):
for j in range(i, -1, -1):
a[j + 1] += a[j]
a[j] = a[j] * j % m
for i in range(k + 1):
r = (r + p * a[i]) % m
p = p * 500000004 * (n... | output | 1 | 77,326 | 14 | 154,653 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a team of N people. For a particular task, you can pick any non-empty subset of people. The cost of having x people for the task is xk.
Output the sum of costs over all non-empty subsets of people.
Input
Only line of input conta... | instruction | 0 | 77,327 | 14 | 154,654 |
Tags: combinatorics, dp, math
Correct Solution:
```
n, k = map(int, input().split())
m = 0x3b9aca07
v = 500000004
r = 0
p = pow(2, n, m)
a = [1] + [0] * k
for i in range(k):
for j in range(i, -1, -1):
a[j + 1] += a[j]
a[j] = a[j] * j % m
for i in range(k + 1):
r = (r + p * a[i]) % m
p = p * ... | output | 1 | 77,327 | 14 | 154,655 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a team of N people. For a particular task, you can pick any non-empty subset of people. The cost of having x people for the task is xk.
Output the sum of costs over all non-empty subsets of people.
Input
Only line of input conta... | instruction | 0 | 77,328 | 14 | 154,656 |
Tags: combinatorics, dp, math
Correct Solution:
```
n, k = map(int, input().split())
m = int(1e9 + 7)
r = 0
p = pow(2, n, m)
a = [1] + [0] * k
for i in range(k):
for j in range(i, -1, -1):
a[j + 1] += a[j]
a[j] = a[j] * j % m
for i in range(k + 1):
r = (r + p * a[i]) % m
p = p * 500000004 * ... | output | 1 | 77,328 | 14 | 154,657 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Phoenix is trying to take a photo of his n friends with labels 1, 2, ..., n who are lined up in a row in a special order. But before he can take the photo, his friends get distracted by a duck a... | instruction | 0 | 77,705 | 14 | 155,410 |
No | output | 1 | 77,705 | 14 | 155,411 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Phoenix is trying to take a photo of his n friends with labels 1, 2, ..., n who are lined up in a row in a special order. But before he can take the photo, his friends get distracted by a duck a... | instruction | 0 | 77,706 | 14 | 155,412 |
No | output | 1 | 77,706 | 14 | 155,413 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Phoenix is trying to take a photo of his n friends with labels 1, 2, ..., n who are lined up in a row in a special order. But before he can take the photo, his friends get distracted by a duck a... | instruction | 0 | 77,707 | 14 | 155,414 |
No | output | 1 | 77,707 | 14 | 155,415 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Phoenix is trying to take a photo of his n friends with labels 1, 2, ..., n who are lined up in a row in a special order. But before he can take the photo, his friends get distracted by a duck a... | instruction | 0 | 77,708 | 14 | 155,416 |
No | output | 1 | 77,708 | 14 | 155,417 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Emily's birthday is next week and Jack has decided to buy a present for her. He knows she loves books so he goes to the local bookshop, where there are n books on sale from one of m genres.
In the bookshop, Jack decides to buy two books of ... | instruction | 0 | 77,873 | 14 | 155,746 |
Tags: constructive algorithms, implementation
Correct Solution:
```
from functools import *
n, m = map(int, input().split())
cnt = [0] * (m + 1)
a = list(map(int, input().split()))
for x in a:
cnt[x] += 1
print(reduce(lambda res, x: res + x * (n - x), cnt, 0) // 2)
``` | output | 1 | 77,873 | 14 | 155,747 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Emily's birthday is next week and Jack has decided to buy a present for her. He knows she loves books so he goes to the local bookshop, where there are n books on sale from one of m genres.
In the bookshop, Jack decides to buy two books of ... | instruction | 0 | 77,874 | 14 | 155,748 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n, m = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
t = n
for i in range(1, m):
cai = a.count(i)
ans += cai * (t - cai)
t -= cai
print(ans)
``` | output | 1 | 77,874 | 14 | 155,749 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Emily's birthday is next week and Jack has decided to buy a present for her. He knows she loves books so he goes to the local bookshop, where there are n books on sale from one of m genres.
In the bookshop, Jack decides to buy two books of ... | instruction | 0 | 77,875 | 14 | 155,750 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n, m = [int(x) for x in input().split()]
# inisialisasi array untuk menghitung bayak buku setiap genre
cnt = [0 for x in range(m)]
for x in input().split():
# kurangi dengan satu agar nomor genre dimulai dari 0-(m-1)
num = int(x) - 1
cnt[num] += ... | output | 1 | 77,875 | 14 | 155,751 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Emily's birthday is next week and Jack has decided to buy a present for her. He knows she loves books so he goes to the local bookshop, where there are n books on sale from one of m genres.
In the bookshop, Jack decides to buy two books of ... | instruction | 0 | 77,876 | 14 | 155,752 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n, m = map(int, input().split())
books_per_genre = [0]*m
books = list(map(int, input().split()))
for book in books:
books_per_genre[book-1] += 1
result = 0
used = 0
for genre in books_per_genre:
result += (genre*(n-genre-used))
used += genr... | output | 1 | 77,876 | 14 | 155,753 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Emily's birthday is next week and Jack has decided to buy a present for her. He knows she loves books so he goes to the local bookshop, where there are n books on sale from one of m genres.
In the bookshop, Jack decides to buy two books of ... | instruction | 0 | 77,877 | 14 | 155,754 |
Tags: constructive algorithms, implementation
Correct Solution:
```
duplicated_keys = {}
def calculate_chinh_hop_of_2(number_books):
return int(number_books * (number_books - 1) / 2)
number_books, number_genders = list(map(int, input().split()))
number_data = list(map(int, input().split()))
number_of_choosing_b... | output | 1 | 77,877 | 14 | 155,755 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Emily's birthday is next week and Jack has decided to buy a present for her. He knows she loves books so he goes to the local bookshop, where there are n books on sale from one of m genres.
In the bookshop, Jack decides to buy two books of ... | instruction | 0 | 77,878 | 14 | 155,756 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n,m = map(int, input().split())
l = list(map(int, input().split()))
num = [0]*int(2*1e5+5)
for i in l:
num[i] += 1
ans = n*(n-1)//2
for i in num:
ans -= i*(i-1)//2
print(ans)
``` | output | 1 | 77,878 | 14 | 155,757 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Emily's birthday is next week and Jack has decided to buy a present for her. He knows she loves books so he goes to the local bookshop, where there are n books on sale from one of m genres.
In the bookshop, Jack decides to buy two books of ... | instruction | 0 | 77,879 | 14 | 155,758 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n,m=map(int,input().split())
arr=list(map(int,input().split()))
arr2=[0]*m
ans=0
for i in range(n):
arr2[arr[i]-1]+=1
for i in range(m):
for j in range(i+1,m):
ans+=arr2[i]*arr2[j]
print(ans)
``` | output | 1 | 77,879 | 14 | 155,759 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Emily's birthday is next week and Jack has decided to buy a present for her. He knows she loves books so he goes to the local bookshop, where there are n books on sale from one of m genres.
In the bookshop, Jack decides to buy two books of ... | instruction | 0 | 77,880 | 14 | 155,760 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n, m = map(int, input().split())
a = [int(x) for x in input().split()]
# a = list(map(int, input().split()))
c = [0] * 11
ans = 0
for i in range(n):
c[a[i]] += 1
for i in range(1, m):
for j in range(i + 1, m + 1):
ans +=... | output | 1 | 77,880 | 14 | 155,761 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.