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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s446185372
|
p03471
|
u566619532
| 2,000
| 262,144
|
Wrong Answer
| 2,104
| 3,064
| 744
|
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
|
# -*- coding: utf-8 -*-
n, y = map(int,input().split())
a = 0
b = 0
c = 0
flag = True
for i in range(n+1):
if 10000*i > y:
break
if flag is False:
break
for g in range(n+1):
if 10000*i + 5000*g > y:
break
if flag is False:
break
for h in range(n+1):
if 10000*i + 5000*g + 1000*h == y and i + g + h == n:
a = i
b = g
c = h
flag = False
break
if 10000*i + 5000*g + 1000*h > y :
break
print (a,b,c)
|
s644337202
|
Accepted
| 1,458
| 2,940
| 454
|
#-*- coding: utf-8 -*-#
n, y = map(int,input().split())
a = -1
b = -1
c = -1
for i in range(n+1):
for g in range(n+1):
if y == 10000*i + 5000*g + 1000*(n - i - g) and n - i - g >= 0:
a = i
b = g
c = n - i - g
print (a,b,c)
|
s862926388
|
p03495
|
u123756661
| 2,000
| 262,144
|
Wrong Answer
| 146
| 32,264
| 193
|
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=map(int,input().split())
a=[int(i) for i in input().split()]
d={}
for i in a:
if i in d:
d[i]+=1
else:
d[i]=1
t=[]
for i in d:
t.append(d[i])
print(sum(t[0:-2]))
|
s898497463
|
Accepted
| 151
| 33,152
| 202
|
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
d={}
for i in a:
if i in d:
d[i]+=1
else:
d[i]=1
t=[]
for i in d:
t.append(d[i])
t.sort()
print(sum(t[0:-k]))
|
s514981465
|
p03251
|
u921027074
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 144
|
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
|
N,M,X,Y=map(int, input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
print('War' if max(y)>=max(x) else 'No War')
|
s983843900
|
Accepted
| 17
| 3,060
| 179
|
N,M,X,Y=map(int, input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
print("No War" if (max(x)<min(y) and X<Y and X<min(y) and Y>max(x)) else "War")
|
s394841024
|
p03160
|
u385792265
| 2,000
| 1,048,576
|
Wrong Answer
| 186
| 14,540
| 214
|
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
|
import math
n=int(input())
a=list(map(int, input().split() ) )
b=[0]*n
b[1]=int(math.fabs(a[0]-a[1]))
for i in range(2, n):
b[i]=int(min(b[i-1]+math.fabs(a[i]-a[i-1]), b[i-2]+math.fabs(a[i]-a[i-2]) ) )
print(b)
|
s372880541
|
Accepted
| 176
| 14,104
| 218
|
import math
n=int(input())
a=list(map(int, input().split() ) )
b=[0]*n
b[1]=int(math.fabs(a[0]-a[1]))
for i in range(2, n):
b[i]=int(min(b[i-1]+math.fabs(a[i]-a[i-1]), b[i-2]+math.fabs(a[i]-a[i-2]) ) )
print(b[-1])
|
s548098170
|
p03386
|
u209619667
| 2,000
| 262,144
|
Wrong Answer
| 2,104
| 21,968
| 109
|
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 = list(map(int,input().split()))
for a in range(A[0],A[1]+1):
if a == A[2]:
pass
else:
print(a)
|
s281182205
|
Accepted
| 18
| 3,064
| 262
|
A = list(map(int,input().split()))
a = 0
k = []
for c in range(A[0],A[1]+1):
k.append(c)
a += 1
if a== A[2]:
break;
a = 0
for c in range(A[1], A[0], -1):
if a == A[2]:
break;
k.append(c)
a += 1
k = sorted(list(set(k)))
for i in k:
print(i)
|
s295753564
|
p03836
|
u271469978
| 2,000
| 262,144
|
Wrong Answer
| 24
| 3,060
| 250
|
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
|
sx, sy, tx, ty = map(int, input().split())
w = tx - sx
h = ty - sy
ans =""
ans += "U" * h
ans += "L" * w
ans += "D" * h
ans += "R" * (w+1)
ans += "U" * (h+1)
ans += "L" * (w+1)
ans += "D"
ans += "L"
ans += "D" * h
ans += "R" * w
ans += "U"
print(ans)
|
s808283764
|
Accepted
| 19
| 3,064
| 258
|
sx, sy, tx, ty = map(int, input().split())
w = tx - sx
h = ty - sy
ans =""
ans += "U" * h
ans += "R" * w
ans += "D" * h
ans += "L" * (w+1)
ans += "U" * (h+1)
ans += "R" * (w+1)
ans += "D"
ans += "R"
ans += "D" * (h+1)
ans += "L" * (w+1)
ans += "U"
print(ans)
|
s504940454
|
p03471
|
u050622763
| 2,000
| 262,144
|
Wrong Answer
| 2,104
| 3,552
| 203
|
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
|
n,yen = map(int,input().split())
for x in range(n+1):
for y in range(n+1):
for z in range(n+1):
if 10000*x+5000*y+1000*z==yen:
print(x,y,z)
break
|
s941030403
|
Accepted
| 1,066
| 3,064
| 402
|
n,yen = map(int,input().split())
ans = [-1,-1,-1]
for x in range(n+1):
for y in range(n+1-x):
z= int(yen/1000) - 10*x - 5*y
if (0<= z) and (z == n-x-y):
#print(x,y,n-x-y,z)
bol = True
ans = [x,y,z]
break
print(ans[0],ans[1],ans[2])
|
s809197963
|
p03377
|
u841222846
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 126
|
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 = list(map(int, input().split(" ")))
if(a <= x):
if(a + b >= x):
print("Yes")
exit()
print("No")
|
s901679677
|
Accepted
| 17
| 2,940
| 126
|
a, b, x = list(map(int, input().split(" ")))
if(a <= x):
if(a + b >= x):
print("YES")
exit()
print("NO")
|
s738746814
|
p04029
|
u293825440
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 311
|
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
|
moji = []
ans=""
s = str(input())
s = list(s)
def keyboard(key,list):
if key == "0":
list.append("0")
elif key == "1":
list.append("1")
elif key == "B" and len(list) != 0:
list.pop(-1)
for i in range(len(s)):
keyboard(s[i],moji)
for x in moji:
ans += x
print(ans)
|
s708747073
|
Accepted
| 18
| 2,940
| 85
|
N = int(input())
candy=0
for i in range(1,N+1):
candy = candy + i
print(candy)
|
s803617250
|
p03493
|
u197078193
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 25
|
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.
|
print(input().count('s'))
|
s164285293
|
Accepted
| 17
| 2,940
| 25
|
print(input().count('1'))
|
s219665734
|
p03139
|
u954488273
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 2,940
| 86
|
We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A respondents answered "yes" to Question 1, and B respondents answered "yes" to Question 2. What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y? Write a program to answer this question.
|
s = list(map(int,input().split()))
a=max(s[1],s[2])
b=max(s[1]+s[2]-s[0],0)
print(a,b)
|
s005679633
|
Accepted
| 17
| 2,940
| 86
|
s = list(map(int,input().split()))
a=min(s[1],s[2])
b=max(s[1]+s[2]-s[0],0)
print(a,b)
|
s926104053
|
p03719
|
u275934251
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 64
|
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
|
a,b,c=map(int,input().split())
print("YES" if a<=c<=b else "NO")
|
s879357795
|
Accepted
| 17
| 2,940
| 64
|
a,b,c=map(int,input().split())
print("Yes" if a<=c<=b else "No")
|
s256491773
|
p03759
|
u168416324
| 2,000
| 262,144
|
Wrong Answer
| 26
| 9,048
| 78
|
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
|
a,b,c=map(int,input().split())
if b*2==a+c:
print("Yes")
else:
print("No")
|
s619588860
|
Accepted
| 26
| 9,160
| 78
|
a,b,c=map(int,input().split())
if b*2==a+c:
print("YES")
else:
print("NO")
|
s186778069
|
p03597
|
u914198331
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 149
|
We have an N \times N square grid. We will paint each square in the grid either black or white. If we paint exactly A squares white, how many squares will be painted black?
|
N = int(input())
A = list(map(int, input().split()))
T = 1
for i in A:
T = T * i
if T > 10**18:
print(-1)
else:
print(T)
|
s507545984
|
Accepted
| 17
| 2,940
| 47
|
N = int(input())
A = int(input())
print(N*N-A)
|
s940251184
|
p03623
|
u992736202
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 101
|
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
|
l=list(map(int,input().split()))
if abs(l[1]-l[0])-abs(l[2]-l[0])>=0:
print("A")
else:
print("B")
|
s302694117
|
Accepted
| 18
| 2,940
| 101
|
l=list(map(int,input().split()))
if abs(l[1]-l[0])-abs(l[2]-l[0])<=0:
print("A")
else:
print("B")
|
s156870967
|
p03698
|
u758649177
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 174
|
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
|
S= input()
k=len(S)
c=0
for i in range(k):
for j in range(k-i):
if S[i]!=S[i+j]:
c+=1
print(c)
if c==k*(k-1)/2:
print("yes")
else:
print("No")
|
s874330572
|
Accepted
| 17
| 2,940
| 166
|
S=input()
k=len(S)
c=0
for i in range(k):
for j in range(k-i):
if S[i]!=S[i+j]:
c+=1
if c==k*(k-1)/2:
print('yes')
else:
print('no')
|
s705004080
|
p02972
|
u182004566
| 2,000
| 1,048,576
|
Wrong Answer
| 1,178
| 7,532
| 604
|
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
|
def sum_remainder_before_i(i, a):
ans = 0
j = 1
while True:
if (j+1)*(i+1)-1 > len(a)-1:
return ans
else:
ans = ans + a[(j+1)*(i+1)-1]
j = j + 1
N = int(input())
a = tuple(map(int, input().split()))
i = N - 1
ans = [-1]*N
result = False
while True:
sum = sum_remainder_before_i(i, ans)
if sum % 2 == a[i]:
ans[i] = 0
else:
ans[i] = 1
if i == 0:
break
i = i - 1
n = 0
for i, a in enumerate(ans):
if a == 1:
print(i+1)
n = n + 1
if n == 0:
print(0)
|
s595405078
|
Accepted
| 1,128
| 19,116
| 659
|
def sum_remainder_before_i(i, a):
ans = 0
j = 1
while True:
if (j+1)*(i+1)-1 > len(a)-1:
return ans
else:
ans = ans + a[(j+1)*(i+1)-1]
j = j + 1
N = int(input())
a = tuple(map(int, input().split()))
i = N - 1
ans = [-1]*N
result = False
while True:
sum = sum_remainder_before_i(i, ans)
if sum % 2 == a[i]:
ans[i] = 0
else:
ans[i] = 1
if i == 0:
break
i = i - 1
m = 0
answers = []
for i, a in enumerate(ans):
if a == 1:
answers.append(i+1)
m = m + 1
print(m)
if m > 0:
print(" ".join(map(str,answers)))
|
s965296845
|
p02850
|
u844789719
| 2,000
| 1,048,576
|
Wrong Answer
| 417
| 60,668
| 465
|
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.
|
import collections
I = [int(_) for _ in open(0).read().split()]
N = I[0]
A, B = I[1::2], I[2::2]
s = collections.defaultdict(set)
for i, ab in enumerate(zip(A, B)):
a, b = ab
s[a].add(i)
s[b].add(i)
c = collections.Counter(A + B)
d = c.most_common()[::-1]
K = d[-1][1]
ans = [0] * (N - 1)
while d:
j, _ = d.pop()
L = K
for p in s[j]:
if ans[p] == 0:
ans[p] = L
L -= 1
print(K)
print('\n'.join(map(str, ans)))
|
s542640164
|
Accepted
| 518
| 67,084
| 621
|
import collections
I = [int(_) for _ in open(0).read().split()]
N = I[0]
A, B = I[1::2], I[2::2]
s = collections.defaultdict(set)
for i, ab in enumerate(zip(A, B)):
a, b = ab
s[a].add(i)
s[b].add(i)
c = collections.Counter(A + B)
d = c.most_common()[::-1]
p, k = d.pop()
ans = [None] * (N - 1)
Q = collections.deque([(p, 0)])
while Q:
p, fr = Q.popleft()
color = 1
for i in s[p]:
if ans[i] is None:
if color == fr:
color += 1
ans[i] = color
Q += [(A[i] + B[i] - p, color)]
color += 1
print(k)
print('\n'.join(map(str, ans)))
|
s777627530
|
p03050
|
u806855121
| 2,000
| 1,048,576
|
Wrong Answer
| 208
| 3,060
| 141
|
Snuke received a positive integer N from Takahashi. A positive integer m is called a _favorite number_ when the following condition is satisfied: * The quotient and remainder of N divided by m are equal, that is, \lfloor \frac{N}{m} \rfloor = N \bmod m holds. Find all favorite numbers and print the sum of those.
|
import math
N = int(input())
ans = 0
sqi = math.sqrt(N)
for i in range(1, int(sqi)):
if (N-i)%i == 0:
ans += (N-i)//i
print(ans)
|
s228952691
|
Accepted
| 181
| 3,060
| 209
|
import math
N = int(input())
ans = 0
sqi = math.sqrt(N)
for i in range(1, int(sqi)+1):
if (N-i)%i == 0:
m = (N-i)//i
if m > 0:
if N//m == N%m:
ans += (N-i)//i
print(ans)
|
s803020259
|
p03605
|
u311592491
| 2,000
| 262,144
|
Wrong Answer
| 23
| 9,016
| 58
|
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
|
N=input()
if "9" in N:
print("YES")
else:
print("NO")
|
s501528006
|
Accepted
| 26
| 8,920
| 59
|
N=input()
if "9" in N:
print("Yes")
else:
print("No")
|
s064765760
|
p00176
|
u203261375
| 1,000
| 131,072
|
Wrong Answer
| 70
| 5,640
| 681
|
ウェブデザイナーを目指す太郎君はただいま修行中。事務所の先輩から「このページの背景色は#ffe085で」と、ウェブデザイン特有の色番号で指示されるのですが、それがどんな色かパッと思い浮かべることができません。 この色番号は光の三原色である赤、緑、青それぞれの強さを表わしています。具体的には2 桁の 16 進数を3 つ組み合わせたもので、色番号を“#RGB”とするとき、R は赤の強さ、G は緑の強さ、は青の強さを表します。それぞれ 00 から ff までの値になります。 色番号にまだ不慣れな太郎君のために、色番号を入力とし、色の表の中からもっとも近い色の名前 を出力するプログラムを作成してください。使用する色の表は以下の通りです。 | 色の名前| 赤の強さ| 緑の強さ| 青の強さ ---|---|---|---|--- | black| 00| 00| 00 | blue| 00| 00| ff | lime| 00| ff| 00 | aqua| 00| ff| ff | red| ff| 00| 00 | fuchsia| ff| 00| ff | yellow| ff| ff| 00 | white| ff| ff| ff 「もっとも近い色」とは、以下のように定義します。与えられた色番号での赤、緑、青の強さをそれぞれ R、G、B とし、表の k 番目の色の赤、緑、青の強さをそれぞれ Rk、Gk、Bk とするとき、次の式で計算する dk の値が最も小さい色がもっとも近い色とします。 なお、dk の値が同じになる色が複数存在する場合は表の中でより上にある色がもっとも近い色になり ます。
|
colors = {
'black': [0, 0, 0],
'blue': [0, 0, 255],
'lime': [0, 255, 0],
'aqua': [0, 255, 255],
'red': [255, 0, 0],
'fuchsia': [255, 0, 255],
'yellow': [255, 255, 0],
'white': [255, 255, 255]
}
while True:
color = input()
if color == '0':
break
r, g, b = (int(color[1:3], 16),
int(color[3:5], 16),
int(color[5:7], 16))
print(r, g, b)
near_color = ['', float('inf')]
for k, v in colors.items():
dk = ((v[0] - r) ** 2 +
(v[1] - g) ** 2 +
(v[2] - b) ** 2) ** .5
if dk < near_color[1]:
near_color = [k, dk]
print(near_color[0])
|
s611355217
|
Accepted
| 70
| 6,040
| 740
|
from collections import OrderedDict
colors = OrderedDict()
colors['black'] = [0, 0, 0]
colors['blue'] = [0, 0, 255]
colors['lime'] = [0, 255, 0]
colors['aqua'] = [0, 255, 255]
colors['red'] = [255, 0, 0]
colors['fuchsia'] = [255, 0, 255]
colors['yellow'] = [255, 255, 0]
colors['white'] = [255, 255, 255]
while True:
color = input()
if color == '0':
break
r, g, b = (int(color[1:3], 16),
int(color[3:5], 16),
int(color[5:7], 16))
near_color = ['', float('inf')]
for k, v in colors.items():
dk = ((v[0] - r) ** 2 +
(v[1] - g) ** 2 +
(v[2] - b) ** 2) ** .5
if dk < near_color[1]:
near_color = [k, dk]
print(near_color[0])
|
s492493500
|
p03485
|
u881028805
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 110
|
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
a, b = map(int, input().split())
if (a + b) % 2 == 1:
print((a + b) / 2 + 1)
else:
print((a + b) / 2)
|
s477291059
|
Accepted
| 17
| 2,940
| 120
|
a, b = map(int, input().split())
if (a + b) % 2 == 1:
print(int((a + b + 1) / 2))
else:
print(int((a + b) / 2))
|
s987712587
|
p03854
|
u014386369
| 2,000
| 262,144
|
Wrong Answer
| 61
| 9,188
| 330
|
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()
def solve(query):
while 1:
if not query:
print("Yes")
break
for frag in ("erase","eraser","dream","dreamer"):
if query.endswith(frag):
query=query[:-len(frag)]
break
else:
print("No")
break
solve(S)
|
s830737871
|
Accepted
| 60
| 9,224
| 330
|
S=input()
def solve(query):
while 1:
if not query:
print("YES")
break
for frag in ("erase","eraser","dream","dreamer"):
if query.endswith(frag):
query=query[:-len(frag)]
break
else:
print("NO")
break
solve(S)
|
s062846387
|
p02409
|
u670498238
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,740
| 372
|
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left. Assume that initially no person lives in the building.
|
data = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
n = int(input())
for _ in range(n):
(b,f,r,v) = [int(i) for i in input().split()]
data[b - 1][f - 1][r - 1] += v
for b in range(4):
for f in range(3):
for r in range(10):
print('',data[b][f][r], end = '')
print()
if b < 3:
print('#' * 20)
|
s439501480
|
Accepted
| 20
| 7,748
| 362
|
data = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
n = int(input())
for _ in range(n):
(b,f,r,v) = [int(i) for i in input().split()]
data[b - 1][f - 1][r - 1] += v
for b in range(4):
for f in range(3):
for r in range(10):
print('',data[b][f][r], end='')
print()
if b < 3:
print('#' * 20)
|
s201948021
|
p04011
|
u992759582
| 2,000
| 262,144
|
Wrong Answer
| 19
| 2,940
| 132
|
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
|
n,k,x,y = map(int,open(0))
price = 0
for i in range(n):
if i <= k :
price += x
else:
price += y
print(price)
|
s953265089
|
Accepted
| 19
| 2,940
| 134
|
n,k,x,y = map(int,open(0))
price = 0
for i in range(n):
if i+1 <= k :
price += x
else:
price += y
print(price)
|
s411117514
|
p03543
|
u672316981
| 2,000
| 262,144
|
Wrong Answer
| 29
| 9,112
| 149
|
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**?
|
n = str(input())
flag = False
if n[0] == n[1] == n[2] and n[1] == n[2] == n[3]:
flag = True
if flag:
print('Yes')
else:
print('No')
|
s351519459
|
Accepted
| 30
| 8,920
| 144
|
n = str(input())
flag = False
if n[0] == n[1] == n[2] or n[1] == n[2] == n[3]:
flag = True
if flag:
print('Yes')
else:
print('No')
|
s504761294
|
p03448
|
u181318511
| 2,000
| 262,144
|
Wrong Answer
| 51
| 3,060
| 214
|
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
A = int(input())
B = int(input())
C = int(input())
X = int(input())
n=0
for a in range(A) :
for b in range(B) :
for c in range(C) :
if 500*a+100*b+50*c == X :
n+=1
print(n)
|
s544301987
|
Accepted
| 51
| 3,064
| 302
|
A = int(input())
B = int(input())
C = int(input())
X = int(input())
a = 0
b = 0
c = 0
n=0
for a in range(A+1) :
for b in range(B+1) :
for c in range(C+1) :
if 500*a + 100*b + 50*c == X :
n+=1
c=0
b=0
if 0 == X :
n+=1
print(n)
|
s184288823
|
p03545
|
u202570162
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 263
|
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.
|
n=[int(i) for i in list(input())]
op=[1,-1]
ans=[]
for op1 in op:
for op2 in op:
for op3 in op:
if n[0]+op1*n[1]+op2*n[2]+op3*n[3]==7:
ans=[op1,op2,op3]
out=''
for i in range(3):
out+=str(n[i])
out+='+' if ans[i]==1 else '-'
print(out+str(n[3]))
|
s438372907
|
Accepted
| 18
| 3,064
| 402
|
nums=[int(i) for i in input()]
ops=[1,-1]
ans=-1
for op1 in ops:
for op2 in ops:
for op3 in ops:
if nums[0]+op1*nums[1]+op2*nums[2]+op3*nums[3]==7:
ans=''+str(nums[0])
ans+='+' if op1==1 else '-'
ans+=str(nums[1])
ans+='+' if op2==1 else '-'
ans+=str(nums[2])
ans+='+' if op3==1 else '-'
ans+=str(nums[3])
ans+='=7'
print(ans)
|
s577089583
|
p02645
|
u525065967
| 2,000
| 1,048,576
|
Wrong Answer
| 19
| 9,096
| 135
|
When you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters. You have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him.
|
s = input()
m = set()
for c in s:
m.add(c)
# print(m)
i = 0
for c in m:
print(c,end='')
i += 1
if i==3:break
print('')
|
s598096242
|
Accepted
| 23
| 9,016
| 19
|
print(input()[:3])
|
s763977146
|
p02975
|
u474925961
| 2,000
| 1,048,576
|
Wrong Answer
| 74
| 14,212
| 370
|
Snuke has N hats. The i-th hat has an integer a_i written on it. There are N camels standing in a circle. Snuke will put one of his hats on each of these camels. If there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print `Yes`; otherwise, print `No`. * The bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself. What is XOR? The bitwise XOR x_1 \oplus x_2 \oplus \ldots \oplus x_n of n non- negative integers x_1, x_2, \ldots, x_n is defined as follows: - When x_1 \oplus x_2 \oplus \ldots \oplus x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. For example, 3 \oplus 5 = 6.
|
n=int(input())
a=sorted(list(map(int,input().split())))
p=set(a[:n//3])
q=set(a[n//3:(n//3)*2])
r=set(a[(n//3)*2:n])
flag=True
if n%3!=0:
flag=False
if flag and len(p)==1 and len(q)==1 and len(r)==1:
if a[0] & a[n//3]==a[(2*n)//3]:
print("Yes")
if a[0]==0 and a[n//3]==0:
print("Yes")
else:
print("No")
else:
print("No")
|
s238815914
|
Accepted
| 79
| 15,788
| 395
|
import sys
n=int(input())
a=sorted(list(map(int,input().split())))
p=set(a[:n//3])
q=set(a[n//3:(n//3)*2])
r=set(a[(n//3)*2:n])
flag=True
if n%3!=0:
flag=False
if len(set(a))==1 and a[0]==0:
print("Yes")
sys.exit()
if flag and len(p)==1 and len(q)==1 and len(r)==1:
if a[0] ^ a[n//3]==a[(2*n)//3]:
print("Yes")
else:
print("No")
else:
print("No")
|
s202470019
|
p02272
|
u148628801
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,624
| 948
|
Write a program of a Merge Sort algorithm implemented by the following pseudocode. You should also report the number of comparisons in the Merge function. Merge(A, left, mid, right) n1 = mid - left; n2 = right - mid; create array L[0...n1], R[0...n2] for i = 0 to n1-1 do L[i] = A[left + i] for i = 0 to n2-1 do R[i] = A[mid + i] L[n1] = SENTINEL R[n2] = SENTINEL i = 0; j = 0; for k = left to right-1 if L[i] <= R[j] then A[k] = L[i] i = i + 1 else A[k] = R[j] j = j + 1 Merge-Sort(A, left, right){ if left+1 < right then mid = (left + right)/2; call Merge-Sort(A, left, mid) call Merge-Sort(A, mid, right) call Merge(A, left, mid, right)
|
import sys
def merge(A, left, mid, right, num_compare):
n1 = mid - left
n2 = right - mid
L = [0 for i in range(n1)]
R = [0 for i in range(n2)]
for i in range(n1):
L[i] = A[left + i]
for i in range(n2):
R[i] = A[mid + i]
i = 0
j = 0
num_compare += right - left
for k in range(left, right):
if j >= n2:
A[k] = L[i]
i += 1
elif i < n1 and L[i] <= R[j]:
A[k] = L[i]
i += 1
else:
A[k] = R[j]
j += 1
return num_compare
def merge_sort(A, left, right, num_compare):
if left + 1 < right:
mid = (left + right) // 2
num_compare = merge_sort(A, left, mid, num_compare)
num_compare = merge_sort(A, mid, right, num_compare)
num_compare = merge(A, left, mid, right, num_compare)
return num_compare
#fin = open("test.txt", "r")
fin = sys.stdin
n = int(fin.readline())
S = list(map(int, fin.readline().split()))
num_compare = 0
num_compare = merge_sort(S, 0, n, num_compare)
print(S)
print(num_compare)
|
s295106922
|
Accepted
| 4,220
| 67,716
| 912
|
import sys
def merge(A, left, mid, right, num_compare):
n1 = mid - left
n2 = right - mid
L = A[left:mid] + [SENTINEL]
R = A[mid:right] + [SENTINEL]
i = 0
j = 0
num_compare += right - left
for k in range(left, right):
if L[i] <= R[j]:
A[k] = L[i]
i += 1
else:
A[k] = R[j]
j += 1
return num_compare
def merge_sort(A, left, right, num_compare):
if left + 1 < right:
mid = (left + right) // 2
num_compare = merge_sort(A, left, mid, num_compare)
num_compare = merge_sort(A, mid, right, num_compare)
num_compare = merge(A, left, mid, right, num_compare)
return num_compare
#fin = open("test.txt", "r")
fin = sys.stdin
SENTINEL = float("inf")
n = int(fin.readline())
S = list(map(int, fin.readline().split()))
num_compare = 0
num_compare = merge_sort(S, 0, n, num_compare)
print(S[0], end = "")
for s in S[1:]:
print(" " + str(s), end = "")
print("")
print(num_compare)
|
s201788790
|
p03577
|
u729133443
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 33
|
Rng is going to a festival. The name of the festival is given to you as a string S, which ends with `FESTIVAL`, from input. Answer the question: "Rng is going to a festival of what?" Output the answer. Here, assume that the name of "a festival of s" is a string obtained by appending `FESTIVAL` to the end of s. For example, `CODEFESTIVAL` is a festival of `CODE`.
|
print(input().rstrip('FESTIVAL'))
|
s224355669
|
Accepted
| 17
| 2,940
| 19
|
print(input()[:-8])
|
s471137119
|
p03494
|
u955907183
| 2,000
| 262,144
|
Time Limit Exceeded
| 2,104
| 2,940
| 170
|
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
|
a = int(input())
b = map(int, input().split())
cnt = 0
while(True):
for idata in b:
if ((idata % 2 ) == 0):
continue
else:
break
print(cnt)
|
s407063815
|
Accepted
| 20
| 3,064
| 260
|
a = int(input())
b = list(map(int, input().split()))
cnt = 0
endflag = False
while(True):
for i in range(0,a):
if ((b[i] %2 ) == 0):
b[i] = b[i] / 2
else:
endflag = True
break
if (endflag):
break
cnt = cnt + 1
print(cnt)
|
s357709672
|
p03993
|
u782930273
| 2,000
| 262,144
|
Wrong Answer
| 71
| 20,540
| 141
|
There are N rabbits, numbered 1 through N. The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i. For a pair of rabbits i and j (i<j), we call the pair (i,j) a _friendly pair_ if the following condition is met. * Rabbit i likes rabbit j and rabbit j likes rabbit i. Calculate the number of the friendly pairs.
|
N = int(input())
A = [int(a) - 1 for a in input().split()]
count = 0
for i in range(N):
if i == A[A[i]]:
count += 1
print(count)
|
s574669385
|
Accepted
| 75
| 20,612
| 147
|
N = int(input())
A = [int(a) - 1 for a in input().split()]
count = 0
for i in range(N):
if i == A[A[i]]:
count += 1
print(count // 2)
|
s326707386
|
p03494
|
u549383771
| 2,000
| 262,144
|
Wrong Answer
| 20
| 3,060
| 294
|
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
|
a = int(input())
num_list = list(map(int,input().split()))
max_count = 0
for i in num_list:
count = 0
while True:
if i%2 == 0:
count += 1
i = i/2
else:
break
if count > max_count:
max_count = count
print(max_count)
|
s610167619
|
Accepted
| 20
| 3,060
| 294
|
a = int(input())
num_list = list(map(int,input().split()))
count = 0
true = True
while true:
for i in range(a):
if num_list[i]%2 == 0:
num_list[i] = num_list[i]/2
else:
true = False
count -= 1
break
count += 1
print(count)
|
s986153305
|
p02317
|
u938045879
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,628
| 327
|
For a given sequence A = {a0, a1, ... , an-1}, find the length of the longest increasing subsequnece (LIS) in A. An increasing subsequence of A is defined by a subsequence {ai0, ai1, ... , aik} where 0 ≤ i0 < i1 < ... < ik < n and ai0 < ai1 < ... < aik.
|
from bisect import bisect_left
n = int(input())
dp = []
a=[int(input()) for i in range(n)]
length=-1
for i in range(n):
k = bisect_left(dp, a[i])
dp.append(a[i])
if(length < k):
dp.append(a[i])
length += 1
else:
dp[k] = a[i]
print(length+1)
|
s437990349
|
Accepted
| 310
| 10,352
| 265
|
from bisect import bisect_left
n = int(input())
dp = []
a=[int(input()) for i in range(n)]
length=-1
for i in range(n):
k = bisect_left(dp, a[i])
if(length < k):
dp.append(a[i])
length += 1
else:
dp[k] = a[i]
print(length+1)
|
s858133332
|
p02659
|
u663710122
| 2,000
| 1,048,576
|
Wrong Answer
| 23
| 9,192
| 89
|
Compute A \times B, truncate its fractional part, and print the result as an integer.
|
S = input().split()
A = int(S[0])
B = float(S[1])
B = B * 100 // 1
print(A * B // 100)
|
s164406957
|
Accepted
| 26
| 10,028
| 83
|
from decimal import Decimal
A, B = map(Decimal, input().split())
print(int(A * B))
|
s454727100
|
p03081
|
u197300773
| 2,000
| 1,048,576
|
Wrong Answer
| 2,104
| 10,748
| 410
|
There are N squares numbered 1 to N from left to right. Each square has a character written on it, and Square i has a letter s_i. Besides, there is initially one golem on each square. Snuke cast Q spells to move the golems. The i-th spell consisted of two characters t_i and d_i, where d_i is `L` or `R`. When Snuke cast this spell, for each square with the character t_i, all golems on that square moved to the square adjacent to the left if d_i is `L`, and moved to the square adjacent to the right if d_i is `R`. However, when a golem tried to move left from Square 1 or move right from Square N, it disappeared. Find the number of golems remaining after Snuke cast the Q spells.
|
N,Q=map(int,input().split())
chr=input()
s=[-1]+[ord(chr[i])-ord("A")+1 for i in range(N)]+[-1]
state=[0]+[1 for i in range(N)]+[0]
print(s)
for i in range(Q):
a,b=input().split()
k=ord(a)-ord("A")+1
for j in range(1,N+1):
if s[j]==k:
if b=="R": state[j+1]+=state[j]
if b=="L": state[j-1]+=state[j]
state[j]=0
zanki=N-state[0]-state[N+1]
print(zanki)
|
s451321959
|
Accepted
| 550
| 26,832
| 331
|
N,Q=map(int,input().split())
s="0"+input()+"0"
queri=[list(input().split()) for i in range(Q)]
L,R=0,N+1
for i in range(Q-1,-1,-1):
t,d=queri[i]
if t==s[L] and d=="R":
L-=1
elif t==s[L+1] and d=="L":
L+=1
if t==s[R] and d=="L":
R+=1
elif t==s[R-1] and d=="R":
R-=1
print(R-L-1)
|
s839121400
|
p03797
|
u934868410
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 73
|
Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces. Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces.
|
n,m = map(int,input().split())
print(min(n, m//2) + min(0, (m-2*n) // 4))
|
s775403356
|
Accepted
| 17
| 2,940
| 73
|
n,m = map(int,input().split())
print(min(n, m//2) + max(0, (m-2*n) // 4))
|
s300704099
|
p03671
|
u708211626
| 2,000
| 262,144
|
Wrong Answer
| 28
| 9,020
| 98
|
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.
|
a,b,c=map(int,input().split())
if a>b:
print(b+c)
elif b>c:
print(a+c)
else:
print(a+b)
|
s310185304
|
Accepted
| 27
| 8,976
| 93
|
a,b,c=map(int,input().split())
s=[]
s.append(a+b)
s.append(a+c)
s.append(b+c)
print(min(s))
|
s504916673
|
p03845
|
u787449825
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 443
|
Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her.
|
n = int(input())
a = list(map(int, input().split()))
numbers = set(a)
for i in range(n):
if a.count(0)>=2 or a.count(i)>=3:
print(0)
exit(0)
if max(a)>(n-1):
print(0)
exit(0)
if n%2==1:
if all(i%2==0 for i in a):
print(1 if numbers==1 else (len(numbers)-1)**2%(10**9+7))
else:
print(0)
else:
if all(i%2==1 for i in a):
print((len(numbers))**2%(10**9+7))
else:
print(0)
|
s272591429
|
Accepted
| 17
| 3,064
| 251
|
n = int(input())
t =list(map(int, input().split()))
m = int(input())
p, x = [0]*m, [0]*m
for i in range(m):
p[i], x[i] = map(int, input().split())
for j in range(m):
prev = t[p[j]-1]
t[p[j]-1] = x[j]
print(sum(t))
t[p[j]-1] = prev
|
s113111602
|
p02613
|
u173151534
| 2,000
| 1,048,576
|
Wrong Answer
| 147
| 9,060
| 359
|
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
word = input()
if word == "AC":
ac += 1
elif word == "WA":
wa += 1
elif word == "TLE":
tle += 1
elif word == "RE":
re += 1
print("AC × {}".format(ac))
print("WA × {}".format(wa))
print("TLE × {}".format(tle))
print("RE × {}".format(re))
|
s196934493
|
Accepted
| 144
| 9,236
| 354
|
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
word = input()
if word == "AC":
ac += 1
elif word == "WA":
wa += 1
elif word == "TLE":
tle += 1
elif word == "RE":
re += 1
print("AC x {}".format(ac))
print("WA x {}".format(wa))
print("TLE x {}".format(tle))
print("RE x {}".format(re))
|
s003926410
|
p03696
|
u395420491
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 313
|
You are given a string S of length N consisting of `(` and `)`. Your task is to insert some number of `(` and `)` into S to obtain a _correct bracket sequence_. Here, a correct bracket sequence is defined as follows: * `()` is a correct bracket sequence. * If X is a correct bracket sequence, the concatenation of `(`, X and `)` in this order is also a correct bracket sequence. * If X and Y are correct bracket sequences, the concatenation of X and Y in this order is also a correct bracket sequence. * Every correct bracket sequence can be derived from the rules above. Find the shortest correct bracket sequence that can be obtained. If there is more than one such sequence, find the lexicographically smallest one.
|
N = int(input())
s = input()
hist = [(0, 0)]
max_dist = 0
for v in s:
x, y = hist[-1]
if v == "(": x += 1
elif v == ")": y += 1
hist.append((x,y))
print((x,y), max_dist)
max_dist = max(y - x, max_dist)
lastx , lasty = hist[-1]
print ("(" * max_dist + s + ")" *(lastx - lasty + max_dist))
|
s749995978
|
Accepted
| 17
| 3,060
| 286
|
N = int(input())
s = input()
hist = [(0, 0)]
max_dist = 0
for v in s:
x, y = hist[-1]
if v == "(": x += 1
elif v == ")": y += 1
hist.append((x,y))
max_dist = max(y - x, max_dist)
lastx , lasty = hist[-1]
print ("(" * max_dist + s + ")" *(lastx - lasty + max_dist))
|
s161521956
|
p03407
|
u746428948
| 2,000
| 262,144
|
Wrong Answer
| 19
| 2,940
| 98
|
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
|
a,b,c = map(int,input().split())
if c == a or c == b or c == a+b:
print('Yes')
else: print('No')
|
s594370655
|
Accepted
| 17
| 2,940
| 78
|
a,b,c = map(int,input().split())
if c <= a + b: print('Yes')
else: print('No')
|
s635861863
|
p03577
|
u642012866
| 2,000
| 262,144
|
Wrong Answer
| 25
| 9,084
| 19
|
Rng is going to a festival. The name of the festival is given to you as a string S, which ends with `FESTIVAL`, from input. Answer the question: "Rng is going to a festival of what?" Output the answer. Here, assume that the name of "a festival of s" is a string obtained by appending `FESTIVAL` to the end of s. For example, `CODEFESTIVAL` is a festival of `CODE`.
|
print(input()[:-9])
|
s612649898
|
Accepted
| 25
| 9,040
| 19
|
print(input()[:-8])
|
s358147845
|
p03478
|
u626228246
| 2,000
| 262,144
|
Wrong Answer
| 47
| 9,304
| 152
|
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
|
n,a,b = map(int,input().split())
cnt = []
for i in range(1,n+1):
s = list(map(int,str(i)))
print(s)
if a<=sum(s)<=b:
cnt.append(i)
print(sum(cnt))
|
s916068936
|
Accepted
| 44
| 9,296
| 142
|
n,a,b = map(int,input().split())
cnt = []
for i in range(1,n+1):
s = list(map(int,str(i)))
if a<=sum(s)<=b:
cnt.append(i)
print(sum(cnt))
|
s375028956
|
p03415
|
u502200133
| 2,000
| 262,144
|
Wrong Answer
| 25
| 9,032
| 60
|
We have a 3×3 square grid, where each square contains a lowercase English letters. The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}. Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.
|
c = input()
d = input()
e = input()
ans = c[0] + d[1] + e[2]
|
s930253545
|
Accepted
| 31
| 8,804
| 71
|
c = input()
d = input()
e = input()
ans = c[0] + d[1] + e[2]
print(ans)
|
s545381690
|
p03759
|
u065939424
| 2,000
| 262,144
|
Wrong Answer
| 29
| 9,096
| 211
|
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
|
a, b, c = map(int, input().split())
result = 'No'
if b - a == c - b:
result = 'Yes'
elif a - b == b - c:
result = 'Yes'
print(result)
|
s371450263
|
Accepted
| 27
| 9,160
| 211
|
a, b, c = map(int, input().split())
result = 'NO'
if b - a == c - b:
result = 'YES'
elif a - b == b - c:
result = 'YES'
print(result)
|
s688617554
|
p00542
|
u327546577
| 8,000
| 262,144
|
Wrong Answer
| 20
| 5,592
| 152
|
JOI 君は物理,化学,生物,地学,歴史,地理の 6 科目のテストを受けた. それぞれのテストは 100 点満点で採点された. JOI 君は物理,化学,生物,地学の 4 科目から 3 科目を選択し,歴史,地理の 2 科目から 1 科目を選択する. テストの合計点が最も高くなるように科目を選ぶとき, JOI 君の選んだ科目のテストの合計点を求めよ.
|
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
F = int(input())
print(sum(sorted([A, B, C, D])[:3]) + max(E, F))
|
s697044350
|
Accepted
| 20
| 5,600
| 166
|
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
F = int(input())
print(sum(sorted([A, B, C, D], reverse=True)[:3]) + max(E, F))
|
s824890646
|
p03605
|
u106181248
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 75
|
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
|
s = input().split()
if s.count("9") > 0:
print("Yes")
else:
print("No")
|
s490006905
|
Accepted
| 18
| 2,940
| 74
|
s = list(input())
if s.count("9") > 0:
print("Yes")
else:
print("No")
|
s084782592
|
p04029
|
u708211626
| 2,000
| 262,144
|
Wrong Answer
| 26
| 9,028
| 85
|
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
|
s=input()
a=''
for i in s:
if i=='B':
a=a[:-1]
else:
a+=i
print(a)
|
s114295815
|
Accepted
| 25
| 9,088
| 56
|
a=int(input())
s=0
while a>0:
s+=a
a-=1
print(s)
|
s032319211
|
p03861
|
u075595666
| 2,000
| 262,144
|
Wrong Answer
| 2,108
| 2,940
| 103
|
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
|
a,b,x = map(int,input().split())
count = 0
for i in range(a,b):
if i%x == 0:
count += 1
print(count)
|
s648242480
|
Accepted
| 20
| 3,316
| 85
|
a,b,x = map(int,input().split())
ans = b//x - a//x
if a%x == 0:
ans += 1
print(ans)
|
s713978089
|
p03574
|
u055687574
| 2,000
| 262,144
|
Wrong Answer
| 24
| 3,188
| 298
|
You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process.
|
H,W = map(int,input().split())
s = [[''for i in range(W+2)]for j in range(H+2)]
for i in range(H):
s[i+1][1:W+1] = input()
for j in range(W):
if s[i+1][j+1] == '.':
s[i+1][j+1] = str(1*(sum(s[k+i][j:j+3].count('#') for k in range(3))))
print(*s[i+1][1:W+1],sep='')
|
s304341119
|
Accepted
| 33
| 3,444
| 401
|
H, W = map(int, input().split())
area = []
for i in range(H):
area.append(input())
for i in range(H):
for j in range(W):
if area[i][j] == '#':
print('#', end='')
else:
count = 0
for k in range(max(0, i-1), min(i+1, H-1)+1):
for l in range(max(0, j-1), min(j+1, W-1)+1):
if area[k][l] == '#':
count += 1
print(count, end='')
print()
|
s191741322
|
p02612
|
u373274281
| 2,000
| 1,048,576
|
Wrong Answer
| 25
| 9,020
| 40
|
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())
x = N % 1000
print(N-x)
|
s814907587
|
Accepted
| 28
| 9,072
| 54
|
N = int(input())
N = N % 1000
print((1000 - N) % 1000)
|
s350255932
|
p03408
|
u139112865
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 169
|
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.
|
#091_B
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]
res=0
for S in set(s):
res+=max(0,s.count(S)-t.count(S))
print(res)
|
s556826834
|
Accepted
| 18
| 3,064
| 170
|
#091_B
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]
res=0
for S in set(s):
res=max(res,s.count(S)-t.count(S))
print(res)
|
s911733553
|
p03878
|
u052499405
| 2,000
| 262,144
|
Wrong Answer
| 431
| 12,588
| 506
|
There are N computers and N sockets in a one-dimensional world. The coordinate of the i-th computer is a_i, and the coordinate of the i-th socket is b_i. It is guaranteed that these 2N coordinates are pairwise distinct. Snuke wants to connect each computer to a socket using a cable. Each socket can be connected to only one computer. In how many ways can he minimize the total length of the cables? Compute the answer modulo 10^9+7.
|
MOD = 10**9 + 7
n = int(input())
a_s = []; b_s = []
for i in range(n):
a_s.append(int(input()))
for i in range(n):
b_s.append(int(input()))
match = [0] * (n - 1)
for i, (a, b) in enumerate(zip(a_s[1:], b_s)):
if a == b:
match[i] = 1
for i, (a, b) in enumerate(zip(a_s, b_s[1:])):
if a == b:
match[i] = 1
match += [0]
ans = 1
cnt = 0
for item in match:
if item == 1:
cnt += 1
else:
ans *= pow(2, cnt, MOD)
ans %= MOD
cnt = 0
print(ans)
|
s806050589
|
Accepted
| 792
| 30,740
| 422
|
MOD = 10**9 + 7
n = int(input())
nodes = []
for i in range(n):
nodes.append([int(input()), 0])
for i in range(n):
nodes.append([int(input()), 1])
nodes.sort()
ans = 1
cnt = 0
state = 0
for x, label in nodes:
if cnt == 0:
cnt += 1
state = label
else:
if state == label:
cnt += 1
else:
ans *= cnt
ans %= MOD
cnt -= 1
print(ans)
|
s334448802
|
p02742
|
u680503348
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 147
|
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:
|
def invr():
return(map(int, input().split()))
h, w = invr()
c = (int((h+1)/2)*w)
print(c)
if h % 2 != 0:
c = c - (w-1)/2
print(int(c))
|
s882964152
|
Accepted
| 18
| 2,940
| 169
|
def invr():
return(map(int, input().split()))
h, w = invr()
c = (int((h+1)/2)*w)
if h % 2 != 0:
c = c - (w-1)/2
if h == 1 or w == 1:
c = 1
print(int(c))
|
s771387128
|
p03337
|
u487288850
| 2,000
| 1,048,576
|
Wrong Answer
| 26
| 9,144
| 47
|
You are given two integers A and B. Find the largest value among A+B, A-B and A \times B.
|
a,b = map(int,input().split())
max(a+b,a-b,a*b)
|
s243531039
|
Accepted
| 24
| 9,000
| 54
|
a,b = map(int,input().split())
print(max(a+b,a-b,a*b))
|
s638195069
|
p03721
|
u667024514
| 2,000
| 262,144
|
Wrong Answer
| 323
| 14,836
| 245
|
There is an empty array. The following N operations will be performed to insert integers into the array. In the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array. Find the K-th smallest integer in the array after the N operations. For example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.
|
n,k = map(int,input().split())
t = [[0,0] for i in range(n)]
for i in range(n):
a,b = map(int,input().split())
kk = 0
t = sorted(t, key=lambda t:t[0])
for i in range(n):
kk += t[i][1]
if kk >= k:
print(t[i][1])
break
|
s567967625
|
Accepted
| 474
| 27,872
| 191
|
n,m = map(int,input().split())
lis = [list(map(int,input().split())) for i in range(n)]
cou = 0
lis.sort()
for i in range(n):
cou += lis[i][1]
if cou >= m:
print(lis[i][0])
exit()
|
s796725939
|
p04043
|
u375616706
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 129
|
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
l = (list)(map(int,input().split()))
l = sorted(l)
ans = 'NO'
if l[0]=='5' and l[1]=='5' and l[2]=='7':
ans = 'YES'
print(ans)
|
s076138717
|
Accepted
| 17
| 2,940
| 133
|
l = (list)(map(int, input().split()))
l = sorted(l)
ans = 'NO'
if l[0] == 5 and l[1] == 5 and l[2] == 7:
ans = 'YES'
print(ans)
|
s580790297
|
p03971
|
u759076129
| 2,000
| 262,144
|
Wrong Answer
| 68
| 9,140
| 347
|
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these. Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests. * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B. * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students. A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these. Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass.
|
n, a, b = [int(i) for i in input().split()]
border = a + b
foreign_pass = 0
passed = 0
s = input()
for x in s:
if passed >= border:
print('No')
continue
if x == 'a':
print('Yes')
passed += 1
elif x == 'b' and foreign_pass < b:
print('Yes')
foreign_pass += 1
else:
print('No')
|
s400316674
|
Accepted
| 67
| 9,232
| 368
|
n, a, b = [int(i) for i in input().split()]
border = a + b
foreign_pass = 0
passed = 0
s = input()
for x in s:
if passed >= border:
print('No')
continue
if x == 'a':
print('Yes')
passed += 1
elif x == 'b' and foreign_pass < b:
print('Yes')
passed += 1
foreign_pass += 1
else:
print('No')
|
s443850162
|
p03434
|
u865413330
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 185
|
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.
|
n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
Alice = 0
for i in range(0, n, 2):
print(i)
Alice += l[i]
Bob = sum(l) - Alice
print(abs(Bob - Alice))
|
s721775251
|
Accepted
| 18
| 2,940
| 172
|
n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
Alice = 0
for i in range(0, n, 2):
Alice += l[i]
Bob = sum(l) - Alice
print(abs(Bob - Alice))
|
s067194835
|
p03610
|
u551109821
| 2,000
| 262,144
|
Wrong Answer
| 41
| 5,032
| 101
|
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
|
s = list(input())
ans = []
for i in range(len(s)):
if i%2==0:
ans.append(s[i])
print(ans)
|
s035465547
|
Accepted
| 35
| 4,268
| 110
|
s = list(input())
ans = []
for i in range(len(s)):
if i%2==0:
ans.append(s[i])
print(''.join(ans))
|
s590994526
|
p02614
|
u145145077
| 1,000
| 1,048,576
|
Wrong Answer
| 161
| 9,108
| 424
|
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.
|
h,w,k=map(int,input().split())
c=list()
for i in range(h):
d=list(input())
c.append(d)
num_h = 2**(h+1)
num_w = 2**(w+1)
result = 0
for i in range(num_h):
for j in range(num_w):
tmp = 0
for row in range(h):
for col in range(w):
if (j >> row) & 1 == 0:
if (i >> col) & 1 == 0:
if c[row][col] == '#':
tmp += 1
if tmp == k:
result += 1
print(result/4)
|
s043455719
|
Accepted
| 66
| 9,188
| 452
|
h,w,k=map(int,input().split())
c=list()
for i in range(h):
d=list(input())
c.append(d)
num_h = 2**h-1
num_w = 2**w-1
result = 0
for i in range(num_h):
for j in range(num_w):
tmp = 0
for row in range(h):
for col in range(w):
if (i >> row) & 1 == 1:
continue
if (j >> col) & 1 == 1:
continue
if c[row][col] == '#':
tmp += 1
if tmp == k:
result += 1
print(int(result))
|
s707229908
|
p03854
|
u733321071
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,188
| 339
|
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`.
|
# -*- coding: utf-8
s = input()
s = s[-1]
t = ['maerd', 'remaerd', 'esare', 'resare']
flag = True
while s:
for n in range(len(t)):
if s[0:len(t[n])] == t[n]:
s.lstrip(t[n])
flag = True
else:
flag = False
if not flag:
break
if flag:
print('Yes')
else:
print('No')
|
s904422572
|
Accepted
| 18
| 3,188
| 172
|
# -*- coding: utf-8
s = input()
t = ["eraser", "erase", "dreamer", "dream"]
for n in range(4):
s = s.replace(t[n], "")
if not s:
print('YES')
else:
print('NO')
|
s019939151
|
p03470
|
u853064660
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 389
|
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
|
N = int(input())
d = [int(input()) for j in range(N)]
# d = [3,15,15]
d.sort(reverse=True)
current_mochi = 0
next_mochi = 0
counter = 0
for i,num in enumerate(d):
next_mochi = num
if i == 0:
counter+=1
current_mochi = num
elif i + 1 == len(d):
break
elif current_mochi > next_mochi:
counter+=1
current_mochi = num
print(counter)
|
s347306711
|
Accepted
| 17
| 3,064
| 483
|
N = int(input())
d = [int(input()) for j in range(N)]
# d = [1,2]
d.sort(reverse=True)
current_mochi = 0
next_mochi = 0
counter = 0
for i,num in enumerate(d):
next_mochi = num
if i == 0:
counter+=1
current_mochi = num
elif i + 1 == len(d):
if current_mochi > next_mochi:
counter+=1
break
else:
break
elif current_mochi > next_mochi:
counter+=1
current_mochi = num
print(counter)
|
s363266432
|
p03698
|
u331997680
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 102
|
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
|
S = input()
M = len(S)
N = set(S)
O = list(N)
P = len(O)
if M == P:
print('Yes')
else:
print('No')
|
s072085511
|
Accepted
| 17
| 2,940
| 102
|
S = input()
M = len(S)
N = set(S)
O = list(N)
P = len(O)
if M == P:
print('yes')
else:
print('no')
|
s126859763
|
p03659
|
u602873084
| 2,000
| 262,144
|
Wrong Answer
| 71
| 24,832
| 260
|
Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it. They will share these cards. First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards. Here, both Snuke and Raccoon have to take at least one card. Let the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively. They would like to minimize |x-y|. Find the minimum possible value of |x-y|.
|
N = int(input())
a = list(map(int, input().split()))
total = sum(a)
half = total / 2.0
base = 0
diff = half
for i in range(len(a)):
base += a[i]
diff_n = abs(base - half)
if diff_n > diff:
print(abs(sum(a[:i]) * 2 - total))
break
|
s180824127
|
Accepted
| 160
| 28,956
| 227
|
N = int(input())
a = list(map(int, input().split()))
total = sum(a)
acc_sum = [0] * N
base = 0
for i in range(N):
base += a[i]
acc_sum[i] = base
diff = [abs(acc * 2 - total) for acc in acc_sum]
print(min(diff[:-1]))
|
s986237378
|
p03048
|
u209918867
| 2,000
| 1,048,576
|
Wrong Answer
| 1,703
| 2,940
| 129
|
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes. How many triples of non-negative integers (r,g,b) achieve this?
|
a,b,c,n=map(int,input().split())
q=0
for i in range(n//a+1):
for j in range((n-a*i)//b+1):
if(n-i*a+j*b)%c==0:q+=1
print(q)
|
s168473338
|
Accepted
| 1,722
| 2,940
| 143
|
a,b,c,n=map(int,input().split())
q=0
for i in range(n//a+1):
for j in range((n-a*i)//b+1):
t=n-i*a-j*b
if t%c==0:
q+=1
print(q)
|
s916795406
|
p03853
|
u399280934
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 108
|
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
|
h,w=map(int,input().split())
x=[input() for _ in range(h)]
for i in x:
print(i)
for i in x:
print(i)
|
s674624678
|
Accepted
| 17
| 3,060
| 96
|
h,w=map(int,input().split())
x=[input() for _ in range(h)]
for i in x:
print(i)
print(i)
|
s434861253
|
p01101
|
u600006574
| 8,000
| 262,144
|
Wrong Answer
| 3,670
| 5,628
| 396
|
Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to buy the pair of two items with the highest price sum, not exceeding the amount Mammy allows. As getting two of the same item is boring, he wants two different items. You are asked to help Taro select the two items. The price list for all of the items is given. Among pairs of two items in the list, find the pair with the highest price sum not exceeding the allowed amount, and report the sum. Taro is buying two items, not one, nor three, nor more. Note that, two or more items in the list may be priced equally.
|
import sys
while(True):
items=[]
max=0
n, m = map(int, input().split())
if (n == 0 & m == 0):exit()
items = list(map(int, input().split()))
for i in range(n):
for j in range(n):
sum = items[i] + items[j]
if (i != j and sum < m and sum > max):
max = sum
if (max == 0):
print("NONE")
else:
print(max)
|
s430658634
|
Accepted
| 3,600
| 5,632
| 397
|
import sys
while(True):
items=[]
max=0
n, m = map(int, input().split())
if (n == 0 & m == 0):exit()
items = list(map(int, input().split()))
for i in range(n):
for j in range(n):
sum = items[i] + items[j]
if (i != j and sum <= m and sum > max):
max = sum
if (max == 0):
print("NONE")
else:
print(max)
|
s815103888
|
p04043
|
u451206510
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 84
|
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
A = list(map(int, input().split()))
A.sort()
print("Yes" if A == [5,5,7] else "No")
|
s441606231
|
Accepted
| 17
| 2,940
| 84
|
A = list(map(int, input().split()))
A.sort()
print("YES" if A == [5,5,7] else "NO")
|
s684851318
|
p04043
|
u759718348
| 2,000
| 262,144
|
Wrong Answer
| 22
| 9,104
| 120
|
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
A = list(map(int, input().split()))
A.sort()
if A[0] == 5 and A[1] == 5 and A[2] ==7:
print('Yes')
else:
print('No')
|
s124948784
|
Accepted
| 21
| 9,028
| 120
|
A = list(map(int, input().split()))
A.sort()
if A[0] == 5 and A[1] == 5 and A[2] ==7:
print('YES')
else:
print('NO')
|
s192621748
|
p03485
|
u638282348
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 87
|
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
print(math.ceil(eval(input().replace(" ", "+")) / 2) for math in [__import__("math")])
|
s429837630
|
Accepted
| 17
| 2,940
| 88
|
[print(math.ceil(eval(input().replace(" ", "+")) / 2)) for math in [__import__("math")]]
|
s163302340
|
p03625
|
u739843002
| 2,000
| 262,144
|
Wrong Answer
| 225
| 20,040
| 499
|
We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.
|
N = int(input())
A = [int(a) for a in input().split(" ")]
A.sort(reverse=True)
l1 = 0
c1 = 0
l2 = 0
c2 = 0
L1 = 0
L2 = 0
for i in range(len(A)):
print(" ".join([str(s) for s in [i, l1, c1, l2, c2, L1, L2]]))
if L1 and L2:
break
elif L1:
if l2 == A[i]:
c2 += 1
elif l2 != A[i]:
l2 = A[i]
c2 = 1
if c2 == 2:
L2 = l2
else:
if l1 == A[i]:
c1 += 1
elif l1 != A[i]:
l1 = A[i]
c1 = 1
if c1 == 2:
L1 = l1
print(L1 * L2)
|
s358267020
|
Accepted
| 90
| 20,048
| 434
|
N = int(input())
A = [int(a) for a in input().split(" ")]
A.sort(reverse=True)
l1 = 0
c1 = 0
l2 = 0
c2 = 0
L1 = 0
L2 = 0
for i in range(len(A)):
if L1 and L2:
break
elif L1:
if l2 == A[i]:
c2 += 1
elif l2 != A[i]:
l2 = A[i]
c2 = 1
if c2 == 2:
L2 = l2
else:
if l1 == A[i]:
c1 += 1
elif l1 != A[i]:
l1 = A[i]
c1 = 1
if c1 == 2:
L1 = l1
print(L1 * L2)
|
s601397750
|
p03377
|
u733925602
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 132
|
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.
|
#Cats and Dogs
A, B, X = map(int, input().split())
if ((X-A) <= B) and (A <= X):
print("Yes")
else:
print("No")
|
s875098743
|
Accepted
| 17
| 2,940
| 132
|
#Cats and Dogs
A, B, X = map(int, input().split())
if ((X-A) <= B) and (A <= X):
print("YES")
else:
print("NO")
|
s438577943
|
p03493
|
u770308589
| 2,000
| 262,144
|
Wrong Answer
| 30
| 9,036
| 118
|
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.
|
n = input()
count = 0
if(n[0]=='1'):
count+=1
elif(n[1]=='1'):
count+=1
elif(n[2]=='1'):
count+=1
print(count)
|
s132388521
|
Accepted
| 26
| 9,036
| 116
|
n = input()
count = 0
if(n[0]=='1'):
count+=1
if(n[1]=='1'):
count+=1
if(n[2]=='1'):
count+=1
print(count)
|
s663219549
|
p00026
|
u299798926
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,620
| 1,390
|
As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (x, y) coordinate system. We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. Your task is to write a program which reads a sequence of points of fall (x, y) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. You may assume that the paper always consists of 10 × 10, and 0 ≤ x < 10, 0 ≤ y < 10\.
|
A=[[int(0) for i in range(10)]for j in range(10)]
count=0
while 1:
try:
x,y,s = map(int, input().split(','))
if s==1:
for i in range(x-1,x+1):
if i>=0 and i<=9:
A[i][y]=A[i][y]+1
for i in range(y-1,y+1):
if i>=0 and i<=9:
A[x][i]=A[x][i]+1
A[x][y]=A[x][y]-1
elif s==2:
for i in range(x-1,x+1):
for j in range(y-1,y+1):
if i>=0 and i<=9 and j>=0 and j<=9:
A[i][j]=A[i][j]+1
else:
for i in range(x-2,x+2):
if i>=0 and i<=9:
A[i][y]=A[i][y]+1
for i in range(y-2,y+2):
if i>=0 and i<=9:
A[x][i]=A[x][i]+1
for i in range(x-1,x+1):
if i>=0 and i<=9:
A[i][y]=A[i][y]-1
for i in range(y-1,y+1):
if i>=0 and i<=9:
A[x][i]=A[x][i]-1
for i in range(x-1,x+1):
for j in range(y-1,y+1):
if i>=0 and i<=9 and j>=0 and j<=9:
A[i][j]=A[i][j]+1
except EOFError:
break
for i in range(10):
for j in range(10):
if A[i][j]==0:
count=count+1
print(count)
print(max(A))
|
s138880683
|
Accepted
| 20
| 5,624
| 1,435
|
A=[[int(0) for i in range(10)]for j in range(10)]
count=0
while 1:
try:
x,y,s = map(int, input().split(','))
if s==1:
for i in range(x-1,x+2):
if i>=0 and i<=9:
A[i][y]=A[i][y]+1
for i in range(y-1,y+2):
if i>=0 and i<=9:
A[x][i]=A[x][i]+1
A[x][y]=A[x][y]-1
elif s==2:
for i in range(x-1,x+2):
for j in range(y-1,y+2):
if i>=0 and i<=9 and j>=0 and j<=9:
A[i][j]=A[i][j]+1
else:
for i in range(x-2,x+3):
if i>=0 and i<=9:
A[i][y]=A[i][y]+1
for i in range(y-2,y+3):
if i>=0 and i<=9:
A[x][i]=A[x][i]+1
for i in range(x-1,x+2):
if i>=0 and i<=9:
A[i][y]=A[i][y]-1
for i in range(y-1,y+2):
if i>=0 and i<=9:
A[x][i]=A[x][i]-1
for i in range(x-1,x+2):
for j in range(y-1,y+2):
if i>=0 and i<=9 and j>=0 and j<=9:
A[i][j]=A[i][j]+1
except:
break
num=0
for i in range(10):
for j in range(10):
if A[i][j]==0:
count=count+1
if A[i][j]!=0:
if num<A[i][j]:
num=A[i][j]
print(count)
print(num)
|
s119592537
|
p03693
|
u774838740
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 95
|
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
|
A = list(input().split())
a = int(''.join(A))
if a%4==0:
print("Yes")
else:
print("No")
|
s331495019
|
Accepted
| 17
| 2,940
| 95
|
A = list(input().split())
a = int(''.join(A))
if a%4==0:
print("YES")
else:
print("NO")
|
s625712415
|
p04029
|
u209918867
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 29
|
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
|
n=int(input());print(n*-~n/2)
|
s705331957
|
Accepted
| 17
| 2,940
| 30
|
n=int(input());print(n*-~n//2)
|
s692178529
|
p00030
|
u150984829
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,600
| 126
|
0 から 9 の数字から異なる n 個の数を取り出して合計が s となる組み合わせの数を出力するプログラムを作成してください。n 個の数はおのおの 0 から 9 までとし、1つの組み合わせに同じ数字は使えません。たとえば、n が 3 で s が 6 のとき、3 個の数字の合計が 6 になる組み合わせは、 1 + 2 + 3 = 6 0 + 1 + 5 = 6 0 + 2 + 4 = 6 の 3 通りとなります。
|
while 1:
n,x=map(int,input().split())
if n+x==0:break
print(sum([max(0,(x-a-1)//2-max(a,x-a-1-n))for a in range(1,x//3)]))
|
s240044308
|
Accepted
| 20
| 5,648
| 136
|
import itertools
for e in iter(input,'0 0'):
n,s=map(int,e.split())
print(sum(s==sum(p)for p in itertools.combinations(range(10),n)))
|
s689571946
|
p03543
|
u229333839
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 119
|
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**?
|
n=input()
if n[0]==n[1] and n[1]==n[2]:
print("Yes")
if n[1]==n[2] and n[3]==n[2]:
print("Yes")
else:
print("No")
|
s214586121
|
Accepted
| 17
| 2,940
| 103
|
n=input()
if n[0]==n[1]==n[2]:
print("Yes")
elif n[1]==n[2]==n[3]:
print("Yes")
else:
print("No")
|
s639878530
|
p03495
|
u597374218
| 2,000
| 262,144
|
Wrong Answer
| 334
| 56,984
| 219
|
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.
|
from collections import Counter
n,k=map(int,input().split())
a=Counter(input().split())
ans=0
keys,counts=zip(*a.most_common())
for num,(key,count) in enumerate(zip(keys,counts)):
if int(num)>k:ans+=count
print(ans)
|
s364212576
|
Accepted
| 92
| 35,996
| 135
|
from collections import Counter
n,k=map(int,input().split())
a=Counter(input().split())
print(sum(sorted(a.values(),reverse=True)[k:]))
|
s077047994
|
p03599
|
u869919400
| 3,000
| 262,144
|
Wrong Answer
| 277
| 3,064
| 562
|
Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations. * Operation 1: Pour 100A grams of water into the beaker. * Operation 2: Pour 100B grams of water into the beaker. * Operation 3: Put C grams of sugar into the beaker. * Operation 4: Put D grams of sugar into the beaker. In our experimental environment, E grams of sugar can dissolve into 100 grams of water. Snuke will make sugar water with the highest possible density. The beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker. Find the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it. If there is more than one candidate, any of them will be accepted. We remind you that the sugar water that contains a grams of water and b grams of sugar is \frac{100b}{a + b} percent. Also, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.
|
a, b, c, d, e, f = map(int, input().split())
result = [0, 0]
noude = 0
for i in range(31):
for j in range(31):
for k in range(101):
for l in range(101):
water = a * 100 * i + b * 100 * j
sugar = c * k + d * l
if water == 0 or water + sugar > f:
break
if (water / 100) * e >= sugar and noude < (100 * sugar) / (water + sugar):
noude = (100 * sugar) / (water + sugar)
result = [water + sugar, sugar]
print(result)
|
s269536534
|
Accepted
| 301
| 3,064
| 627
|
a, b, c, d, e, f = map(int, input().split())
result = [0, 0]
noude = 0
for i in range(31):
for j in range(31):
for k in range(101):
for l in range(101):
water = a * 100 * i + b * 100 * j
sugar = c * k + d * l
if water == 0 or water + sugar > f:
break
if (water / 100) * e >= sugar and noude < (100 * sugar) / (water + sugar):
noude = (100 * sugar) / (water + sugar)
result = [water + sugar, sugar]
if result[1] == 0:
print(a * 100, 0)
else:
print(result[0], result[1])
|
s843644637
|
p03623
|
u254871849
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 114
|
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
|
from sys import stdin
x, a, b = map(int, stdin.readline().split())
print('A' if abs(a - x) > abs(b - x) else "B")
|
s632621952
|
Accepted
| 16
| 2,940
| 202
|
import sys
x, a, b = map(int, sys.stdin.readline().split())
def main():
db = abs(b - x)
da = abs(a - x)
ans = 'A' if da < db else 'B'
print(ans)
if __name__ == '__main__':
main()
|
s498407468
|
p03563
|
u333768710
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 808
|
Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the contest is b. * Then, the new rating of the user will be the avarage of a and b. For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000. Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest. Find the performance required to achieve it.
|
if __name__ == '__main__':
hidden_key = input()
flag_string = input()
key_length = len(hidden_key)
flag_length = len(flag_string)
if key_length < flag_length:
print('UNRESTORABLE')
exit()
key_list = list(hidden_key.replace('?', 'a'))
for i in reversed(range(key_length - flag_length + 1)):
part_key = hidden_key[i:i + flag_length]
is_match = True
for j in range(flag_length):
if part_key[j] != '?' and part_key[j] != flag_string[j]:
is_match = False
break
if is_match:
for k in range(flag_length):
key_list[i + k] = flag_string[k]
print(''.join(key_list))
break
if not is_match:
print('UNRESTORABLE')
|
s406557428
|
Accepted
| 17
| 2,940
| 83
|
current_rate = int(input())
target = int(input())
print(target * 2 - current_rate)
|
s099409569
|
p02694
|
u572839972
| 2,000
| 1,048,576
|
Wrong Answer
| 22
| 9,152
| 119
|
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
X = int(input())
dep = 100
year = 0
while dep <= X:
dep += int(0.01*dep)
year += 1
#print(dep)
print(year)
|
s096117346
|
Accepted
| 23
| 9,156
| 120
|
X = int(input())
dep = 100
year = 0
while dep < X:
dep += int(0.01*dep)
year += 1
#print(dep)
print(year)
|
s919181501
|
p03400
|
u163421511
| 2,000
| 262,144
|
Wrong Answer
| 27
| 9,184
| 234
|
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 = [int(input()) for _ in range(n)]
eat = 0
for i, item in enumerate(a):
if d // a[i] == 0:
eat += d // a[i]
else:
eat += d // a[i]+1
print(x + eat)
|
s660869774
|
Accepted
| 24
| 9,104
| 189
|
n = int(input())
d, x = map(int, input().split())
a = [int(input()) for _ in range(n)]
eat = 0
for i in range(len(a)):
for j in range(1, d+1, a[i]):
eat += 1
print(x + eat)
|
s520334036
|
p00456
|
u855694108
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,768
| 305
|
先日,オンラインでのプログラミングコンテストが行われた. W大学とK大学のコンピュータクラブは以前からライバル関係にあり,このコンテストを利用して両者の優劣を決めようということになった. 今回,この2つの大学からはともに10人ずつがこのコンテストに参加した.長い議論の末,参加した10人のうち,得点の高い方から3人の得点を合計し,大学の得点とすることにした. W大学およびK大学の参加者の得点のデータが与えられる.このとき,おのおのの大学の得点を計算するプログラムを作成せよ.
|
def main():
a = []
b = []
for _ in range(10):
a.append(int(input()))
for _ in range(10):
b.append(int(input()))
a_sum = 0
b_sum = 0
for x in a:
a_sum += x
for x in b:
b_sum += x
print(a_sum, b_sum)
if __name__ == "__main__":
main()
|
s286596344
|
Accepted
| 20
| 7,792
| 339
|
def main():
a = []
b = []
for _ in range(10):
a.append(int(input()))
for _ in range(10):
b.append(int(input()))
a.sort(reverse = True)
b.sort(reverse = True)
aa = 0
bb = 0
for x in range(3):
aa += a[x]
bb += b[x]
print(aa, bb)
if __name__ == "__main__":
main()
|
s789924916
|
p03386
|
u496131003
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 185
|
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())
if 2*K < B-A+1:
for i in range(K):
print(A+i)
for i in range(K):
print(B-i)
else:
for i in range(B-A+1):
print(A+i)
|
s459311766
|
Accepted
| 17
| 3,060
| 189
|
A,B,K = map(int, input().split())
if 2*K < B-A+1:
for i in range(K):
print(A+i)
for i in range(K):
print(B-K+i+1)
else:
for i in range(B-A+1):
print(A+i)
|
s182980188
|
p02417
|
u208157605
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,544
| 226
|
Write a program which counts and reports the number of each alphabetical letter. Ignore the case of characters.
|
alphabet = 'abcdefghijklmnopqrstuvwxyz'
from collections import defaultdict
adict = defaultdict(int)
str = input().lower()
for c in str:
adict[c] += 1
print(adict)
for k in alphabet:
print('%s : %i' %(k, adict[k]))
|
s039815991
|
Accepted
| 40
| 7,604
| 243
|
alphabet = 'abcdefghijklmnopqrstuvwxyz'
from collections import defaultdict
import sys
adict = defaultdict(int)
for l in sys.stdin:
for c in l.lower():
adict[c] += 1
for k in alphabet:
print('%s : %i' %(k, adict[k]))
|
s282479558
|
p03624
|
u757274384
| 2,000
| 262,144
|
Wrong Answer
| 40
| 4,204
| 106
|
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead.
|
S = list(input())
S. sort()
if S[len(S)-1] == "z":
print("None")
else:
print(chr(ord(S[len(S)-1])+1))
|
s196965981
|
Accepted
| 74
| 4,856
| 196
|
S = list(input())
S. sort()
a = ord("a")
z = ord("z")
X = []
for i in range(len(S)):
X.append(ord(S[i]))
for j in range(a,z+1):
if j not in X:
print(chr(j))
exit()
print("None")
|
s182655442
|
p02842
|
u894934980
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 122
|
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.
|
import math
N = int(input())
ans = int(int(math.ceil(N / 1.08)) * 1.08)
if N == ans:
print(ans)
else:
print(":(")
|
s996188602
|
Accepted
| 18
| 3,060
| 117
|
import math
N = int(input())
ans = math.ceil(N / 1.08)
if N == int(ans * 1.08):
print(ans)
else:
print(":(")
|
s051300664
|
p03759
|
u934740772
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 81
|
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
|
a,b,c=map(int,input().split())
if a==b==c:
print('YES')
else:
print('NO')
|
s510289592
|
Accepted
| 17
| 2,940
| 84
|
a,b,c=map(int,input().split())
if b-a==c-b:
print('YES')
else:
print(('NO'))
|
s669403372
|
p03679
|
u227085629
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 93
|
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+x:
print('dangerous')
else:
print('delicious')
|
s166483004
|
Accepted
| 17
| 2,940
| 121
|
x,a,b = map(int, input().split())
if b > a+x:
print('dangerous')
elif b > a:
print('safe')
else:
print('delicious')
|
s504100191
|
p02255
|
u535719732
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,596
| 178
|
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
|
n = int(input())
a = list(map(int,input().split()))
for i in range(1,n):
print(a)
j = i -1
v = a[i]
while j >= 0 and a[j] > v:
a[j+1] = a[j]
j -= 1
a[j+1] = v
print(a)
|
s128668126
|
Accepted
| 20
| 5,984
| 180
|
n = int(input())
a = list(map(int,input().split()))
for i in range(1,n):
print(*a)
j = i -1
v = a[i]
while j >= 0 and a[j] > v:
a[j+1] = a[j]
j -= 1
a[j+1] = v
print(*a)
|
s812465292
|
p02262
|
u939814144
| 6,000
| 131,072
|
Wrong Answer
| 20
| 7,668
| 578
|
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$
|
def insertion_sort(A, n, g, count):
for i in range(n):
v = A[i]
j = i - g
while(j>=0 and A[j] > v):
A[j+1] = A[j]
j = j - g
count += 1
A[j+1] = v
return count
def shell_sort(A, n):
count = 0
g = 1
G = []
while g < n/9:
G.insert(0, g)
g = g*3 + 1
for i in range(len(G)):
count = insertion_sort(A, n, G[i], count)
print(' '.join(map(str, A)))
if __name__ == '__main__':
n = int(input())
A = [input() for i in range(n)]
shell_sort(A, n)
|
s527335383
|
Accepted
| 20,620
| 127,884
| 655
|
def insertion_sort(A, n, g, count):
for i in range(g, n):
v = A[i]
j = i - g
while(j>=0 and A[j] > v):
A[j+g] = A[j]
j = j - g
count += 1
A[j+g] = v
return count
def shell_sort(A, n):
count = 0
g = 1
G = []
while g <= n:
G.insert(0, g)
g = g*3 + 1
print(len(G))
print(' '.join(map(str, G)))
for i in range(len(G)):
count = insertion_sort(A, n, G[i], count)
print(count)
print('\n'.join(map(str, A)))
if __name__ == '__main__':
n = int(input())
A = [int(input()) for i in range(n)]
shell_sort(A, n)
|
s554398597
|
p03227
|
u807772568
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 82
|
You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.
|
a = list(input())
if len(a) == 2:
print(a)
else:
a.reverse()
print(a)
|
s175978469
|
Accepted
| 17
| 2,940
| 120
|
a = list(input())
if len(a) == 2:
a = "".join(a)
print(a)
else:
a.reverse()
a = "".join(a)
print(a)
|
s719076146
|
p03044
|
u149752754
| 2,000
| 1,048,576
|
Wrong Answer
| 721
| 16,004
| 1,500
|
We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied: * For any two vertices painted in the same color, the distance between them is an even number. Find a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.
|
import sys
sys.setrecursionlimit(100000000)
class UnionFind():
def __init__(self,size):
self.table = [-1 for _ in range(size)]
def find(self,x):
if self.table[x] < 0:
return x
else:
self.table[x] = self.find(self.table[x])
return self.table[x]
def union(self,a,b):
a1 = self.find(a)
a2 = self.find(b)
if a1!= a2:
if self.table[a1] < self.table[a2]:
self.table[a1] = a2
elif self.table[a2] < self.table[a1]:
self.table[a2] = a1
else:
self.table[a1] = a2
self.table[a2] -= 1
return
N = int(input())
uf = UnionFind(N)
ou = []
ov = []
for _ in range(N-1):
u,v,w = map(int,input().split())
if w %2 == 0:
uf.union(u-1,v-1)
else:
ou.append(u-1)
ov.append(v-1)
M = len(ou)
oj = [0] * N
for i in range(M):
if (oj[uf.find(ou[i])] == 0)&(oj[uf.find(ov[i])] == 0):
oj[uf.find(ou[i])] = 1
elif (oj[uf.find(ou[i])] == 0)&(oj[uf.find(ov[i])] == 1):
oj[uf.find(ou[i])] = 2
elif (oj[uf.find(ou[i])] == 0)&(oj[uf.find(ov[i])] == 2):
oj[uf.find(ou[i])] = 1
elif (oj[uf.find(ou[i])] == 1)&(oj[uf.find(ov[i])] == 0):
oj[uf.find(ov[i])] = 2
elif (oj[uf.find(ou[i])] == 2)&(oj[uf.find(ov[i])] == 0):
oj[uf.find(ov[i])] = 1
for i in range(N):
if oj[uf.find(i)] == 1:
print(1)
else:
print(0)
|
s777511693
|
Accepted
| 927
| 81,884
| 783
|
import sys
sys.setrecursionlimit(10000000)
N = int(input())
JU = [-1 for _ in range(N)]
LI = [[] for _ in range(N)]
for _ in range(N-1):
u,v,w = map(int,input().split())
W = w%2
LI[u-1].append([v-1,W])
LI[v-1].append([u-1,W])
def dfs(x):
for i in range(len(LI[x])):
j = LI[x][i][0]
k = LI[x][i][1]
if JU[j] == -1:
if JU[x] == 0:
if k == 0:
JU[j] = 0
dfs(j)
else:
JU[j] = 1
dfs(j)
else:
if k == 0:
JU[j] = 1
dfs(j)
else:
JU[j] = 0
dfs(j)
JU[0] = 0
dfs(0)
for i in range(N):
print(JU[i])
|
s469409252
|
p03448
|
u534319350
| 2,000
| 262,144
|
Wrong Answer
| 2,104
| 3,064
| 260
|
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.
|
X = int(input())
A = int(input())
B = int(input())
C = int(input())
count = 0
for i in range(A + 1):
for j in range(B + 1):
for l in range(C + 1):
if (500*i + 100*j + 50*l) == X:
count += 1
print(count)
|
s817536302
|
Accepted
| 50
| 3,060
| 260
|
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A + 1):
for j in range(B + 1):
for l in range(C + 1):
if (500*i + 100*j + 50*l) == X:
count += 1
print(count)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.