wrong_submission_id
stringlengths 10
10
| problem_id
stringlengths 6
6
| user_id
stringlengths 10
10
| time_limit
float64 1k
8k
| memory_limit
float64 131k
1.05M
| wrong_status
stringclasses 2
values | wrong_cpu_time
float64 10
40k
| wrong_memory
float64 2.94k
3.37M
| wrong_code_size
int64 1
15.5k
| problem_description
stringlengths 1
4.75k
| wrong_code
stringlengths 1
6.92k
| acc_submission_id
stringlengths 10
10
| acc_status
stringclasses 1
value | acc_cpu_time
float64 10
27.8k
| acc_memory
float64 2.94k
960k
| acc_code_size
int64 19
14.9k
| acc_code
stringlengths 19
14.9k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s132667621
|
p02613
|
u367323774
| 2,000 | 1,048,576 |
Wrong Answer
| 143 | 9,108 | 264 |
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
n=int(input())
ac=0
tle=0
wa=0
re=0
for i in range(n):
a=input()
if a=='AC':
ac=ac+1
elif a=='TLE':
tle=tle+1
elif a=='WA':
w=wa+1
else:
re=re+1
print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))
|
s276009347
|
Accepted
| 145 | 9,072 | 265 |
n=int(input())
ac=0
tle=0
wa=0
re=0
for i in range(n):
a=input()
if a=='AC':
ac=ac+1
elif a=='TLE':
tle=tle+1
elif a=='WA':
wa=wa+1
else:
re=re+1
print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))
|
s980364004
|
p03836
|
u243699903
| 2,000 | 262,144 |
Wrong Answer
| 34 | 4,468 | 514 |
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
|
sx,sy,tx,ty=map(int,input().split())
for _ in range(ty-sy):
print("U",end='')
for _ in range(tx-sx):
print("R",end='')
for _ in range(ty-sy):
print("D",end='')
for _ in range(tx-sx+1):
print("L",end='')
print("L",end='')
for _ in range(ty-sy+1):
print("U",end='')
for _ in range(tx-sx+1):
print("R",end='')
print("D",end='')
print("R",end='')
for _ in range(ty-sy+1):
print("D",end='')
for _ in range(tx-sx+1):
print("L",end='')
print("U",end='')
print()
|
s337610386
|
Accepted
| 33 | 4,468 | 512 |
sx,sy,tx,ty=map(int,input().split())
for _ in range(ty-sy):
print("U",end='')
for _ in range(tx-sx):
print("R",end='')
for _ in range(ty-sy):
print("D",end='')
for _ in range(tx-sx):
print("L",end='')
print("L",end='')
for _ in range(ty-sy+1):
print("U",end='')
for _ in range(tx-sx+1):
print("R",end='')
print("D",end='')
print("R",end='')
for _ in range(ty-sy+1):
print("D",end='')
for _ in range(tx-sx+1):
print("L",end='')
print("U",end='')
print()
|
s041085542
|
p03160
|
u245299842
| 2,000 | 1,048,576 |
Wrong Answer
| 237 | 17,344 | 407 |
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
|
dp = []
for i in range(100001):
dp.append(float('inf'))
N = int(input())
h = list(map(int, input().split()))
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(N - 2):
dp[i + 2] = min(dp[i + 1] + abs(h[i + 2] - h[i + 1]), dp[i] + abs(h[i + 2] - h[i]))
for i in range(N):
print(dp[i])
|
s101753028
|
Accepted
| 167 | 17,464 | 387 |
dp = []
for i in range(100001):
dp.append(float('inf'))
N = int(input())
h = list(map(int, input().split()))
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(N - 2):
dp[i + 2] = min(dp[i + 1] + abs(h[i + 2] - h[i + 1]), dp[i] + abs(h[i + 2] - h[i]))
print(dp[N-1])
|
s718184704
|
p02467
|
u908651435
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,600 | 109 |
Factorize a given integer n.
|
n=int(input())
p=n
x=[]
for i in range(2,p):
if n%i==0:
n=n/i
x.append(i)
print(p,':',x)
|
s890793831
|
Accepted
| 20 | 5,660 | 245 |
import math
n = int(input())
nc = n
result = []
i = 2
while i <= math.sqrt(n):
if n%i == 0:
n //= i
result.append(str(i))
else:
i += 1
if n != 1:
result.append(str(n))
print(str(nc) + ": " + " ".join(result))
|
s263625326
|
p02936
|
u453306058
| 2,000 | 1,048,576 |
Wrong Answer
| 2,106 | 41,908 | 452 |
Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0. Now, the following Q operations will be performed: * Operation j (1 \leq j \leq Q): Increment by x_j the counter on every vertex contained in the subtree rooted at Vertex p_j. Find the value of the counter on each vertex after all operations.
|
import queue
n,q = map(int,input().split())
graph = [[] for _ in range(n)]
for i in range(n-1):
a,b = map(int,input().split())
graph[a-1].append(b-1)
v = [0 for _ in range(n)]
qs = queue.Queue()
for i in range(q):
p,x = map(int,input().split())
qs.put(p-1)
while not qs.empty():
now = qs.get()
v[now] += x
for y in graph[now]:
qs.put(y)
#v[y] += x
for i in v:
print(i,end=' ')
|
s580241894
|
Accepted
| 1,836 | 55,728 | 507 |
n,q = map(int,input().split())
graph = [[] for _ in range(n)]
point = [0]*n
for i in range(n-1):
a,b = map(int,input().split())
graph[a-1].append(b-1)
graph[b-1].append(a-1)
for _ in range(q):
a,b = map(int,input().split())
a = a -1
point[a]+=b
stack = []
stack.append(0)
visited = [False]*n
while stack:
x = stack.pop()
visited[x] = True
for y in graph[x]:
if visited[y] == False:
point[y] += point[x]
stack.append(y)
print(*point)
|
s562502717
|
p02694
|
u509739538
| 2,000 | 1,048,576 |
Wrong Answer
| 23 | 9,120 | 244 |
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
import math
def readInt():
return int(input())
def readInts():
return list(map(int, input().split()))
def readChars():
return input().split()
x = readInt()
m = 100
n = 0
while 1:
if m>x:
print(n)
break
n+=1
m=math.floor(m*1.01)
|
s808844432
|
Accepted
| 22 | 9,184 | 248 |
import math
def readInt():
return int(input())
def readInts():
return list(map(int, input().split()))
def readChars():
return input().split()
x = readInt()
m = 100
n = 0
while 1:
if m>=x:
print(n)
break
n+=1
m=math.floor(m*1.01)
|
s903478037
|
p02565
|
u102461423
| 5,000 | 1,048,576 |
Wrong Answer
| 543 | 107,712 | 2,819 |
Consider placing N flags on a line. Flags are numbered through 1 to N. Flag i can be placed on the coordinate X_i or Y_i. For any two different flags, the distance between them should be at least D. Decide whether it is possible to place all N flags. If it is possible, print such a configulation.
|
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
@njit((i8, i8[:, :], i8[:], i8[:], i8[:], i8[:], i8[:], i8, i8, i8, i8),
cache=True)
def scc_dfs(N, G, idx, low, ord, ids, visited, now_ord, group_num, vis_i, v):
low[v] = ord[v] = now_ord
now_ord += 1
visited[vis_i], vis_i = v, vis_i + 1
for e in range(idx[v], idx[v + 1]):
to = G[e, 1]
if ord[to] == -1:
now_ord, group_num, vis_i = \
scc_dfs(N, G, idx, low, ord, ids,
visited, now_ord, group_num,
vis_i, to)
low[v] = min(low[v], low[to])
else:
low[v] = min(low[v], ord[to])
if low[v] == ord[v]:
while True:
u, vis_i = visited[vis_i - 1], vis_i - 1
ord[u] = N
ids[u] = group_num
if u == v:
break
group_num += 1
return now_ord, group_num, vis_i
@njit((i8, i8[:, :]), cache=True)
def scc(N, G):
idx = np.searchsorted(G[:, 0], np.arange(N + 1))
low = np.zeros(N, np.int64)
ord = np.zeros(N, np.int64) - 1
now_ord = 0
group_num = 0
visited, vis_i = np.empty(N, np.int64), 0
ids = np.zeros(N, np.int64)
for v in range(N):
if ord[v] == -1:
now_ord, group_num, vis_i = \
scc_dfs(N, G, idx, low, ord, ids,
visited, now_ord, group_num,
vis_i, v)
return group_num, group_num - ids - 1
@njit((i8, i8, i8[:]), cache=True)
def main(N, D, XY):
X, Y = XY[::2], XY[1::2]
G, g = np.empty((4 * N * N, 2), np.int64), 0
for i in range(N):
for j in range(N):
if i == j:
continue
if abs(X[i] - X[j]) < D:
G[g], g = (i, j + N), g + 1
if abs(X[i] - Y[j]) < D:
G[g], g = (i, j), g + 1
if abs(Y[i] - X[j]) < D:
G[g], g = (i + N, j + N), g + 1
if abs(Y[i] - Y[j]) < D:
G[g], g = (i + N, j), g + 1
G = G[:g]
n_comp, comp = scc(N + N, G)
ans = np.empty(N, np.int64)
for i in range(N):
if comp[i] < comp[i + N]:
ans[i] = Y[i]
elif comp[i] > comp[i + N]:
ans[i] = X[i]
else:
print('No')
return
print('Yes')
for x in ans:
print(x)
N, D = map(int, readline().split())
XY = np.array(read().split(), np.int64)
main(N, D, XY)
|
s055516366
|
Accepted
| 534 | 108,080 | 2,850 |
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
@njit((i8, i8[:, :], i8[:], i8[:], i8[:], i8[:], i8[:], i8, i8, i8, i8),
cache=True)
def scc_dfs(N, G, idx, low, ord, ids, visited, now_ord, group_num, vis_i, v):
low[v] = ord[v] = now_ord
now_ord += 1
visited[vis_i], vis_i = v, vis_i + 1
for e in range(idx[v], idx[v + 1]):
to = G[e, 1]
if ord[to] == -1:
now_ord, group_num, vis_i = \
scc_dfs(N, G, idx, low, ord, ids,
visited, now_ord, group_num,
vis_i, to)
low[v] = min(low[v], low[to])
else:
low[v] = min(low[v], ord[to])
if low[v] == ord[v]:
while True:
u, vis_i = visited[vis_i - 1], vis_i - 1
ord[u] = N
ids[u] = group_num
if u == v:
break
group_num += 1
return now_ord, group_num, vis_i
@njit((i8, i8[:, :]), cache=True)
def scc(N, G):
idx = np.searchsorted(G[:, 0], np.arange(N + 1))
low = np.zeros(N, np.int64)
ord = np.zeros(N, np.int64) - 1
now_ord = 0
group_num = 0
visited, vis_i = np.empty(N, np.int64), 0
ids = np.zeros(N, np.int64)
for v in range(N):
if ord[v] == -1:
now_ord, group_num, vis_i = \
scc_dfs(N, G, idx, low, ord, ids,
visited, now_ord, group_num,
vis_i, v)
return group_num, group_num - ids - 1
@njit((i8, i8, i8[:]), cache=True)
def main(N, D, XY):
X, Y = XY[::2], XY[1::2]
G, g = np.empty((4 * N * N, 2), np.int64), 0
for i in range(N):
for j in range(N):
if i == j:
continue
if abs(X[i] - X[j]) < D:
G[g], g = (i, j + N), g + 1
if abs(X[i] - Y[j]) < D:
G[g], g = (i, j), g + 1
if abs(Y[i] - X[j]) < D:
G[g], g = (i + N, j + N), g + 1
if abs(Y[i] - Y[j]) < D:
G[g], g = (i + N, j), g + 1
G = G[:g]
G = G[np.argsort(G[:,0])]
n_comp, comp = scc(N + N, G)
ans = np.empty(N, np.int64)
for i in range(N):
if comp[i] < comp[i + N]:
ans[i] = Y[i]
elif comp[i] > comp[i + N]:
ans[i] = X[i]
else:
print('No')
return
print('Yes')
for x in ans:
print(x)
N, D = map(int, readline().split())
XY = np.array(read().split(), np.int64)
main(N, D, XY)
|
s423409586
|
p03852
|
u025504404
| 2,000 | 262,144 |
Wrong Answer
| 22 | 3,064 | 346 |
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`.
|
s = input()
if len(s) < 5:
print('NO')
else:
flag = True
i = 0
j = 5
while(flag):
if (j <= len(s)) and (s[i:j] in ['dream', 'erase']):
i = j
j += 5
elif (len(s) > 5) and (j <= len(s)) and (s[i:(j+1)] in ['dreamer','eraser']):
i = j
j += 5
else:
print('NO')
flag = False
if flag:
print('YES')
else:
print('NO')
|
s762306153
|
Accepted
| 22 | 3,064 | 85 |
c = input()
if c in ['a','e','i','o','u']:
print('vowel')
else:
print('consonant')
|
s375619823
|
p03730
|
u353652911
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 228 |
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
|
a,b,c=map(int,input().split())
d=a
jol=[]
while True:
if d%b==c:
print("Yes")
exit()
elif d%b not in jol:
jol.append(a%b)
else:
print("No")
exit()
d+=a
|
s265408611
|
Accepted
| 17 | 2,940 | 228 |
a,b,c=map(int,input().split())
d=a
jol=[]
while True:
if d%b==c:
print("YES")
exit()
elif d%b not in jol:
jol.append(a%b)
else:
print("NO")
exit()
d+=a
|
s730519471
|
p03636
|
u246809151
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 59 |
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
|
s = input()
num = int(len(s)-2)
print(s[1]+str(num)+s[-1])
|
s666932524
|
Accepted
| 17 | 3,064 | 48 |
S = input()
print(S[0]+str(len(S[0:-2]))+S[-1])
|
s928639467
|
p03407
|
u286955577
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 106 |
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
|
def solve():
A, B, C = map(int, input().split())
return 'Yes' if A + B <= C else 'No'
print(solve())
|
s841011608
|
Accepted
| 17 | 2,940 | 95 |
print('Yes' if (lambda l: l[0] + l[1] - l[2])(list(map(int, input().split()))) >= 0 else 'No')
|
s088034226
|
p02262
|
u300645821
| 6,000 | 131,072 |
Wrong Answer
| 40 | 6,800 | 586 |
Shell Sort is a generalization of [Insertion Sort](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A) to arrange a list of $n$ elements $A$. 1 insertionSort(A, n, g) 2 for i = g to n-1 3 v = A[i] 4 j = i - g 5 while j >= 0 && A[j] > v 6 A[j+g] = A[j] 7 j = j - g 8 cnt++ 9 A[j+g] = v 10 11 shellSort(A, n) 12 cnt = 0 13 m = ? 14 G[] = {?, ?,..., ?} 15 for i = 0 to m-1 16 insertionSort(A, n, G[i]) A function shellSort(A, n) performs a function insertionSort(A, n, g), which considers every $g$-th elements. Beginning with large values of $g$, it repeats the insertion sort with smaller $g$. Your task is to complete the above program by filling ?. Write a program which reads an integer $n$ and a sequence $A$, and prints $m$, $G_i (i = 0, 1, ..., m − 1)$ in the pseudo code and the sequence $A$ in ascending order. The output of your program must meet the following requirements: * $1 \leq m \leq 100$ * $0 \leq G_i \leq n$ * cnt does not exceed $\lceil n^{1.5}\rceil$
|
#!/usr/bin/ruby
from __future__ import print_function
import sys
if sys.version_info[0]>=3: raw_input=input
def insertionSort(a, n, g):
global cnt
for i in range(g,n):
v = a[i]
j = i - g
while j >= 0 and a[j] > v:
a[j+g] = a[j]
j = j - g
cnt+=1
a[j+g] = v
def shellSort(a, n):
global cnt
cnt = 0
g = []
h = 1
while h <= n:
g.append(h)
h = 3*h+1
g.reverse()
m = len(g)
print(m)
print(' '.join(map(str,g)))
for i in range(m):
insertionSort(a, n, g[i])
a=[int(raw_input()) for i in range(int(raw_input()))]
shellSort(a,len(a))
print(cnt)
map(print,a)
|
s118486216
|
Accepted
| 27,750 | 47,252 | 550 |
#!/usr/bin/python
import sys
if sys.version_info[0]>=3: raw_input=input
def insertionSort(a,g):
global cnt
for i in range(g,len(a)):
v = a[i]
j = i - g
while j >= 0 and a[j] > v:
a[j+g] = a[j]
j = j - g
cnt+=1
a[j+g] = v
def shellSort(a):
global cnt
cnt = 0
g = []
h = 1
while h <= len(a):
g.append(h)
h = 3*h+1
g.reverse()
m = len(g)
print(m)
print(' '.join(map(str,g)))
for i in range(m):
insertionSort(a,g[i])
a=[int(raw_input()) for i in range(int(raw_input()))]
shellSort(a)
print(cnt)
for e in a: print(e)
|
s455125941
|
p03845
|
u340781749
| 2,000 | 262,144 |
Wrong Answer
| 23 | 3,064 | 163 |
Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her.
|
input()
ts = list(map(int, input().split()))
t_sum = sum(ts)
m = int(input())
for _ in range(m):
p, x = map(int, input().split())
print(t_sum - ts[p] + x)
|
s204178675
|
Accepted
| 24 | 3,064 | 167 |
input()
ts = list(map(int, input().split()))
t_sum = sum(ts)
m = int(input())
for _ in range(m):
p, x = map(int, input().split())
print(t_sum - ts[p - 1] + x)
|
s070021077
|
p03448
|
u626881915
| 2,000 | 262,144 |
Wrong Answer
| 57 | 9,100 | 216 |
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a+1):
for j in range(b+1):
for k in range(c+1):
if 500*a + 100*b + 50*c == x:
count += 1
print(count)
|
s363153169
|
Accepted
| 55 | 9,056 | 217 |
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a+1):
for j in range(b+1):
for k in range(c+1):
if 500*i + 100*j + 50*k == x:
count += 1
print(count)
|
s489038267
|
p02865
|
u127499732
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 47 |
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
|
n=int(input())
print(n/2-1 if n%2==0 else n//2)
|
s314673029
|
Accepted
| 17 | 2,940 | 60 |
n=int(input())
print(int(n/2)-1 if n%2==0 else int((n-1)/2))
|
s930402948
|
p03469
|
u689835643
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 39 |
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.
|
x = list(input())
x[3] = "8"
print(x)
|
s232389852
|
Accepted
| 17 | 2,940 | 48 |
x = list(input())
x[3] = "8"
print("".join(x))
|
s468845137
|
p02559
|
u102461423
| 5,000 | 1,048,576 |
Wrong Answer
| 5,517 | 193,904 | 1,363 |
You are given an array a_0, a_1, ..., a_{N-1} of length N. Process Q queries of the following types. * `0 p x`: a_p \gets a_p + x * `1 l r`: Print \sum_{i = l}^{r - 1}{a_i}.
|
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
@njit((i8[:], ), cache=True)
def build(raw_data):
bit = raw_data.copy()
for i in range(len(bit)):
j = i + (i & (-i))
if j < len(bit):
bit[j] += bit[i]
return bit
@njit((i8[:], i8), cache=True)
def get_sum(bit, i):
s = 0
while i:
s += bit[i]
i -= i & -i
return s
@njit((i8[:], i8, i8), cache=True)
def add(bit, i, x):
while i < len(bit):
bit[i] += x
i += i & -i
@njit((i8[:], i8), cache=True)
def find_kth_element(bit, k):
N = len(bit)
x, sx = 0, 0
dx = 1
while 2 * dx < N:
dx *= 2
while dx:
y = x + dx
if y < N:
sy = sx + bit[y]
if sy < k:
x, sx = y, sy
dx //= 2
return x + 1
@njit((i8[:], i8[:]), cache=True)
def main(X, TAB):
bit = build(X)
for i in range(0, len(TAB), 3):
t, a, b = TAB[i:i+3]
if t == 0:
add(bit, a, b)
else:
x = get_sum(bit, b) - get_sum(bit, a)
print(x)
N, Q = map(int, readline().split())
X = np.array([0] + readline().split(), np.int64)
TAB = np.array(read().split(), np.int64)
main(X, TAB)
|
s670706060
|
Accepted
| 1,025 | 193,128 | 1,369 |
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
@njit((i8[:], ), cache=True)
def build(raw_data):
bit = raw_data.copy()
for i in range(len(bit)):
j = i + (i & (-i))
if j < len(bit):
bit[j] += bit[i]
return bit
@njit((i8[:], i8), cache=True)
def get_sum(bit, i):
s = 0
while i:
s += bit[i]
i -= i & -i
return s
@njit((i8[:], i8, i8), cache=True)
def add(bit, i, x):
while i < len(bit):
bit[i] += x
i += i & -i
@njit((i8[:], i8), cache=True)
def find_kth_element(bit, k):
N = len(bit)
x, sx = 0, 0
dx = 1
while 2 * dx < N:
dx *= 2
while dx:
y = x + dx
if y < N:
sy = sx + bit[y]
if sy < k:
x, sx = y, sy
dx //= 2
return x + 1
@njit((i8[:], i8[:]), cache=True)
def main(X, TAB):
bit = build(X)
for i in range(0, len(TAB), 3):
t, a, b = TAB[i:i + 3]
if t == 0:
add(bit, a + 1, b)
else:
x = get_sum(bit, b) - get_sum(bit, a)
print(x)
N, Q = map(int, readline().split())
X = np.array([0] + readline().split(), np.int64)
TAB = np.array(read().split(), np.int64)
main(X, TAB)
|
s292417663
|
p02678
|
u785213188
| 2,000 | 1,048,576 |
Wrong Answer
| 2,270 | 2,384,312 | 649 |
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
|
from collections import deque, defaultdict
N, M = map(int, input().split())
D = [[float("inf")]*N for _ in range(N)]
for i in range(N):
D[i][i] = 0
for i in range(M):
s, t = map(int, input().split())
s -= 1
t -= 1
D[s][t] = 1
D[t][s] = 1
q = deque()
q.append(0)
d = defaultdict(lambda : int(-1))
d[0] = 0
while q:
u = q.popleft()
for v in range(N):
if D[u][v] == float("inf"):
continue
if not d[v] == -1:
continue
d[v] = d[u] + 1
q.append(v)
break
if len(d) == N:
print("Yes")
else:
print("No")
exit()
for i in range(1, N):
print(d[i])
|
s612674902
|
Accepted
| 806 | 47,488 | 497 |
from collections import deque, defaultdict
N, M = map(int, input().split())
D = defaultdict(list)
for i in range(M):
s, t = map(int, input().split())
D[s].append(t)
D[t].append(s)
q = deque()
q.append(1)
d = defaultdict(lambda : float("inf"))
d[1] = 0
while q:
u = q.popleft()
for v in D[u]:
if d[v] == float("inf"):
d[v] = u
q.append(v)
if len(d) == N:
print("Yes")
else:
print("No")
exit()
for i in range(2, N+1):
print(d[i])
|
s096977128
|
p03227
|
u735763891
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 174 |
You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.
|
def tpbc_2018_a():
import sys
input = sys.stdin.readline
s = input()
if len(s) == 2:
return s
else:
return s[::-1]
print(tpbc_2018_a())
|
s559586034
|
Accepted
| 17 | 2,940 | 127 |
def tpbc_2018_a():
s = input()
if len(s) == 2:
return s
else:
return s[::-1]
print(tpbc_2018_a())
|
s357373022
|
p03623
|
u766566560
| 2,000 | 262,144 |
Wrong Answer
| 19 | 2,940 | 107 |
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
|
x, a, b = map(int, input().split())
A = abs(a - x)
B = abs(b - x)
if A > B:
print('A')
else:
print('B')
|
s794807551
|
Accepted
| 17 | 3,064 | 107 |
x, a, b = map(int, input().split())
A = abs(a - x)
B = abs(b - x)
if A > B:
print('B')
else:
print('A')
|
s469837509
|
p03730
|
u059828923
| 2,000 | 262,144 |
Wrong Answer
| 27 | 9,120 | 228 |
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
|
a, b, c = map(int, input().split())
l = []
for i in range(b + 1):
if i == 0:
pass
else:
l.append((i * a) % b)
if c in l == True:
print("Yes")
else:
print("No")
|
s043959275
|
Accepted
| 27 | 9,052 | 250 |
a, b, c = map(int, input().split())
count = 0
for i in range(b + 1):
if ((i * a) % b) == c:
print("YES")
count += 1
break
else:
pass
if count == 0:
print("NO")
else:
pass
|
s470500184
|
p02615
|
u667084803
| 2,000 | 1,048,576 |
Wrong Answer
| 134 | 31,488 | 135 |
Quickly after finishing the tutorial of the online game _ATChat_ , you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the **friendliness** of Player i is A_i. The N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere. When each player, except the first one to arrive, arrives at the place, the player gets **comfort** equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0. What is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?
|
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = 0
for i in range(N):
ans += A[(i+1)//2]
print(ans)
|
s758094677
|
Accepted
| 145 | 31,444 | 137 |
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = 0
for i in range(N-1):
ans += A[(i+1)//2]
print(ans)
|
s920727645
|
p03814
|
u316603606
| 2,000 | 262,144 |
Wrong Answer
| 86 | 9,260 | 201 |
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.
|
s = input ()
n = len (s)
print (n)
for i in range (n):
if s[i] == 'A':
x = i
break
for i in range (n):
print (s[-1-i])
if s[-1-i] == 'Z':
y = n-i-1
break
print (x,y)
print (y-x+1)
|
s016876392
|
Accepted
| 48 | 9,152 | 161 |
s = input ()
n = len (s)
for i in range (n):
if s[i] == 'A':
x = i
break
for i in range (n):
if s[-1-i] == 'Z':
y = n-i-1
break
print (y-x+1)
|
s353192956
|
p03852
|
u063073794
| 2,000 | 262,144 |
Wrong Answer
| 16 | 2,940 | 92 |
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`.
|
s=input()
l=["a","i","u","e","o"]
if s is not l:
print("consonant")
else:
print("vowel")
|
s465967111
|
Accepted
| 17 | 2,940 | 88 |
s=input()
l=["a","i","u","e","o"]
if s in l:
print("vowel")
else:
print("consonant")
|
s397841460
|
p02396
|
u480053997
| 1,000 | 131,072 |
Wrong Answer
| 140 | 7,656 | 118 |
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.
|
for i in range(1,10001):
x = int(input())
if x == 0:
break
print('case ' + str(i) + ': ' + str(x))
|
s506342590
|
Accepted
| 70 | 7,432 | 127 |
import sys
for i, x in enumerate(sys.stdin):
x = x.strip()
if x == '0':
break
print('Case %d: %s'%(i+1, x))
|
s812753301
|
p03623
|
u821251381
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 61 |
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
|
x,a,b= map(int,input().split())
print(min(abs(x-a),abs(x-b)))
|
s545474163
|
Accepted
| 17 | 2,940 | 74 |
x,a,b= map(int,input().split())
print("A" if abs(x-a) < abs(x-b) else "B")
|
s091992919
|
p02381
|
u510829608
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,624 | 339 |
You have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn. The variance α2 is defined by α2 = (∑n _i_ =1(s _i_ \- m)2)/n where m is an average of si. The standard deviation of the scores is the square root of their variance.
|
import math
li = []
n_var = 0.0
while True:
temp = list(map(int, input().split()))
if len(temp) == 1 and temp[0] == 0:
break
if len(temp) > 1:
li.extend(temp)
ave = sum(li) / len(li)
for i in range(len(li)):
n_var += ( li[i] - ave )**2
var = n_var / len(li)
print('{0:.8f}'.format(math.sqrt(var)))
print('{0:.8f}'.format(0))
|
s127285923
|
Accepted
| 30 | 7,732 | 259 |
import math
while True:
cnt = int(input())
if cnt == 0:
break
li = list(map(int, input().split()))
ave = sum(li) / cnt
n_var = 0.0
for i in range(cnt):
n_var += ( li[i] - ave )**2
var = n_var / cnt
print('{0:.8f}'.format(math.sqrt(var)))
|
s701255972
|
p04043
|
u170410075
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 145 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
A,B,C = map(int,input().split())
if A==1 or B==1 or C==1:
print('NO')
MLT = A*B*C
if MLT == 125:
print('YES')
else:
print('NO')
|
s559144421
|
Accepted
| 17 | 2,940 | 145 |
A,B,C = map(int,input().split())
if A==1 or B==1 or C==1:
print('NO')
MLT = A*B*C
if MLT == 175:
print('YES')
else:
print('NO')
|
s450601849
|
p03998
|
u023229441
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 292 |
Alice, Bob and Charlie are playing _Card Game for Three_ , as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * If the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says `a`, Alice takes the next turn.) * If the current player's deck is empty, the game ends and the current player wins the game. You are given the initial decks of the players. More specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way. Determine the winner of the game.
|
A=list(input())
B=list(input())
C=list(input())
s=A[0]
while len(A)!=0 and len(B)!=0 and len(C)!=0:
if s=="a":
s=A[0]
del A[0]
if s=="b":
s=B[0]
del B[0]
if s=="c":
s=C[0]
del C[0]
if len(A)==0:
print("A")
if len(B)==0:
print("B")
if len(C)==0:
print("C")
|
s633532137
|
Accepted
| 18 | 3,064 | 304 |
A=list(input())+["d"]
B=list(input())+["d"]
C=list(input())+["d"]
s=A[0]
while s!="d":
if s=="a":
s=A[0]
del A[0]
elif s=="b":
s=B[0]
del B[0]
elif s=="c":
s=C[0]
del C[0]
if len(A)==0:
print("A")
if len(B)==0:
print("B")
if len(C)==0:
print("C")
|
s878971066
|
p03720
|
u799479335
| 2,000 | 262,144 |
Wrong Answer
| 152 | 12,396 | 201 |
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
|
import numpy as np
N,M = map(int, input().split())
a = np.zeros(M)
b = np.zeros(M)
for i in range(M):
a[i],b[i] = map(int, input().split())
for i in range(N):
print((a==i).sum() + (b==i).sum())
|
s163977926
|
Accepted
| 342 | 21,916 | 206 |
import numpy as np
N,M = map(int, input().split())
a = np.zeros(M)
b = np.zeros(M)
for i in range(M):
a[i],b[i] = map(int, input().split())
for i in range(1,N+1):
print((a==i).sum() + (b==i).sum())
|
s286352168
|
p03573
|
u636775911
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 155 |
You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
|
#coding:utf-8
n=[int(i) for i in input().split()]
if(n.count(n[0]==1)):
print(n[0])
else:
if(n.count(n[1]==1)):
print(n[1])
else:
print(n[2])
|
s603622707
|
Accepted
| 17 | 3,060 | 143 |
#coding:utf-8
n=[int(i) for i in input().split()]
if(n.count(n[0])==1):
print(n[0])
elif(n.count(n[1])==1):
print(n[1])
else:
print(n[2])
|
s667125365
|
p03449
|
u500207661
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,064 | 341 |
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them. At most how many candies can you collect when you choose the best way to travel?
|
n = int(input().strip())
a = [ list(map(int, input().strip().split())) for i in range(2) ]
maximum = 0
mov = 0
for i in range(n):
ans = 0
for i in range(mov+1):
ans += a[0][i]
for i in range(n-mov):
ans += a[1][i+mov]
print(ans)
mov += 1
if maximum < ans:
maximum = ans
print(maximum)
|
s030674865
|
Accepted
| 19 | 3,064 | 326 |
n = int(input().strip())
a = [ list(map(int, input().strip().split())) for i in range(2) ]
maximum = 0
mov = 0
for i in range(n):
ans = 0
for i in range(mov+1):
ans += a[0][i]
for i in range(n-mov):
ans += a[1][i+mov]
mov += 1
if maximum < ans:
maximum = ans
print(maximum)
|
s901814452
|
p03416
|
u308684517
| 2,000 | 262,144 |
Wrong Answer
| 207 | 4,040 | 174 |
Find the number of _palindromic numbers_ among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward.
|
a, b = map(int, input().split())
c = 0
for i in range(a, b+1):
s = str(i)
print(s[:len(s)//2], s[len(s)//2+1:])
if s[:len(s)//2] == s[len(s)//2+1:]:
c += 1
print(c)
|
s490966259
|
Accepted
| 71 | 2,940 | 137 |
a, b = map(int, input().split())
c = 0
for i in range(a, b+1):
s = str(i)
t = s[4] + s[3]
if s[0] + s[1] == t :
c += 1
print(c)
|
s552160326
|
p04030
|
u973069173
| 2,000 | 262,144 |
Wrong Answer
| 26 | 9,056 | 187 |
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
|
a = input()
test = ''
for i in range(len(a)):
if a[i] == '0':
test += '0'
elif a[i] == '1':
test += '1'
else:
if len(a) == 0:
pass
else:
test = test[:-1]
|
s250202807
|
Accepted
| 31 | 9,028 | 204 |
a = input()
test = ''
for i in range(len(a)):
if a[i] == '0':
test += '0'
elif a[i] == '1':
test += '1'
else:
if len(a) == 0:
pass
else:
test = test[:-1]
print(test)
|
s717880664
|
p02613
|
u343850880
| 2,000 | 1,048,576 |
Wrong Answer
| 149 | 16,656 | 357 |
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline())
import collections
n = int(input())
s = [input() for i in range(n)]
c = collections.Counter(s)
print(f'AC x {c["AC"]}')
print(f'WA x {c["WA"]}')
print(f'LTE x {c["TLE"]}')
print(f'RE x {c["RE"]}')
|
s717385636
|
Accepted
| 144 | 16,544 | 357 |
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline())
import collections
n = int(input())
s = [input() for i in range(n)]
c = collections.Counter(s)
print(f'AC x {c["AC"]}')
print(f'WA x {c["WA"]}')
print(f'TLE x {c["TLE"]}')
print(f'RE x {c["RE"]}')
|
s631013812
|
p04043
|
u016622494
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 82 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
a , b , c = input().split()
if a + b + c == 22:
print("YES")
else:
print("NO")
|
s128450811
|
Accepted
| 17 | 2,940 | 202 |
a , b , c =map(int,input().split())
if a + b + c ==17:
if a != 5:
if b == c and b ==5:
print("YES")
exit()
else:
if b == 5 or c == 5:
print("YES")
exit()
print("NO")
|
s901900027
|
p03943
|
u759412327
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 104 |
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
a = list(map(int,input().split()))
b = sorted(a)
if b[1]+b[2]==b[0]:
print("Yes")
else:
print("No")
|
s166272528
|
Accepted
| 26 | 9,140 | 86 |
a,b,c = sorted(map(int,input().split()))
if a+b==c:
print("Yes")
else:
print("No")
|
s964332038
|
p02615
|
u907865484
| 2,000 | 1,048,576 |
Wrong Answer
| 150 | 32,940 | 192 |
Quickly after finishing the tutorial of the online game _ATChat_ , you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the **friendliness** of Player i is A_i. The N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere. When each player, except the first one to arrive, arrives at the place, the player gets **comfort** equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0. What is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?
|
import math
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
comfortPoint = A[0]
for i in range(N)[1::]:
comfortPoint += A[math.ceil(i/2)]
print(comfortPoint)
|
s477640048
|
Accepted
| 149 | 32,836 | 194 |
import math
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
comfortPoint = A[0]
for i in range(N-1)[1::]:
comfortPoint += A[math.ceil(i/2)]
print(comfortPoint)
|
s595229333
|
p03557
|
u798818115
| 2,000 | 262,144 |
Wrong Answer
| 91 | 23,328 | 637 |
The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower. He has N parts for each of the three categories. The size of the i-th upper part is A_i, the size of the i-th middle part is B_i, and the size of the i-th lower part is C_i. To build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar. How many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different.
|
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
def binary (l,num):
high=len(l)-1
low=0
while True:
print(high,low)
mid=int((high+low))//2
if l[mid]<num:
if l[mid+1]>=num:
return mid
else:
print("a")
low=mid
elif l[mid]>=num:
if l[mid-1]<num:
return (mid-1)
else:
print("b")
high=mid
print(binary([1,3,4,5,6],3))
|
s221112362
|
Accepted
| 1,866 | 23,328 | 1,029 |
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
ans=[]
count=0
def binary (l,num):
high=len(l)-1
low=0
if num<=l[0]:
return 0
elif num>l[-1]:
return len(l)
while True:
#print(high,low)
mid=int((high+low))//2
if l[mid]<num:
if l[mid+1]>=num:
return mid+1
else:
#print("a")
low=mid
elif l[mid]>=num:
if l[mid-1]<num:
return (mid-1)+1
else:
#print("b")
high=mid
for i in range(len(B)):
if i==0:
ans.append(binary(A,B[i]))
else:
ans.append(binary(A,B[i])+ans[i-1])
for item in C:
z=binary(B,item)
if z==0:
continue
else:
count+=ans[binary(B,item)-1]
print(count)
|
s928424561
|
p03456
|
u207799478
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 125 |
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
|
a=list(input().split())
aa=''.join(a)
for i in range(1,101):
if i*i==aa:
print('Yes')
exit()
print('No')
|
s225676270
|
Accepted
| 157 | 2,940 | 144 |
a=list(input().split())
aa=int(''.join(a))
for i in range(1,1000000):
if i*i==aa:
print('Yes')
break
else:
print('No')
|
s124437733
|
p03110
|
u667505876
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 186 |
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative. For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins. If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?
|
n = int(input())
money = 0
for i in range(n):
a,b = map(str,input().split(' '))
x = float(a)
if b == 'JPY':
money = money + x
else:
money = money + x * 380000.0
print('money')
|
s886825495
|
Accepted
| 17 | 2,940 | 220 |
import sys
n = int(input())
money = 0
for i in range(n):
y = sys.stdin.readline().rstrip('\n')
a,b = y.split(' ')
x = float(a)
if b == 'JPY':
money = money + x
else:
money = money + x * 380000.0
print(money)
|
s784054568
|
p03494
|
u527993431
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 3,060 | 239 |
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
|
N = int(input())
A = list(map(int,input().split()))
count = 0
tmp = 0
while(1):
if tmp == 1:
break
for i in range (N):
if A[i]%2 == 1:
print(count)
tmp = 1
break
else:
count += 1
for i in range (N):
A[i] = A[i]/2
|
s390815753
|
Accepted
| 19 | 3,060 | 278 |
N = int(input())
A = list(map(int,input().split()))
count = 0
tmp = 0
while(1):
tmp_2=0
if tmp == 1:
break
for i in range (N):
if A[i]%2 == 1:
print(count)
tmp = 1
break
else:
tmp_2 += 1
if tmp_2 == N:
count += 1
for i in range (N):
A[i] = A[i]/2
|
s234089628
|
p03567
|
u698535708
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 824 |
Snuke built an online judge to hold a programming contest. When a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring. (The judge can return any two-character substring of S.) Determine whether the judge can return the string `AC` as the verdict to a program.
|
s = input()
s_x = [i for i in s if 'x' not in i]
cnt = 1
cen = int(len(s) / 2)
for i, c in enumerate(s):
d = len(s_x)/2
if cnt == int(d):
cen = i+1
if c == 'x':
pass
elif c != s_x[len(s_x)-cnt]:
print(-1)
break
else:
cnt += 1
else:
a = s[:cen]
for i in range(cen, len(s)):
if s[i] == 'x':
a += s[i]
else:
break
b = s[cen:]
b = b[::-1]
ans = 0
i, j = 0, 0
while i < len(a)-1 or j < len(b)-1:
if i >= len(a):
i -= 1
if j >= len(b):
j -= 1
if a[i] == b[j]:
i += 1
j += 1
elif a[i] == 'x':
i += 1
ans += 1
elif b[j] == 'x':
j += 1
ans += 1
print(ans)
|
s952188889
|
Accepted
| 17 | 2,940 | 41 |
print("Yes" if "AC" in input() else "No")
|
s665208860
|
p03433
|
u083960235
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 203 |
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
N=int(input())#total
A=int(input())#1
#500*x+1*A=N
#x is undecided
a=N-1*A
#a can devided by 500?
if(N>=A):
if(a%500==0):
print("yes")
else:
print("No")
else:
print("No")
|
s283271569
|
Accepted
| 18 | 2,940 | 120 |
N=int(input())#total
A=int(input())#1
#500*x+1*A=N
#x is undecided
if(N%500<=A):
print("Yes")
else:
print("No")
|
s278009670
|
p03501
|
u484856305
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 70 |
You are parking at a parking lot. You can choose from the following two fee plans: * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours. * Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours.
|
a,b,c=map(int,input().split())
if a*b>c:
print(a*b)
else:
print(c)
|
s577086445
|
Accepted
| 17 | 2,940 | 70 |
a,b,c=map(int,input().split())
if a*b>c:
print(c)
else:
print(a*b)
|
s751390384
|
p03160
|
u695079172
| 2,000 | 1,048,576 |
Wrong Answer
| 128 | 14,616 | 560 |
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
|
def flog(heights,n):
dp = [0 for _ in heights]
dp [0] = 0
dp [1] = abs(heights[1]-heights[0])
for i in range(2,n):
from_one_before = dp[i-1] + abs(heights[i] - heights[i-1])
from_two_before = dp[i-2] + abs(heights[i] - heights[i-2])
dp[i] = min(from_one_before,from_two_before)
print(dp)
return dp[n-1]
def main():
n = int(input())
heights = list(map(int,input().split()))
print(flog(heights,n))
if __name__ == '__main__':
main()
|
s276614962
|
Accepted
| 100 | 20,572 | 345 |
def main():
n = int(input())
h = list(map(int,input().split()))
dp = [0] * n
dp[1] = abs(h[1]-h[0])
for i in range(2,n):
one_behind = dp[i-1] + abs(h[i-1] - h[i])
two_behind = dp[i-2] + abs(h[i-2] - h[i])
dp[i] = min(one_behind,two_behind)
print(dp[n-1])
if __name__ == '__main__':
main()
|
s732281476
|
p03963
|
u672898046
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 52 |
There are N balls placed in a row. AtCoDeer the deer is painting each of these in one of the K colors of his paint cans. For aesthetic reasons, any two adjacent balls must be painted in different colors. Find the number of the possible ways to paint the balls.
|
n, k = map(int, input().split())
print(k*(n**(k-1)))
|
s041388940
|
Accepted
| 17 | 2,940 | 56 |
n, k = map(int, input().split())
print(((k-1)**(n-1))*k)
|
s940720331
|
p02399
|
u131984977
| 1,000 | 131,072 |
Wrong Answer
| 40 | 6,744 | 101 |
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
|
import sys
(a, b) = [int(i) for i in sys.stdin.readline().split(' ')]
print(a // b, a % b, a / b)
|
s210166779
|
Accepted
| 30 | 7,700 | 114 |
a, b = [int(i) for i in input().split()]
d = a // b
r = a % b
f = a / b
print("{0} {1} {2:.5f}".format(d, r, f))
|
s287732836
|
p03456
|
u430198125
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 161 |
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
|
# -*- coding: utf-8 -*-
import math
a, b = map(str, input().split())
c = int(a + b)
if math.sqrt(c).is_integer():
print ("YES")
else:
print("No")
|
s465055617
|
Accepted
| 17 | 2,940 | 161 |
# -*- coding: utf-8 -*-
import math
a, b = map(str, input().split())
c = int(a + b)
if math.sqrt(c).is_integer():
print ("Yes")
else:
print("No")
|
s505697921
|
p03943
|
u546235346
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 131 |
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
n = input().split()
a = int(n[0])
b = int(n[1])
c = int(n[2])
m = max([a,b,c])
if 2*m == a+b+c:
print("YES")
else:
print("NO")
|
s507752940
|
Accepted
| 18 | 2,940 | 131 |
n = input().split()
a = int(n[0])
b = int(n[1])
c = int(n[2])
m = max([a,b,c])
if 2*m == a+b+c:
print("Yes")
else:
print("No")
|
s312223550
|
p03371
|
u764401543
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 3,064 | 314 |
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.
|
A, B, C, X, Y = map(int, input().split())
ans = float('inf')
if A + B > 2 * C:
p = (2 * max(X, Y)) * C
ans = min(ans, p)
else:
for x in range(X + 1):
for y in range(Y + 1):
c = max(X - x, Y - y)
p = x * A + y * B + (2 * c) * C
ans = min(ans, p)
print(ans)
|
s208344914
|
Accepted
| 17 | 3,060 | 351 |
A, B, C, X, Y = map(int, input().split())
# ans = float('inf')
# ans = min(ans, A * max(X - i, 0) + B * max(Y - i, 0) + 2 * C * i)
# print(ans)
min_xy = min(X, Y)
max_xy = max(X, Y)
ans1 = 2 * C * min_xy + A * (X - min_xy) + B * (Y - min_xy)
ans2 = A * X + B * Y
ans3 = 2 * C * max_xy
print(min(ans1, ans2, ans3))
|
s388548256
|
p03814
|
u217627525
| 2,000 | 262,144 |
Wrong Answer
| 71 | 3,512 | 256 |
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.
|
s=input()
a=0
find_a=0
z=len(s)-1
find_z=0
while find_a==0 or find_z==0:
if find_a==0 and s[a]=="A":
find_a=1
if find_z==0 and s[z]=="Z":
find_z=1
if find_a==0:
a+=1
if find_z==0:
z-=1
print(z,a)
print(z-a+1)
|
s862868853
|
Accepted
| 59 | 3,516 | 269 |
s=input()
a=0
find_a=0
z=len(s)-1
find_z=0
while find_a==0 or find_z==0:
if find_a==0:
if s[a]=="A":
find_a=1
else:
a+=1
if find_z==0:
if s[z]=="Z":
find_z=1
else:
z-=1
print(z-a+1)
|
s528001245
|
p03369
|
u085334230
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 43 |
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen.
|
s = str(input())
print(s.count("o") * 100)
|
s190474029
|
Accepted
| 17 | 2,940 | 48 |
s = str(input())
print(s.count("o") * 100 + 700)
|
s786015025
|
p02615
|
u414050834
| 2,000 | 1,048,576 |
Wrong Answer
| 123 | 31,324 | 220 |
Quickly after finishing the tutorial of the online game _ATChat_ , you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the **friendliness** of Player i is A_i. The N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere. When each player, except the first one to arrive, arrives at the place, the player gets **comfort** equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0. What is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?
|
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
t=(len(a)-1)//2
ans=a[0]
if t%2==0:
for i in range(1,t+1):
ans+=a[i]*2
else:
ans=ans+a[t+1]
for i in range(1,t+1):
ans+=a[i]*2
print(ans)
|
s805676878
|
Accepted
| 127 | 31,596 | 230 |
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
t=(len(a)-2)//2
ans=a[0]
if (len(a)-2)%2==0:
for i in range(1,t+1):
ans+=a[i]*2
else:
ans=ans+a[t+1]
for i in range(1,t+1):
ans+=a[i]*2
print(ans)
|
s669519014
|
p02392
|
u600195957
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,632 | 95 |
Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No".
|
a,b,c = [int(i) for i in input().split()]
if a < b < c:
print("YES")
else:
print("NO")
|
s447027463
|
Accepted
| 20 | 7,700 | 95 |
a,b,c = [int(i) for i in input().split()]
if a < b < c:
print("Yes")
else:
print("No")
|
s549622353
|
p03605
|
u439392790
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 76 |
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
|
N=str(input())
if N[0]==9 or N[1]==9:
print('Yes')
else:
print('No')
|
s086589922
|
Accepted
| 20 | 2,940 | 66 |
N=str(input())
if '9' in N:
print('Yes')
else:
print('No')
|
s412566106
|
p02415
|
u283452598
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,420 | 33 |
Write a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string.
|
s = input()
s.swapcase()
print(s)
|
s216385274
|
Accepted
| 20 | 7,408 | 31 |
s = input()
print(s.swapcase())
|
s016581933
|
p02601
|
u581248859
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 9,188 | 201 |
M-kun has the following three cards: * A red card with the integer A. * A green card with the integer B. * A blue card with the integer C. He is a genius magician who can do the following operation at most K times: * Choose one of the three cards and multiply the written integer by 2. His magic is successful if both of the following conditions are satisfied after the operations: * The integer on the green card is **strictly** greater than the integer on the red card. * The integer on the blue card is **strictly** greater than the integer on the green card. Determine whether the magic can be successful.
|
A,B,C = map(int,input().split())
K = int(input())
cnt = 0
for _ in range(K):
if A>B:
B *= 2
cnt += 1
for _ in range(K-cnt):
if B>C:
C *= 2
if (A<B) and (B<C):
print('YES')
else:
print('NO')
|
s768053330
|
Accepted
| 31 | 9,076 | 245 |
A,B,C = map(int,input().split())
K = int(input())
cnt = 0
for _ in range(K):
if A>=B:
B *= 2
cnt += 1
else:
break
for _ in range(K-cnt):
if B>=C:
C *= 2
else:
break
#print(cnt)
if (A<B) and (B<C):
print('Yes')
else:
print('No')
|
s493815357
|
p03857
|
u001024152
| 2,000 | 262,144 |
Wrong Answer
| 790 | 46,248 | 1,530 |
There are N cities. There are also K roads and L railways, extending between the cities. The i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities. No two roads connect the same pair of cities. Similarly, no two railways connect the same pair of cities. We will say city A and B are _connected by roads_ if city B is reachable from city A by traversing some number of roads. Here, any city is considered to be connected to itself by roads. We will also define _connectivity by railways_ similarly. For each city, find the number of the cities connected to that city by both roads and railways.
|
# D
class UnionFind:
def __init__(self, size: int):
self.par = [-1]*size
for i in range(size):
self.par[i] = i
def root(self, x: int) -> int:
if self.par[x] == x: # if root
return x
else:
self.par[x] = self.root(self.par[x])
return self.par[x]
def isSame(self, x:int, y:int)->bool:
return self.root(x)==self.root(y)
def unite(self, x:int, y:int):
x = self.root(x)
y = self.root(y)
if x == y: return
self.par[x] = y
# ------------------
N,K,L = map(int, input().split())
pq, rs = set(), set()
for _ in range(K):
p,q = map(int, input().split())
pq.add((p-1, q-1))
for _ in range(L):
r,s= map(int, input().split())
rs.add((r-1, s-1))
edge = pq&rs
uf = UnionFind(N)
for s,t in edge:
uf.unite(s,t)
cnt = [0]*N
for i in range(N):
r = uf.root(i)
cnt[r] += 1
ans = []
for i in range(N):
r = uf.root(i)
ans.append(cnt[r])
print(ans, sep=" ")
|
s968458364
|
Accepted
| 1,880 | 52,960 | 1,632 |
# D
class UnionFind:
def __init__(self, size: int):
self.par = [-1]*size
for i in range(size):
self.par[i] = i
def root(self, x: int) -> int:
if self.par[x] == x: # if root
return x
else:
self.par[x] = self.root(self.par[x])
return self.par[x]
def isSame(self, x:int, y:int)->bool:
return self.root(x)==self.root(y)
def unite(self, x:int, y:int):
x = self.root(x)
y = self.root(y)
if x == y: return
self.par[x] = y
# ------------------
N,K,L = map(int, input().split())
uf_k = UnionFind(N)
uf_l = UnionFind(N)
for _ in range(K):
p,q = map(int, input().split())
uf_k.unite(p-1, q-1)
for _ in range(L):
r,s= map(int, input().split())
uf_l.unite(r-1, s-1)
cnt = dict()
for i in range(N):
r_k,r_l = uf_k.root(i), uf_l.root(i)
if (r_k,r_l) in cnt.keys():
cnt[(r_k,r_l)] += 1
else:
cnt[(r_k,r_l)] = 1
ans = []
for i in range(N):
r_k,r_l = uf_k.root(i), uf_l.root(i)
ans.append(cnt[(r_k,r_l)])
print(*ans, sep=" ", end="\n")
|
s394897125
|
p03407
|
u923712635
| 2,000 | 262,144 |
Wrong Answer
| 20 | 2,940 | 87 |
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
|
A,B,C = [int(x) for x in input().split()]
if(A+B<C):
print('Yes')
else:
print('No')
|
s630313310
|
Accepted
| 17 | 2,940 | 88 |
A,B,C = [int(x) for x in input().split()]
if(A+B>=C):
print('Yes')
else:
print('No')
|
s808803338
|
p03681
|
u662613022
| 2,000 | 262,144 |
Wrong Answer
| 70 | 3,064 | 617 |
Snuke has N dogs and M monkeys. He wants them to line up in a row. As a Japanese saying goes, these dogs and monkeys are on bad terms. _("ken'en no naka", literally "the relationship of dogs and monkeys", means a relationship of mutual hatred.)_ Snuke is trying to reconsile them, by arranging the animals so that there are neither two adjacent dogs nor two adjacent monkeys. How many such arrangements there are? Find the count modulo 10^9+7 (since animals cannot understand numbers larger than that). Here, dogs and monkeys are both distinguishable. Also, two arrangements that result from reversing each other are distinguished.
|
import math
N,M = map(int,input().split())
ans = 1
if N-M >= 2 or M-N >= 2:
print(0)
else:
if N > M:
for i in range(1,N+1):
if i == N:
ans *= i
else:
ans *= i**2
ans = ans % 1000000007
elif N < M:
for i in range(1,M+1):
if i == M:
ans *= i
else:
ans *= i**2
ans = ans % 1000000007
elif N == M:
for i in range(1,N+1):
ans *= i**2
if i == N:
ans *= 2
ans = ans % 1000000007
|
s680841832
|
Accepted
| 69 | 3,064 | 632 |
import math
N,M = map(int,input().split())
ans = 1
if N-M >= 2 or M-N >= 2:
print(0)
else:
if N > M:
for i in range(1,N+1):
if i == N:
ans *= i
else:
ans *= i**2
ans = ans % 1000000007
elif N < M:
for i in range(1,M+1):
if i == M:
ans *= i
else:
ans *= i**2
ans = ans % 1000000007
elif N == M:
for i in range(1,N+1):
ans *= i**2
if i == N:
ans *= 2
ans = ans % 1000000007
print(ans)
|
s099791235
|
p03407
|
u390958150
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 81 |
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
|
a,b,c = map(int,input().split())
if a+b <= c:
print("Yes")
else:
print("No")
|
s505090802
|
Accepted
| 17 | 2,940 | 82 |
a,b,c = map(int,input().split())
if a+b >= c:
print("Yes")
else:
print("No")
|
s372167378
|
p03729
|
u614917104
| 2,000 | 262,144 |
Wrong Answer
| 27 | 9,092 | 116 |
You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `YES`. Otherwise, print `NO`.
|
a,b,c = input().split()
n = 0
if a[len(a)-1] == b[0] and b[len(b)-1] == c[0]:
print('Yes')
else:
print('No')
|
s159911676
|
Accepted
| 27 | 8,968 | 116 |
a,b,c = input().split()
n = 0
if a[len(a)-1] == b[0] and b[len(b)-1] == c[0]:
print('YES')
else:
print('NO')
|
s396632110
|
p03719
|
u668352391
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 107 |
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
|
a, b, c = map(lambda x: int(x), input().split())
if a <= c and b >= c:
print('YES')
else:
print('NO')
|
s304911418
|
Accepted
| 17 | 2,940 | 106 |
a, b, c = map(lambda x: int(x), input().split())
if a <= c and b >= c:
print('Yes')
else:
print('No')
|
s902226141
|
p03814
|
u074220993
| 2,000 | 262,144 |
Wrong Answer
| 49 | 9,076 | 198 |
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.
|
s = input()
i, j = 0, len(s)-1
while(1):
if s[i] == "A":
start = i
break
i += 1
while(1):
if s[j] == "Z":
end = j + 1
break
j -= 1
print(s[start:end])
|
s306671152
|
Accepted
| 27 | 9,196 | 45 |
s = input()
print(s.rfind('Z')-s.find('A')+1)
|
s949998539
|
p03448
|
u477651929
| 2,000 | 262,144 |
Wrong Answer
| 29 | 3,060 | 351 |
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in range(a):
if x - (500 * i) >= 0:
x_ = x - (500 * i)
for j in range(b):
if x_ - (100 * j) >= 0:
x_ = x - (100 * j)
for k in range(c):
if x_ - (50 * k) == 0:
ans += 1
print(ans)
|
s871908996
|
Accepted
| 50 | 3,060 | 235 |
a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in range(a + 1):
for j in range(b + 1):
for k in range(c + 1):
if x - 500 * i - 100 * j - 50 * k == 0:
ans += 1
print(ans)
|
s375120788
|
p03624
|
u798129018
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,188 | 169 |
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead.
|
s = input()
a = list("abcdefghijklmnopqrstuvwxyz")
for i in range(len(a)):
if s.count(a[i]):
break
else:
print(a[i])
exit()
print("None")
|
s824379744
|
Accepted
| 21 | 3,188 | 172 |
s = input()
a = list("abcdefghijklmnopqrstuvwxyz")
for i in range(len(a)):
if s.count(a[i]):
continue
else:
print(a[i])
exit()
print("None")
|
s085500827
|
p03697
|
u325282913
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 86 |
You are given two integers A and B as the input. Output the value of A + B. However, if A + B is 10 or greater, output `error` instead.
|
A, B = map(int, input().split())
if A+B <= 10:
print('error')
else:
print(A+B)
|
s073074452
|
Accepted
| 17 | 2,940 | 86 |
A, B = map(int, input().split())
if A+B >= 10:
print('error')
else:
print(A+B)
|
s456875855
|
p04000
|
u149991748
| 3,000 | 262,144 |
Wrong Answer
| 3,196 | 796,080 | 533 |
We have a grid with H rows and W columns. At first, all cells were painted white. Snuke painted N of these cells. The i-th ( 1 \leq i \leq N ) cell he painted is the cell at the a_i-th row and b_i-th column. Compute the following: * For each integer j ( 0 \leq j \leq 9 ), how many subrectangles of size 3×3 of the grid contains exactly j black cells, after Snuke painted N cells?
|
h, w, n = map(int, input().split())
hako = [[0 for i in range(w)] for j in range(h)]
ans = [0]*10
#print("hako1 = {0}".format(hako))
if n != 0:
print('a')
for i in range(n):
s, t = map(int, input().split())
hako[s-1][t-1] = 1
#print("hako2 = {0}".format(hako))
for i in range(h-2):
for j in range(w-2):
s = 0
for p in range(3):
for q in range(3):
if hako[i+p][j+q] == 1:
s += 1
ans[s] += 1
for i in range(10):
print(ans[i])
|
s547516322
|
Accepted
| 1,894 | 174,432 | 270 |
f=lambda:map(int,input().split())
h,w,n = f()
d={}
while n:
n-=1
x,y=f()
for i in range(9):
a=(x+i%3,y+i//3)
d[a]=d.get(a,0)+(h>=a[0]>2<a[1]<=w)
c=[list(d.values()).count(i+1)for i in range(9)]
print((h-2)*(w-2)-sum(c))
for i in range(9):
print(c[i])
|
s817780836
|
p03852
|
u508273185
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 78 |
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`.
|
c = input()
if c == "aiueo":
print("vowel")
else :
print("consonant")
|
s935565972
|
Accepted
| 18 | 2,940 | 78 |
c = input()
if c in "aiueo":
print("vowel")
else :
print("consonant")
|
s502494389
|
p02646
|
u134520518
| 2,000 | 1,048,576 |
Wrong Answer
| 20 | 9,196 | 176 |
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
|
a,v = map(int, input().split())
b,w = map(int, input().split())
t = int(input())
if v <= w:
print('No')
elif ((a-b)/(v-w))**2 <t**2:
print('Yes')
else:
print('No')
|
s775193733
|
Accepted
| 19 | 9,120 | 177 |
a,v = map(int, input().split())
b,w = map(int, input().split())
t = int(input())
if v <= w:
print('NO')
elif ((a-b)/(v-w))**2 <=t**2:
print('YES')
else:
print('NO')
|
s070369635
|
p02272
|
u772417059
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,596 | 495 |
Write a program of a Merge Sort algorithm implemented by the following pseudocode. You should also report the number of comparisons in the Merge function. Merge(A, left, mid, right) n1 = mid - left; n2 = right - mid; create array L[0...n1], R[0...n2] for i = 0 to n1-1 do L[i] = A[left + i] for i = 0 to n2-1 do R[i] = A[mid + i] L[n1] = SENTINEL R[n2] = SENTINEL i = 0; j = 0; for k = left to right-1 if L[i] <= R[j] then A[k] = L[i] i = i + 1 else A[k] = R[j] j = j + 1 Merge-Sort(A, left, right){ if left+1 < right then mid = (left + right)/2; call Merge-Sort(A, left, mid) call Merge-Sort(A, mid, right) call Merge(A, left, mid, right)
|
cnt = 0
INFTY=10**10
def merge_sort(a,left,right):
if left+1<right:
mid=(left+right)//2
merge_sort(a,left,mid)
merge_sort(a,mid,right)
merge(a,left,mid,right)
def merge(a,left,mid,right):
L=a[left:mid]
R=a[mid:right]
L.append(INFTY)
R.append(INFTY)
global cnt
i=0
j=0
for k in range(left,right):
cnt+=1
if L[i] <= R[j]:
a[k]=L[i]
i+=1
else:
a[k]=R[j]
j+=1
n=int(input())
cnt=0
a=list(map(int,input().split()))
merge_sort(a,0,len(a))
print(a)
print(cnt)
|
s970528420
|
Accepted
| 3,780 | 61,648 | 496 |
cnt = 0
INFTY=10**10
def merge_sort(a,left,right):
if left+1<right:
mid=(left+right)//2
merge_sort(a,left,mid)
merge_sort(a,mid,right)
merge(a,left,mid,right)
def merge(a,left,mid,right):
L=a[left:mid]
R=a[mid:right]
L.append(INFTY)
R.append(INFTY)
global cnt
i=0
j=0
for k in range(left,right):
cnt+=1
if L[i] <= R[j]:
a[k]=L[i]
i+=1
else:
a[k]=R[j]
j+=1
n=int(input())
cnt=0
a=list(map(int,input().split()))
merge_sort(a,0,len(a))
print(*a)
print(cnt)
|
s335807973
|
p03637
|
u487594898
| 2,000 | 262,144 |
Wrong Answer
| 193 | 23,104 | 574 |
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
|
import numpy as np
N=int(input())
A = list(map(int,input().split()))
Aa = np.array(A) %4
if np.count_nonzero(Aa%4==2)==0 and N//2-np.count_nonzero(Aa%4==0)>0:
print("No")
elif np.count_nonzero(Aa%4==2)==0 and N//2-np.count_nonzero(Aa%4==0)<=0:
print("Yes")
elif np.count_nonzero(Aa%4==2)!=0:
if N%2==np.count_nonzero(Aa%4==2)%2 and np.count_nonzero(Aa%2==1)-np.count_nonzero(Aa%4==0)<=0:
print("No")
elif N%2!=np.count_nonzero(Aa%4==2)%2 and np.count_nonzero(Aa%4==2)-1-np.count_nonzero(Aa%4==0)<=0:
print("No")
else:
print("Yes")
|
s501771690
|
Accepted
| 199 | 23,136 | 574 |
import numpy as np
N=int(input())
A = list(map(int,input().split()))
Aa = np.array(A) %4
if np.count_nonzero(Aa%4==2)==0 and N//2-np.count_nonzero(Aa%4==0)>0:
print("No")
elif np.count_nonzero(Aa%4==2)==0 and N//2-np.count_nonzero(Aa%4==0)<=0:
print("Yes")
elif np.count_nonzero(Aa%4==2)!=0:
if N%2==np.count_nonzero(Aa%4==2)%2 and np.count_nonzero(Aa%2==1)-np.count_nonzero(Aa%4==0)>0:
print("No")
elif N%2 != np.count_nonzero(Aa%4==2)%2 and np.count_nonzero(Aa%2==1)+1-np.count_nonzero(Aa%4==0)>0:
print("No")
else:
print("Yes")
|
s898618582
|
p03547
|
u029329478
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 137 |
In programming, hexadecimal notation is often used. In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters `A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12, 13, 14 and 15, respectively. In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`, `C`, `D`, `E` or `F`. When X and Y are seen as hexadecimal numbers, which is larger?
|
X, Y = map(str, input().split())
x = int(X, 16)
y = int(Y, 16)
if x > y:
print(">")
elif y < x:
print("<")
else:
print("=")
|
s187858985
|
Accepted
| 19 | 3,060 | 137 |
X, Y = map(str, input().split())
x = int(X, 16)
y = int(Y, 16)
if x > y:
print(">")
elif x < y:
print("<")
else:
print("=")
|
s003717748
|
p02646
|
u658987783
| 2,000 | 1,048,576 |
Wrong Answer
| 25 | 9,228 | 283 |
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
|
a,v=list(map(int,input().split()))
b,w=a,v=list(map(int,input().split()))
n=int(input())
if a<=b:
if (a+v*n)>=(b+w*n):
print("Yes")
exit()
else:
print("No")
exit()
if a>b:
if (a-v*n)<=(b-w*n):
print("Yes")
exit()
else:
print("No")
exit()
|
s405667598
|
Accepted
| 21 | 9,196 | 235 |
a,v=list(map(int,input().split()))
b,w=list(map(int,input().split()))
n=int(input())
if a<=b:
if (a+v*n)>=(b+w*n):
print("YES")
else:
print("NO")
if a>b:
if (a-v*n)<=(b-w*n):
print("YES")
else:
print("NO")
|
s614721828
|
p03588
|
u796424048
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 11,044 | 225 |
A group of people played a game. All players had distinct scores, which are positive integers. Takahashi knows N facts on the players' scores. The i-th fact is as follows: the A_i-th highest score among the players is B_i. Find the maximum possible number of players in the game.
|
N = int(input())
A = []
B = []
for i in range(N):
a,b = map(int,input().split())
A.append(a)
B.append(b)
res_1 = min(A)-1
for i in range(N):
if B[i] == min(B):
res_2 = B[i]
print(max(B)+res_1+res_2)
|
s441065889
|
Accepted
| 316 | 11,052 | 156 |
N = int(input())
A = []
B = []
for i in range(N):
a,b = map(int,input().split())
A.append(a)
B.append(b)
res = max(A)
res += min(B)
print(res)
|
s550734358
|
p04011
|
u728611988
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,060 | 165 |
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
|
n = int(input())
k = int(input())
x = int(input())
y = int(input())
ans = 0
for i in range(n+1):
if i < k:
ans += x
else:
ans += y
print(ans)
|
s254002103
|
Accepted
| 19 | 3,060 | 168 |
n = int(input())
k = int(input())
x = int(input())
y = int(input())
ans = 0
for i in range(1,n+1):
if i <= k:
ans += x
else:
ans += y
print(ans)
|
s461403314
|
p01101
|
u617401892
| 8,000 | 262,144 |
Wrong Answer
| 1,480 | 6,036 | 560 |
Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to buy the pair of two items with the highest price sum, not exceeding the amount Mammy allows. As getting two of the same item is boring, he wants two different items. You are asked to help Taro select the two items. The price list for all of the items is given. Among pairs of two items in the list, find the pair with the highest price sum not exceeding the allowed amount, and report the sum. Taro is buying two items, not one, nor three, nor more. Note that, two or more items in the list may be priced equally.
|
#!/usr/bin/env python3
n_list = []
m_list = []
a_list = []
while True:
n, m = list(map(int, input().split(' ')))
if n == 0 and m == 0:
break
a = list(map(int, input().split(' ')))
n_list.append(n)
m_list.append(m)
a_list.append(a)
for n, m, a in zip(n_list, m_list, a_list):
m_sum = 0
for i in range(0, n):
for j in range(i + 1, n):
tmp = a[i] + a[j]
if m_sum < tmp and tmp <= m:
m_sum = tmp
if m_sum > 0:
print(m_sum)
else:
print('None')
|
s639109009
|
Accepted
| 1,480 | 6,044 | 560 |
#!/usr/bin/env python3
n_list = []
m_list = []
a_list = []
while True:
n, m = list(map(int, input().split(' ')))
if n == 0 and m == 0:
break
a = list(map(int, input().split(' ')))
n_list.append(n)
m_list.append(m)
a_list.append(a)
for n, m, a in zip(n_list, m_list, a_list):
m_sum = 0
for i in range(0, n):
for j in range(i + 1, n):
tmp = a[i] + a[j]
if m_sum < tmp and tmp <= m:
m_sum = tmp
if m_sum > 0:
print(m_sum)
else:
print('NONE')
|
s419093050
|
p00001
|
u114315703
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,600 | 142 |
There is a data which provides heights (in meter) of mountains. The data is only for ten mountains. Write a program which prints heights of the top three mountains in descending order.
|
N = 10
mnts = []
for i in range(N):
mnts.append(int(input()))
mnts.sort(reverse=True)
print(mnts)
for mnt in mnts[:3]:
print(mnt)
|
s541827829
|
Accepted
| 20 | 5,600 | 130 |
N = 10
mnts = []
for i in range(N):
mnts.append(int(input()))
mnts.sort(reverse=True)
for mnt in mnts[:3]:
print(mnt)
|
s272648791
|
p03712
|
u046136258
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 177 |
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
|
# coding: utf-8
# Your code here!
h,w=map(int,input().split())
moji=[]
for i in range(h):
moji.append(input())
print('#'*w)
for s in moji:
print('#'+s+'#')
print('#'*w)
|
s736726817
|
Accepted
| 18 | 3,060 | 185 |
# coding: utf-8
# Your code here!
h,w=map(int,input().split())
moji=[]
for i in range(h):
moji.append(input())
print('#'*(w+2))
for s in moji:
print('#'+s+'#')
print('#'*(w+2))
|
s115792675
|
p03160
|
u225685297
| 2,000 | 1,048,576 |
Wrong Answer
| 129 | 14,716 | 310 |
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
|
from sys import stdin,stdout
n = int(stdin.readline())
dp = [0 for i in range(n)]
a = list(map(int,stdin.readline().split()))
dp[1] = a[1] - a[0]
for i in range(2,n):
if(abs(a[i] - a[i-1]) < abs(a[i] - a[i-2])):
dp[i] = dp[i-1] + a[i] - a[i-1]
else:
dp[i] = dp[i-2] + a[i] - a[i-2]
print(dp[-1])
|
s088340198
|
Accepted
| 138 | 14,716 | 272 |
from sys import stdin,stdout
n = int(stdin.readline())
dp = [0 for i in range(n)]
a = list(map(int,stdin.readline().split()))
dp[1] = abs(a[1] - a[0])
if(n>1):
for i in range(2,n):
dp[i] = min(dp[i-1] + abs(a[i]-a[i-1]) , dp[i-2] + abs(a[i]-a[i-2]))
print(dp[-1])
|
s394514434
|
p03696
|
u000349418
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,188 | 1,152 |
You are given a string S of length N consisting of `(` and `)`. Your task is to insert some number of `(` and `)` into S to obtain a _correct bracket sequence_. Here, a correct bracket sequence is defined as follows: * `()` is a correct bracket sequence. * If X is a correct bracket sequence, the concatenation of `(`, X and `)` in this order is also a correct bracket sequence. * If X and Y are correct bracket sequences, the concatenation of X and Y in this order is also a correct bracket sequence. * Every correct bracket sequence can be derived from the rules above. Find the shortest correct bracket sequence that can be obtained. If there is more than one such sequence, find the lexicographically smallest one.
|
N = int(input())
s=list(input())
n=0
l=0
r=0
L=[]
while n < N:
if s[n] == '(':
l+=1
if r != 0:
L.append(-1*r)
r=0
n +=1
else:
r += 1
if l != 0:
L.append(l)
l=0
n += 1
if r!=0:
L.append(-1*r)
elif l != 0:
L.append(l)
print(L)
i=0
p=0
while i<len(L):
if L[i] < 0:
ins=0
while ins < abs(L[i]):
s.insert(p,'(')
ins+=1
p += 2*abs(L[i])
i += 1
elif (i+1)<len(L):
if abs(L[i+1])>abs(L[i]):
ins=0
while ins < (abs(L[i+1])-abs(L[i])):
s.insert(p,'(')
ins += 1
p += 2*abs(L[i+1])
i += 2
elif abs(L[i])>abs(L[i+1]):
p += abs(L[i])
ins=0
while ins < (abs(L[i])-abs(L[i+1])):
s.insert(p,')')
ins+=1
p += abs(L[i])
i += 2
else:
p += abs(L[i])
i += 2
else:
ins=0
while ins < L[i]:
s.insert(-1,')')
ins+=1
i+=1
print(''.join(s))
|
s263159202
|
Accepted
| 17 | 3,064 | 331 |
n=int(input());s=input()
ans = '';v = 0;vmin = 0
for s0 in s:
if s0 == '(':
v += 1
else:
v -= 1
vmin = min(v,vmin)
left = '('; right = ')'
if vmin < 0:
ans += left*(-1*vmin)
v += (-1*vmin)
if v == 0:
ans += s
elif v > 0:
ans += s + right*v
else:
ans += left*(-1*v) + s
print(ans)
|
s868702856
|
p03731
|
u667458133
| 2,000 | 262,144 |
Wrong Answer
| 161 | 26,836 | 194 |
In a public bath, there is a shower which emits water for T seconds when the switch is pushed. If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds. N people will push the switch while passing by the shower. The i-th person will push the switch t_i seconds after the first person pushes it. How long will the shower emit water in total?
|
N, T = map(int, input().split())
t = list(map(int, input().split()))
result = T
for i in range(1, N):
if t[i]-t[i-1] < T:
result += T-t[i]+t[i-1]
else:
result += T
print(result)
|
s654261253
|
Accepted
| 148 | 26,708 | 209 |
N, T = map(int, input().split())
t = list(map(int, input().split()))
result = T
for i in range(1, N):
if t[i] - t[i-1] < T:
result += (t[i] - t[i-1])
else:
result += T
print(result)
|
s034553657
|
p03478
|
u755180064
| 2,000 | 262,144 |
Wrong Answer
| 28 | 3,060 | 279 |
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
|
n, r_from, r_to = [int(v) for v in input().split(' ')]
ans = 0
for nn in range(1, n + 1):
ad_digit = 0
tmp = nn
while True:
ad_digit += tmp % 10
tmp //= 10
if tmp == 0:
break
if r_from <= ad_digit and ad_digit <= r_to:
ans += ad_digit
print(ans)
|
s624113057
|
Accepted
| 29 | 3,060 | 278 |
n, r_from, r_to = [int(v) for v in input().split(' ')]
ans = 0
for nn in range(1, n + 1):
ad_digit = 0
tmp = nn
while True:
ad_digit += tmp % 10
tmp = tmp // 10
if tmp == 0:
break
if r_from <= ad_digit and ad_digit <= r_to:
ans += nn
print(ans)
|
s188554150
|
p03943
|
u065466683
| 2,000 | 262,144 |
Wrong Answer
| 29 | 9,104 | 187 |
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
x = list(map(int, input().split(' ')))
if x[0] == x[1] + x[2]:
print('yes')
elif x[0] + x[1] == x[2]:
print('yes')
elif x[0] + x[2] == x[1]:
print('yes')
else:
print('no')
|
s914497392
|
Accepted
| 27 | 9,084 | 187 |
x = list(map(int, input().split(' ')))
if x[0] == x[1] + x[2]:
print('Yes')
elif x[0] + x[1] == x[2]:
print('Yes')
elif x[0] + x[2] == x[1]:
print('Yes')
else:
print('No')
|
s453117685
|
p03698
|
u569776981
| 2,000 | 262,144 |
Wrong Answer
| 30 | 9,040 | 147 |
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
|
S = input()
N = len(S)
a = []
for i in range(N):
if S[i] in a:
print('No')
exit()
else:
a.append(S[i])
print('Yes')
|
s202482518
|
Accepted
| 26 | 9,052 | 147 |
S = input()
N = len(S)
a = []
for i in range(N):
if S[i] in a:
print('no')
exit()
else:
a.append(S[i])
print('yes')
|
s870407265
|
p03564
|
u905582793
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 90 |
Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value: * Operation A: The displayed value is doubled. * Operation B: The displayed value increases by K. Square1001 needs to perform these operations N times in total. Find the minimum possible value displayed in the board after N operations.
|
n=int(input())
k=int(input())
ans = 1
for i in range(n):
ans=max(2*ans,ans+k)
print(ans)
|
s404489875
|
Accepted
| 17 | 2,940 | 90 |
n=int(input())
k=int(input())
ans = 1
for i in range(n):
ans=min(2*ans,ans+k)
print(ans)
|
s385036080
|
p02603
|
u464819941
| 2,000 | 1,048,576 |
Wrong Answer
| 38 | 8,840 | 448 |
To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives. He is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows: * A_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day. In the i-th day, M-kun can make the following trade **any number of times** (possibly zero), **within the amount of money and stocks that he has at the time**. * Buy stock: Pay A_i yen and receive one stock. * Sell stock: Sell one stock for A_i yen. What is the maximum possible amount of money that M-kun can have in the end by trading optimally?
|
import math
N = int(input())
A = list(map(int, input().split()))
C = 1
m = A[0]
M = A[0]
money = 1000;
for i in range(1,N):
if C == 1 and M <= A[i]:
M = A[i]
elif C == 1 and M > A[i]:
money = (money % m) + math.floor(money / m)*M
C = 0
m = A[i]
print(money)
elif C == 0 and m >= A[i]:
m = A[i]
elif C == 0 and m < A[i]:
M = A[i]
C = 1
if C == 1:
money = (money % m) + math.floor(money / m)*M
print(money)
|
s049561835
|
Accepted
| 31 | 9,232 | 429 |
import math
N = int(input())
A = list(map(int, input().split()))
C = 1
m = A[0]
M = A[0]
money = 1000;
for i in range(1,N):
if C == 1 and M <= A[i]:
M = A[i]
elif C == 1 and M > A[i]:
money = (money % m) + math.floor(money / m)*M
C = 0
m = A[i]
elif C == 0 and m >= A[i]:
m = A[i]
elif C == 0 and m < A[i]:
M = A[i]
C = 1
if C == 1:
money = (money % m) + math.floor(money / m)*M
print(money)
|
s159360953
|
p03597
|
u211349618
| 2,000 | 262,144 |
Wrong Answer
| 32 | 8,960 | 42 |
We have an N \times N square grid. We will paint each square in the grid either black or white. If we paint exactly A squares white, how many squares will be painted black?
|
a=int(input())
b=int(input())
print(a^2-b)
|
s637960428
|
Accepted
| 25 | 9,092 | 42 |
a=int(input())
b=int(input())
print(a*a-b)
|
s258340901
|
p02396
|
u580737984
| 1,000 | 131,072 |
Time Limit Exceeded
| 40,000 | 8,408 | 201 |
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.
|
case = []
i = j = 0
while True:
num = int(input())
if num == 0:
break
case.append(num)
i += 1
while j < i:
print("Case",end=' ')
print(j+1,end=': ')
print(case[j])
|
s120983181
|
Accepted
| 110 | 8,216 | 212 |
case = []
i = j = 0
while True:
num = int(input())
if num == 0:
break
case.append(num)
i += 1
while j < i:
print("Case",end=' ')
print(j+1,end=': ')
print(case[j])
j += 1
|
s136155600
|
p03606
|
u703890795
| 2,000 | 262,144 |
Wrong Answer
| 20 | 2,940 | 105 |
Joisino is working as a receptionist at a theater. The theater has 100000 seats, numbered from 1 to 100000. According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive). How many people are sitting at the theater now?
|
N = int(input())
s = 0
for i in range(N):
l, r = map(int, input().split())
s = s + 1 + (l-r)
print(s)
|
s310018021
|
Accepted
| 20 | 2,940 | 105 |
N = int(input())
s = 0
for i in range(N):
l, r = map(int, input().split())
s = s + 1 + (r-l)
print(s)
|
s125296953
|
p03400
|
u811730180
| 2,000 | 262,144 |
Wrong Answer
| 20 | 3,444 | 310 |
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces. Find the number of chocolate pieces prepared at the beginning of the camp.
|
n = int(input())
d, x= map(int, input().split())
a = []
for i in range(n):
a.append(int(input()))
# n = 3
# d, x = 7, 1
# a = [2, 5, 10]
choco = n+x
for A in a:
j = 0
while (j+1)*A+1 <= d:
print("A:%s" % A)
print((j+1)*A+1)
choco += 1
j += 1
print(choco)
|
s616531850
|
Accepted
| 17 | 2,940 | 164 |
n = int(input())
d, x= map(int, input().split())
a = []
for i in range(n):
a.append(int(input()))
c = n+x
for A in a:
c += int((d-1)/A)
print(c)
|
s294042881
|
p02603
|
u331390010
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 9,028 | 278 |
To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives. He is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows: * A_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day. In the i-th day, M-kun can make the following trade **any number of times** (possibly zero), **within the amount of money and stocks that he has at the time**. * Buy stock: Pay A_i yen and receive one stock. * Sell stock: Sell one stock for A_i yen. What is the maximum possible amount of money that M-kun can have in the end by trading optimally?
|
N = int(input())
A = list(map(int, input().split()))
M = 1000
X = 0
for i in range(N-1):
if A[i] < A[i+1]:
X = int(M/A[i])
M = M - X * A[i]
elif A[i] > A[i+1]:
M = M + A[i] * X
X = 0
if X > 0:
M = M + X * A[N-1]
print(M,X)
|
s494547733
|
Accepted
| 35 | 9,184 | 222 |
N = int(input())
A = list(map(int, input().split()))
M = 1000
X = 0
for i in range(N-1):
if A[i] < A[i+1]:
X = int(M/A[i])
M = int(M - X * A[i])
M = M + X * A[i+1]
X = 0
print(int(M))
|
s547166243
|
p02647
|
u111652094
| 2,000 | 1,048,576 |
Wrong Answer
| 2,206 | 32,292 | 323 |
We have N bulbs arranged on a number line, numbered 1 to N from left to right. Bulb i is at coordinate i. Each bulb has a non-negative integer parameter called intensity. When there is a bulb of intensity d at coordinate x, the bulb illuminates the segment from coordinate x-d-0.5 to x+d+0.5. Initially, the intensity of Bulb i is A_i. We will now do the following operation K times in a row: * For each integer i between 1 and N (inclusive), let B_i be the number of bulbs illuminating coordinate i. Then, change the intensity of each bulb i to B_i. Find the intensity of each bulb after the K operations.
|
N,K=map(int,input().split())
A=list(map(int,input().split()))
B=[0]*N
sousa=0
while sousa<K:
for i in range(N):
ma=i+A[i]+1
if ma>N:
ma=N
mi=i-A[i]
if mi<0:
mi=0
for j in range(mi,ma):
B[j]+=1
A=list(B)
B=[0]*N
sousa+=1
print(A)
|
s081725707
|
Accepted
| 1,468 | 51,476 | 362 |
import numpy as np
N,K=map(int,input().split())
A=list(map(int,input().split()))
B=np.zeros(shape=N+1,dtype=np.int64)
C=np.arange(0,N)
sousa=0
kaisuu=min(K,42)
while sousa<kaisuu:
np.add.at(B, np.maximum(0,C-A),1)
np.add.at(B,np.minimum(N,C+A+1),-1)
A = B.cumsum()[:-1]
sousa+=1
B *= 0
A=[str(k) for k in A]
print(" ".join(A))
|
s376887429
|
p03545
|
u694810977
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 441 |
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
|
S = str(input())
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])
lists = [A,B,C,D]
lists.sort(reverse=True)
ans = lists[0]
lists_2 = [lists[1],lists[2],lists[3]]
op_list = []
for i in lists_2:
if ans < 7:
ans += i
op_list.append("+")
else:
ans -= i
op_list.append("-")
print(str(lists[0]) + op_list[0] + str(lists[1]) + op_list[1] + str(lists[2]) + op_list[2] + str(lists[3]) + "=" + str(ans))
|
s437825103
|
Accepted
| 17 | 3,064 | 745 |
s = str(input())
n = len(s)
lists = []
ans_list = []
Sum = 0
for i in range(2**n):
lists = []
ans_list = []
Sum = int(s[0])
for j in range(n-1):
if ((i >> j) & 1):
lists.append(1)
else:
lists.append(0)
for k in range(n-1):
ans_list.append(s[k])
if lists[k] == 1:
ans_list.append("+")
else:
ans_list.append("-")
ans_list.append(s[-1])
for l in range(1,len(ans_list) -1 ):
if ans_list[l] == "+":
Sum += int(ans_list[l+1])
elif ans_list[l] == "-":
Sum -= int(ans_list[l+1])
if Sum == 7:
ans_list.append("=7")
ans = "".join(ans_list)
print(ans)
exit()
|
s811269551
|
p02928
|
u234636620
| 2,000 | 1,048,576 |
Wrong Answer
| 2,112 | 22,316 | 722 |
We have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}. Let B be a sequence of K \times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2. Find the inversion number of B, modulo 10^9 + 7. Here the inversion number of B is defined as the number of ordered pairs of integers (i,~j)~(0 \leq i < j \leq K \times N - 1) such that B_i > B_j.
|
import numpy as np
import sys
from functools import lru_cache
def main():
count = 0
n,k = map(int, input().split(' '))
a = [i for i in map(int, input().split(' '))]
for i in range(n):
moto = a[i]
for j in range(n):
if i == j:
continue
if moto > a[j]:
print(i,j)
if i > j:
plus = int(k*(k-1)/2)
count += plus
elif i < j:
plus = int(k*(k+1)/2)
count += plus
count = count%(10**9+7)
print(int(count))
if __name__ == '__main__':
main()
|
s703232959
|
Accepted
| 572 | 13,412 | 587 |
import numpy as np
import random
import sys
from functools import lru_cache
def main(n,k,a):
mod = 10**9 + 7
c1,c2 = 0,0
for i in range(len(a)):
for j in range(len(a)):
# print('--- ---', i,j)
if a[i] > a[j]:
if i < j:
c1 += 1
elif i > j:
c2 += 1
count = (c1*k*(k+1)//2 + c2*k*(k-1)//2)%mod
print(count)
if __name__ == '__main__':
n,k = map(int,input().split(' '))
a = list(map(int, input().split(' ')))
main(n,k,a)
|
s970611206
|
p02744
|
u572026348
| 2,000 | 1,048,576 |
Wrong Answer
| 234 | 18,332 | 724 |
In this problem, we only consider strings consisting of lowercase English letters. Strings s and t are said to be **isomorphic** when the following conditions are satisfied: * |s| = |t| holds. * For every pair i, j, one of the following holds: * s_i = s_j and t_i = t_j. * s_i \neq s_j and t_i \neq t_j. For example, `abcac` and `zyxzx` are isomorphic, while `abcac` and `ppppp` are not. A string s is said to be in **normal form** when the following condition is satisfied: * For every string t that is isomorphic to s, s \leq t holds. Here \leq denotes lexicographic comparison. For example, `abcac` is in normal form, but `zyxzx` is not since it is isomorphic to `abcac`, which is lexicographically smaller than `zyxzx`. You are given an integer N. Print all strings of length N that are in normal form, in lexicographically ascending order.
|
import collections
def main():
n = int(input())
# if n == 1:
# print("a")
# bin_str = "0" + format(i, f'0{n-1}b')
# print(bin_str.replace("0", "a").replace("1", "b"))
ret = [[] for _ in range(10)]
ret[0] = ["a"]
alp = "abcdefghijklmnopqrstuvwxyz"
if n == 1:
print(ret[n-1])
return
ind = 1
while ind < n:
tmp_len = len(ret[ind-1])
for j, _r in enumerate(ret[ind-1]):
alphabet_num = len(collections.Counter(_r))
for k in range(alphabet_num+1):
ret[ind].append(_r+alp[k])
ind += 1
print(ret[n-1])
return
if __name__ == '__main__':
main()
|
s476764573
|
Accepted
| 264 | 14,852 | 748 |
import collections
def main():
n = int(input())
# if n == 1:
# print("a")
# bin_str = "0" + format(i, f'0{n-1}b')
# print(bin_str.replace("0", "a").replace("1", "b"))
ret = [[] for _ in range(10)]
ret[0] = ["a"]
alp = "abcdefghijklmnopqrstuvwxyz"
if n == 1:
print(ret[n-1][0])
return
ind = 1
while ind < n:
tmp_len = len(ret[ind-1])
for j, _r in enumerate(ret[ind-1]):
alphabet_num = len(collections.Counter(_r))
for k in range(alphabet_num+1):
ret[ind].append(_r+alp[k])
ind += 1
for r in ret[n-1]:
print(r)
return
if __name__ == '__main__':
main()
|
s517783599
|
p03160
|
u969639186
| 2,000 | 1,048,576 |
Wrong Answer
| 131 | 20,576 | 305 |
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
|
N = int(input())
H = list(map(int,input().split()))
DP = [float('inf')]*N
DP[0] = 0
DP[1] = abs(H[1] - H[0])
for i in range(2,N):
one_step = DP[i-1] + abs(H[i]-H[i-1])
two_step = DP[i-2] + abs(H[i]-H[i-2])
DP[i] = min(one_step,two_step)
print(DP)
print(DP[N-1])
|
s977918065
|
Accepted
| 123 | 20,572 | 295 |
N = int(input())
H = list(map(int,input().split()))
DP = [float('inf')]*N
DP[0] = 0
DP[1] = abs(H[1] - H[0])
for i in range(2,N):
one_step = DP[i-1] + abs(H[i]-H[i-1])
two_step = DP[i-2] + abs(H[i]-H[i-2])
DP[i] = min(one_step,two_step)
print(DP[N-1])
|
s418836546
|
p02399
|
u737311644
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,604 | 75 |
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
|
a,b=map(int,input().split())
d=str(a//b)
r=str(a%b)
f=str(a/b)
print(d,r,f)
|
s260745531
|
Accepted
| 20 | 5,608 | 80 |
a,b= map(int, input().split())
d=a//b
r=a%b
f=a/b
print(d,r,"{0:.5f}".format(f))
|
s164964805
|
p03408
|
u506858457
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 188 |
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen. Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.) At most how much can he earn on balance? Note that the same string may be written on multiple cards.
|
N=int(input())
n=[input() for _ in range(N)]
M=int(input())
m=[input() for _ in range(M)]
l=list(set(n))
ans=0
for i in range(len(l)):
ans+=n.count(l[i])
ans-=m.count(l[i])
print(ans)
|
s877620408
|
Accepted
| 17 | 3,064 | 221 |
N=int(input())
n=[input() for _ in range(N)]
M=int(input())
m=[input() for _ in range(M)]
l=list(set(n))
ans=0
for i in range(len(l)):
tmp=0
tmp+=n.count(l[i])
tmp-=m.count(l[i])
ans=max(ans,tmp)
print(max(ans,0))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.