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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s696247866
|
p03475
|
u589969467
| 3,000 | 262,144 |
Wrong Answer
| 31 | 9,356 | 462 |
A railroad running from west to east in Atcoder Kingdom is now complete. There are N stations on the railroad, numbered 1 through N from west to east. Tomorrow, the opening ceremony of the railroad will take place. On this railroad, for each integer i such that 1≤i≤N-1, there will be trains that run from Station i to Station i+1 in C_i seconds. No other trains will be operated. The first train from Station i to Station i+1 will depart Station i S_i seconds after the ceremony begins. Thereafter, there will be a train that departs Station i every F_i seconds. Here, it is guaranteed that F_i divides S_i. That is, for each Time t satisfying S_i≤t and t%F_i=0, there will be a train that departs Station i t seconds after the ceremony begins and arrives at Station i+1 t+C_i seconds after the ceremony begins, where A%B denotes A modulo B, and there will be no other trains. For each i, find the earliest possible time we can reach Station N if we are at Station i when the ceremony begins, ignoring the time needed to change trains.
|
def jikan(now_t,i):
if i==n:
return now_t
else:
if now_t<=s[i]:
now_t = s[i]
else:
tmp1 = now_t//f[i]
if now_t%f[i]!=0:
now_t = (tmp1+1)*f[i]
tmp = jikan(now_t+c[i],i+1)
return tmp
n = int(input())
c,s,f = [0],[0],[0]
for i in range(n-1):
ci,si,fi = map(int,input().split())
c.append(ci)
s.append(si)
f.append(fi)
#print(c,s,f)
print(jikan(0,1))
|
s745580115
|
Accepted
| 75 | 9,276 | 490 |
def jikan(now_t,i):
if i==n:
return now_t
else:
if now_t<=s[i]:
now_t = s[i]
else:
tmp1 = now_t//f[i]
if now_t%f[i]!=0:
now_t = (tmp1+1)*f[i]
tmp = jikan(now_t+c[i],i+1)
return tmp
n = int(input())
c,s,f = [0],[0],[0]
for i in range(n-1):
ci,si,fi = map(int,input().split())
c.append(ci)
s.append(si)
f.append(fi)
#print(c,s,f)
for i in range(1,n+1):
print(jikan(0,i))
|
s476684259
|
p03007
|
u463655976
| 2,000 | 1,048,576 |
Wrong Answer
| 181 | 14,648 | 740 |
There are N integers, A_1, A_2, ..., A_N, written on a blackboard. We will repeat the following operation N-1 times so that we have only one integer on the blackboard. * Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y. Find the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.
|
from collections import deque
N = int(input())
a = deque(sorted(map(int, input().split())))
max_a = a.pop()
min_a = a.popleft()
ans_s = ""
while True:
if len(a) <= 0:
ans = max_a - min_a
ans_s += "{} {}\n".format(max_a, min_a)
break
if max_a <= 0:
max_a -= min_a
ans_s += "{} {}\n".format(max_a, min_a)
min_a = a.popleft()
elif min_a >= 0:
min_a -= max_a
ans_s += "{} {}\n".format(min_a, max_a)
max_a = a.pop()
else:
w = a.pop()
if w < 0:
max_a -= w
ans_s += "{} {}\n".format(max_a, w)
else:
min_a -= w
ans_s += "{} {}\n".format(min_a, w)
print(ans)
print(ans_s, end="")
|
s564554435
|
Accepted
| 179 | 14,648 | 740 |
from collections import deque
N = int(input())
a = deque(sorted(map(int, input().split())))
max_a = a.pop()
min_a = a.popleft()
ans_s = ""
while True:
if len(a) <= 0:
ans_s += "{} {}\n".format(max_a, min_a)
ans = max_a - min_a
break
if max_a <= 0:
ans_s += "{} {}\n".format(max_a, min_a)
max_a -= min_a
min_a = a.popleft()
elif min_a >= 0:
ans_s += "{} {}\n".format(min_a, max_a)
min_a -= max_a
max_a = a.pop()
else:
w = a.pop()
if w < 0:
ans_s += "{} {}\n".format(max_a, w)
max_a -= w
else:
ans_s += "{} {}\n".format(min_a, w)
min_a -= w
print(ans)
print(ans_s, end="")
|
s737728353
|
p03024
|
u002459665
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 74 |
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day. Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
|
S = input()
if S.count('o') >= 8:
print('YES')
else:
print('NO')
|
s259020048
|
Accepted
| 17 | 2,940 | 85 |
S = input()
N = len(S)
if S.count('x') <= 7:
print('YES')
else:
print('NO')
|
s954976094
|
p03433
|
u871596687
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 107 |
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())
A = int(input())
if (A <= N%500) and (N%500 <= A):
print("Yes")
else:
print("No")
|
s112839733
|
Accepted
| 17 | 2,940 | 93 |
N = int(input())
A = int(input())
if N%500 <= A:
print("Yes")
else:
print("No")
|
s081862258
|
p00586
|
u814278309
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,580 | 40 |
Compute A + B.
|
a,b=map(int,input().split())
print(a+b)
|
s781457300
|
Accepted
| 20 | 5,584 | 102 |
while 1:
try:
a,b = map(int,input().split())
print(a+b)
except:
break
|
s994684352
|
p03565
|
u519923151
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 475 |
E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One more thing he found is a sheet of paper with the following facts written on it: * Condition 1: The string S contains a string T as a contiguous substring. * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1. Print the string S. If such a string does not exist, print `UNRESTORABLE`.
|
s = input()
t = input()
x = "UNRESTORABLE"
sl = len(s)
tl = len(t)
if sl < tl:
print(x)
exit()
flag =0
for i in range(sl-tl,-1,-1):
temp = s[i:i+tl]
print(temp)
for j in range(tl):
if temp[j] == t[j] or temp[j] =="?":
if j == tl-1:
x = s[:i] + t + s[i+tl:]
flag = 1
break
else:
break
if flag ==1:
break
x = x.replace("?","a")
print(x)
|
s257991202
|
Accepted
| 17 | 3,064 | 459 |
s = input()
t = input()
x = "UNRESTORABLE"
sl = len(s)
tl = len(t)
if sl < tl:
print(x)
exit()
flag =0
for i in range(sl-tl,-1,-1):
temp = s[i:i+tl]
for j in range(tl):
if temp[j] == t[j] or temp[j] =="?":
if j == tl-1:
x = s[:i] + t + s[i+tl:]
flag = 1
break
else:
break
if flag ==1:
break
x = x.replace("?","a")
print(x)
|
s317193541
|
p00038
|
u150984829
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,608 | 301 |
ポーカーの手札データを読み込んで、それぞれについてその役を出力するプログラムを作成してください。ただし、この問題では、以下のルールに従います。 * ポーカーはトランプ 5 枚で行う競技です。 * 同じ数字のカードは 5 枚以上ありません。 * ジョーカーは無いものとします。 * 以下のポーカーの役だけを考えるものとします。(番号が大きいほど役が高くなります。) 1. 役なし(以下に挙げるどれにも当てはまらない) 2. ワンペア(2 枚の同じ数字のカードが1 組ある) 3. ツーペア(2 枚の同じ数字のカードが2 組ある) 4. スリーカード(3 枚の同じ数字のカードが1 組ある) 5. ストレート(5 枚のカードの数字が連続している) ただし、A を含むストレートの場合、A で終わる並びもストレートとします。つまり、A を含むストレート は、A 2 3 4 5 と 10 J Q K A の2種類です。J Q K A 2 などのように、A をまたぐ並び はストレートではありません。(この場合、「役なし」になります)。 6. フルハウス(3 枚の同じ数字のカードが1 組と、残りの2 枚が同じ数字のカード) 7. フォーカード(4 枚の同じ数字のカードが1 組ある)
|
import sys
for e in sys.stdin:
c=[list(map(int,e.split(','))).count(i+1)for i in range(13)];d=c+c
print('four card'if 4 in c else'full house'if 2 in c else'three card'if 3 in c else'two pair'if c.count(2)-1 else'one pair'if 2 in c else'straight'if sum([1]*5==d[i:i+5]for i in range(10)) else'null')
|
s781942829
|
Accepted
| 20 | 5,608 | 215 |
import sys
for e in sys.stdin:
e=sorted(map(int,e.split(',')))
print([['null','straight'][e[0]*9<e[1]or e[4]-e[0]<5],'one pair','two pair','three card','full house',0,'four card'][sum(e.count(s)for s in e)//2-2])
|
s504278326
|
p02390
|
u775586391
| 1,000 | 131,072 |
Wrong Answer
| 50 | 7,660 | 99 |
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
|
s = int(input())
a = s % 60
b = s // 60
c = b % 60
d = b // 60
print(str(a)+':'+str(c)+':'+str(d))
|
s066228738
|
Accepted
| 70 | 7,652 | 101 |
S = int(input())
s = S % 60
m1 = S // 60
m = m1 % 60
h = m1 // 60
print(str(h)+':'+str(m)+':'+str(s))
|
s454062597
|
p03095
|
u597455618
| 2,000 | 1,048,576 |
Wrong Answer
| 32 | 9,228 | 117 |
You are given a string S of length N. Among its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings. Here, a subsequence of a string is a concatenation of **one or more** characters from the string without changing the order.
|
n = int(input())
s = input()
ans = 1
for x in set(s):
ans *= s.count(x)+1
print(ans)
print((ans-1)%(10**9+7))
|
s788123764
|
Accepted
| 30 | 9,196 | 102 |
n = int(input())
s = input()
ans = 1
for x in set(s):
ans *= s.count(x)+1
print((ans-1)%(10**9+7))
|
s963038246
|
p03457
|
u082704159
| 2,000 | 262,144 |
Wrong Answer
| 328 | 3,060 | 160 |
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
|
n = int(input())
for i in range(n):
t,x,y = map(int, input().split())
if (x + y) > t or (x + y + t) % 2:
print("NO")
exit()
print("YES")
|
s384900535
|
Accepted
| 329 | 3,060 | 147 |
n = int(input())
for i in range(n):
t,x,y = map(int,input().split())
if (x + y) > t or (x + y + t) % 2:
print("No")
exit()
print("Yes")
|
s838701790
|
p03457
|
u985596066
| 2,000 | 262,144 |
Wrong Answer
| 386 | 11,636 | 387 |
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
|
N = int(input())
t = [0] * N
x = [0] * N
y = [0] * N
for i in range(N):
t[i], x[i] ,y[i]=map (int, input().split(' '))
ox = 0
oy = 0
ot =0
for i in range(N):
dt=t[i] - ot
d = abs(x[i] - ox) + abs(y[i] - oy)
if d > abs(dt):
print('No')
exit()
if d%2!= dt%2:
print('No')
exit()
ox=x[i]
oy=y[i]
ot=t[i]
print('OK')
|
s877122233
|
Accepted
| 386 | 11,636 | 389 |
N = int(input())
t = [0] * N
x = [0] * N
y = [0] * N
for i in range(N):
t[i], x[i] ,y[i]=map (int, input().split(' '))
ox = 0
oy = 0
ot =0
for i in range(N):
dt=t[i] - ot
d = abs(ox - x[i]) + abs(oy - y[i])
if dt - d < 0:
print('No')
exit()
if (dt-d)%2 > 0:
print('No')
exit()
ox=x[i]
oy=y[i]
ot=t[i]
print('Yes')
|
s830506573
|
p02842
|
u068142202
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 2,940 | 83 |
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer). Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer. If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.
|
n = int(input())
x = n / 1.08
if int(x * 1.08) == n:
print(x)
else:
print(":(")
|
s983396068
|
Accepted
| 17 | 2,940 | 113 |
import math
n = int(input())
X = math.ceil(n / 1.08)
if math.floor(X * 1.08) == n:
print(X)
else:
print(":(")
|
s950077286
|
p03795
|
u032189172
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 79 |
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
|
from math import factorial
N = int(input())
P = factorial(N)
print(P%(10**9+7))
|
s854747664
|
Accepted
| 17 | 2,940 | 53 |
N = int(input())
x = 800*N
y = 200*(N//15)
print(x-y)
|
s382881252
|
p02536
|
u366558796
| 2,000 | 1,048,576 |
Wrong Answer
| 290 | 25,476 | 196 |
There are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: * Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?
|
n, m = map(int ,input().split())
graph = [[] for _ in range(n)]
for i in range(m):
a,b = map(int, input().split())
graph[a-1].append(b-1)
graph[b-1].append(a-1)
val = n*(n-1)//2
print(val-m)
|
s396788803
|
Accepted
| 344 | 26,652 | 449 |
from collections import deque
n, m = map(int ,input().split())
graph = [[] for _ in range(n)]
for i in range(m):
a,b = map(int, input().split())
graph[a-1].append(b-1)
graph[b-1].append(a-1)
v = [0]*n
ans = 0
for i in range(n):
if v[i] == 0:
ans += 1
q = deque()
q.append(i)
v[i] = 1
while q:
node = q.popleft()
for j in graph[node]:
if v[j] == 0:
q.append(j)
v[j] = 1
print(ans-1)
|
s625901764
|
p03565
|
u169501420
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 829 |
E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One more thing he found is a sheet of paper with the following facts written on it: * Condition 1: The string S contains a string T as a contiguous substring. * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1. Print the string S. If such a string does not exist, print `UNRESTORABLE`.
|
# -*- coding: utf-8 -*-
S_dash = input()
T = input()
S_dash_list = list(S_dash)
T_list = list(T)
ei = len(S_dash_list)
si = ei - len(T_list)
insert_flag = False
while si >= 0:
print('si: {}, ei: {}'.format(si, ei))
target = S_dash_list[si:ei]
flag = True
print(S_dash_list[si:ei])
for i in range(len(T_list)):
if S_dash_list[si + i] != T_list[i] and S_dash_list[si + i] != '?':
flag = False
break
if flag:
for i in range(len(T_list)):
S_dash_list[si + i] = T_list[i]
insert_flag = True
break
else:
ei = si
si = si - len(T_list)
if not insert_flag:
print('UNRESTORABLE')
else:
ans = ''.join(S_dash_list)
print(ans)
print(ans.replace('?', 'a'))
|
s308045946
|
Accepted
| 17 | 3,064 | 822 |
# -*- coding: utf-8 -*-
S_dash = input()
T = input()
S_dash_list = list(S_dash)
T_list = list(T)
ei = len(S_dash_list)
si = ei - len(T_list)
insert_flag = False
while si >= 0:
target = S_dash_list[si:ei]
flag = True
for i in reversed(range(len(T_list))):
if S_dash_list[si + i] != T_list[i] and S_dash_list[si + i] != '?':
flag = False
ei -= 1
si = ei - len(T_list)
break
if flag:
for i in range(len(T_list)):
S_dash_list[si + i] = T_list[i]
insert_flag = True
break
if not insert_flag:
print('UNRESTORABLE')
else:
ans = ''.join(S_dash_list)
#print(ans)
print(ans.replace('?', 'a'))
|
s605769422
|
p03433
|
u102242691
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 98 |
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())
A = int(input())
if (N - A) % 500 == 0:
print("Yes")
else:
print("No")
|
s990974227
|
Accepted
| 17 | 2,940 | 94 |
N = int(input())
A = int(input())
if (N % 500) <= A:
print("Yes")
else:
print("No")
|
s406563879
|
p02411
|
u027634846
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,808 | 672 |
Write a program which reads a list of student test scores and evaluates the performance for each student. The test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examination r (out of 100). If the student does not take the examination, the score is indicated by -1. The final performance of a student is evaluated by the following procedure: * If the student does not take the midterm or final examination, the student's grade shall be F. * If the total score of the midterm and final examination is greater than or equal to 80, the student's grade shall be A. * If the total score of the midterm and final examination is greater than or equal to 65 and less than 80, the student's grade shall be B. * If the total score of the midterm and final examination is greater than or equal to 50 and less than 65, the student's grade shall be C. * If the total score of the midterm and final examination is greater than or equal to 30 and less than 50, the student's grade shall be D. However, if the score of the makeup examination is greater than or equal to 50, the grade shall be C. * If the total score of the midterm and final examination is less than 30, the student's grade shall be F.
|
scores = []
while True:
score = list(map(int, input().split()))
if score[0] == -1 and score[1] == -1 and score[2] == -1:
break
else:
scores.append(score)
print(scores)
for i in scores:
mid_exam = i[0]
final_exam = i[1]
re_exam = i[2]
total = i[0] + i[1]
if mid_exam == -1 or final_exam == -1:
print("F")
elif total >= 80:
print("A")
elif total in range(65, 80):
print("B")
elif total in range(50, 65):
print("C")
elif total < 30:
print("F")
elif total in range(30, 50):
if re_exam >= 50:
print("C")
else:
print("D")
|
s266742914
|
Accepted
| 20 | 7,732 | 644 |
scores = []
while True:
score = list(map(int, input().split()))
if score[0] == -1 and score[1] == -1 and score[2] == -1:
break
else:
scores.append(score)
for i in scores:
mid_exam = i[0]
final_exam = i[1]
re_exam = i[2]
total = i[0] + i[1]
if mid_exam == -1 or final_exam == -1:
print("F")
elif total >= 80:
print("A")
elif total in range(65, 80):
print("B")
elif total in range(50, 65):
print("C")
elif 30 <= total < 50:
if re_exam >= 50:
print("C")
else:
print("D")
elif total < 30:
print("F")
|
s363911707
|
p03493
|
u752552310
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 34 |
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
|
a = input()
print(a.count == "1")
|
s640129967
|
Accepted
| 26 | 8,972 | 30 |
a=input()
print(a.count("1"))
|
s435590848
|
p03380
|
u578462133
| 2,000 | 262,144 |
Wrong Answer
| 217 | 15,196 | 305 |
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.
|
n = int(input())
a = [0]*n
a = list(map(int, input().split()))
a.sort()
hoge = a[n-1] / 2 - a[0]
ans = 0
for i in range(n-1):
print(abs(a[n-1] / 2 - a[i+1]))
if abs(a[n-1] / 2 - a[i+1]) > hoge:
ans = i
break
else:
hoge = abs(a[n-1] / 2 - a[i+1])
print(a[n-1], a[ans])
|
s518060555
|
Accepted
| 117 | 15,196 | 270 |
n = int(input())
a = [0]*n
a = list(map(int, input().split()))
a.sort()
hoge = a[n-1] / 2 - a[0]
ans = 0
for i in range(n-1):
if abs(a[n-1] / 2 - a[i+1]) > hoge:
ans = i
break
else:
hoge = abs(a[n-1] / 2 - a[i+1])
print(a[n-1], a[ans])
|
s163903046
|
p02612
|
u418826171
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 9,148 | 30 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
N = int(input())
print(N%1000)
|
s845774709
|
Accepted
| 30 | 9,144 | 39 |
N = int(input())
print((10000-N)%1000)
|
s657146910
|
p03565
|
u392319141
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 559 |
E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One more thing he found is a sheet of paper with the following facts written on it: * Condition 1: The string S contains a string T as a contiguous substring. * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1. Print the string S. If such a string does not exist, print `UNRESTORABLE`.
|
S = input()
T = input()
for i in range(len(S)) :
if i + len(T) >= len(S) :
print('UNRESTORABLE')
break
for j, t in enumerate(T) :
if S[i + j] != t and S[i + j] != '?':
break
else :
for s in S[:i] :
if s == '?' :
print('a', end='')
else :
print(s, end='')
print(T, end='')
for s in S[i + len(T) + 1:] :
print(s, end='')
print('')
break
else :
print('UNRESTORABLE')
|
s469721020
|
Accepted
| 17 | 3,060 | 341 |
S = input()
T = input()
ans = []
for l in range(len(S) - len(T) + 1):
U = S[l: l + len(T)]
for u, t in zip(U, T):
if u == '?':
continue
if u != t:
break
else:
ans.append((S[:l] + T + S[l + len(T):]).replace('?', 'a'))
ans.sort()
print(ans[0] if len(ans) > 0 else 'UNRESTORABLE')
|
s243164763
|
p03024
|
u635949425
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 184 |
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day. Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
|
X= input('')
Y=0
Z=0
for i in range(len(X)):
c = X[i]
if c == "o" :
Y += 1
elif c == 'x' :
Z += 1
if Z >= 8 :
print("NO")
elif Y >= 8 :
print("YES")
|
s833846139
|
Accepted
| 17 | 3,060 | 177 |
X= input('')
Y=0
Z=0
for i in range(len(X)):
c = X[i]
if c == "o" :
Y += 1
elif c == 'x' :
Z += 1
if Z >= 8 :
print("NO")
else :
print("YES")
|
s119401295
|
p02612
|
u118760114
| 2,000 | 1,048,576 |
Wrong Answer
| 33 | 9,136 | 31 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
N = int(input())
print(N%1000)
|
s073579542
|
Accepted
| 29 | 9,108 | 73 |
N = int(input())
if N%1000==0:
print(0)
else:
print(1000-N%1000)
|
s472572564
|
p02613
|
u655048024
| 2,000 | 1,048,576 |
Wrong Answer
| 168 | 9,204 | 305 |
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())
jud = [0,0,0,0]
for i in range(N):
s = str(input())
if(s == "AC"):
jud[0]+=1
elif(s == "WA"):
jud[1] += 1
elif(s == "TLE"):
jud[2]+=1
else:
jud[3]+=1
print("AC x" +str(jud[0]))
print("WA x" +str(jud[1]))
print("TLE x" +str(jud[2]))
print("RE x" + str(jud[3]))
|
s518965099
|
Accepted
| 162 | 9,200 | 310 |
N = int(input())
jud = [0,0,0,0]
for i in range(N):
s = str(input())
if(s == "AC"):
jud[0]+=1
elif(s == "WA"):
jud[1] += 1
elif(s == "TLE"):
jud[2]+=1
else:
jud[3]+=1
print("AC x " +str(jud[0]))
print("WA x " +str(jud[1]))
print("TLE x " +str(jud[2]))
print("RE x " + str(jud[3]))
|
s292943641
|
p03854
|
u469254913
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,188 | 274 |
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
|
S = input()
while 'eraser' in S:
S = S.replace('eraser','')
while 'erase' in S:
S = S.replace('erase','')
while 'dreamer' in S:
S = S.replace('dreamer','')
while 'dream' in S:
S = S.replace('dream','')
if S == '':
print('Yes')
else:
print('No')
|
s351721030
|
Accepted
| 106 | 3,448 | 691 |
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
def main():
S = input().rstrip()
words = ['dream','dreamer','erase','eraser']
res = 'YES'
pre = S
now = S
while True:
for i in range(4):
word = words[i]
N = len(word)
M = len(now)
if N <= M:
r = now[M-N:]
if r == word:
now = now[:M-N]
if now == '':
break
elif now == pre:
res = 'NO'
break
else:
pre = now
print(res)
main()
|
s880948120
|
p00036
|
u811733736
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,408 | 1,698 |
縦 8、横 8 のマスからなる図 1 のような平面があります。 □| □| □| □| □| □| □| □ ---|---|---|---|---|---|---|--- □| □| □| □| □| □| □| □ □| □| □| □| □| □| □| □ □| □| □| □| □| □| □| □ □| □| □| □| □| □| □| □ □| □| □| □| □| □| □| □ □| □| □| □| □| □| □| □ □| □| □| □| □| □| □| □ 図1 --- この平面上に、以下の A から G の図形のどれかが一つだけ置かれています。 | A --- ■| ■| | ---|---|---|--- ■| ■| | | | | | | | | B --- | ■| | ---|---|---|--- | ■| | | ■| | | ■| | | C --- ■| ■| ■| ■ ---|---|---|--- | | | | | | | | | | D --- | ■| | ---|---|---|--- ■| ■| | ■| | | | | | | E --- ■| ■| | ---|---|---|--- | ■| ■| | | | | | | | F --- ■| | | ---|---|---|--- ■| ■| | | ■| | | | | | G --- | ■| ■| ---|---|---|--- ■| ■| | | | | | | | たとえば、次の図 2 の例では E の図形が置かれています。 | □| □| □| □| □| □| □| □ ---|---|---|---|---|---|---|--- □| □| □| □| □| □| □| □ □| ■| ■| □| □| □| □| □ □| □| ■| ■| □| □| □| □ □| □| □| □| □| □| □| □ □| □| □| □| □| □| □| □ □| □| □| □| □| □| □| □ □| □| □| □| □| □| □| □ 図2 --- 平面の中で図形が占めているマスを 1、占めていないマスを 0 で表現した数字の列を読み込んで、置かれている図形の種類(A〜G)を出力するプログラムを作成してください。 ただし、ひとつの平面に置かれている図形は必ず1つで、複数の図形が置かれていることはありません。また、A〜G で表される図形以外のものが置かれていることはありません。
|
import sys
def analyze_figure(data):
for i, row in enumerate(data):
if '1' not in row:
continue
dot = row.count('1')
if dot == 1: # B, D, F???????????????
x = row.index('1')
try:
if data[i+2][x] == '1':
return 'B'
elif data[i+1][x+1] == '1':
return 'F'
else:
return 'D'
except IndexError:
return None
else: # A, C, E, G???????????????
x = row.index('1')
try:
if data[i][x+2] == '1':
return 'C'
elif data[i+1][x] == '0':
return 'E'
elif data[i+1][x+1] == '1':
return 'A'
else:
return 'G'
except IndexError:
return None
if __name__ == '__main__':
data = []
for line in sys.stdin:
if '0' in line or '1' in line:
data.append(line.strip())
continue
# data.append('00000000')
# data.append('00000000')
# data.append('00000000')
# data.append('00000000')
# data.append('00000000')
# data.append('00000000')
# data.append('00000000')
# data.append('00000000')
# ???????????????
ans = analyze_figure(data)
if ans:
print(ans)
data = []
|
s038252632
|
Accepted
| 30 | 7,488 | 1,826 |
import sys
def analyze_figure(data):
for i, row in enumerate(data):
if '1' not in row:
continue
dot = row.count('1')
if dot == 1: # B, D, F???????????????
x = row.index('1')
try:
if data[i+2][x] == '1':
return 'B'
elif data[i+1][x+1] == '1':
return 'F'
else:
return 'D'
except IndexError:
return None
else: # A, C, E, G???????????????
x = row.index('1')
try:
if data[i][x+2] == '1':
return 'C'
elif data[i+1][x] == '0':
return 'E'
elif data[i+1][x+1] == '1':
return 'A'
else:
return 'G'
except IndexError:
return None
if __name__ == '__main__':
data = []
for line in sys.stdin:
t = line.strip()
if t:
t = '00' + t + '00'
data.append(t)
# data.append('00000000')
# data.append('00000000')
# data.append('00000000')
# data.append('00000000')
# data.append('00000000')
# data.append('00000000')
# data.append('00000000')
# data.append('00000000')
# ???????????????
if len(data) == 8:
data.append('000000000000')
data.append('000000000000')
ans = analyze_figure(data)
if ans:
print(ans)
data = []
|
s868594070
|
p02612
|
u834224054
| 2,000 | 1,048,576 |
Wrong Answer
| 26 | 9,140 | 31 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
N = int(input())
print(1000-N)
|
s948146836
|
Accepted
| 29 | 9,152 | 91 |
N = int(input())
if not N%1000==0:
p = N//1000+1
else:
p = N//1000
print(p*1000-N)
|
s558830926
|
p02613
|
u720119376
| 2,000 | 1,048,576 |
Wrong Answer
| 153 | 16,308 | 248 |
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())
l = []
for i in range(N):
text = input()
l.append(text)
print("AC" + " x " + str(l.count("AC")))
print("AC" + " x " + str(l.count("WA")))
print("TLE" + " x " + str(l.count("TLE")))
print("RE" + " x " + str(l.count("RE")))
|
s271582546
|
Accepted
| 156 | 16,224 | 248 |
N = int(input())
l = []
for i in range(N):
text = input()
l.append(text)
print("AC" + " x " + str(l.count("AC")))
print("WA" + " x " + str(l.count("WA")))
print("TLE" + " x " + str(l.count("TLE")))
print("RE" + " x " + str(l.count("RE")))
|
s060816119
|
p03448
|
u581603131
| 2,000 | 262,144 |
Wrong Answer
| 52 | 2,940 | 200 |
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 = [int(input()) for i in range(4)]
count = 0
for a in range(A):
for b in range(B):
for c in range(C):
if 500*a+100*b+50*c==X:
count += 1
print(count)
|
s808125703
|
Accepted
| 47 | 8,276 | 140 |
A, B, C, X = [int(input()) for i in range(4)]
print([500*a+100*b+50*c for a in range(A+1) for b in range(B+1) for c in range(C+1)].count(X))
|
s837548724
|
p03408
|
u854093727
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 400 |
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())
s = []
for i in range(N):
s.append(input())
M = int(input())
t = []
for i in range(M):
t.append(input())
money = 0
money_list = []
word_list = list(set(s+t))
for i in range(len(word_list)):
sum = s.count(word_list[i])
sum -= t.count(word_list[i])
else:
money_list.append(sum)
money_list.sort()
if money_list[0] < 0:
print(0)
else:
print(money_list[0])
|
s249307256
|
Accepted
| 18 | 3,064 | 395 |
N = int(input())
s = []
for i in range(N):
s.append(input())
M = int(input())
t = []
for i in range(M):
t.append(input())
money = 0
money_list = []
word_list = list(set(s+t))
for i in range(len(word_list)):
sum = s.count(word_list[i])
sum -= t.count(word_list[i])
if sum < 0:
sum = 0
money_list.append(sum)
money_list.sort(reverse = True)
print(money_list[0])
|
s201593108
|
p03671
|
u762008592
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 108 |
Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
|
number = list(map(int,input().split()))
min = min(number)
number.remove(min)
print(number[0] + number[1])
|
s325999007
|
Accepted
| 17 | 2,940 | 108 |
number = list(map(int,input().split()))
max = max(number)
number.remove(max)
print(number[0] + number[1])
|
s020906402
|
p03055
|
u415905784
| 2,000 | 1,048,576 |
Wrong Answer
| 1,365 | 75,668 | 520 |
Takahashi and Aoki will play a game on a tree. The tree has N vertices numbered 1 to N, and the i-th of the N-1 edges connects Vertex a_i and Vertex b_i. At the beginning of the game, each vertex contains a coin. Starting from Takahashi, he and Aoki will alternately perform the following operation: * Choose a vertex v that contains one or more coins, and remove all the coins from v. * Then, move each coin remaining on the tree to the vertex that is nearest to v among the adjacent vertices of the coin's current vertex. The player who becomes unable to play, loses the game. That is, the player who takes his turn when there is no coin remaining on the tree, loses the game. Determine the winner of the game when both players play optimally.
|
N = int(input())
E = [[] for _ in range(N)]
for _ in range(N - 1):
a, b = map(int, input().split())
E[a - 1].append(b - 1)
E[b - 1].append(a - 1)
def dijkstra(s):
D = [-1] * N
D[s] = s
Q = [0] * N
Q[0] = s
pos = 1
for i in range(N):
v = Q[i]
for adj in E[v]:
if D[adj] >= 0:
continue
Q[pos] = adj
pos += 1
D[adj] = D[v] + 1
return D
D = dijkstra(0)
_, s = max([[D[i], i] for i in range(N)])
D = dijkstra(s)
L = max(D)
print('First' if L % 3 != 1 else 'Second')
|
s401164704
|
Accepted
| 1,446 | 75,668 | 520 |
N = int(input())
E = [[] for _ in range(N)]
for _ in range(N - 1):
a, b = map(int, input().split())
E[a - 1].append(b - 1)
E[b - 1].append(a - 1)
def dijkstra(s):
D = [-1] * N
D[s] = 0
Q = [0] * N
Q[0] = s
pos = 1
for i in range(N):
v = Q[i]
for adj in E[v]:
if D[adj] >= 0:
continue
Q[pos] = adj
pos += 1
D[adj] = D[v] + 1
return D
D = dijkstra(0)
_, s = max([[D[i], i] for i in range(N)])
D = dijkstra(s)
L = max(D)
print('First' if L % 3 != 1 else 'Second')
|
s469430996
|
p03545
|
u973712798
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 580 |
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.
|
def bi(x, length):
ret = "".join(["0" for _ in range(length)])
return (ret + str(bin(x))[2:])[-length:]
def solve(inp):
l = len(inp) - 1
for i in range(2 ** l):
binary = bi(i, l)
tot = int(inp[0])
for j in range(l):
if binary[j] == "1":
tot += int(inp[j+1])
else:
tot -= int(inp[j+1])
print(tot)
if tot == 7:
return ''.join([inp[j] + "+" if binary[j] == "1" else inp[j] + "-" for j in range(l)] + [inp[-1] + "=7"])
inp = input()
print(solve(str(inp)))
|
s716056858
|
Accepted
| 17 | 3,064 | 561 |
def bi(x, length):
ret = "".join(["0" for _ in range(length)])
return (ret + str(bin(x))[2:])[-length:]
def solve(inp):
l = len(inp) - 1
for i in range(2 ** l):
binary = bi(i, l)
tot = int(inp[0])
for j in range(l):
if binary[j] == "1":
tot += int(inp[j+1])
else:
tot -= int(inp[j+1])
if tot == 7:
return ''.join([inp[j] + "+" if binary[j] == "1" else inp[j] + "-" for j in range(l)] + [inp[-1] + "=7"])
inp = input()
print(solve(str(inp)))
|
s661729305
|
p03401
|
u587452053
| 2,000 | 262,144 |
Wrong Answer
| 197 | 14,048 | 406 |
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled.
|
def main():
n = int(input())
a = list(map(int, input().split()))
a.insert(n, 0)
a.insert(0, 0)
print(a)
all_cost = 0
for i in range(1, n+2):
all_cost += abs(a[i] - a[i-1])
for i in range(1, n+1):
diff_cost = abs(a[i+1] - a[i-1]) - ( abs(a[i+1] - a[i]) + abs(a[i] - a[i-1]) )
print(all_cost + diff_cost)
if __name__ == '__main__':
main()
|
s692330434
|
Accepted
| 178 | 14,048 | 392 |
def main():
n = int(input())
a = list(map(int, input().split()))
a.insert(n, 0)
a.insert(0, 0)
all_cost = 0
for i in range(1, n+2):
all_cost += abs(a[i] - a[i-1])
for i in range(1, n+1):
diff_cost = abs(a[i+1] - a[i-1]) - ( abs(a[i+1] - a[i]) + abs(a[i] - a[i-1]) )
print(all_cost + diff_cost)
if __name__ == '__main__':
main()
|
s579661707
|
p03067
|
u022039716
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 256 |
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
|
# coding: utf-8
# Your code here!
A, B, C = list(map(int, input().split()))
if A < B:
if A < C and C < B:
print("yes")
else:
print("no")
if A > B:
if A > C and C > B:
print("yes")
else:
print("no")
|
s049455936
|
Accepted
| 17 | 2,940 | 214 |
A, B, C = list(map(int, input().split()))
if A < B:
if A < C and C < B:
print("Yes")
else:
print("No")
elif A > B:
if A > C and C > B:
print("Yes")
else:
print("No")
|
s519397546
|
p03672
|
u075595666
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 147 |
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.
|
s = input()
n = len(s)
s = s[:-2]
for _ in range(n):
n = len(s)
m = int(n/2)
if s[:m] == s[m:]:
print(s)
break
else:
s = s[:-2]
|
s050768510
|
Accepted
| 17 | 3,060 | 152 |
s = input()
n = len(s)
s = s[:-2]
for _ in range(n):
n = len(s)
m = int(n/2)
if s[:m] == s[m:]:
print(len(s))
break
else:
s = s[:-2]
|
s835786114
|
p02748
|
u316464887
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,064 | 119 |
You are visiting a large electronics store to buy a refrigerator and a microwave. The store sells A kinds of refrigerators and B kinds of microwaves. The i-th refrigerator ( 1 \le i \le A ) is sold at a_i yen (the currency of Japan), and the j-th microwave ( 1 \le j \le B ) is sold at b_j yen. You have M discount tickets. With the i-th ticket ( 1 \le i \le M ), you can get a discount of c_i yen from the total price when buying the x_i-th refrigerator and the y_i-th microwave together. Only one ticket can be used at a time. You are planning to buy one refrigerator and one microwave. Find the minimum amount of money required.
|
S = input()
for i in range(6):
x = 'hi'*i
if S == x:
print('Yes')
break;
else:
print('No')
|
s039085280
|
Accepted
| 422 | 18,736 | 232 |
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
r = min(a) + min(b)
for S in range(M):
x, y, c = map(int, input().split())
r = min(r, a[x-1] + b[y-1] - c)
print(r)
|
s491177204
|
p03679
|
u085883871
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 131 |
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.
|
(x, a, b) = map(int, input().split())
if(b<a):
print("delicious")
elif(b-a>x):
print("safe")
else:
print("dangerous")
|
s957459685
|
Accepted
| 19 | 2,940 | 133 |
(x, a, b) = map(int, input().split())
if(b<=a):
print("delicious")
elif(b-a<=x):
print("safe")
else:
print("dangerous")
|
s840299949
|
p02256
|
u411881271
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,592 | 75 |
Write a program which finds the greatest common divisor of two natural numbers _a_ and _b_
|
a,b=map(int,input().split())
x=a%b
while x>0:
a=b
x=a%x
b=x
print(a)
|
s128527733
|
Accepted
| 20 | 5,596 | 75 |
a,b=map(int,input().split())
x=a%b
while x>0:
a=b
b=x
x=a%b
print(b)
|
s656437026
|
p02928
|
u114648678
| 2,000 | 1,048,576 |
Wrong Answer
| 379 | 3,188 | 312 |
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.
|
n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=10**9+7
srt=sorted(a)
b=[]
for i in range(n):
b.append(srt.index(a[i]))
print(b)
ans=0
for j in range(n):
ans+=((b[j]+b[j]*k)*k//2)%mod
res=0
for ii in range(n):
for ij in range(ii+1):
if a[ii]>a[ij]:
res+=1
print((ans-res*k)%mod)
|
s806901022
|
Accepted
| 442 | 3,188 | 303 |
n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=10**9+7
srt=sorted(a)
b=[]
for i in range(n):
b.append(srt.index(a[i]))
ans=0
for j in range(n):
ans+=((b[j]+b[j]*k)*k//2)%mod
res=0
for ii in range(n):
for ij in range(ii+1):
if a[ii]>a[ij]:
res+=1
print((ans-res*k)%mod)
|
s125361030
|
p03658
|
u095021077
| 2,000 | 262,144 |
Wrong Answer
| 29 | 9,060 | 92 |
Snuke has N sticks. The length of the i-th stick is l_i. Snuke is making a snake toy by joining K of the sticks together. The length of the toy is represented by the sum of the individual sticks that compose it. Find the maximum possible length of the toy.
|
N, K=map(int, input().split())
l=list(map(int, input().split()))
l.sort()
print(sum(l[:-K]))
|
s302667090
|
Accepted
| 25 | 9,136 | 93 |
N, K=map(int, input().split())
l=list(map(int, input().split()))
l.sort()
print(sum(l[-K:]))
|
s223081104
|
p02798
|
u197300773
| 2,000 | 1,048,576 |
Wrong Answer
| 2,104 | 11,452 | 1,341 |
We have N cards numbered 1, 2, ..., N. Card i (1 \leq i \leq N) has an integer A_i written in red ink on one side and an integer B_i written in blue ink on the other side. Initially, these cards are arranged from left to right in the order from Card 1 to Card N, with the red numbers facing up. Determine whether it is possible to have a non-decreasing sequence facing up from left to right (that is, for each i (1 \leq i \leq N - 1), the integer facing up on the (i+1)-th card from the left is not less than the integer facing up on the i-th card from the left) by repeating the operation below. If the answer is yes, find the minimum number of operations required to achieve it. * Choose an integer i (1 \leq i \leq N - 1). Swap the i-th and (i+1)-th cards from the left, then flip these two cards.
|
import sys
import itertools
import math
def first(i,a,b):
if i%2==0: return [a,b]
else: return [b,a]
def chk(a,b):
if n%2==0:
for i in range(m-1):
if a[i][0]>b[i][0] or b[i][0]>a[i+1][0]:
return 0
if a[m-1][0]>b[m-1][0]: return 0
else:
for i in range(m-1):
if a[i][0]>b[i][0] or b[i][0]>a[i+1][0]:
return 0
return 1
def cal(a,b):
l=[]
if n%2==0:
for i in range(m):
l+=[a[i][1],b[i][1]]
if n%2==1:
for i in range(m-1):
l+=[a[i][1],b[i][1]]
l.append(a[m-1][1])
return l
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
if n==1:
print(0)
sys.exit()
x=[first(i,a[i],b[i]) for i in range(n)]
x.sort()
m=math.ceil(n/2)
p=[i for i in range(n)]
ans=1000000
for q in list(itertools.combinations(p,m)):
tmpa,tmpb=[],[]
for i in range(n):
if i in q: tmpa.append( [a[i],i] )
else: tmpb.append([b[i],i])
tmpb.sort()
if chk(tmpa,tmpb)==1:
s=[0 for i in range(n)]
t=cal(tmpa,tmpb)
tans=0
for i in range(n-1):
for j in range(1,n):
if a[i]>a[j]: tans+=1
ans=min(ans,tans)
print(ans//2 if ans<1000000 and ans%2==0 else -1)
|
s075093892
|
Accepted
| 1,945 | 3,192 | 1,302 |
import sys
import itertools
import math
def first(i,a,b):
if i%2==0: return [a,b,i]
else: return [b,a,i]
def chk(a,b):
if m==l:
for i in range(m-1):
if a[i][0]>b[i][0] or b[i][0]>a[i+1][0]:
return 0
if a[m-1][0]>b[m-1][0]: return 0
else:
for i in range(l):
if a[i][0]>b[i][0] or b[i][0]>a[i+1][0]:
return 0
return 1
def cal(a,b):
w=[]
if m==l:
for i in range(l):
w+=[a[i][1],b[i][1]]
else:
for i in range(l):
w+=[a[i][1],b[i][1]]
w.append(a[m-1][1])
return w
n=int(input())
m,l=n-n//2,n//2
a=list(map(int,input().split()))
b=list(map(int,input().split()))
if n==1:
print(0)
sys.exit()
x=[first(i,a[i],b[i]) for i in range(n)]
p=[i for i in range(n)]
ans=1000000
for q in itertools.combinations(p,m):
tmpa,tmpb=[],[]
for i in range(n):
if i in q: tmpa.append([ x[i][0],x[i][2] ])
else: tmpb.append([x[i][1],x[i][2]])
tmpa.sort()
tmpb.sort()
if chk(tmpa,tmpb)==1:
t=cal(tmpa,tmpb)
tans=0
for i in range(n):
for j in range(i):
if t[j]>t[i]: tans+=1
ans=min(ans,tans)
print(ans if ans<=n*(n-1)/2 else -1)
|
s540271150
|
p03150
|
u328207927
| 2,000 | 1,048,576 |
Wrong Answer
| 26 | 3,700 | 244 |
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
|
import itertools
s=str(input())
n='keyence'
k=''
w=list(itertools.combinations(range(len(s)+1), 2))
print(w)
for i,y in w:
k=s[i:y]
ss=s.replace(k,'',1)
print(ss)
if ss==n or k==n:
print('YES')
exit()
print('NO')
|
s671693183
|
Accepted
| 23 | 3,316 | 237 |
import itertools
s=str(input())
n='keyence'
k=''
w=list(itertools.combinations(range(len(s)+1), 2))
for i,y in w:
k=s[i:y]
ss=s.replace(k,'',1)
#print(ss)
if ss==n or k==n:
print('YES')
exit()
print('NO')
|
s432787877
|
p03456
|
u102126195
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 151 |
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.
|
import math
a, b = map(int, input().split())
c = a * len(str(b)) * 10 + b
print(c)
if math.sqrt(c) == int(math.sqrt(c)): print("Yes")
else: print("No")
|
s669036238
|
Accepted
| 17 | 2,940 | 176 |
import math
a, b = map(int, input().split())
c = 1
for i in range(len(str(b))):
c *= 10
c = a * c + b
if math.sqrt(c) == int(math.sqrt(c)): print("Yes")
else: print("No")
|
s073107901
|
p03555
|
u246572032
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 91 |
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
|
s = input()
j = input()
print('YES' if s[0]==j[2] and s[2]==j[2] and s[2]==j[0] else 'NO')
|
s949080650
|
Accepted
| 17 | 2,940 | 61 |
s = input()
t = input()
print('YES' if s==t[::-1] else 'NO')
|
s035853413
|
p03140
|
u026155812
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,064 | 238 |
You are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters. Our objective is to make all these three strings equal. For that, you can repeatedly perform the following operation: * Operation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter. What is the minimum number of operations required to achieve the objective?
|
N = int(input())
a = []
for i in range(3):
a.append(input())
ans = 0
for i in range(N):
if a[0][i] != a[1][i] and a[1][i] != a[2][i]:
ans += 2
elif a[0][i] != a[1][i] or a[1][i] != a[2][i]:
ans += 1
print(ans)
|
s456165128
|
Accepted
| 17 | 3,064 | 312 |
N = int(input())
a = []
for i in range(3):
a.append(input())
ans = 0
for i in range(N):
if a[0][i] != a[1][i] and a[1][i] != a[2][i] and a[0][i] != a[2][i]:
ans += 2
elif a[0][i] == a[1][i] and a[1][i] == a[2][i] and a[0][i] == a[2][i]:
continue
else:
ans += 1
print(ans)
|
s217497869
|
p03643
|
u185037583
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 20 |
This contest, _AtCoder Beginner Contest_ , is abbreviated as _ABC_. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer.
|
print('ABC',input())
|
s255717926
|
Accepted
| 17 | 2,940 | 20 |
print('ABC'+input())
|
s470825552
|
p03386
|
u825528847
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,444 | 112 |
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
|
A, B, K = map(int, input().split())
for i in range(A, A+K):
print(i)
for j in range(B-K+1, B):
print(j)
|
s144403237
|
Accepted
| 17 | 3,060 | 191 |
A, B, K = map(int, input().split())
tmp = []
for i in range(A, min(A+K, B)):
tmp.append(i)
print(i)
for i in range(max(B-K+1, A), B+1):
if i in tmp:
continue
print(i)
|
s359320401
|
p03679
|
u822738981
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 115 |
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.
|
# -*- coding: utf-8 -*-
x, a, b = map(int, input().split())
print('dangerous' if x - a - b < 0 else 'delicious')
|
s109925458
|
Accepted
| 18 | 3,060 | 166 |
# -*- coding: utf-8 -*-
x, a, b = map(int, input().split())
if x + a - b < 0:
print('dangerous')
elif a - b >= 0:
print('delicious')
else:
print('safe')
|
s967717076
|
p03543
|
u146346223
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 212 |
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
|
A, B, C, D = map(str, input())
for op1 in '+-':
for op2 in '+-':
for op3 in '+-':
if eval(A+op1+B+op2+C+op3+D) == 7:
print(A+op1+B+op2+C+op3+D+'=7')
exit()
|
s804661103
|
Accepted
| 17 | 2,940 | 82 |
a, b, c, d = input()
if a==b==c or b==c==d:
print('Yes')
else:
print('No')
|
s014052935
|
p03992
|
u740284863
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 38 |
This contest is `CODE FESTIVAL`. However, Mr. Takahashi always writes it `CODEFESTIVAL`, omitting the single space between `CODE` and `FESTIVAL`. So he has decided to make a program that puts the single space he omitted. You are given a string s with 12 letters. Output the string putting a single space between the first 4 letters and last 8 letters in the string s.
|
s=str(input())
print(s[0:3]+" "+s[4:])
|
s041802795
|
Accepted
| 18 | 2,940 | 39 |
s= str(input())
print(s[0:4]+" "+s[4:])
|
s850229135
|
p03624
|
u405256066
| 2,000 | 262,144 |
Wrong Answer
| 22 | 3,956 | 140 |
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.
|
from sys import stdin
S = (stdin.readline().rstrip())
if len(set(list(S))) == 26:
print("None")
else:
print(sorted(set(list(S)))[0])
|
s970810420
|
Accepted
| 22 | 3,956 | 194 |
from sys import stdin
S = (stdin.readline().rstrip())
if len(set(list(S))) == 26:
print("None")
else:
s = set(list("abcdefghijklmnopqrstuvwxyz")) - (set(list(S)))
print(sorted(s)[0])
|
s992072845
|
p02866
|
u474423089
| 2,000 | 1,048,576 |
Wrong Answer
| 122 | 25,216 | 380 |
Given is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition: * For every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.
|
import sys
from collections import Counter
input = sys.stdin.readline
N = int(input())
ans = 1
mod = 998244353
D = sorted(Counter(list(map(int, input().split()))).items())
tmp = D[0][1]
stream = -1
for n, i in D:
if stream + 1 != n:
print(0)
exit()
if n == 0:
continue
ans *= pow(tmp, i)
ans %= mod
tmp = i
stream += 1
print(ans)
|
s007195869
|
Accepted
| 174 | 25,732 | 497 |
import sys
from collections import Counter
input = sys.stdin.readline
N = int(input())
ans = 1
mod = 998244353
D = list(map(int, input().split()))
if D[0] != 0:
print(0)
exit()
D = sorted(Counter(D).items())
tmp = D[0][1]
stream = 0
for n, i in D:
if stream != n:
print(0)
exit()
if n == 0 and i == 1:
stream += 1
continue
elif n==0:
print(0)
exit()
ans *= pow(tmp, i)
ans %= mod
tmp = i
stream += 1
print(ans)
|
s208340975
|
p03495
|
u796708718
| 2,000 | 262,144 |
Wrong Answer
| 89 | 34,212 | 113 |
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them.
|
N, K = [int(x) for x in input().split(" ")]
setlst = {int(x) for x in input().split(" ")}
print(K-len(setlst))
|
s187591856
|
Accepted
| 462 | 59,264 | 435 |
N, K = [int(x) for x in input().split(" ")]
lst = [int(x) for x in input().split(" ")]
dic= {}
cnt = 0
swap = 0
prep = len(set(lst))-K
for i in range(1,N+1):
dic["{}".format(i)] = 0
for i in range(0,N):
dic["{}".format(lst[i])] += 1
sorted_dic = sorted(dic.items(), key = lambda x : x[1])
for i in range(0,N):
swap += sorted_dic[i][1]
if sorted_dic[i][1] != 0:
cnt +=1
if cnt >= prep:
break
print(swap)
|
s712665972
|
p02743
|
u454524105
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 119 |
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?
|
a, b, c = map(int, input().split())
l, r = a + b + 2 * (a**0.5) * (b**0.5), c**2
print("Yes") if l < r else print("No")
|
s385317457
|
Accepted
| 28 | 9,112 | 129 |
a, b, c = map(int, input().split())
if c-a-b <= 0:
print("No")
else: print("Yes") if (c-a-b)*(c-a-b) > 4*a*b else print("No")
|
s443167421
|
p03729
|
u642528832
| 2,000 | 262,144 |
Wrong Answer
| 30 | 9,020 | 84 |
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()
print(a,b,c)
print(['NO','YES'][a[-1]==b[0]and b[-1]==c[0]])
|
s059015442
|
Accepted
| 28 | 9,096 | 71 |
a,b,c = input().split()
print(['NO','YES'][a[-1]==b[0]and b[-1]==c[0]])
|
s115490125
|
p03493
|
u027165539
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 62 |
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
|
s = input()
c = 0
for i in s:
if i == 1:
c += 1
print(c)
|
s005509174
|
Accepted
| 17 | 2,940 | 91 |
s = input()
c = 0
for i in s:
if int(i) == 1:
c += 1
print(c)
# be careful of dtype!
|
s919053754
|
p03214
|
u390793752
| 2,525 | 1,048,576 |
Wrong Answer
| 147 | 12,444 | 396 |
Niwango-kun is an employee of Dwango Co., Ltd. One day, he is asked to generate a thumbnail from a video a user submitted. To generate a thumbnail, he needs to select a frame of the video according to the following procedure: * Get an integer N and N integers a_0, a_1, ..., a_{N-1} as inputs. N denotes the number of the frames of the video, and each a_i denotes the representation of the i-th frame of the video. * Select t-th frame whose representation a_t is nearest to the average of all frame representations. * If there are multiple such frames, select the frame with the smallest index. Find the index t of the frame he should select to generate a thumbnail.
|
import numpy as np
n = int(input())
a = str(input())
array = [int(s) for s in a.split()]
sum = 0
difference = 0
index = 0
avarage = np.average(array)
for i, a in enumerate(array):
tmp_diff = abs(a-avarage)
if i == 0:
difference = tmp_diff
index = 0
else:
if difference > tmp_diff:
difference = tmp_diff
index = i
print(array[index])
|
s661854540
|
Accepted
| 277 | 20,436 | 389 |
import numpy as np
n = int(input())
a = str(input())
array = [int(s) for s in a.split()]
sum = 0
difference = 0
index = 0
avarage = np.average(array)
for i, a in enumerate(array):
tmp_diff = abs(a-avarage)
if i == 0:
difference = tmp_diff
index = 0
else:
if difference > tmp_diff:
difference = tmp_diff
index = i
print(index)
|
s195377925
|
p02615
|
u366963613
| 2,000 | 1,048,576 |
Wrong Answer
| 209 | 49,464 | 914 |
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?
|
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
import math
def minu_int(i):
return -1*int(i)
def zz():
return list(map(int, sys.stdin.readline().split()))
def z():
return int(sys.stdin.readline())
def S():
return sys.stdin.readline()
def C(line):
return [sys.stdin.readline() for _ in range(line)]
def primes(n):
is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, int(n**0.5) + 1):
if not is_prime[i]:
continue
for j in range(i * 2, n + 1, i):
is_prime[j] = False
return [i for i in range(n + 1) if is_prime[i]]
N = z()
A = zz()
A = sorted(A, reverse=True)
# heapq.heapify(A)
# ans = 0
ans = sum(A[1:])
# ans +=
print(ans)
|
s815128929
|
Accepted
| 242 | 49,536 | 1,089 |
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
import math
def minu_int(i):
return -1*int(i)
def zz():
return list(map(int, sys.stdin.readline().split()))
def z():
return int(sys.stdin.readline())
def S():
return sys.stdin.readline()
def C(line):
return [sys.stdin.readline() for _ in range(line)]
def primes(n):
is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, int(n**0.5) + 1):
if not is_prime[i]:
continue
for j in range(i * 2, n + 1, i):
is_prime[j] = False
return [i for i in range(n + 1) if is_prime[i]]
N = z()
A = zz()
A = sorted(A, reverse=True)
if (N == 2):
print(max(A))
exit()
elif (N == 3):
print(sum(A[:2]))
exit()
else:
ans = A[0]
index = 1
for i in range(1, N-1):
# print(A[index])
ans += A[index]
if (i % 2 == 0):
index += 1
print(ans)
|
s534113110
|
p03730
|
u314837274
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 211 |
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())
#A*B % B=0
#A*(B+1) % B=A
for i in range(A,A*B+1,A):
if i%B==C:
print("Yes")
exit()
print("No")
|
s692675858
|
Accepted
| 17 | 2,940 | 211 |
A,B,C=map(int,input().split())
#A*B % B=0
#A*(B+1) % B=A
for i in range(A,A*B+1,A):
if i%B==C:
print("YES")
exit()
print("NO")
|
s843959450
|
p03640
|
u064408584
| 2,000 | 262,144 |
Wrong Answer
| 291 | 21,020 | 226 |
We have a grid with H rows and W columns of squares. Snuke is painting these squares in colors 1, 2, ..., N. Here, the following conditions should be satisfied: * For each i (1 ≤ i ≤ N), there are exactly a_i squares painted in Color i. Here, a_1 + a_2 + ... + a_N = H W. * For each i (1 ≤ i ≤ N), the squares painted in Color i are _4-connected_. That is, every square painted in Color i can be reached from every square painted in Color i by repeatedly traveling to a horizontally or vertically adjacent square painted in Color i. Find a way to paint the squares so that the conditions are satisfied. It can be shown that a solution always exists.
|
import numpy as np
h,w=map(int, input().split())
n=int(input())
a=list(map(int, input().split()))
m=np.arange(w*h)
c=0
for i,j in enumerate(a):
m[c:c+j]=i
c+=j
m=m.reshape(h,w)
m[::2,:]=m[::2,::-1]
for i in m:print(*i)
|
s873103393
|
Accepted
| 201 | 13,608 | 228 |
import numpy as np
h,w=map(int, input().split())
n=int(input())
a=list(map(int, input().split()))
m=np.arange(w*h)
c=0
for i,j in enumerate(a):
m[c:c+j]=i+1
c+=j
m=m.reshape(h,w)
m[::2,:]=m[::2,::-1]
for i in m:print(*i)
|
s466823754
|
p03434
|
u129709378
| 2,000 | 262,144 |
Wrong Answer
| 27 | 9,080 | 230 |
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
|
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
alice = 0
bob = 0
sorted_a = sorted(a)
print(a, sorted_a)
for i in sorted_a:
alice += sorted_a.pop()
bob += sorted_a.pop()
print(alice - bob)
|
s803582732
|
Accepted
| 27 | 9,076 | 226 |
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
alice = 0
bob = 0
a.sort()
for i in range(len(a)):
if i % 2 == 0:
alice += a.pop()
else:
bob += a.pop()
print(alice - bob)
|
s597912521
|
p03377
|
u788137651
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 93 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
A, B, X = map(int, input().split())
if A+B >= X >= A:
print("Yes")
else:
print("No")
|
s652421394
|
Accepted
| 17 | 2,940 | 93 |
A, B, X = map(int, input().split())
if A+B >= X >= A:
print("YES")
else:
print("NO")
|
s936994868
|
p03636
|
u600261652
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 41 |
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()
print(s[0] + s[1:-1] + s[-1])
|
s557433474
|
Accepted
| 17 | 2,940 | 47 |
s = input()
print(s[0] + str(len(s)-2) + s[-1])
|
s043616782
|
p03827
|
u052499405
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 144 |
You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).
|
s = input().rstrip()
ans = 0
val = 0
for ch in s:
if ch == "I":
val += 1
ans = max(ans, val)
elif ch == "D":
val -= 1
print(ans)
|
s738370122
|
Accepted
| 18 | 3,060 | 223 |
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
n = int(input())
s = input().rstrip()
ans = 0
val = 0
for ch in s:
if ch == "I":
val += 1
ans = max(ans, val)
elif ch == "D":
val -= 1
print(ans)
|
s754098323
|
p03545
|
u637451088
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 875 |
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.
|
import sys
n = input()
code_1 = ['+', '-']
code_2 = ['+', '-']
code_3 = ['+', '-']
answer = ''
flag = False
for i in range(2):
for j in range(2):
for k in range(2):
sum_num = 0
if code_1[i] == '+':
sum_num += int(n[0]) + int(n[1])
else:
sum_num += int(n[0]) - int(n[1])
if code_2[j] == '+':
sum_num += int(n[2])
else:
sum_num -= int(n[2])
if code_3[k] == '+':
sum_num += int(n[3])
else:
sum_num -= int(n[3])
if sum_num == 7:
answer = n[0] + code_1[i] + n[1] + code_2[j] + n[2] + code_3[k] + n[3]
flag = True
if flag:
break
if flag:
break
if flag:
break
print(answer)
|
s293981663
|
Accepted
| 18 | 3,064 | 882 |
import sys
n = input()
code_1 = ['+', '-']
code_2 = ['+', '-']
code_3 = ['+', '-']
answer = ''
flag = False
for i in range(2):
for j in range(2):
for k in range(2):
sum_num = 0
if code_1[i] == '+':
sum_num += int(n[0]) + int(n[1])
else:
sum_num += int(n[0]) - int(n[1])
if code_2[j] == '+':
sum_num += int(n[2])
else:
sum_num -= int(n[2])
if code_3[k] == '+':
sum_num += int(n[3])
else:
sum_num -= int(n[3])
if sum_num == 7:
answer = n[0] + code_1[i] + n[1] + code_2[j] + n[2] + code_3[k] + n[3] + '=7'
flag = True
if flag:
break
if flag:
break
if flag:
break
print(answer)
|
s137115649
|
p03854
|
u314050667
| 2,000 | 262,144 |
Wrong Answer
| 20 | 3,188 | 155 |
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
|
S=input()
S.replace('eraser','')
S.replace('erase','')
S.replace('dreamer','')
S.replace('dream','')
if len(S)==0:
print('YES')
else:
print('NO')
|
s316432688
|
Accepted
| 19 | 3,188 | 165 |
S=input()
S = S.replace('eraser','')
S=S.replace('erase','')
S=S.replace('dreamer','')
S=S.replace('dream','')
if len(S)==0:
print('YES')
else:
print('NO')
|
s971148759
|
p03555
|
u860002137
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 67 |
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
|
c1 = input()
c2 = input()
print("Yes" if c1 == c2[::-1] else "No")
|
s390738496
|
Accepted
| 17 | 2,940 | 67 |
c1 = input()
c2 = input()
print("YES" if c1 == c2[::-1] else "NO")
|
s211666819
|
p03493
|
u364386647
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 128 |
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
|
s = str(input())
count = 0
if s[0] == 1:
count += 1
if s[1] == 1:
count += 1
if s[2] == 1:
count += 1
print(count)
|
s743554430
|
Accepted
| 19 | 2,940 | 135 |
s = str(input())
count = 0
if s[0] == "1":
count += 1
if s[1] == "1":
count += 1
if s[2] == "1":
count += 1
print(count)
|
s711441840
|
p03385
|
u159335277
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 63 |
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
|
if sorted(input()) == 'abc':
print('Yes')
else:
print('No')
|
s347044023
|
Accepted
| 17 | 2,940 | 72 |
if ''.join(sorted(input())) == 'abc':
print('Yes')
else:
print('No')
|
s624729852
|
p03155
|
u507351902
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 186 |
It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board. The bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns. How many ways are there to choose where to put the notice so that it completely covers exactly HW squares?
|
n = int(input())
h = int(input())
w = int(input())
"""
n = 5
h = 2
w = 2
"""
print("type")
print(type(n))
yoko_num = (n % h)+1
tate_num = (n % w)+1
ans = yoko_num * tate_num
print(ans)
|
s042077360
|
Accepted
| 17 | 2,940 | 131 |
n = int(input())
h = int(input())
w = int(input())
yoko_num = n - h + 1
tate_num = n - w + 1
ans = yoko_num * tate_num
print(ans)
|
s434229636
|
p04030
|
u765721093
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 129 |
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?
|
y=""
a=str(input())
print(len(a))
for i in range (len(a)):
if a[i]=="B":
y=y[:-1]
else:
y=y+a[i]
print(y)
|
s059019974
|
Accepted
| 17 | 2,940 | 115 |
y=""
a=str(input())
for i in range (len(a)):
if a[i]=="B":
y=y[:-1]
else:
y=y+a[i]
print(y)
|
s585203076
|
p03854
|
u973712798
| 2,000 | 262,144 |
Wrong Answer
| 24 | 3,316 | 338 |
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
|
string = input()
keys = ["dreamer","eraser","dream","erase"]
keys_to_find = ["dreamer","eraser","dream","erase"]
for key in keys_to_find:
index = string.find(key)
if index != -1:
string = string.replace(key,"")
print("index:",index)
print("string:",string)
if string == "":
print("YES")
else:
print("NO")
|
s161595049
|
Accepted
| 284 | 3,188 | 325 |
s = input()
head = 0
dreameraser = ["dream","dreamer","erase","eraser"]
for i in range(len(s)):
for word in dreameraser:
head = len(s) - len(word)
cut = s[head:head+len(word)]
# print(cut)
if cut in dreameraser:
s = s[0:head]
if s == "":
print("YES")
else:
print("NO")
|
s471487619
|
p02936
|
u554954744
| 2,000 | 1,048,576 |
Wrong Answer
| 2,129 | 402,844 | 816 |
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 sys
sys.setrecursionlimit(10**6)
N, Q = map(int, input().split())
edges = [[] for _ in range(N+1)]
for i in range(N-1):
a, b = map(int, input().split())
edges[a].append(b)
edges[b].append(a)
task = [[] for _ in range(N+1)]
for i in range(Q):
p, x = map(int, input().split())
task[p].append(x)
task_sum = [[] for _ in range(N+1)]
for i in range(N+1):
task_sum[i].append(sum(task[i]))
print('task_sum:', task_sum)
cnt = [[] for i in range(N+1)]
def dfs(v, p, cost):
for nv in edges[v]:
if nv == p:
continue
dfs(nv, v, cost+task_sum[nv])
cnt[v].append(cost)
dfs(1, -1, task_sum[1])
print(cnt)
for i in range(1, N+1):
print(int(sum(cnt[i][0])), end=' ')
value = [0] * (N+1)
print(value)
|
s582230642
|
Accepted
| 1,091 | 65,636 | 642 |
from collections import deque
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
N, Q = map(int, input().split())
g = [[] for _ in range(N+1)]
for i in range(N-1):
a, b = map(int, input().split())
g[a].append(b)
g[b].append(a)
cnt = [0] * (N+1)
for i in range(Q):
p, x = map(int, input().split())
cnt[p] += x
def bfs():
q = deque()
q.append((1, 0))
while q:
v, p = q.popleft()
cnt[v] += cnt[p]
for nv in g[v]:
if nv == p:
continue
q.append((nv, v))
ret = ' '.join(map(str, cnt[1:]))
return ret
ans = bfs()
print(ans)
|
s786001176
|
p03945
|
u798316285
| 2,000 | 262,144 |
Wrong Answer
| 33 | 3,188 | 79 |
Two foxes Jiro and Saburo are playing a game called _1D Reversi_. This game is played on a board, using black and white stones. On the board, stones are placed in a row, and each player places a new stone to either end of the row. Similarly to the original game of Reversi, when a white stone is placed, all black stones between the new white stone and another white stone, turn into white stones, and vice versa. In the middle of a game, something came up and Saburo has to leave the game. The state of the board at this point is described by a string S. There are |S| (the length of S) stones on the board, and each character in S represents the color of the i-th (1 ≦ i ≦ |S|) stone from the left. If the i-th character in S is `B`, it means that the color of the corresponding stone on the board is black. Similarly, if the i-th character in S is `W`, it means that the color of the corresponding stone is white. Jiro wants all stones on the board to be of the same color. For this purpose, he will place new stones on the board according to the rules. Find the minimum number of new stones that he needs to place.
|
s=input()
a=s[0]
ans=0
for i in s[1:]:
if i!=a:
ans+=1
a=1
print(ans)
|
s202640312
|
Accepted
| 34 | 3,188 | 79 |
s=input()
a=s[0]
ans=0
for i in s[1:]:
if i!=a:
ans+=1
a=i
print(ans)
|
s883906332
|
p03475
|
u721970149
| 3,000 | 262,144 |
Wrong Answer
| 112 | 3,188 | 475 |
A railroad running from west to east in Atcoder Kingdom is now complete. There are N stations on the railroad, numbered 1 through N from west to east. Tomorrow, the opening ceremony of the railroad will take place. On this railroad, for each integer i such that 1≤i≤N-1, there will be trains that run from Station i to Station i+1 in C_i seconds. No other trains will be operated. The first train from Station i to Station i+1 will depart Station i S_i seconds after the ceremony begins. Thereafter, there will be a train that departs Station i every F_i seconds. Here, it is guaranteed that F_i divides S_i. That is, for each Time t satisfying S_i≤t and t%F_i=0, there will be a train that departs Station i t seconds after the ceremony begins and arrives at Station i+1 t+C_i seconds after the ceremony begins, where A%B denotes A modulo B, and there will be no other trains. For each i, find the earliest possible time we can reach Station N if we are at Station i when the ceremony begins, ignoring the time needed to change trains.
|
import sys
input = sys.stdin.readline
N = int(input())
CSF = [list(map(int,input().split())) for i in range(N-1)]
print(CSF)
ans = [0 for _ in range(N)]
for i in range(N-1) :
temp = CSF[i][1] + CSF[i][0]
t = i + 1
while t < N-1 :
if temp < CSF[t][1] :
temp = CSF[t][1] + CSF[t][0]
else :
temp = ((temp+CSF[t][2]-1)//CSF[t][2])*CSF[t][2] + CSF[t][0]
t += 1
ans[i] = temp
for answer in ans :
print(answer)
|
s714305869
|
Accepted
| 105 | 3,188 | 464 |
import sys
input = sys.stdin.readline
N = int(input())
CSF = [list(map(int,input().split())) for i in range(N-1)]
ans = [0 for _ in range(N)]
for i in range(N-1) :
temp = CSF[i][1] + CSF[i][0]
t = i + 1
while t < N-1 :
if temp < CSF[t][1] :
temp = CSF[t][1] + CSF[t][0]
else :
temp = ((temp+CSF[t][2]-1)//CSF[t][2])*CSF[t][2] + CSF[t][0]
t += 1
ans[i] = temp
for answer in ans :
print(answer)
|
s490246821
|
p03943
|
u936035004
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 130 |
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,b,c = map(int,input().split())
if a+b==c:
print("YES")
elif b+c==a:
print("YES")
elif a+c==b:
print("YES")
else:
print("NO")
|
s409617715
|
Accepted
| 17 | 2,940 | 130 |
a,b,c = map(int,input().split())
if a+b==c:
print("Yes")
elif b+c==a:
print("Yes")
elif a+c==b:
print("Yes")
else:
print("No")
|
s266277207
|
p02615
|
u092061507
| 2,000 | 1,048,576 |
Wrong Answer
| 2,206 | 31,612 | 437 |
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=False)
ret = 0
array = []
array.append(A.pop())
while len(A) > 0:
#print('array', array)
comfort = [0 for i in range(len(array))]
for i in range(len(comfort)):
comfort[i] = min(array[i-1], array[i])
#print('comfort', comfort)
val = max(comfort)
ret += val
print('ret', ret)
array.insert(comfort.index(val), A.pop())
print(ret)
|
s708808085
|
Accepted
| 178 | 31,760 | 281 |
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=False)
ret = 0
c_pointer = 0
comfort = []
tmp = A.pop()
comfort.append(tmp)
while len(A) > 0:
tmp = A.pop()
c_pointer += 1
comfort.append(tmp)
comfort.append(tmp)
print(sum(comfort[:c_pointer]))
|
s523526604
|
p03565
|
u048238198
| 2,000 | 262,144 |
Wrong Answer
| 41 | 9,960 | 1,804 |
E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One more thing he found is a sheet of paper with the following facts written on it: * Condition 1: The string S contains a string T as a contiguous substring. * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1. Print the string S. If such a string does not exist, print `UNRESTORABLE`.
|
import sys
import math
import re
sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))
def rle_comp(S):
rle = []
pre = 'X'
chain = 1
for c in S:
if c == pre:
chain += 1
else:
if pre != 'X':
rle.append([pre,chain])
pre = c
chain = 1
rle.append([pre,chain])
#print(rle)
return rle
s2 = input()
t = input()
s2_r = s2[::-1]
t_r = ''
t_r += t[::-1]
rle = rle_comp(s2_r)
p = ''
結果を用いて正規表現パターン作成
for c in rle:
if c[0] == '?':
p+='.{1,'
p+=str(c[1])
p+='}'
else:
p+=str(c[0])
p+='{'
p+=str(c[1])
p+='}'
flag = False
mojisuu = 0
for iter_m in re.finditer('}', p):
clo_index = iter_m.span()[1]
mojisuu += int(p[clo_index-2])
if mojisuu >= len(t_r):
m = re.search(p[:clo_index],t_r)
if m != None:
ans = s2_r[:m.span()[0]] + t_r + s2_r[m.span()[1]:]
ans = ans.replace('?','a')
ans = ans[::-1]
print(ans)
flag = True
if flag == False:
print('UNRESTORABLE')
|
s826314815
|
Accepted
| 35 | 9,668 | 1,518 |
import sys
import math
import re
sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))
s2 = input()
t = input()
s2_r = s2[::-1]
t_r = t[::-1]
ans_flag = False
for i in range(len(s2)):
for j in range(i+1,len(s2)+1):
if (j-i) == len(t_r):
flag = True
for k,l in enumerate(range(i,j)):
if s2_r[l] != t_r[k] and s2_r[l] != '?':
flag = False
if flag == True:
ans = s2_r[:i] + t_r + s2_r[j:]
ans = ans.replace('?','a')
ans = ans[::-1]
print(ans)
ans_flag = True
break
else:
continue
break
if ans_flag == False:
print('UNRESTORABLE')
|
s438062980
|
p02850
|
u047535298
| 2,000 | 1,048,576 |
Wrong Answer
| 1,035 | 48,708 | 723 |
Given is a tree G with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i. Consider painting the edges in G with some number of colors. We want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different. Among the colorings satisfying the condition above, construct one that uses the minimum number of colors.
|
from collections import deque
N = int(input())
data = {}
inputData = []
edges = {}
maxColor = 0
for i in range(N-1):
a, b = map(int, input().split())
data[(a, b)] = 0
inputData.append((a, b))
if a not in edges:
edges[a] = []
if b not in edges:
edges[b] = []
edges[a].append(b)
edges[b].append(a)
maxColor = max(maxColor, len(edges[a]))
queue = deque([(1, 1)])
while(len(queue)):
q, c = queue.popleft()
for i, v in enumerate(edges[q]):
a = min(q,v)
b = max(q,v)
if(data[(a, b)]) != 0:
continue
data[(a, b)] = c+i
queue.append((v, c+i))
print(maxColor)
for i in range(N-1):
print(data[inputData[i]]%maxColor+1)
|
s064939164
|
Accepted
| 1,072 | 48,708 | 738 |
from collections import deque
N = int(input())
data = {}
inputData = []
edges = {}
maxColor = 0
for i in range(N-1):
a, b = map(int, input().split())
data[(a, b)] = 0
inputData.append((a, b))
if a not in edges:
edges[a] = []
if b not in edges:
edges[b] = []
edges[a].append(b)
edges[b].append(a)
maxColor = max(maxColor, len(edges[a]))
queue = deque([(1, 0)])
while(len(queue)):
q, c = queue.popleft()
k = 0
for v in edges[q]:
a = min(q,v)
b = max(q,v)
if(data[(a, b)]) != 0:
continue
k += 1
data[(a, b)] = c+k
queue.append((v, c+k))
print(maxColor)
for i in range(N-1):
print((data[inputData[i]]-1)%maxColor+1)
|
s988615781
|
p02608
|
u473172054
| 2,000 | 1,048,576 |
Wrong Answer
| 2,206 | 8,892 | 473 |
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
N = int(input())
count = 0
for n in range(1, N + 1):
for i in range(1, 31):
for j in range(1, i + 1):
for k in range(1, j + 1):
if i ** 2 + j ** 1 + k ** 2 + i * j + j * k + k * i == n:
if i == j and j == k:
count += 1
elif i == j or j == k:
count += 3
else:
count += 6
print(count)
count = 0
|
s125632832
|
Accepted
| 184 | 9,168 | 495 |
N = int(input())
counts = [0] * 10001
for i in range(1, 101):
for j in range(1, i + 1):
for k in range(1, j + 1):
result = i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i
if result > 10000:
continue
if i == j and j == k:
counts[result] += 1
elif i == j or j == k:
counts[result] += 3
else:
counts[result] += 6
for n in range(1, N + 1):
print(counts[n])
|
s582704846
|
p02262
|
u007270338
| 6,000 | 131,072 |
Wrong Answer
| 20 | 5,612 | 656 |
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$
|
#coding:utf-8
n = int(input())
A = [int(input()) for i in range(n)]
def insertionSort(A,n,g):
cnt = 0
for i in range(g,n,g):
v = A[i]
j = i - g
while j >= 0 and v < A[j]:
A[j+g] = A[j]
j -= g
cnt += 1
A[j+g] = v
return cnt
def shellSort(A,n):
cnt = 0
m = 0
while 2 ** m < n:
m += 1
G = [2 ** num for num in range(m)]
G.sort(reverse=True)
for i in range(m):
a = insertionSort(A,n,G[i])
cnt += a
print(m)
G = " ".join([str(num) for num in G])
print(G)
print(cnt)
shellSort(A,n)
for num in A:
print(num)
|
s547674962
|
Accepted
| 19,480 | 45,520 | 677 |
#coding:utf-8
n = int(input())
A = [int(input()) for i in range(n)]
def insertionSort(A,n,g):
cnt = 0
for i in range(g,n):
v = A[i]
j = i - g
while j >= 0 and v < A[j]:
A[j+g] = A[j]
j -= g
cnt += 1
A[j+g] = v
return cnt
def shellSort(A,n):
cnt = 0
p = 1
G = [p]
while 3 * p + 1 < n:
p = 3 * p + 1
G.append(p)
G.sort(reverse=True)
m = len(G)
for i in range(m):
a = insertionSort(A,n,G[i])
cnt += a
print(m)
G = " ".join([str(num) for num in G])
print(G)
print(cnt)
shellSort(A,n)
for num in A:
print(num)
|
s920514702
|
p03854
|
u821297681
| 2,000 | 262,144 |
Wrong Answer
| 23 | 6,516 | 98 |
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
|
import re;
s = input();
print("Yes" if re.match(r'^(dream|dreamer|eraser|erase)+$', s) else "NO")
|
s625337219
|
Accepted
| 23 | 6,516 | 102 |
import re;
s = input();
print("YES" if re.fullmatch(r'^(dream|dreamer|eraser|erase)*$', s) else "NO")
|
s645384694
|
p03472
|
u088552457
| 2,000 | 262,144 |
Wrong Answer
| 351 | 12,116 | 296 |
You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, …, Katana N, and can perform the following two kinds of attacks in any order: * Wield one of the katana you have. When you wield Katana i (1 ≤ i ≤ N), the monster receives a_i points of damage. The same katana can be wielded any number of times. * Throw one of the katana you have. When you throw Katana i (1 ≤ i ≤ N) at the monster, it receives b_i points of damage, and you lose the katana. That is, you can no longer wield or throw that katana. The monster will vanish when the total damage it has received is H points or more. At least how many attacks do you need in order to vanish it in total?
|
N, HP = map(int, input().split())
K = []
A = []
B = []
for _ in range(N):
a, b = map(int, input().split())
B.append(b)
A.append(a)
MA = max(A)
ans = 0
for b in sorted(B, reverse=True):
HP -= b
ans += 1
if HP <= 0:
exit()
if MA > b:
break
ans += HP // MA
print(ans)
|
s615879556
|
Accepted
| 356 | 12,112 | 345 |
N, HP = map(int, input().split())
K = []
A = []
B = []
for _ in range(N):
a, b = map(int, input().split())
B.append(b)
A.append(a)
MA = max(A)
ans = 0
for b in sorted(B, reverse=True):
if MA > b:
break
HP -= b
ans += 1
if HP <= 0:
print(ans)
exit()
c = HP // MA
ans += c
if HP - (c*MA) > 0:
ans += 1
print(ans)
|
s079082126
|
p03400
|
u210827208
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 153 |
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()))
cnt=0
for j in range(n):
cnt+=(d+1)//A[j]
print(x+cnt)
|
s867670671
|
Accepted
| 17 | 3,060 | 155 |
n=int(input())
d,x=map(int,input().split())
A=[]
for i in range(n):
A.append(int(input()))
cnt=0
for j in range(n):
cnt+=(d-1)//A[j]+1
print(x+cnt)
|
s637113541
|
p00027
|
u553148578
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,600 | 175 |
Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29.
|
day = ['Wednes','Thurs','Fri','Satur','Sun','Mon','Tues']
month = [0,31,60,91,121,152,182,213,244,274,305,335]
m,d=map(int,input().split())
print(day[(month[m-1]+d)%7]+'day')
|
s824616735
|
Accepted
| 20 | 5,604 | 208 |
while 1:
day = ['Wednes','Thurs','Fri','Satur','Sun','Mon','Tues']
month = [0,31,60,91,121,152,182,213,244,274,305,335]
m,d=map(int,input().split())
if m == 0:
break
print(day[(month[m-1]+d)%7]+'day')
|
s871990545
|
p02614
|
u879921371
| 1,000 | 1,048,576 |
Wrong Answer
| 285 | 27,092 | 867 |
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.
|
import numpy as np
h,w,k=map(int,input().split())
c=[None]*h
for i in range(h):
c[i]=list(map(int,input().replace(".","0 ").replace("#","1 ").split()))
#sum_c=sum(c)
d=np.array(c)
c=np.copy(d)
e=np.copy(d)
r=0
#h+=-1
#w+=-1
for j in range(2**h):
j_b=bin(j)[:1:-1]
e=np.copy(c)
#print(j)
for i_j,d_j in enumerate(j_b):
#print(d_j)
if d_j=="1":
#print(d[i_j])
e[i_j]=0
#print(d)
#else:
# e[i_j]=c[i_j]
for m in range(2**w):
d=np.copy(e)
#print(m)
m_b=bin(m)[:1:-1]
#print(j_b)
#print(m_b)
for i_m,d_m in enumerate(m_b):
if d_m=="1":
d[:,i_m]=0
#else:
#print(m_b)
# d[:,i_m]=c[:,i_m]
#print(d)
if np.sum(d)==k:
r+=1
#print(m_b)
#rint(j_b)
#print(d)
#d=np.copy(e)
#d=np.copy(c)
print(r)
|
s213343777
|
Accepted
| 145 | 27,124 | 852 |
import numpy as np
h,w,k=map(int,input().split())
c=[None]*h
for i in range(h):
c[i]=list(map(int,input().replace(".","0 ").replace("#","1 ").split()))
#sum_c=sum(c)
d=np.array(c)
c=np.copy(d)
e=np.copy(c)
r=0
#h+=-1
#w+=-1
for j in range(2**h):
j_b=bin(j)[:1:-1]
e=np.copy(c)
#print(j)
for i_j,d_j in enumerate(j_b):
#print(d_j)
if d_j=="1":
#print(d[i_j])
e[i_j]=0
#print(d)
#else:
# e[i_j]=c[i_j]
for m in range(2**w):
d=np.copy(e)
#print(m)
m_b=bin(m)[:1:-1]
#print(j_b)
#print(m_b)
for i_m,d_m in enumerate(m_b):
if d_m=="1":
d[:,i_m]=0
#else:
#print(m_b)
# d[:,i_m]=c[:,i_m]
#print(d)
if np.sum(d)==k:
r+=1
#print(m_b)
#print(j_b)
#print(d)
#d=np.copy(e)
#d=np.copy(c)
print(r)
|
s295872212
|
p03636
|
u634079249
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 215 |
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.
|
import sys
import os
def main():
if os.getenv("LOCAL"):
sys.stdin = open("input.txt", "r")
a, *b, c = sys.stdin.readline()
print(a, len(b), c, sep="")
if __name__ == '__main__':
main()
|
s393325408
|
Accepted
| 18 | 3,064 | 689 |
import sys
import os
ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]
iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]
def main():
if os.getenv("LOCAL"):
sys.stdin = open("input.txt", "r")
S = list(iss())
print(S[0] + str(len(S)-2) + S[-1])
if __name__ == '__main__':
main()
|
s864639161
|
p02742
|
u665224938
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 62 |
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
|
H, W = map(int, input().split(" "))
S = H * W
print(S + S % 2)
|
s111619519
|
Accepted
| 17 | 2,940 | 110 |
H, W = map(int, input().split(" "))
if H == 1 or W == 1:
print(1)
else:
S = H * W
print(S // 2 + S % 2)
|
s682264219
|
p03131
|
u203669169
| 2,000 | 1,048,576 |
Wrong Answer
| 2,104 | 40,424 | 217 |
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the maximum possible number of biscuits in Snuke's pocket after K operations.
|
K, A, B = [int(_) for _ in input().split()]
bis = 1
upbis = 0
k = 0
ma = 1 + K
while K >= k + (A-bis) + 2:
k += (A-bis) + 2
upbis += B
bis = 0
print(K, k, upbis)
upbis += K - k
print(max(ma, upbis))
|
s059809656
|
Accepted
| 18 | 3,060 | 145 |
K, A, B = [int(_) for _ in input().split()]
upbis = 0
k = K - A + 1
if B > A:
upbis = A + (k // 2) * (B-A) + (k % 2)
print(max(1+K, upbis))
|
s454109620
|
p03545
|
u105290050
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 54 |
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=input()
l=[]
for i in s:
l.append(int(i))
print(l)
|
s860486487
|
Accepted
| 17 | 3,064 | 467 |
s=input()
n=len(s)
l=[]
for i in s:
l.append(int(i))
for i in range(2 ** n):
check = []
for j in range(n):
if ((i >> j) & 1):
check.append(l[j])
else:
check.append(-l[j])
if sum(check)==7:
print(str(check[0]), end="")
for i in range(1, n):
if check[i]>=0:
print("+"+str(check[i]), end="")
else:
print(str(check[i]), end="")
print("=7")
exit()
|
s998551948
|
p03377
|
u298297089
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 76 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
A,B,X = map(int, input().split())
print('YES' if A+B < X or A > X else 'NO')
|
s030709172
|
Accepted
| 17 | 2,940 | 108 |
a,b,x = map(int, input().split())
if a > x:
print('NO')
elif x-a <= b:
print('YES')
else :
print('NO')
|
s181359011
|
p02692
|
u477320129
| 2,000 | 1,048,576 |
Wrong Answer
| 184 | 27,176 | 1,632 |
There is a game that involves three variables, denoted A, B, and C. As the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by a string s_i. If s_i is `AB`, you must add 1 to A or B then subtract 1 from the other; if s_i is `AC`, you must add 1 to A or C then subtract 1 from the other; if s_i is `BC`, you must add 1 to B or C then subtract 1 from the other. After each choice, none of A, B, and C should be negative. Determine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices.
|
#!/usr/bin/env python3
import sys
YES = "Yes" # type: str
NO = "No" # type: str
class Impossible(Exception):
pass
def f(q, qq, state):
n, m = q
if state[n] == state[m] == 0:
return -1
if state[n] == state[m] == 1:
if n in qq:
return m
return n
if state[n] > state[m]:
return n
return m
def solve(N: int, A: int, B: int, C: int, s: "List[str]"):
D = {'AB': (0, 1), 'AC': (0, 2), 'BC': (1, 2)}
E = 'ABC'
Q = tuple(map(lambda x: D[x], s))
state = [A, B, C]
for q, qq in zip(Q, Q[1:] + (tuple(),)):
r = f(q, qq, state)
if r == -1:
raise Impossible
yield E[r]
state[r] -= 1
state[q[q.index(r)^1]] += 1
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
tokens = iterate_tokens()
N = int(next(tokens)) # type: int
A = int(next(tokens)) # type: int
B = int(next(tokens)) # type: int
C = int(next(tokens)) # type: int
s = [next(tokens) for _ in range(N)] # type: "List[str]"
try:
ans = list(solve(N, A, B, C, s))
print(YES)
print(*ans, sep='\n')
except Impossible:
print(NO)
def test():
import doctest
doctest.testmod()
if __name__ == '__main__':
test()
main()
|
s880449918
|
Accepted
| 183 | 27,104 | 1,922 |
#!/usr/bin/env python3
import sys
YES = "Yes" # type: str
NO = "No" # type: str
class Impossible(Exception):
pass
def f(q, qq, state):
n, m = q
if state[n] == state[m] == 0:
return -1
if state[n] == state[m] == 1:
if n in qq:
return n
return m
if state[n] > state[m]:
return m
return n
def solve(N: int, A: int, B: int, C: int, s: "List[str]"):
D = {'AB': (0, 1), 'AC': (0, 2), 'BC': (1, 2)}
E = 'ABC'
Q = tuple(map(lambda x: D[x], s))
state = [A, B, C]
for q, qq in zip(Q, Q[1:] + (tuple(),)):
r = f(q, qq, state)
if r == -1:
raise Impossible
yield E[r]
state[r] += 1
state[q[q.index(r)^1]] -= 1
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
tokens = iterate_tokens()
N = int(next(tokens)) # type: int
A = int(next(tokens)) # type: int
B = int(next(tokens)) # type: int
C = int(next(tokens)) # type: int
s = [next(tokens) for _ in range(N)] # type: "List[str]"
try:
ans = list(solve(N, A, B, C, s))
print(YES)
print(*ans, sep='\n')
except Impossible:
print(NO)
def test():
import doctest
doctest.testmod()
if __name__ == '__main__':
test()
main()
|
s783229868
|
p02393
|
u725843728
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,580 | 73 |
Write a program which reads three integers, and prints them in ascending order.
|
a,b,c = map(int,input().split())
list = [a,b,c]
list.sort()
print(list)
|
s654673763
|
Accepted
| 20 | 5,584 | 76 |
num = list(map(int,input().split()))
num.sort()
print(num[0],num[1],num[2])
|
s439180567
|
p03047
|
u155236040
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 43 |
Snuke has N integers: 1,2,\ldots,N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers?
|
n,k = map(int,input().split())
print(n-k-1)
|
s553008605
|
Accepted
| 17 | 2,940 | 43 |
n,k = map(int,input().split())
print(n-k+1)
|
s797359134
|
p03611
|
u821262411
| 2,000 | 262,144 |
Wrong Answer
| 54 | 13,964 | 273 |
You are given an integer sequence of length N, a_1,a_2,...,a_N. For each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing. After these operations, you select an integer X and count the number of i such that a_i=X. Maximize this count by making optimal choices.
|
n=int(input())
a=list(map(int,input().split()))
ans=0
if a[0]==1:
buf=a[0]
a[0]=a[1]
a[1]=buf
ans += 1
for i in range(1,n-1):
if a[i]==i+1:
buf=a[i]
a[i]=a[i+1]
a[i+1]=buf
ans += 1
if a[n-1]==n:
ans += 1
print(ans)
|
s023637661
|
Accepted
| 98 | 14,008 | 221 |
N=int(input())
a=list(map(int,input().split()))
L=max(a)+1
b=[0]*L
for i in a:
b[i]+=1
ans=0
if L<=2:
print(sum(b))
else:
for p in range(L-2):
ans = max(ans,b[p]+b[p+1]+b[p+2])
print(ans)
|
s865082267
|
p03673
|
u462626125
| 2,000 | 262,144 |
Wrong Answer
| 2,105 | 21,844 | 127 |
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b. The i-th operation is as follows: 1. Append a_i to the end of b. 2. Reverse the order of the elements in b. Find the sequence b obtained after these n operations.
|
n = int(input())
A = [x for x in input().split()]
B = []
for i in range(n):
B.append(A[i])
B=B[::-1]
print("".join(B))
|
s639693827
|
Accepted
| 104 | 26,692 | 405 |
# coding: utf-8
# Here your code !
from collections import deque
n = int(input())
A = [x for x in input().split()]
B = deque()
if n % 2 == 0:
for i in range(n):
if i % 2 == 0:
B.append(A[i])
else:
B.appendleft(A[i])
else:
for i in range(n):
if i % 2 == 0:
B.appendleft(A[i])
else:
B.append(A[i])
print(" ".join(B))
|
s144443868
|
p02865
|
u385244248
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 2,940 | 75 |
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
|
N = int(input())
if N%2 ==1:
print(int(N+1)/2)
else:
print(int(N/2))
|
s509473812
|
Accepted
| 17 | 2,940 | 85 |
N = int(input())
if N%2 == 0:
print(int((N/2)-1))
else:
print(int((N+1)/2)-1)
|
s039654153
|
p02853
|
u982591663
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 238 |
We held two competitions: Coding Contest and Robot Maneuver. In each competition, the contestants taking the 3-rd, 2-nd, and 1-st places receive 100000, 200000, and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competitions receives an additional 400000 yen. DISCO-Kun took the X-th place in Coding Contest and the Y-th place in Robot Maneuver. Find the total amount of money he earned.
|
X, Y = map(int, input().split())
ranks = [X, Y]
ans = 0
for i in ranks:
if i == 1:
ans += 300000
elif i == 2:
ans += 200000
elif i == 3:
ans += 100000
if (X, Y) == (1, 1):
ans = 700000
print(ans)
|
s528120817
|
Accepted
| 17 | 3,060 | 239 |
X, Y = map(int, input().split())
ranks = [X, Y]
ans = 0
for i in ranks:
if i == 1:
ans += 300000
elif i == 2:
ans += 200000
elif i == 3:
ans += 100000
if (X, Y) == (1, 1):
ans = 1000000
print(ans)
|
s363970042
|
p03352
|
u944015274
| 2,000 | 1,048,576 |
Wrong Answer
| 384 | 21,996 | 360 |
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
|
import math
import numpy as np
x = int(input())
x_sqrt = math.sqrt(x)
maxlist = []
def hoge(x, x_sqrt):
for b in range(2, x_sqrt+1):
i = 1
while b ** i <= x:
i += 1
maxlist.append(b **(i-1))
print(maxlist)
return np.max(np.array(maxlist))
if x - x_sqrt == 0:
print(x)
else:
print(hoge(x, int(x_sqrt)))
|
s291636022
|
Accepted
| 151 | 12,376 | 341 |
import math
import numpy as np
x = int(input())
x_sqrt = math.sqrt(x)
maxlist = []
def hoge(x, x_sqrt):
for b in range(2, x_sqrt+1):
i = 1
while b ** i <= x:
i += 1
maxlist.append(b **(i-1))
return np.max(np.array(maxlist))
if x - x_sqrt == 0:
print(x)
else:
print(hoge(x, int(x_sqrt)))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.