output_description stringlengths 15 956 | submission_id stringlengths 10 10 | status stringclasses 3 values | problem_id stringlengths 6 6 | input_description stringlengths 9 2.55k | attempt stringlengths 1 13.7k | problem_description stringlengths 7 5.24k | samples stringlengths 2 2.72k |
|---|---|---|---|---|---|---|---|
Print the minimum number of inspectors that we need to deploy to achieve the
objective.
* * * | s578771647 | Wrong Answer | p02970 | Input is given from Standard Input in the following format:
N D | a, s = map(int, input().split())
print(-(-a // (2 * s)))
| Statement
There are N apple trees in a row. People say that one of them will bear golden
apples.
We want to deploy some number of inspectors so that each of these trees will
be inspected.
Each inspector will be deployed under one of the trees. For convenience, we
will assign numbers from 1 through N to the trees. An inspector deployed under
the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between
i-D and i+D (inclusive).
Find the minimum number of inspectors that we need to deploy to achieve the
objective. | [{"input": "6 2", "output": "2\n \n\nWe can achieve the objective by, for example, placing an inspector under Tree\n3 and Tree 4.\n\n* * *"}, {"input": "14 3", "output": "2\n \n\n* * *"}, {"input": "20 4", "output": "3"}] |
Print the minimum number of inspectors that we need to deploy to achieve the
objective.
* * * | s779884593 | Runtime Error | p02970 | Input is given from Standard Input in the following format:
N D | a, b = list(map(int, input()))
print((a - 1) / (2 * b + 1) / 1)
| Statement
There are N apple trees in a row. People say that one of them will bear golden
apples.
We want to deploy some number of inspectors so that each of these trees will
be inspected.
Each inspector will be deployed under one of the trees. For convenience, we
will assign numbers from 1 through N to the trees. An inspector deployed under
the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between
i-D and i+D (inclusive).
Find the minimum number of inspectors that we need to deploy to achieve the
objective. | [{"input": "6 2", "output": "2\n \n\nWe can achieve the objective by, for example, placing an inspector under Tree\n3 and Tree 4.\n\n* * *"}, {"input": "14 3", "output": "2\n \n\n* * *"}, {"input": "20 4", "output": "3"}] |
Print the minimum number of inspectors that we need to deploy to achieve the
objective.
* * * | s178004653 | Wrong Answer | p02970 | Input is given from Standard Input in the following format:
N D | import io
import sys
from math import ceil
def IN_S():
return input()
def IN_I():
return int(input())
def IN_L_I():
return list(map(int, input().split()))
def IN_L_S():
return list(map(str, input().split()))
def STR_SPLIT(s, n):
for l in range(0, len(s), n):
yield s[0 + l : n + l]
def T_IN():
global test_str
sys.stdin = io.StringIO(test_str[1:-1])
test_str = """
20 4
"""
def MAIN():
T_IN()
A()
def A():
n, d = IN_L_I()
print(ceil(n / (d * 2 + 1)))
return None
def B():
return None
def C():
return None
MAIN()
| Statement
There are N apple trees in a row. People say that one of them will bear golden
apples.
We want to deploy some number of inspectors so that each of these trees will
be inspected.
Each inspector will be deployed under one of the trees. For convenience, we
will assign numbers from 1 through N to the trees. An inspector deployed under
the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between
i-D and i+D (inclusive).
Find the minimum number of inspectors that we need to deploy to achieve the
objective. | [{"input": "6 2", "output": "2\n \n\nWe can achieve the objective by, for example, placing an inspector under Tree\n3 and Tree 4.\n\n* * *"}, {"input": "14 3", "output": "2\n \n\n* * *"}, {"input": "20 4", "output": "3"}] |
Print the minimum number of inspectors that we need to deploy to achieve the
objective.
* * * | s726251741 | Runtime Error | p02970 | Input is given from Standard Input in the following format:
N D | N, D = map(int, input())
if N % 2 * D + 1 == 0:
print(N // ((2 * D) + 1))
else:
print(N // ((2 * D) + 1) + 1)
| Statement
There are N apple trees in a row. People say that one of them will bear golden
apples.
We want to deploy some number of inspectors so that each of these trees will
be inspected.
Each inspector will be deployed under one of the trees. For convenience, we
will assign numbers from 1 through N to the trees. An inspector deployed under
the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between
i-D and i+D (inclusive).
Find the minimum number of inspectors that we need to deploy to achieve the
objective. | [{"input": "6 2", "output": "2\n \n\nWe can achieve the objective by, for example, placing an inspector under Tree\n3 and Tree 4.\n\n* * *"}, {"input": "14 3", "output": "2\n \n\n* * *"}, {"input": "20 4", "output": "3"}] |
Print the minimum number of inspectors that we need to deploy to achieve the
objective.
* * * | s058495898 | Wrong Answer | p02970 | Input is given from Standard Input in the following format:
N D | num = input().split()
ans = int(num[0]) // (int(num[1]) * 2 + 1)
print(ans + 1)
| Statement
There are N apple trees in a row. People say that one of them will bear golden
apples.
We want to deploy some number of inspectors so that each of these trees will
be inspected.
Each inspector will be deployed under one of the trees. For convenience, we
will assign numbers from 1 through N to the trees. An inspector deployed under
the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between
i-D and i+D (inclusive).
Find the minimum number of inspectors that we need to deploy to achieve the
objective. | [{"input": "6 2", "output": "2\n \n\nWe can achieve the objective by, for example, placing an inspector under Tree\n3 and Tree 4.\n\n* * *"}, {"input": "14 3", "output": "2\n \n\n* * *"}, {"input": "20 4", "output": "3"}] |
Print the minimum number of inspectors that we need to deploy to achieve the
objective.
* * * | s855307054 | Accepted | p02970 | Input is given from Standard Input in the following format:
N D | N, D = map(int, (input().split()))
print(N // (2 * D + 1) + int(N % (2 * D + 1) != 0))
| Statement
There are N apple trees in a row. People say that one of them will bear golden
apples.
We want to deploy some number of inspectors so that each of these trees will
be inspected.
Each inspector will be deployed under one of the trees. For convenience, we
will assign numbers from 1 through N to the trees. An inspector deployed under
the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between
i-D and i+D (inclusive).
Find the minimum number of inspectors that we need to deploy to achieve the
objective. | [{"input": "6 2", "output": "2\n \n\nWe can achieve the objective by, for example, placing an inspector under Tree\n3 and Tree 4.\n\n* * *"}, {"input": "14 3", "output": "2\n \n\n* * *"}, {"input": "20 4", "output": "3"}] |
Print the minimum number of inspectors that we need to deploy to achieve the
objective.
* * * | s146891286 | Accepted | p02970 | Input is given from Standard Input in the following format:
N D | N, D = [int(x) for x in input().split()]
trees_per_man = 2 * D + 1
print(N // trees_per_man if N % trees_per_man == 0 else N // trees_per_man + 1)
| Statement
There are N apple trees in a row. People say that one of them will bear golden
apples.
We want to deploy some number of inspectors so that each of these trees will
be inspected.
Each inspector will be deployed under one of the trees. For convenience, we
will assign numbers from 1 through N to the trees. An inspector deployed under
the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between
i-D and i+D (inclusive).
Find the minimum number of inspectors that we need to deploy to achieve the
objective. | [{"input": "6 2", "output": "2\n \n\nWe can achieve the objective by, for example, placing an inspector under Tree\n3 and Tree 4.\n\n* * *"}, {"input": "14 3", "output": "2\n \n\n* * *"}, {"input": "20 4", "output": "3"}] |
Print the minimum number of inspectors that we need to deploy to achieve the
objective.
* * * | s315436881 | Wrong Answer | p02970 | Input is given from Standard Input in the following format:
N D | a, b = map(int, input().split())
c = b
n = 0
if 1 + c + c >= a:
n = n + 1
print(n)
if 1 + c + c < a:
n = n + 2
if 2 * (1 + c + c) >= a:
print(n)
if 2 * (1 + c + c) < a:
n = n + 1
print(n)
| Statement
There are N apple trees in a row. People say that one of them will bear golden
apples.
We want to deploy some number of inspectors so that each of these trees will
be inspected.
Each inspector will be deployed under one of the trees. For convenience, we
will assign numbers from 1 through N to the trees. An inspector deployed under
the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between
i-D and i+D (inclusive).
Find the minimum number of inspectors that we need to deploy to achieve the
objective. | [{"input": "6 2", "output": "2\n \n\nWe can achieve the objective by, for example, placing an inspector under Tree\n3 and Tree 4.\n\n* * *"}, {"input": "14 3", "output": "2\n \n\n* * *"}, {"input": "20 4", "output": "3"}] |
Print the minimum number of inspectors that we need to deploy to achieve the
objective.
* * * | s393050439 | Wrong Answer | p02970 | Input is given from Standard Input in the following format:
N D | N, D = (int(x) for x in input().split())
S = N // (D * 2 + 1) + 1
print(S)
| Statement
There are N apple trees in a row. People say that one of them will bear golden
apples.
We want to deploy some number of inspectors so that each of these trees will
be inspected.
Each inspector will be deployed under one of the trees. For convenience, we
will assign numbers from 1 through N to the trees. An inspector deployed under
the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between
i-D and i+D (inclusive).
Find the minimum number of inspectors that we need to deploy to achieve the
objective. | [{"input": "6 2", "output": "2\n \n\nWe can achieve the objective by, for example, placing an inspector under Tree\n3 and Tree 4.\n\n* * *"}, {"input": "14 3", "output": "2\n \n\n* * *"}, {"input": "20 4", "output": "3"}] |
Print the minimum number of inspectors that we need to deploy to achieve the
objective.
* * * | s481783046 | Wrong Answer | p02970 | Input is given from Standard Input in the following format:
N D | n, d = input().split(" ")
n = int(n)
d = int(d)
print(n / (2 * d + 1) + int(n % (2 * d + 1) != 0))
| Statement
There are N apple trees in a row. People say that one of them will bear golden
apples.
We want to deploy some number of inspectors so that each of these trees will
be inspected.
Each inspector will be deployed under one of the trees. For convenience, we
will assign numbers from 1 through N to the trees. An inspector deployed under
the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between
i-D and i+D (inclusive).
Find the minimum number of inspectors that we need to deploy to achieve the
objective. | [{"input": "6 2", "output": "2\n \n\nWe can achieve the objective by, for example, placing an inspector under Tree\n3 and Tree 4.\n\n* * *"}, {"input": "14 3", "output": "2\n \n\n* * *"}, {"input": "20 4", "output": "3"}] |
Print the minimum number of inspectors that we need to deploy to achieve the
objective.
* * * | s021227229 | Accepted | p02970 | Input is given from Standard Input in the following format:
N D | A = list(map(int, input().split()))
print((A[0] - 1) // (1 + 2 * A[1]) + 1)
| Statement
There are N apple trees in a row. People say that one of them will bear golden
apples.
We want to deploy some number of inspectors so that each of these trees will
be inspected.
Each inspector will be deployed under one of the trees. For convenience, we
will assign numbers from 1 through N to the trees. An inspector deployed under
the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between
i-D and i+D (inclusive).
Find the minimum number of inspectors that we need to deploy to achieve the
objective. | [{"input": "6 2", "output": "2\n \n\nWe can achieve the objective by, for example, placing an inspector under Tree\n3 and Tree 4.\n\n* * *"}, {"input": "14 3", "output": "2\n \n\n* * *"}, {"input": "20 4", "output": "3"}] |
Print the minimum number of inspectors that we need to deploy to achieve the
objective.
* * * | s202636887 | Wrong Answer | p02970 | Input is given from Standard Input in the following format:
N D | n, d = map(int, input().split(" "))
width = 2 * d + 1
print(n // width + 1)
| Statement
There are N apple trees in a row. People say that one of them will bear golden
apples.
We want to deploy some number of inspectors so that each of these trees will
be inspected.
Each inspector will be deployed under one of the trees. For convenience, we
will assign numbers from 1 through N to the trees. An inspector deployed under
the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between
i-D and i+D (inclusive).
Find the minimum number of inspectors that we need to deploy to achieve the
objective. | [{"input": "6 2", "output": "2\n \n\nWe can achieve the objective by, for example, placing an inspector under Tree\n3 and Tree 4.\n\n* * *"}, {"input": "14 3", "output": "2\n \n\n* * *"}, {"input": "20 4", "output": "3"}] |
Print the minimum number of inspectors that we need to deploy to achieve the
objective.
* * * | s459012490 | Accepted | p02970 | Input is given from Standard Input in the following format:
N D | N, D = [int(s) for s in input().split()]
print(N // (2 * D + 1) + (N % (2 * D + 1) != 0))
| Statement
There are N apple trees in a row. People say that one of them will bear golden
apples.
We want to deploy some number of inspectors so that each of these trees will
be inspected.
Each inspector will be deployed under one of the trees. For convenience, we
will assign numbers from 1 through N to the trees. An inspector deployed under
the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between
i-D and i+D (inclusive).
Find the minimum number of inspectors that we need to deploy to achieve the
objective. | [{"input": "6 2", "output": "2\n \n\nWe can achieve the objective by, for example, placing an inspector under Tree\n3 and Tree 4.\n\n* * *"}, {"input": "14 3", "output": "2\n \n\n* * *"}, {"input": "20 4", "output": "3"}] |
Print the minimum number of inspectors that we need to deploy to achieve the
objective.
* * * | s274091050 | Accepted | p02970 | Input is given from Standard Input in the following format:
N D | N, D = map(int, input().split()) # 横に2個
A = 2 * D + 1
if N % A == 0:
print(N // A)
else:
print(N // A + 1)
| Statement
There are N apple trees in a row. People say that one of them will bear golden
apples.
We want to deploy some number of inspectors so that each of these trees will
be inspected.
Each inspector will be deployed under one of the trees. For convenience, we
will assign numbers from 1 through N to the trees. An inspector deployed under
the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between
i-D and i+D (inclusive).
Find the minimum number of inspectors that we need to deploy to achieve the
objective. | [{"input": "6 2", "output": "2\n \n\nWe can achieve the objective by, for example, placing an inspector under Tree\n3 and Tree 4.\n\n* * *"}, {"input": "14 3", "output": "2\n \n\n* * *"}, {"input": "20 4", "output": "3"}] |
For all of the N! orders, find the total cost of the N operations, and print
the sum of those N! total costs, modulo 10^9+7.
* * * | s828102766 | Runtime Error | p03232 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | ef multiply(x, y):
return (x * y) % mod
def power(x, y):
if y == 0:
return 1
elif y == 1:
return x
elif x == 1:
return 1
elif x == 0:
return 0
else:
# print(mod)
tmp = power(x, y // 2)
return (multiply(tmp, tmp) * [1, x][y % 2]) % mod
N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7
plist = [0]
nfact = 1
N
tmp = 0
for i in range(1, N):
tmp = (tmp + power(i + 1, mod - 2)) % mod
nfact = (nfact * (i + 1)) % mod
plist.append(tmp)
ans = 0
# print(plist)
# print(nfact)
for i, a in enumerate(A):
# print(i, N - i - 1, N)
tmp = (1 + plist[i] + plist[N - i - 1]) % mod
ans = (ans + multiply(multiply(a, tmp), nfact)) % mod
print(ans) | Statement
There are N blocks arranged in a row, numbered 1 to N from left to right. Each
block has a weight, and the weight of Block i is A_i. Snuke will perform the
following operation on these blocks N times:
* Choose one block that is still not removed, and remove it. The cost of this operation is the sum of the weights of the blocks that are connected to the block being removed (including itself). Here, two blocks x and y ( x \leq y ) are _connected_ when, for all z ( x \leq z \leq y ), Block z is still not removed.
There are N! possible orders in which Snuke removes the blocks. For all of
those N! orders, find the total cost of the N operations, and calculate the
sum of those N! total costs. As the answer can be extremely large, compute the
sum modulo 10^9+7. | [{"input": "2\n 1 2", "output": "9\n \n\nFirst, we will consider the order \"Block 1 -> Block 2\". In the first\noperation, the cost of the operation is 1+2=3, as Block 1 and 2 are connected.\nIn the second operation, the cost of the operation is 2, as only Block 2\nremains. Thus, the total cost of the two operations for this order is 3+2=5.\n\nThen, we will consider the order \"Block 2 -> Block 1\". In the first operation,\nthe cost of the operation is 1+2=3, as Block 1 and 2 are connected. In the\nsecond operation, the cost of the operation is 1, as only Block 1 remains.\nThus, the total cost of the two operations for this order is 3+1=4.\n\nTherefore, the answer is 5+4=9.\n\n* * *"}, {"input": "4\n 1 1 1 1", "output": "212\n \n\n* * *"}, {"input": "10\n 1 2 4 8 16 32 64 128 256 512", "output": "880971923"}] |
For all of the N! orders, find the total cost of the N operations, and print
the sum of those N! total costs, modulo 10^9+7.
* * * | s079980680 | Runtime Error | p03232 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | N = int(input())
w = [int(i) for i in input().split()]
def f(n):
i = 1
for j in range(0,n):
i = i*(j+1)
return i
def c(l):
n = len(l)
if n == 0
return 0
elif n == 1:
return l[0]
else:
t = f(n)*sum(l)
for i in range(0,n):
a = l[0:i]
b = l[i+1:n]
t = t + (f(n-1)/f(i))*c(a) + (f(n-1)/f(n-i-1))*c(b)
return int(t)
print(c(w)) | Statement
There are N blocks arranged in a row, numbered 1 to N from left to right. Each
block has a weight, and the weight of Block i is A_i. Snuke will perform the
following operation on these blocks N times:
* Choose one block that is still not removed, and remove it. The cost of this operation is the sum of the weights of the blocks that are connected to the block being removed (including itself). Here, two blocks x and y ( x \leq y ) are _connected_ when, for all z ( x \leq z \leq y ), Block z is still not removed.
There are N! possible orders in which Snuke removes the blocks. For all of
those N! orders, find the total cost of the N operations, and calculate the
sum of those N! total costs. As the answer can be extremely large, compute the
sum modulo 10^9+7. | [{"input": "2\n 1 2", "output": "9\n \n\nFirst, we will consider the order \"Block 1 -> Block 2\". In the first\noperation, the cost of the operation is 1+2=3, as Block 1 and 2 are connected.\nIn the second operation, the cost of the operation is 2, as only Block 2\nremains. Thus, the total cost of the two operations for this order is 3+2=5.\n\nThen, we will consider the order \"Block 2 -> Block 1\". In the first operation,\nthe cost of the operation is 1+2=3, as Block 1 and 2 are connected. In the\nsecond operation, the cost of the operation is 1, as only Block 1 remains.\nThus, the total cost of the two operations for this order is 3+1=4.\n\nTherefore, the answer is 5+4=9.\n\n* * *"}, {"input": "4\n 1 1 1 1", "output": "212\n \n\n* * *"}, {"input": "10\n 1 2 4 8 16 32 64 128 256 512", "output": "880971923"}] |
For all of the N! orders, find the total cost of the N operations, and print
the sum of those N! total costs, modulo 10^9+7.
* * * | s389934492 | Wrong Answer | p03232 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | n = int(input())
wt = list(map(int, input().split()))
PN = 1
S = 0
a = 0
rev = []
for i in range(n):
a += 1 / (i + 1)
rev += [a]
for i in range(n):
PN = (PN * (i + 1)) % (10**9 + 7)
pij = rev[n - i - 1] + rev[i] - 1
S += pij * wt[i]
print(round(PN * S) % (10**9 + 7))
| Statement
There are N blocks arranged in a row, numbered 1 to N from left to right. Each
block has a weight, and the weight of Block i is A_i. Snuke will perform the
following operation on these blocks N times:
* Choose one block that is still not removed, and remove it. The cost of this operation is the sum of the weights of the blocks that are connected to the block being removed (including itself). Here, two blocks x and y ( x \leq y ) are _connected_ when, for all z ( x \leq z \leq y ), Block z is still not removed.
There are N! possible orders in which Snuke removes the blocks. For all of
those N! orders, find the total cost of the N operations, and calculate the
sum of those N! total costs. As the answer can be extremely large, compute the
sum modulo 10^9+7. | [{"input": "2\n 1 2", "output": "9\n \n\nFirst, we will consider the order \"Block 1 -> Block 2\". In the first\noperation, the cost of the operation is 1+2=3, as Block 1 and 2 are connected.\nIn the second operation, the cost of the operation is 2, as only Block 2\nremains. Thus, the total cost of the two operations for this order is 3+2=5.\n\nThen, we will consider the order \"Block 2 -> Block 1\". In the first operation,\nthe cost of the operation is 1+2=3, as Block 1 and 2 are connected. In the\nsecond operation, the cost of the operation is 1, as only Block 1 remains.\nThus, the total cost of the two operations for this order is 3+1=4.\n\nTherefore, the answer is 5+4=9.\n\n* * *"}, {"input": "4\n 1 1 1 1", "output": "212\n \n\n* * *"}, {"input": "10\n 1 2 4 8 16 32 64 128 256 512", "output": "880971923"}] |
For all of the N! orders, find the total cost of the N operations, and print
the sum of those N! total costs, modulo 10^9+7.
* * * | s650461672 | Wrong Answer | p03232 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | import itertools
n = int(input())
wt = list(map(int, input().split()))
seq = range(n)
mlst = list(itertools.permutations(seq))
ss = 0
for ll in mlst:
ch = [0] + [1] * (n - 1) + [0]
ch[ll[0]] = 0
ch[ll[0] + 1] = 0
for l in ll[1:]:
ss += wt[l]
for i in range(l, -1, -1):
if ch[i] == 1:
ss += wt[i - 1]
else:
break
for i in range(l + 1, n + 1):
if ch[i] == 1:
ss += wt[i]
else:
break
ch[l] = 0
ch[l + 1] = 0
ss = ss % (10**9 + 7)
print(ss)
| Statement
There are N blocks arranged in a row, numbered 1 to N from left to right. Each
block has a weight, and the weight of Block i is A_i. Snuke will perform the
following operation on these blocks N times:
* Choose one block that is still not removed, and remove it. The cost of this operation is the sum of the weights of the blocks that are connected to the block being removed (including itself). Here, two blocks x and y ( x \leq y ) are _connected_ when, for all z ( x \leq z \leq y ), Block z is still not removed.
There are N! possible orders in which Snuke removes the blocks. For all of
those N! orders, find the total cost of the N operations, and calculate the
sum of those N! total costs. As the answer can be extremely large, compute the
sum modulo 10^9+7. | [{"input": "2\n 1 2", "output": "9\n \n\nFirst, we will consider the order \"Block 1 -> Block 2\". In the first\noperation, the cost of the operation is 1+2=3, as Block 1 and 2 are connected.\nIn the second operation, the cost of the operation is 2, as only Block 2\nremains. Thus, the total cost of the two operations for this order is 3+2=5.\n\nThen, we will consider the order \"Block 2 -> Block 1\". In the first operation,\nthe cost of the operation is 1+2=3, as Block 1 and 2 are connected. In the\nsecond operation, the cost of the operation is 1, as only Block 1 remains.\nThus, the total cost of the two operations for this order is 3+1=4.\n\nTherefore, the answer is 5+4=9.\n\n* * *"}, {"input": "4\n 1 1 1 1", "output": "212\n \n\n* * *"}, {"input": "10\n 1 2 4 8 16 32 64 128 256 512", "output": "880971923"}] |
For all of the N! orders, find the total cost of the N operations, and print
the sum of those N! total costs, modulo 10^9+7.
* * * | s311983479 | Wrong Answer | p03232 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | N = int(input())
A = list(map(int, input().split()))
P = 10**9 + 7
memo = {str([]): 0}
def dp(a):
key = str(a)
ret = memo.get(key, None)
if ret != None:
return ret
ret = (sum(a) * len(a)) % P
for i in range(len(a)):
ret += dp(a[:i])
ret += dp(a[i + 1 :])
ret %= P
memo[key] = ret
return ret
print(dp(A))
| Statement
There are N blocks arranged in a row, numbered 1 to N from left to right. Each
block has a weight, and the weight of Block i is A_i. Snuke will perform the
following operation on these blocks N times:
* Choose one block that is still not removed, and remove it. The cost of this operation is the sum of the weights of the blocks that are connected to the block being removed (including itself). Here, two blocks x and y ( x \leq y ) are _connected_ when, for all z ( x \leq z \leq y ), Block z is still not removed.
There are N! possible orders in which Snuke removes the blocks. For all of
those N! orders, find the total cost of the N operations, and calculate the
sum of those N! total costs. As the answer can be extremely large, compute the
sum modulo 10^9+7. | [{"input": "2\n 1 2", "output": "9\n \n\nFirst, we will consider the order \"Block 1 -> Block 2\". In the first\noperation, the cost of the operation is 1+2=3, as Block 1 and 2 are connected.\nIn the second operation, the cost of the operation is 2, as only Block 2\nremains. Thus, the total cost of the two operations for this order is 3+2=5.\n\nThen, we will consider the order \"Block 2 -> Block 1\". In the first operation,\nthe cost of the operation is 1+2=3, as Block 1 and 2 are connected. In the\nsecond operation, the cost of the operation is 1, as only Block 1 remains.\nThus, the total cost of the two operations for this order is 3+1=4.\n\nTherefore, the answer is 5+4=9.\n\n* * *"}, {"input": "4\n 1 1 1 1", "output": "212\n \n\n* * *"}, {"input": "10\n 1 2 4 8 16 32 64 128 256 512", "output": "880971923"}] |
For all of the N! orders, find the total cost of the N operations, and print
the sum of those N! total costs, modulo 10^9+7.
* * * | s015845700 | Accepted | p03232 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input():
return F.readline().strip("\n")
def line_input():
return F.readline().strip("\n").split()
def gcd(a, b):
a, b = max(a, b), min(a, b)
while a % b > 0:
a, b = b, a % b
return b
mod = 7 + 10**9
def solve():
N = int(single_input())
A = [int(a) for a in line_input()]
factorial_N = 1
accumulated_sum_nrev = [0] * (N + 1)
for i in range(1, N + 1):
accumulated_sum_nrev[i] = accumulated_sum_nrev[i - 1] + pow(i, mod - 2, mod)
factorial_N *= i
factorial_N %= mod
ans = 0
for i in range(N):
ans += (
A[i]
* factorial_N
* (accumulated_sum_nrev[i + 1] + accumulated_sum_nrev[N - i] - 1)
% mod
)
ans %= mod
return ans
if __name__ == "__main__":
print(solve())
| Statement
There are N blocks arranged in a row, numbered 1 to N from left to right. Each
block has a weight, and the weight of Block i is A_i. Snuke will perform the
following operation on these blocks N times:
* Choose one block that is still not removed, and remove it. The cost of this operation is the sum of the weights of the blocks that are connected to the block being removed (including itself). Here, two blocks x and y ( x \leq y ) are _connected_ when, for all z ( x \leq z \leq y ), Block z is still not removed.
There are N! possible orders in which Snuke removes the blocks. For all of
those N! orders, find the total cost of the N operations, and calculate the
sum of those N! total costs. As the answer can be extremely large, compute the
sum modulo 10^9+7. | [{"input": "2\n 1 2", "output": "9\n \n\nFirst, we will consider the order \"Block 1 -> Block 2\". In the first\noperation, the cost of the operation is 1+2=3, as Block 1 and 2 are connected.\nIn the second operation, the cost of the operation is 2, as only Block 2\nremains. Thus, the total cost of the two operations for this order is 3+2=5.\n\nThen, we will consider the order \"Block 2 -> Block 1\". In the first operation,\nthe cost of the operation is 1+2=3, as Block 1 and 2 are connected. In the\nsecond operation, the cost of the operation is 1, as only Block 1 remains.\nThus, the total cost of the two operations for this order is 3+1=4.\n\nTherefore, the answer is 5+4=9.\n\n* * *"}, {"input": "4\n 1 1 1 1", "output": "212\n \n\n* * *"}, {"input": "10\n 1 2 4 8 16 32 64 128 256 512", "output": "880971923"}] |
Print the number of unordered pairs (S_i, S_j) where i \neq j and Limak can
obtain one string from the other.
* * * | s754573661 | Accepted | p02589 | Input is given from Standard Input in the following format.
N
S_1
S_2
\vdots
S_N | from collections import Counter
from string import ascii_lowercase
n = int(input())
sss = [input() for _ in range(n)]
flags = {c: 1 << (ord(c) - 97) for c in ascii_lowercase}
trie_chr = [-1]
trie_children = [{}]
trie_fin = [0]
l = 1
for s in sss:
node = 0
for i in range(len(s) - 1, 0, -1):
c = ord(s[i]) - 97
if c in trie_children[node]:
node = trie_children[node][c]
else:
trie_chr.append(c)
trie_children.append({})
trie_fin.append(0)
trie_children[node][c] = l
node = l
l += 1
trie_fin[node] |= flags[s[0]]
ans = 0
for s in sss:
cnt = Counter(s)
flag = 0
for c in cnt:
flag |= flags[c]
node = 0
if len(s) > 1 and trie_fin[node] > 0:
ans += bin(trie_fin[node] & flag).count("1")
for i in range(len(s) - 1, 1, -1):
c = s[i]
cnt[c] -= 1
if cnt[c] == 0:
flag ^= flags[c]
k = ord(c) - 97
node = trie_children[node][k]
if trie_fin[node] > 0:
ans += bin(trie_fin[node] & flag).count("1")
print(ans)
| Statement
Limak can repeatedly remove one of the first two characters of a string, for
example abcxyx \rightarrow acxyx \rightarrow cxyx \rightarrow cyx.
You are given N different strings S_1, S_2, \ldots, S_N. Among N \cdot (N-1) /
2 pairs (S_i, S_j), in how many pairs could Limak obtain one string from the
other? | [{"input": "3\n abcxyx\n cyx\n abc", "output": "1\n \n\nThe only good pair is (abcxyx, cyx).\n\n* * *"}, {"input": "6\n b\n a\n abc\n c\n d\n ab", "output": "5\n \n\nThere are five good pairs: (b, abc), (a, abc), (abc, c), (b, ab), (a, ab)."}] |
Print the number of unordered pairs (S_i, S_j) where i \neq j and Limak can
obtain one string from the other.
* * * | s559685513 | Accepted | p02589 | Input is given from Standard Input in the following format.
N
S_1
S_2
\vdots
S_N | import sys
input = sys.stdin.readline
N = int(input())
S = [input().strip() for i in range(N)]
S.sort(key=len)
VLIST = [[set() for j in range(len(S[i]))] for i in range(N)]
for i in range(N):
for j in range(len(S[i])):
VLIST[i][j] = VLIST[i][j - 1] | {S[i][j]}
# ing木
Next_node_id = [[-1] * 26] # "a"~"z"それぞれについて、対応する次のノードのid
Parent_id = [-1] # 親ノード
End = [[]] # そのノードを終端とするStringがあるか
ANS = 0
Nodes_id = 1
for i in range(N):
S2 = S[i]
L = len(S2)
NOW = 0
for j in range(L - 1, -1, -1):
for s in End[NOW]:
if s in VLIST[i][j]:
ANS += 1
if j == 0:
End[NOW].append(S2[0])
continue
NEXT = ord(S2[j]) - 97
if Next_node_id[NOW][NEXT] == -1: # Nodeを追加する場合
Next_node_id[NOW][NEXT] = Nodes_id
Next_node_id.append([-1] * 26)
Parent_id.append(NOW)
End.append([])
NOW = Nodes_id
Nodes_id += 1
else: # 追加しない場合
NOW = Next_node_id[NOW][NEXT]
print(ANS)
| Statement
Limak can repeatedly remove one of the first two characters of a string, for
example abcxyx \rightarrow acxyx \rightarrow cxyx \rightarrow cyx.
You are given N different strings S_1, S_2, \ldots, S_N. Among N \cdot (N-1) /
2 pairs (S_i, S_j), in how many pairs could Limak obtain one string from the
other? | [{"input": "3\n abcxyx\n cyx\n abc", "output": "1\n \n\nThe only good pair is (abcxyx, cyx).\n\n* * *"}, {"input": "6\n b\n a\n abc\n c\n d\n ab", "output": "5\n \n\nThere are five good pairs: (b, abc), (a, abc), (abc, c), (b, ab), (a, ab)."}] |
Print the number of unordered pairs (S_i, S_j) where i \neq j and Limak can
obtain one string from the other.
* * * | s123564204 | Wrong Answer | p02589 | Input is given from Standard Input in the following format.
N
S_1
S_2
\vdots
S_N | n = int(input())
s = {}
for i in range(n):
temp = input()
s.setdefault(len(temp), [])
s[len(temp)].append(temp)
s2 = []
for i, j in s.items():
s2.append([i, j])
s2.sort()
ans = 0
for i in range(len(s2)):
for j in range(i + 1, len(s2)):
short = s2[i][1]
long = s2[j][1]
short2 = {}
long2 = {}
for k in short:
short2.setdefault((k[0], k[1:]), 0)
short2[(k[0], k[1:])] += 1
for k in long:
temp = s2[j][0] - s2[i][0] + 1
for l in k[:temp]:
long2.setdefault((l, k[temp:]), 0)
long2[(l, k[temp:])] += 1
for k in short2.keys():
if k in long2.keys():
ans += short2[k] * long2[k]
print(ans)
| Statement
Limak can repeatedly remove one of the first two characters of a string, for
example abcxyx \rightarrow acxyx \rightarrow cxyx \rightarrow cyx.
You are given N different strings S_1, S_2, \ldots, S_N. Among N \cdot (N-1) /
2 pairs (S_i, S_j), in how many pairs could Limak obtain one string from the
other? | [{"input": "3\n abcxyx\n cyx\n abc", "output": "1\n \n\nThe only good pair is (abcxyx, cyx).\n\n* * *"}, {"input": "6\n b\n a\n abc\n c\n d\n ab", "output": "5\n \n\nThere are five good pairs: (b, abc), (a, abc), (abc, c), (b, ab), (a, ab)."}] |
Print the number of unordered pairs (S_i, S_j) where i \neq j and Limak can
obtain one string from the other.
* * * | s474178119 | Wrong Answer | p02589 | Input is given from Standard Input in the following format.
N
S_1
S_2
\vdots
S_N | n = int(input())
data = []
count = 1
for i in range(n):
data.append(input())
print(data)
for i in range(n):
for j in range(n):
if i < j:
if len(data[i]) <= len(data[j]):
data_s = data[i]
data_l = data[j]
if len(data[i]) > len(data[j]):
data_s = data[j]
data_l = data[i]
while len(data_l) > len(data_s):
data_l = data_l[2:]
if len(data_l) == len(data_s):
count += 1
print(count)
| Statement
Limak can repeatedly remove one of the first two characters of a string, for
example abcxyx \rightarrow acxyx \rightarrow cxyx \rightarrow cyx.
You are given N different strings S_1, S_2, \ldots, S_N. Among N \cdot (N-1) /
2 pairs (S_i, S_j), in how many pairs could Limak obtain one string from the
other? | [{"input": "3\n abcxyx\n cyx\n abc", "output": "1\n \n\nThe only good pair is (abcxyx, cyx).\n\n* * *"}, {"input": "6\n b\n a\n abc\n c\n d\n ab", "output": "5\n \n\nThere are five good pairs: (b, abc), (a, abc), (abc, c), (b, ab), (a, ab)."}] |
Print the number of unordered pairs (S_i, S_j) where i \neq j and Limak can
obtain one string from the other.
* * * | s913287759 | Runtime Error | p02589 | Input is given from Standard Input in the following format.
N
S_1
S_2
\vdots
S_N | class SparseTable:
def __init__(self, a, func=max, one=-(10**18)):
self.table = [a[:]]
self.n = len(a)
self.logn = self.n.bit_length()
self.func = func
self.one = one
for i in map(lambda x: 1 << x, range(self.logn - 1)):
self.table.append([])
for j in range(self.n - i * 2 + 1):
self.table[-1].append(
self.func(self.table[-2][j], self.table[-2][j + i])
)
def get_section(self, i, j):
length = j - i
log = length.bit_length() - 1
if length <= 0:
return self.one
return self.func(self.table[log][i], self.table[log][j - (1 << log)])
n = int(input())
s = []
for i in range(n):
s.append(input()[::-1])
s.sort()
com = []
for i in range(n - 1):
j = 0
for x, y in zip(s[i], s[i + 1]):
if x != y:
break
j += 1
com.append(j)
mal = max(map(len, s))
abc = "abcdefghijklmnopqrstuvwxyz"
def cou(ind):
ret = [[0] * mal]
for i in range(n):
ret.append([0] * mal)
ss = 0
for j in reversed(range(len(s[i]))):
ss = max(ss, 1 if s[i][j] == abc[ind] else 0)
ret[-1][j] = ss
for i in range(mal):
for j in range(n):
ret[j + 1][i] += ret[j][i]
return ret
c_c = [cou(i) for i in range(26)]
sp = SparseTable(com, min, 10**18)
ans = 0
for i in range(n):
ng = -1
ok = i
while abs(ng - ok) > 1:
m = (ng + ok) // 2
if sp.get_section(m, i) >= len(s[i]) - 1:
ok = m
else:
ng = m
min_ok = ok
ng = n
ok = i
while abs(ng - ok) > 1:
m = (ng + ok) // 2
if sp.get_section(i, m) >= len(s[i]) - 1:
ok = m
else:
ng = m
max_ok = ok
ch = abc.index(s[i][-1])
ans += c_c[ch][max_ok + 1][len(s[i]) - 1] - c_c[ch][min_ok][len(s[i]) - 1]
ans -= n
dic = {}
for i in s:
if i in dic:
ans -= dic[i]
dic[i] += 1
else:
dic[i] = 1
print(ans)
| Statement
Limak can repeatedly remove one of the first two characters of a string, for
example abcxyx \rightarrow acxyx \rightarrow cxyx \rightarrow cyx.
You are given N different strings S_1, S_2, \ldots, S_N. Among N \cdot (N-1) /
2 pairs (S_i, S_j), in how many pairs could Limak obtain one string from the
other? | [{"input": "3\n abcxyx\n cyx\n abc", "output": "1\n \n\nThe only good pair is (abcxyx, cyx).\n\n* * *"}, {"input": "6\n b\n a\n abc\n c\n d\n ab", "output": "5\n \n\nThere are five good pairs: (b, abc), (a, abc), (abc, c), (b, ab), (a, ab)."}] |
Print the number of unordered pairs (S_i, S_j) where i \neq j and Limak can
obtain one string from the other.
* * * | s844520775 | Runtime Error | p02589 | Input is given from Standard Input in the following format.
N
S_1
S_2
\vdots
S_N | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
n = int(readline())
s = read().split()
s.sort(key=lambda x: len(x))
words = dict()
# for si in 'abcdefghijklmnopqrstuvmxyz':
# words[si] = dict()
ans = 0
for si in s:
if len(si) == 1:
head = si[0]
tail = ""
else:
head = si[0]
tail = si[1:]
heads = set()
heads.add(head)
now = ""
stack = [""]
for ti in tail[::-1]:
now += ti
stack.append(now)
for ti in stack[::-1]:
if ti in words:
for j in heads:
if j in words[ti]:
ans += words[ti][j]
if ti == "":
break
heads.add(ti[-1])
tail = stack[-1]
if not tail in words:
words[tail] = dict()
if not head in words[tail]:
words[tail][head] = 1
else:
words[tail][head] += 1
# print(si,ans)
# print(stack)
print(ans)
| Statement
Limak can repeatedly remove one of the first two characters of a string, for
example abcxyx \rightarrow acxyx \rightarrow cxyx \rightarrow cyx.
You are given N different strings S_1, S_2, \ldots, S_N. Among N \cdot (N-1) /
2 pairs (S_i, S_j), in how many pairs could Limak obtain one string from the
other? | [{"input": "3\n abcxyx\n cyx\n abc", "output": "1\n \n\nThe only good pair is (abcxyx, cyx).\n\n* * *"}, {"input": "6\n b\n a\n abc\n c\n d\n ab", "output": "5\n \n\nThere are five good pairs: (b, abc), (a, abc), (abc, c), (b, ab), (a, ab)."}] |
Print the number of unordered pairs (S_i, S_j) where i \neq j and Limak can
obtain one string from the other.
* * * | s568021348 | Wrong Answer | p02589 | Input is given from Standard Input in the following format.
N
S_1
S_2
\vdots
S_N | n = int(input())
ss = [input() for i in range(n)]
m = dict()
def chi(x):
return ord(x) - ord("a")
def cha(x):
return chr(97 + x)
# それぞれの文字列のi文字目までの種類
# set→整数
check = [[0 for j in range(len(ss[i]))] for i in range(n)]
for i in range(n):
check[i][0] = 1 << chi(ss[i][0])
for j in range(1, len(ss[i])):
check[i][j] = check[i][j - 1] ^ (1 << chi(ss[i][j]))
# m[s][i]:0or1
for i in range(n):
if ss[i][1:] not in m:
m[ss[i][1:]] = [0] * 26
m[ss[i][1:]][chi(ss[i][0])] += 1
else:
m[ss[i][1:]][chi(ss[i][0])] += 1
ans = 0
for i in range(n):
s = ""
l = len(ss[i])
for j in range(l, 1, -1):
if j != l:
s = ss[i][j] + s
for k in range(26):
if s in m:
if m[s][k]:
if (check[i][j - 1] >> k) & 1:
ans += 1
print(ans)
| Statement
Limak can repeatedly remove one of the first two characters of a string, for
example abcxyx \rightarrow acxyx \rightarrow cxyx \rightarrow cyx.
You are given N different strings S_1, S_2, \ldots, S_N. Among N \cdot (N-1) /
2 pairs (S_i, S_j), in how many pairs could Limak obtain one string from the
other? | [{"input": "3\n abcxyx\n cyx\n abc", "output": "1\n \n\nThe only good pair is (abcxyx, cyx).\n\n* * *"}, {"input": "6\n b\n a\n abc\n c\n d\n ab", "output": "5\n \n\nThere are five good pairs: (b, abc), (a, abc), (abc, c), (b, ab), (a, ab)."}] |
Print the number of unordered pairs (S_i, S_j) where i \neq j and Limak can
obtain one string from the other.
* * * | s138695034 | Runtime Error | p02589 | Input is given from Standard Input in the following format.
N
S_1
S_2
\vdots
S_N | import numpy as np
N = int(input())
nums = [float(input()) for _ in range(N)]
two_fives = []
for i, num in enumerate(nums):
int_converted = int(num * (10**9))
two_div_count = 0
while int_converted % 2 == 0:
two_div_count += 1
int_converted //= 2
five_div_count = 0
while int_converted % 5 == 0:
five_div_count += 1
int_converted //= 5
two_fives.append((two_div_count, five_div_count))
ok_count = 0
two_five_exists = np.zeros((19, 19), dtype=int)
for i in range(N):
two_count, five_count = two_fives[i]
ok_count += two_five_exists[two_count, five_count]
two_pair = 18 - two_count
five_pair = 18 - five_count
two_five_exists[two_pair:, five_pair:] += 1
print(ok_count)
| Statement
Limak can repeatedly remove one of the first two characters of a string, for
example abcxyx \rightarrow acxyx \rightarrow cxyx \rightarrow cyx.
You are given N different strings S_1, S_2, \ldots, S_N. Among N \cdot (N-1) /
2 pairs (S_i, S_j), in how many pairs could Limak obtain one string from the
other? | [{"input": "3\n abcxyx\n cyx\n abc", "output": "1\n \n\nThe only good pair is (abcxyx, cyx).\n\n* * *"}, {"input": "6\n b\n a\n abc\n c\n d\n ab", "output": "5\n \n\nThere are five good pairs: (b, abc), (a, abc), (abc, c), (b, ab), (a, ab)."}] |
Print the number of unordered pairs (S_i, S_j) where i \neq j and Limak can
obtain one string from the other.
* * * | s244437332 | Wrong Answer | p02589 | Input is given from Standard Input in the following format.
N
S_1
S_2
\vdots
S_N | #
| Statement
Limak can repeatedly remove one of the first two characters of a string, for
example abcxyx \rightarrow acxyx \rightarrow cxyx \rightarrow cyx.
You are given N different strings S_1, S_2, \ldots, S_N. Among N \cdot (N-1) /
2 pairs (S_i, S_j), in how many pairs could Limak obtain one string from the
other? | [{"input": "3\n abcxyx\n cyx\n abc", "output": "1\n \n\nThe only good pair is (abcxyx, cyx).\n\n* * *"}, {"input": "6\n b\n a\n abc\n c\n d\n ab", "output": "5\n \n\nThere are five good pairs: (b, abc), (a, abc), (abc, c), (b, ab), (a, ab)."}] |
Print the given bits, results of inversion, left shift and right shift in a
line respectively. | s196553602 | Accepted | p02423 | The input is given in the following format.
$x$ | n = int(input())
mask = (1 << 32) - 1
print("{:032b}".format(n))
print("{:032b}".format(~n & mask))
print("{:032b}".format((n << 1) & mask))
print("{:032b}".format((n >> 1) & mask))
| Bit Operation I
Given a non-negative decimal integer $x$, convert it to binary representation
$b$ of 32 bits. Then, print the result of the following operations to $b$
respecitvely.
* Inversion: change the state of each bit to the opposite state
* Logical left shift: shift left by 1
* Logical right shift: shift right by 1 | [{"input": "8", "output": "00000000000000000000000000001000\n 11111111111111111111111111110111\n 00000000000000000000000000010000\n 00000000000000000000000000000100"}, {"input": "13", "output": "00000000000000000000000000001101\n 11111111111111111111111111110010\n 00000000000000000000000000011010\n 00000000000000000000000000000110"}] |
Print the answer.
* * * | s014659424 | Wrong Answer | p02566 | Input is given from Standard Input in the following format:
S | import sys
readline = sys.stdin.readline
def SAIS(Sorgin):
# O(N+sigma)
# 非負数列を入れる
S = Sorgin + [-1]
ls = len(S)
lstable = [1] * ls
# 0ならL-type, 1ならLMSではないS-type, LMSについては何番目に大きいLMSかを格納
LMS = []
bucst = [1] + [0] * ls
cnt = -1
for i in range(ls - 2, -1, -1):
bucst[S[i] + 1] += 1
if S[i] > S[i + 1] or (S[i] == S[i + 1] and not lstable[i + 1]):
lstable[i] = 0
if lstable[i + 1]:
lstable[i + 1] = cnt
cnt -= 1
LMS.append(i + 1)
LMS.reverse()
for i in range(ls):
bucst[i] += bucst[i - 1]
bucen = [bucst[i + 1] - 1 for i in range(ls)] + [0]
bucst2 = bucst[:]
bucen2 = bucen[:]
bucen3 = bucen[:]
bucen4 = bucen[:]
table = [None] * ls
for idx in LMS:
table[bucen[S[idx]]] = idx
bucen[S[idx]] -= 1
for i in range(ls):
if not table[i]:
continue
# <=> if table[i] == 0 or table[i] is None
k = table[i] - 1
if not lstable[k]:
table[bucst[S[k]]] = k
bucst[S[k]] += 1
for i in range(ls - 1, -1, -1):
if not table[i]:
continue
k = table[i] - 1
if lstable[k]:
table[bucen2[S[k]]] = k
bucen2[S[k]] -= 1
table[0] = ls - 1
lmsnum = len(LMS)
lmssubord = [None] * lmsnum
lmssubord[0] = ls - 1
lmssublen = [l2 - l1 + 1 for l1, l2 in zip(LMS, LMS[1:])] + [1]
cnt = 1
repet = False
for t in table[1:]:
if lstable[t] < 0:
lmssubord[cnt] = t
cntlen = lmssublen[lstable[t]]
if (
cntlen == lmssublen[lstable[lmssubord[cnt - 1]]]
and S[t : t + cntlen]
== S[lmssubord[cnt - 1] : lmssubord[cnt - 1] + cntlen]
):
repet = True
lstable[t] = lstable[lmssubord[cnt - 1]]
# ここでlstableはLMSsubstringについて同じものをまとめたものを格納するようになっている
cnt += 1
continue
cnt += 1
if repet:
lmssubinv = [None] * ls
for i in range(lmsnum):
lmssubinv[lmssubord[i]] = i
sublst = [lmssubinv[LMS[lstable[t]]] for t in LMS]
lmssubord = [LMS[r] for r in SAIS(sublst)]
table = [None] * ls
for idx in lmssubord[::-1]:
table[bucen3[S[idx]]] = idx
bucen3[S[idx]] -= 1
for i in range(ls):
if not table[i]:
continue
# <=> if table[i] == 0 or table[i] is None
k = table[i] - 1
if not lstable[k]:
table[bucst2[S[k]]] = k
bucst2[S[k]] += 1
for i in range(ls - 1, -1, -1):
if not table[i]:
continue
k = table[i] - 1
if lstable[k]:
table[bucen4[S[k]]] = k
bucen4[S[k]] -= 1
return table[1:]
def salcp(S, SAorg):
N = len(S)
lcp = [0] * N
SA = SAorg + [N]
SAinv = [None] * N
for i in range(N):
SAinv[SA[i]] = i
h = 0
for i in range(N):
j = SA[SAinv[i] + 1]
if h:
h -= 1
while i + h < N and j + h < N and S[i + h] == S[j + h]:
h += 1
lcp[SAinv[i]] = h
return lcp
S = list(map(lambda x: ord(x) - 97, readline().strip()))
N = len(S)
table = [0] * 26
for s in S:
table[s] = 1
table[0] -= 1
for i in range(1, 26):
table[i] += table[i - 1]
S = [table[s] for s in S]
SA = SAIS(S)
LCP = salcp(S, SA)
leng = [N - sa for sa in SA]
ans = sum(l * (l + 1) // 2 for l in leng) - sum(c * (c + 1) // 2 for c in LCP)
print(ans)
| Statement
You are given a string of length N. Calculate the number of distinct
substrings of S. | [{"input": "abcbcba", "output": "21\n \n\n* * *"}, {"input": "mississippi", "output": "53\n \n\n* * *"}, {"input": "ababacaca", "output": "33\n \n\n* * *"}, {"input": "aaaaa", "output": "5"}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s118793158 | Wrong Answer | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | S = list(input())
c = 0
for i in range(int(len(S) / 2)):
if S[i] != S[-(i + 1)]:
c += 1
print(c)
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s786356572 | Accepted | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | a1 = input()
a2 = [i for i in a1.split()]
A1, A2, A3 = [int(a2[i]) for i in (0, 1, 2)]
print("bust" if (A1 + A2 + A3) >= 22 else "win")
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s305078689 | Runtime Error | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | n = int(input())
l = sorted(list(map(int, input().split())))
for i, x in enumerate(l):
l[i] = format(x, "63b")
memo = [0] * 63
for i in range(63):
for j in range(n):
if l[j][i] == "1":
memo[-i - 1] += 1
now = 1
ans = 0
mod = 10**9 + 7
for x in memo:
ans += (now * x * (n - x)) % mod
now *= 2
print(ans % mod)
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s713814248 | Runtime Error | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | n = int(input())
a = list(map(int, input().split()))
s = 0
for j in range(len(bin(max(a))) - 2):
cnt1 = 0
cnt0 = 0
for i in range(n):
if (a[i] >> j) & 1:
cnt1 += 1
else:
cnt0 += 1
s += (cnt1 * cnt0 * 2**j) % (10**9 + 7)
print(s % (10**9 + 7))
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s185869870 | Runtime Error | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | k = int(input())
l = [int(x) for x in input().rstrip().split()]
a = []
for i in l:
for j in l:
if i < j:
a.append([i, j])
A_1 = 0
A_2 = 0
SUM = 0
ans = ""
ANS = []
for i in range(len(a)):
A_1 = format(a[i][0], "b")
A_2 = format(a[i][1], "b")
if len(A_1) < len(A_2):
A_1 = "0" * (len(A_2) - len(A_1)) + A_1
elif len(A_2) < len(A_1):
A_2 = "0" * (len(A_1) - len(A_2)) + A_2
for j in range(len(A_1)):
if A_1[j] == A_2[j]:
ans = ans + "0"
else:
ans = ans + "1"
ANS.append(ans)
SUM += int(ans, 2)
ans = ""
SUM = SUM % (10**9 + 7)
print(SUM)
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s580164070 | Runtime Error | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | N = int(input())
A = list(map(int, input().split()))
B = [0] * 60
for a in A:
for i in range(len(B)):
if a & (2**i):
B[i] += 1
ans = 0
for i, b in enumerate(B):
ans += 2**i * b * (N - b)
ans %= 10**9 + 7
print(ans)
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s532342961 | Accepted | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | x = sum(map(int, input().split()))
print("bust" if x > 21 else "win")
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s010168028 | Accepted | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | print(["bust", "win"][sum(map(int, input().split())) < 22])
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s107885815 | Accepted | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | n = sum(list(map(int, input().split())))
print("win" if n <= 21 else "bust")
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s974675342 | Accepted | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | print("bust" if sum(list(map(int, input().split()))) >= 22 else "win")
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s059220582 | Runtime Error | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | print("bust" if sum(list(map, input().split())) >= 22 else "win")
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s930511814 | Wrong Answer | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | print("win" if sum(list(map(int, input().split()))) < 22 else "best")
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s417879727 | Wrong Answer | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | print("win" if sum(list(map(int, input().split()))) < 21 else "bust")
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s533241881 | Wrong Answer | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | print("bust" if sum(map(int, input().split())) > 21 else "win")
print("test")
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s645994142 | Runtime Error | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | print(["bust", "win"][sum(map(int, input.split())) < 22])
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s381892602 | Accepted | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | a = eval(input().replace(" ", "+"))
print((a > 21) * "bust" or "win")
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s701618293 | Runtime Error | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | def main():
h, w = map(int, input().split())
L = 80 * (h + w) + 1
a = [list(map(int, input().split())) for i in range(h)]
b = [list(map(int, input().split())) for i in range(h)]
x = [[abs(a[i][j] - b[i][j]) for j in range(w)] for i in range(h)]
L = 12800
state = [[0 for j in range(w)] for i in range(h)]
delta = x[0][0]
state[0][0] = (2**L >> delta) | (2**L << delta)
for j in range(1, w):
delta = x[0][j - 1]
state[0][j] = (state[0][j - 1] >> delta) | (state[0][j - 1] << delta)
for i in range(1, h):
delta = x[i - 1][0]
state[i][0] = (state[i - 1][0] >> delta) | (state[i - 1][0] << delta)
for i in range(1, h):
for j in range(1, w):
delta = x[i][j]
state[i][j] = (state[i][j - 1] >> delta) | (state[i][j - 1] << delta)
state[i][j] = (state[i - 1][j] >> delta) | (state[i - 1][j] << delta)
ans = 10**9
for i in range(L * 2):
if state[h - 1][w - 1] & 1:
ans = min(ans, abs(i - L))
state[h - 1][w - 1] >>= 1
print(ans - 1)
if __name__ == "__main__":
main()
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s846818181 | Accepted | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | print("bust") if sum(list(map(int, input().split()))) >= 22 else print("win")
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s160116731 | Accepted | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | a = [int(x) for x in input().split(" ")]
print("bust") if sum(a) >= 22 else print("win")
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s779874002 | Accepted | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | # -*- coding: utf-8 -*-
import sys
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c] * b for i in range(a)]
def list3d(a, b, c, d):
return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1):
return int(-(-x // y))
def INT():
return int(input())
def MAP():
return map(int, input().split())
def LIST(N=None):
return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes():
print("Yes")
def No():
print("No")
def YES():
print("YES")
def NO():
print("NO")
sys.setrecursionlimit(10**9)
INF = 10**18
MOD = 10**9 + 7
a, b, c = MAP()
if a + b + c <= 21:
print("win")
else:
print("bust")
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s362578261 | Runtime Error | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | def checker(bbit, listN, N):
i = 0
j = 0
ng = False
# print(N)
# print(listN)
# print(bin(bbit))
while N > i:
j = 0
checkFig = 3
ibit = 1 << i
while N > j:
cbit = 1 << j
if bbit & cbit == 0:
# print("A:{} {}".format(j,i))
pass
elif listN[j][i] == 3:
# print("B:{} {}".format(j,i))
pass
elif (listN[j][i] == 0) and (bbit & ibit != 0):
ng = True
break
elif checkFig == 3:
# print("C:{} {}".format(j,i))
checkFig = listN[j][i]
elif checkFig != listN[j][i]:
ng = True
# print("D:{} {}".format(j,i))
break
j += 1
if ng:
# print(ng)
break
else:
i += 1
return not ng
def main():
N = int(input())
listA = [[3 for j in range(N)] for k in range(N)]
n = 0
while N > n:
a = int(input())
i = 0
while a > i:
x, y = map(int, input().split())
listA[n][x - 1] = y
i += 1
n += 1
honestBit = pow(2, N) - 1
honest = 0
while honestBit > 0:
ok = checker(honestBit, listA, N)
if ok:
okbit = honestBit
oknum = 0
while okbit > 0:
oknum += okbit % 2
okbit /= 2
if oknum > honest:
honest = oknum
honestBit -= 1
main()
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s227785986 | Runtime Error | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | n = int(input())
a = []
evidences = []
for i in range(n):
ls = []
x = int(input())
a.append(x)
for j in range(x):
l = [int(_) for _ in input().split(" ")]
ls.append(l)
evidences.append(ls)
patterns = []
for i in range(2**n):
pattern = [0] * n
for j in range(n):
if i >> j & 1:
pattern[j] = 1
patterns.append(pattern)
honest = 0
for pattern in patterns:
contradict = False
for i in range(n):
for evidence in evidences[i]:
if pattern[i] == 1:
if pattern[evidence[0] - 1] != evidence[1]:
contradict = True
else:
if pattern[evidence[0] - 1] == evidence[1]:
contradict = True
if contradict == False:
honest = max(honest, pattern.count(1))
print(honest)
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s417678330 | Runtime Error | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | n = int(input())
ret = {}
for i in range(0, n):
a = int(input())
ret[i] = [[], []]
for j in range(a):
x, y = map(int, input().split())
x -= 1
if y == 1:
ret[i][0].append(x)
elif y == 0:
ret[i][1].append(x)
ans = 0
for u in ret:
i = ret[u]
num = 1 + len(i[0])
honest = [u] + i[0]
not_honest = i[1]
for p in i[0]:
# print(p, ret[p])
for h in ret[p][0]:
honest.append(h)
for d in ret[p][1]:
not_honest.append(d)
honest = list(set(honest))
not_honest = list(set(not_honest))
# print(honest, not_honest)
if list(set(honest) & set(not_honest)) == []:
ans = max(ans, len(honest))
for i in range(0, n):
if i not in honest and i not in not_honest:
t_honest, t_not_honest = [], []
for h in ret[i][0]:
t_honest.append(h)
for d in ret[i][1]:
t_not_honest.append(d)
t_honest = list(set(t_honest))
t_not_honest = list(set(t_not_honest))
if list(set(honest) & set(t_not_honest)) == []:
honest = list(set(honest + t_honest))
ans = max(ans, len(honest))
print(ans)
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s712784297 | Accepted | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | print("win" if sum(map(int, input().split())) <= 21 else "bust")
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s601258581 | Accepted | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | A, B, C = [int(n) for n in input().split()]
print("win" if A + B + C <= 21 else "bust")
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s991118742 | Accepted | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | A123 = sum(list(map(int, input().split())))
print("bust" if A123 > 21 else "win")
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s448261278 | Accepted | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | print("win") if 21 >= sum([int(i) for i in input().split()]) else print("bust")
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s672453850 | Wrong Answer | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | print("win") if 21 <= sum([int(i) for i in input().split()]) else print("bust")
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s495449586 | Wrong Answer | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | print("win" if sum(map(int, input().split())) > 21 else "bust")
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s769552522 | Wrong Answer | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | print("bwuisnt"[sum(map(int, input().split())) > 22 :: 2])
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s470741002 | Runtime Error | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | def blackjack(a, b, c):
if (a + b + c) >= 22:
return "bust"
else:
return "win"
A1 = int(input("Input A1:"))
A2 = int(input("Input A2:"))
A3 = int(input("Input A3:"))
print(blackjack(A1, A2, A3))
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s611206894 | Wrong Answer | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | s = str(input())
length = len(s)
n = length // 2
m = 0
for i in range(n):
x = (i + 1) * (-1)
if s[i] != s[x]:
m += 1
print(m)
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s580679641 | Accepted | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | print("bust" if sum([int(i) for i in input().split()]) >= 22 else "win")
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s242840696 | Accepted | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | print("bust" if sum(int(x) for x in input().split()) >= 22 else "win")
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s531178320 | Accepted | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | nums = list(map(int, input().split()))
print("bust" if sum(nums) >= 22 else "win")
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s802573711 | Accepted | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | print("win" if sum(list(map(int, input().split()))) < 22 else "bust")
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s056153614 | Wrong Answer | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | a = [int(i) for i in input().split(" ")]
print(sum(a))
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s614017612 | Runtime Error | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | A1 = input()
A2 = input()
A3 = input()
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s121446301 | Runtime Error | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | print(sum([int(list(input().split())[i]) for i in range(3)]))
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s565912606 | Wrong Answer | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | print("bust")
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s866087381 | Wrong Answer | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | (*a,) = map(int, input().split())
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`.
* * * | s215034138 | Wrong Answer | p02835 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | print("win")
# print('bust')
| Statement
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print
`win`. | [{"input": "5 7 9", "output": "win\n \n\n5+7+9=21, so print `win`.\n\n* * *"}, {"input": "13 7 2", "output": "bust\n \n\n13+7+2=22, so print `bust`."}] |
If it is possible that there are exactly X cats, print `YES`; if it is
impossible, print `NO`.
* * * | s434704992 | Runtime Error | p03377 | Input is given from Standard Input in the following format:
A B X | a,b,x = map(int,input().split())
print("YES" if (a+b)>=x else "NO") | Statement
There are a total of A + B cats and dogs. Among them, A are known to be cats,
but the remaining B are not known to be either cats or dogs.
Determine if it is possible that there are exactly X cats among these A + B
animals. | [{"input": "3 5 4", "output": "YES\n \n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4\ncats in total.\n\n* * *"}, {"input": "2 2 6", "output": "NO\n \n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in\ntotal.\n\n* * *"}, {"input": "5 3 2", "output": "NO\n \n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in\ntotal."}] |
If it is possible that there are exactly X cats, print `YES`; if it is
impossible, print `NO`.
* * * | s387215323 | Runtime Error | p03377 | Input is given from Standard Input in the following format:
A B X | A, B, C = map(int, input().split())
print("YES" if A<=C && B>=C else "NO") | Statement
There are a total of A + B cats and dogs. Among them, A are known to be cats,
but the remaining B are not known to be either cats or dogs.
Determine if it is possible that there are exactly X cats among these A + B
animals. | [{"input": "3 5 4", "output": "YES\n \n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4\ncats in total.\n\n* * *"}, {"input": "2 2 6", "output": "NO\n \n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in\ntotal.\n\n* * *"}, {"input": "5 3 2", "output": "NO\n \n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in\ntotal."}] |
If it is possible that there are exactly X cats, print `YES`; if it is
impossible, print `NO`.
* * * | s364453542 | Wrong Answer | p03377 | Input is given from Standard Input in the following format:
A B X | 0
| Statement
There are a total of A + B cats and dogs. Among them, A are known to be cats,
but the remaining B are not known to be either cats or dogs.
Determine if it is possible that there are exactly X cats among these A + B
animals. | [{"input": "3 5 4", "output": "YES\n \n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4\ncats in total.\n\n* * *"}, {"input": "2 2 6", "output": "NO\n \n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in\ntotal.\n\n* * *"}, {"input": "5 3 2", "output": "NO\n \n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in\ntotal."}] |
If it is possible that there are exactly X cats, print `YES`; if it is
impossible, print `NO`.
* * * | s103742123 | Runtime Error | p03377 | Input is given from Standard Input in the following format:
A B X | a, b, x = map(int, input().split())
print("YES" if a <= x and a + b >= x or "NO") | Statement
There are a total of A + B cats and dogs. Among them, A are known to be cats,
but the remaining B are not known to be either cats or dogs.
Determine if it is possible that there are exactly X cats among these A + B
animals. | [{"input": "3 5 4", "output": "YES\n \n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4\ncats in total.\n\n* * *"}, {"input": "2 2 6", "output": "NO\n \n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in\ntotal.\n\n* * *"}, {"input": "5 3 2", "output": "NO\n \n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in\ntotal."}] |
If it is possible that there are exactly X cats, print `YES`; if it is
impossible, print `NO`.
* * * | s046903432 | Runtime Error | p03377 | Input is given from Standard Input in the following format:
A B X | a,b,x=map(int,input().split())
print(["NO","YES"]][a<=x<a+b]) | Statement
There are a total of A + B cats and dogs. Among them, A are known to be cats,
but the remaining B are not known to be either cats or dogs.
Determine if it is possible that there are exactly X cats among these A + B
animals. | [{"input": "3 5 4", "output": "YES\n \n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4\ncats in total.\n\n* * *"}, {"input": "2 2 6", "output": "NO\n \n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in\ntotal.\n\n* * *"}, {"input": "5 3 2", "output": "NO\n \n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in\ntotal."}] |
If it is possible that there are exactly X cats, print `YES`; if it is
impossible, print `NO`.
* * * | s253664241 | Runtime Error | p03377 | Input is given from Standard Input in the following format:
A B X | n = int(input())
x = map(int, input().split())
temp = sorted(zip(x, range(n)))
ans = [None] * n
for i in range(n):
idx = n // 2
if i >= idx:
idx -= 1
ans[temp[i][1]] = temp[idx][0]
for item in ans:
print(item)
| Statement
There are a total of A + B cats and dogs. Among them, A are known to be cats,
but the remaining B are not known to be either cats or dogs.
Determine if it is possible that there are exactly X cats among these A + B
animals. | [{"input": "3 5 4", "output": "YES\n \n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4\ncats in total.\n\n* * *"}, {"input": "2 2 6", "output": "NO\n \n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in\ntotal.\n\n* * *"}, {"input": "5 3 2", "output": "NO\n \n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in\ntotal."}] |
If it is possible that there are exactly X cats, print `YES`; if it is
impossible, print `NO`.
* * * | s415213676 | Runtime Error | p03377 | Input is given from Standard Input in the following format:
A B X | import copy
n = int(input())
N = int(n/2-1)
x = list(map(int, input().split()))
y = sorted(x)
for i in range(n):
Y = copy.deepcopy(y)
Y.remove(x[i])
print(Y[N)
| Statement
There are a total of A + B cats and dogs. Among them, A are known to be cats,
but the remaining B are not known to be either cats or dogs.
Determine if it is possible that there are exactly X cats among these A + B
animals. | [{"input": "3 5 4", "output": "YES\n \n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4\ncats in total.\n\n* * *"}, {"input": "2 2 6", "output": "NO\n \n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in\ntotal.\n\n* * *"}, {"input": "5 3 2", "output": "NO\n \n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in\ntotal."}] |
If it is possible that there are exactly X cats, print `YES`; if it is
impossible, print `NO`.
* * * | s156668634 | Runtime Error | p03377 | Input is given from Standard Input in the following format:
A B X | a, b, x = map(int, input().split())
if a x or a+b < x:
print('NO')
else:
print('YES') | Statement
There are a total of A + B cats and dogs. Among them, A are known to be cats,
but the remaining B are not known to be either cats or dogs.
Determine if it is possible that there are exactly X cats among these A + B
animals. | [{"input": "3 5 4", "output": "YES\n \n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4\ncats in total.\n\n* * *"}, {"input": "2 2 6", "output": "NO\n \n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in\ntotal.\n\n* * *"}, {"input": "5 3 2", "output": "NO\n \n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in\ntotal."}] |
If it is possible that there are exactly X cats, print `YES`; if it is
impossible, print `NO`.
* * * | s412112601 | Runtime Error | p03377 | Input is given from Standard Input in the following format:
A B X | A,B,C=map(int, iput().split())
if C>A && A+B>C:
print("YES")
else:
print("NO")
| Statement
There are a total of A + B cats and dogs. Among them, A are known to be cats,
but the remaining B are not known to be either cats or dogs.
Determine if it is possible that there are exactly X cats among these A + B
animals. | [{"input": "3 5 4", "output": "YES\n \n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4\ncats in total.\n\n* * *"}, {"input": "2 2 6", "output": "NO\n \n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in\ntotal.\n\n* * *"}, {"input": "5 3 2", "output": "NO\n \n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in\ntotal."}] |
If it is possible that there are exactly X cats, print `YES`; if it is
impossible, print `NO`.
* * * | s935766797 | Accepted | p03377 | Input is given from Standard Input in the following format:
A B X | import math
import sys
def getinputdata():
# 配列初期化
array_result = []
data = input()
array_result.append(data.split(" "))
flg = True
try:
while flg:
data = input()
array_temp = []
if data != "":
array_result.append(data.split(" "))
flg = True
else:
flg = False
finally:
return array_result
arr_data = getinputdata()
# cat
a = int(arr_data[0][0])
b = int(arr_data[0][1])
x = int(arr_data[0][2])
print("YES" if a <= x and x - a <= b else "NO")
| Statement
There are a total of A + B cats and dogs. Among them, A are known to be cats,
but the remaining B are not known to be either cats or dogs.
Determine if it is possible that there are exactly X cats among these A + B
animals. | [{"input": "3 5 4", "output": "YES\n \n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4\ncats in total.\n\n* * *"}, {"input": "2 2 6", "output": "NO\n \n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in\ntotal.\n\n* * *"}, {"input": "5 3 2", "output": "NO\n \n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in\ntotal."}] |
If it is possible that there are exactly X cats, print `YES`; if it is
impossible, print `NO`.
* * * | s549911160 | Runtime Error | p03377 | Input is given from Standard Input in the following format:
A B X | import math
def comb(a, b):
return int(math.factorial(a) / math.factorial(b) / math.factorial(a - b))
if __name__ == "__main__":
n = int(input())
a = [int(x) for x in input().split(" ")]
sa = sorted(a)
oldcmb = -float("inf")
oldi, oldj = (-1, -1)
i, j = (-1, -1)
for i in range(n):
for j in range(n):
if i == j or i < j:
break
cmb = comb(sa[i], sa[j])
# print('old:{} new:{}[{}][{}]'.format(oldcmb, cmb, i, j))
if cmb > oldcmb:
oldcmb = cmb
oldi, oldj = (i, j)
if j == n - 1:
break
print("{} {}".format(sa[oldi], sa[oldj]))
# print('{}:{} {}:{}'.format(oldi, sa[oldi], oldj, sa[oldj]))
| Statement
There are a total of A + B cats and dogs. Among them, A are known to be cats,
but the remaining B are not known to be either cats or dogs.
Determine if it is possible that there are exactly X cats among these A + B
animals. | [{"input": "3 5 4", "output": "YES\n \n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4\ncats in total.\n\n* * *"}, {"input": "2 2 6", "output": "NO\n \n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in\ntotal.\n\n* * *"}, {"input": "5 3 2", "output": "NO\n \n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in\ntotal."}] |
If it is possible that there are exactly X cats, print `YES`; if it is
impossible, print `NO`.
* * * | s474795632 | Runtime Error | p03377 | Input is given from Standard Input in the following format:
A B X | a,b,x=map(int,input().split()
print("YES" if a+b>=x else "NO") | Statement
There are a total of A + B cats and dogs. Among them, A are known to be cats,
but the remaining B are not known to be either cats or dogs.
Determine if it is possible that there are exactly X cats among these A + B
animals. | [{"input": "3 5 4", "output": "YES\n \n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4\ncats in total.\n\n* * *"}, {"input": "2 2 6", "output": "NO\n \n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in\ntotal.\n\n* * *"}, {"input": "5 3 2", "output": "NO\n \n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in\ntotal."}] |
If it is possible that there are exactly X cats, print `YES`; if it is
impossible, print `NO`.
* * * | s087836921 | Runtime Error | p03377 | Input is given from Standard Input in the following format:
A B X | l=list(map(int,input().split()))
print( "YES" if l[0]+l[1]>=l[2] else "NO") | Statement
There are a total of A + B cats and dogs. Among them, A are known to be cats,
but the remaining B are not known to be either cats or dogs.
Determine if it is possible that there are exactly X cats among these A + B
animals. | [{"input": "3 5 4", "output": "YES\n \n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4\ncats in total.\n\n* * *"}, {"input": "2 2 6", "output": "NO\n \n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in\ntotal.\n\n* * *"}, {"input": "5 3 2", "output": "NO\n \n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in\ntotal."}] |
If it is possible that there are exactly X cats, print `YES`; if it is
impossible, print `NO`.
* * * | s877436677 | Runtime Error | p03377 | Input is given from Standard Input in the following format:
A B X | A,B,X=map(int,input().split())
if B<=X-A:
print("YES")
eles:
print("NO")
| Statement
There are a total of A + B cats and dogs. Among them, A are known to be cats,
but the remaining B are not known to be either cats or dogs.
Determine if it is possible that there are exactly X cats among these A + B
animals. | [{"input": "3 5 4", "output": "YES\n \n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4\ncats in total.\n\n* * *"}, {"input": "2 2 6", "output": "NO\n \n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in\ntotal.\n\n* * *"}, {"input": "5 3 2", "output": "NO\n \n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in\ntotal."}] |
If it is possible that there are exactly X cats, print `YES`; if it is
impossible, print `NO`.
* * * | s858670984 | Runtime Error | p03377 | Input is given from Standard Input in the following format:
A B X | n = int(input())
a = list(map(int, input().split()))
ai = max(a)
aj = min(filiter(lambad x: x!=ai, a), key=lambda x: abs(x-ai//2))
print("{} {}".format(ai, aj))
| Statement
There are a total of A + B cats and dogs. Among them, A are known to be cats,
but the remaining B are not known to be either cats or dogs.
Determine if it is possible that there are exactly X cats among these A + B
animals. | [{"input": "3 5 4", "output": "YES\n \n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4\ncats in total.\n\n* * *"}, {"input": "2 2 6", "output": "NO\n \n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in\ntotal.\n\n* * *"}, {"input": "5 3 2", "output": "NO\n \n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in\ntotal."}] |
If it is possible that there are exactly X cats, print `YES`; if it is
impossible, print `NO`.
* * * | s847447101 | Runtime Error | p03377 | Input is given from Standard Input in the following format:
A B X | l = input().split()
n = int(l[0])
m = int(l[1])
x = int(l[2])
a = input().split()
i = 0
while 1:
if int(a[i]) > x:
break
i = i + 1
if i < m - i:
print(i)
else:
print(m - i)
| Statement
There are a total of A + B cats and dogs. Among them, A are known to be cats,
but the remaining B are not known to be either cats or dogs.
Determine if it is possible that there are exactly X cats among these A + B
animals. | [{"input": "3 5 4", "output": "YES\n \n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4\ncats in total.\n\n* * *"}, {"input": "2 2 6", "output": "NO\n \n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in\ntotal.\n\n* * *"}, {"input": "5 3 2", "output": "NO\n \n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in\ntotal."}] |
If it is possible that there are exactly X cats, print `YES`; if it is
impossible, print `NO`.
* * * | s276126850 | Runtime Error | p03377 | Input is given from Standard Input in the following format:
A B X | n = int(input())
a = list(map(int, input().split(" ")))
i = 0
for i in range(n):
ai = a[0:i] + a[i + 1 : n]
aisrt = sorted(ai)
l = int(len(aisrt) / 2)
print(aisrt[l])
| Statement
There are a total of A + B cats and dogs. Among them, A are known to be cats,
but the remaining B are not known to be either cats or dogs.
Determine if it is possible that there are exactly X cats among these A + B
animals. | [{"input": "3 5 4", "output": "YES\n \n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4\ncats in total.\n\n* * *"}, {"input": "2 2 6", "output": "NO\n \n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in\ntotal.\n\n* * *"}, {"input": "5 3 2", "output": "NO\n \n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in\ntotal."}] |
If it is possible that there are exactly X cats, print `YES`; if it is
impossible, print `NO`.
* * * | s452648857 | Runtime Error | p03377 | Input is given from Standard Input in the following format:
A B X | A, B, X = input().split()
if A <= X <= (A+B):
print('Yes')
else
print('No')
| Statement
There are a total of A + B cats and dogs. Among them, A are known to be cats,
but the remaining B are not known to be either cats or dogs.
Determine if it is possible that there are exactly X cats among these A + B
animals. | [{"input": "3 5 4", "output": "YES\n \n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4\ncats in total.\n\n* * *"}, {"input": "2 2 6", "output": "NO\n \n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in\ntotal.\n\n* * *"}, {"input": "5 3 2", "output": "NO\n \n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in\ntotal."}] |
If it is possible that there are exactly X cats, print `YES`; if it is
impossible, print `NO`.
* * * | s707807719 | Wrong Answer | p03377 | Input is given from Standard Input in the following format:
A B X | n, m, x, *l = map(int, open(0).read().split())
s = sum(i in l for i in range(x))
print(min(s, m - s))
| Statement
There are a total of A + B cats and dogs. Among them, A are known to be cats,
but the remaining B are not known to be either cats or dogs.
Determine if it is possible that there are exactly X cats among these A + B
animals. | [{"input": "3 5 4", "output": "YES\n \n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4\ncats in total.\n\n* * *"}, {"input": "2 2 6", "output": "NO\n \n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in\ntotal.\n\n* * *"}, {"input": "5 3 2", "output": "NO\n \n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in\ntotal."}] |
If it is possible that there are exactly X cats, print `YES`; if it is
impossible, print `NO`.
* * * | s217102690 | Runtime Error | p03377 | Input is given from Standard Input in the following format:
A B X | x,y,z=map(int,input().split())
if x <= z and x+y => z :
print("YES")
else:
print("NO") | Statement
There are a total of A + B cats and dogs. Among them, A are known to be cats,
but the remaining B are not known to be either cats or dogs.
Determine if it is possible that there are exactly X cats among these A + B
animals. | [{"input": "3 5 4", "output": "YES\n \n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4\ncats in total.\n\n* * *"}, {"input": "2 2 6", "output": "NO\n \n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in\ntotal.\n\n* * *"}, {"input": "5 3 2", "output": "NO\n \n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in\ntotal."}] |
If it is possible that there are exactly X cats, print `YES`; if it is
impossible, print `NO`.
* * * | s999225865 | Runtime Error | p03377 | Input is given from Standard Input in the following format:
A B X | A,B,X=map(int,input().split())
if A>X:
print("NO")
elif A<=X=<A+B:
print("YES")
else :
print("NO") | Statement
There are a total of A + B cats and dogs. Among them, A are known to be cats,
but the remaining B are not known to be either cats or dogs.
Determine if it is possible that there are exactly X cats among these A + B
animals. | [{"input": "3 5 4", "output": "YES\n \n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4\ncats in total.\n\n* * *"}, {"input": "2 2 6", "output": "NO\n \n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in\ntotal.\n\n* * *"}, {"input": "5 3 2", "output": "NO\n \n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in\ntotal."}] |
If it is possible that there are exactly X cats, print `YES`; if it is
impossible, print `NO`.
* * * | s024191376 | Runtime Error | p03377 | Input is given from Standard Input in the following format:
A B X | a,b,x=map(int,input().split())
print("YES" a<=x and x<=a+b else "NO" )
| Statement
There are a total of A + B cats and dogs. Among them, A are known to be cats,
but the remaining B are not known to be either cats or dogs.
Determine if it is possible that there are exactly X cats among these A + B
animals. | [{"input": "3 5 4", "output": "YES\n \n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4\ncats in total.\n\n* * *"}, {"input": "2 2 6", "output": "NO\n \n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in\ntotal.\n\n* * *"}, {"input": "5 3 2", "output": "NO\n \n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in\ntotal."}] |
If it is possible that there are exactly X cats, print `YES`; if it is
impossible, print `NO`.
* * * | s702232825 | Accepted | p03377 | Input is given from Standard Input in the following format:
A B X | # Cats and Dogs
print(
(lambda x: "YES" if 0 <= x[2] - x[0] <= x[1] else "NO")(
list(map(int, input().split()))
)
)
| Statement
There are a total of A + B cats and dogs. Among them, A are known to be cats,
but the remaining B are not known to be either cats or dogs.
Determine if it is possible that there are exactly X cats among these A + B
animals. | [{"input": "3 5 4", "output": "YES\n \n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4\ncats in total.\n\n* * *"}, {"input": "2 2 6", "output": "NO\n \n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in\ntotal.\n\n* * *"}, {"input": "5 3 2", "output": "NO\n \n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in\ntotal."}] |
If it is possible that there are exactly X cats, print `YES`; if it is
impossible, print `NO`.
* * * | s320108843 | Runtime Error | p03377 | Input is given from Standard Input in the following format:
A B X | input()
a = list(map(int, input().split()))[::-1]
print(a[0], sorted(a, key=lambda x: abs(a[0] - 2 * x))[0])
| Statement
There are a total of A + B cats and dogs. Among them, A are known to be cats,
but the remaining B are not known to be either cats or dogs.
Determine if it is possible that there are exactly X cats among these A + B
animals. | [{"input": "3 5 4", "output": "YES\n \n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4\ncats in total.\n\n* * *"}, {"input": "2 2 6", "output": "NO\n \n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in\ntotal.\n\n* * *"}, {"input": "5 3 2", "output": "NO\n \n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in\ntotal."}] |
If it is possible that there are exactly X cats, print `YES`; if it is
impossible, print `NO`.
* * * | s934288969 | Accepted | p03377 | Input is given from Standard Input in the following format:
A B X | cat, cd, t = map(int, input().split())
f = False
if cat <= t and cd > 0 and cat + cd >= t:
f = True
print("YES") if f else print("NO")
| Statement
There are a total of A + B cats and dogs. Among them, A are known to be cats,
but the remaining B are not known to be either cats or dogs.
Determine if it is possible that there are exactly X cats among these A + B
animals. | [{"input": "3 5 4", "output": "YES\n \n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4\ncats in total.\n\n* * *"}, {"input": "2 2 6", "output": "NO\n \n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in\ntotal.\n\n* * *"}, {"input": "5 3 2", "output": "NO\n \n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in\ntotal."}] |
If it is possible that there are exactly X cats, print `YES`; if it is
impossible, print `NO`.
* * * | s812495000 | Runtime Error | p03377 | Input is given from Standard Input in the following format:
A B X | gatos = int(input())
animais = int(input())
X = int(input())
if X > animais:
print("NO")
elif X <= animais and animais > gatos:
print("SIM")
elif animais < gatos:
print("NO")
| Statement
There are a total of A + B cats and dogs. Among them, A are known to be cats,
but the remaining B are not known to be either cats or dogs.
Determine if it is possible that there are exactly X cats among these A + B
animals. | [{"input": "3 5 4", "output": "YES\n \n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4\ncats in total.\n\n* * *"}, {"input": "2 2 6", "output": "NO\n \n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in\ntotal.\n\n* * *"}, {"input": "5 3 2", "output": "NO\n \n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in\ntotal."}] |
If it is possible that there are exactly X cats, print `YES`; if it is
impossible, print `NO`.
* * * | s875147025 | Runtime Error | p03377 | Input is given from Standard Input in the following format:
A B X | from sys import stdin
a,b,x = [int(x) for x in stdin.readline().rstrip().split()]
if a>x or:
print('NO')
elif a<x and (x-a)>b:
print('NO')
else:
print('YES') | Statement
There are a total of A + B cats and dogs. Among them, A are known to be cats,
but the remaining B are not known to be either cats or dogs.
Determine if it is possible that there are exactly X cats among these A + B
animals. | [{"input": "3 5 4", "output": "YES\n \n\nIf there are one cat and four dogs among the B = 5 animals, there are X = 4\ncats in total.\n\n* * *"}, {"input": "2 2 6", "output": "NO\n \n\nEven if all of the B = 2 animals are cats, there are less than X = 6 cats in\ntotal.\n\n* * *"}, {"input": "5 3 2", "output": "NO\n \n\nEven if all of the B = 3 animals are dogs, there are more than X = 2 cats in\ntotal."}] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.