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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s835970696
|
p03435
|
u416758623
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 514
|
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j. Determine if he is correct.
|
def Infomation():
if not (c11 - c21 == c12 - c22 == c13 - c23):
return False
if not (c11 - c31 == c12 - c33 == c13 - c33):
return False
if not (c11 - c12 == c21 - c22 == c31 - c32):
return False
if not (c11 - c13 == c21 - c23 == c31 - c33):
return False
return True
c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())
flag = Infomation()
if flag:
print("Yes")
else:
print("No")
|
s454256344
|
Accepted
| 30
| 9,212
| 331
|
c = [list(map(int,input().split())) for i in range(3)]
x = [0] * 3
y = [0] * 3
for i in range(3):
y[i] = c[0][i] - x[0]
for i in range(3):
x[i] = c[i][0] - y[0]
flag = True
for i in range(3):
for j in range(3):
if x[i] + y[j] != c[i][j]:
flag = False
if flag:
print("Yes")
else:
print("No")
|
s196499175
|
p03448
|
u842838534
| 2,000
| 262,144
|
Wrong Answer
| 41
| 3,064
| 464
|
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())
counter = 0
for i in range(0, a + 1):
if x - (500 * i) >= 0:
x_f = x - (500 * i)
if x_f == 0:
counter += 1
break
for j in range(0, b + 1):
if x_f - (100 * j) >= 0:
x_s = x_f - (100 * j)
if x_s == 0:
counter += 1
break
for k in range(0, c + 1):
if x_s - (50 * k) >= 0:
x_t = x_s - (50 * k)
if x_t == 0:
counter += 1
break
print(counter)
|
s533373526
|
Accepted
| 39
| 3,188
| 482
|
a = int(input())
b = int(input())
c = int(input())
x = int(input())
counter = 0
for i in range(0, a + 1):
if x - (500 * i) >= 0:
x_f = x - (500 * i)
if x_f == 0:
counter += 1
break
for j in range(0, b + 1):
if x_f - (100 * j) >= 0:
x_s = x_f - (100 * j)
if x_s == 0:
counter += 1
break
for k in range(0, c + 1):
if x_s - (50 * k) >= 0:
x_t = x_s - (50 * k)
if x_t == 0:
counter += 1
break
print(counter)
|
s502532786
|
p03625
|
u946969297
| 2,000
| 262,144
|
Wrong Answer
| 224
| 14,244
| 420
|
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.
|
def C():
n = int(input())
a = sorted(list(map(int,input().split())),reverse=True)
i=0
print(a)
longer = 0
shorter = 0
while i < len(a)-1:
print(i,a[i])
if a[i] == a[i+1]:
if longer == 0:
longer = a[i]
i+=1
elif shorter == 0:
shorter = a[i]
i+=1
i+=1
print(longer*shorter)
C()
|
s122140381
|
Accepted
| 101
| 14,224
| 385
|
def C():
n = int(input())
a = sorted(list(map(int,input().split())),reverse=True)
i=0
longer = 0
shorter = 0
while i < len(a)-1:
if a[i] == a[i+1]:
if longer == 0:
longer = a[i]
i+=1
elif shorter == 0:
shorter = a[i]
i+=1
i+=1
print(longer*shorter)
C()
|
s796924617
|
p02607
|
u256769262
| 2,000
| 1,048,576
|
Wrong Answer
| 29
| 9,044
| 126
|
We have N squares assigned the numbers 1,2,3,\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i. How many squares i satisfy both of the following conditions? * The assigned number, i, is odd. * The written integer is odd.
|
n = int(input())
a = [int(x) for x in input().split()]
cnt = 0
for a0 in a[::1]:
if a0%2 == 1:
cnt += 1
print(cnt)
|
s254614259
|
Accepted
| 25
| 9,108
| 126
|
n = int(input())
a = [int(x) for x in input().split()]
cnt = 0
for a0 in a[::2]:
if a0%2 == 1:
cnt += 1
print(cnt)
|
s109480160
|
p03623
|
u693027786
| 2,000
| 262,144
|
Wrong Answer
| 31
| 9,064
| 107
|
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
|
A, B, X = map(int, input().split())
if (A - X) * (A - X) < (B - X) * (B - X) : print('A')
else : print('B')
|
s870848900
|
Accepted
| 28
| 8,972
| 107
|
X, A, B = map(int, input().split())
if (A - X) * (A - X) < (B - X) * (B - X) : print('A')
else : print('B')
|
s932748454
|
p03605
|
u928784113
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 103
|
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?
|
# -*- coding: utf-8 -*-
N = str(input())
S = N.count("9")
if S == 0:
print("NO")
else:
print("YES")
|
s453103222
|
Accepted
| 18
| 2,940
| 103
|
# -*- coding: utf-8 -*-
N = str(input())
S = N.count("9")
if S == 0:
print("No")
else:
print("Yes")
|
s230312967
|
p03815
|
u944209426
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 114
|
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7. Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation: * Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward. For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back. Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.
|
x=int(input())
if x%11==0:
a=int(x/11*2)
elif x%11/6>1:
a=int(x/11*2)+2
else:
a=int(x/11*2)+1
print(a)
|
s695616004
|
Accepted
| 17
| 2,940
| 116
|
x=int(input())
if x%11==0:
a=int(x/11)*2
elif (x%11)/6>1:
a=int(x/11)*2+2
else:
a=int(x/11)*2+1
print(a)
|
s170401260
|
p03369
|
u829416877
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 115
|
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen.
|
S = input()
X = 700
if S[0] == '○':
X += 100
if S[1] == '○':
X += 100
if S[2] == '○':
X += 100
print(X)
|
s090914258
|
Accepted
| 17
| 2,940
| 109
|
S = input()
X = 700
if S[0] == 'o':
X += 100
if S[1] == 'o':
X += 100
if S[2] == 'o':
X += 100
print(X)
|
s940867253
|
p03067
|
u125337618
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 230
|
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
|
xs = list(map(int,input().split(' ')))
print(xs)
if xs[0] < xs[1]:
if xs[0] < xs[2] and xs[2] < xs[1]:
print('Yes')
else:
print('No')
else:
if xs[0] > xs[2] and xs[2] > xs[1]:
print('Yes')
else:
print('No')
|
s462551714
|
Accepted
| 24
| 3,060
| 220
|
xs = list(map(int,input().split(' ')))
if xs[0] < xs[1]:
if xs[0] < xs[2] and xs[2] < xs[1]:
print('Yes')
else:
print('No')
else:
if xs[0] > xs[2] and xs[2] > xs[1]:
print('Yes')
else:
print('No')
|
s498703705
|
p03370
|
u095756391
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 114
|
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
|
N, X = map(int, input().split())
m = [int(input()) for i in range(N)]
X -= sum(m)
ans = X // min(m)
print(ans)
|
s047723770
|
Accepted
| 17
| 2,940
| 121
|
N, X = map(int, input().split())
m = [int(input()) for i in range(N)]
X -= sum(m)
ans = (X // min(m)) + N
print(ans)
|
s474047607
|
p02613
|
u024609780
| 2,000
| 1,048,576
|
Wrong Answer
| 52
| 9,200
| 297
|
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):
if i == "AC":
ac += 1
elif i == "WA":
wa += 1
elif i == "TLE":
tle += 1
else:
re += 1
print("AC x" + str(ac))
print("WA x" + str(wa))
print("TLE x" + str(tle))
print("RE x" + str(re))
|
s761134187
|
Accepted
| 147
| 9,196
| 317
|
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
j = input()
if j == "AC":
ac += 1
elif j == "WA":
wa += 1
elif j == "TLE":
tle += 1
else:
re += 1
print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))
|
s041848620
|
p02608
|
u057942294
| 2,000
| 1,048,576
|
Wrong Answer
| 48
| 9,296
| 915
|
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
def main():
N = int(input())
f = [0] * (N+1)
for x in range(1, 41):
for y in range(x, 42):
for z in range(y, 42):
if (ans := (x+y+z)**2 - x*y - y*z - z*x) in range(1, N+1):
count = 0
if x == y and y == z:
count = 1
elif x != y and y != z and z != x:
count = 6
else:
count = 3
f[ans] += count
for i in range(1, N+1):
print(i, f[i])
def input_ints():
line_list = input().split()
if len(line_list) == 1:
return int(line_list[0])
else:
return map(int, line_list)
def input_int_list_in_line():
return list(map(int, input().split()))
def input_int_tuple_list(n: int):
return [tuple(map(int, input().split())) for _ in range(n)]
main()
|
s542821426
|
Accepted
| 144
| 9,236
| 915
|
def main():
N = int(input())
f = [0] * (N+1)
for x in range(1, 100):
for y in range(x, 100):
for z in range(y, 100):
if (ans := (x+y+z)**2 - x*y - y*z - z*x) in range(1, N+1):
count = 0
if x == y and y == z:
count = 1
elif x != y and y != z and z != x:
count = 6
else:
count = 3
f[ans] += count
for i in range(1, N+1):
print(f[i])
def input_ints():
line_list = input().split()
if len(line_list) == 1:
return int(line_list[0])
else:
return map(int, line_list)
def input_int_list_in_line():
return list(map(int, input().split()))
def input_int_tuple_list(n: int):
return [tuple(map(int, input().split())) for _ in range(n)]
main()
|
s095563018
|
p02866
|
u940831163
| 2,000
| 1,048,576
|
Wrong Answer
| 2,104
| 13,908
| 544
|
Given is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition: * For every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.
|
import sys
import math
n = int(input())
d = list(map(int, input().split()))
d.sort()
min_d = min(d)
max_d = max(d)
mod = 998244353
if min_d == max_d or d.count(min_d) >= 2:
print(0)
sys.exit()
count = [1 for _ in range(max_d-min_d+1)]
for i in range(min_d, max_d+1):
count[i-min_d] = d.count(i)
if count[i-min_d] == 0:
print(0)
sys.exit()
ans = count[1]
for i in range(1,max_d-min_d):
n = count[i]-1
m = count[i+1]
ans *= (math.factorial(n+m)//(math.factorial(n)*math.factorial(m)))%mod
print(ans)
|
s990130613
|
Accepted
| 176
| 14,396
| 343
|
n = int(input())
d = list(map(int, input().split()))
max_d = max(d)
mod = 998244353
if d[0] != 0:
print(0)
exit()
count = [0 for _ in range(max_d+1)]
for i in range(n):
count[d[i]] += 1
if count[0] != 1:
print(0)
exit()
ans = 1
for i in range(max_d):
n = count[i]
m = count[i+1]
ans *= n**m%mod
print(ans%mod)
|
s351531547
|
p03385
|
u258436671
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 118
|
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
|
S = input()
if S.count('a') == '1' and S.count('b') == '1' and S.count('c') == '1':
print('Yes')
else:
print('No')
|
s139336832
|
Accepted
| 17
| 2,940
| 112
|
S = input()
if S.count('a') == 1 and S.count('b') == 1 and S.count('c') == 1:
print('Yes')
else:
print('No')
|
s662414784
|
p04012
|
u230621983
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 128
|
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
|
w = input()
cs = set(w)
print(cs)
ans = 'Yes'
for c in cs:
if w.count(c)%2 != 0:
ans = 'No'
break
print(ans)
|
s792039828
|
Accepted
| 17
| 2,940
| 118
|
w = input()
cs = set(w)
ans = 'Yes'
for c in cs:
if w.count(c)%2 != 0:
ans = 'No'
break
print(ans)
|
s038102002
|
p03679
|
u405660020
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 129
|
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())
k=-a+b
if k<=0:
print('delicious')
elif k<=x:
print('safer')
else:
print('dangerous')
|
s920079674
|
Accepted
| 17
| 2,940
| 128
|
x,a,b=map(int,input().split())
k=-a+b
if k<=0:
print('delicious')
elif k<=x:
print('safe')
else:
print('dangerous')
|
s010435807
|
p03860
|
u440161695
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,060
| 25
|
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
|
print("A"+input()[0]+"C")
|
s894627832
|
Accepted
| 17
| 2,940
| 25
|
print("A"+input()[8]+"C")
|
s288303436
|
p03457
|
u403301154
| 2,000
| 262,144
|
Wrong Answer
| 373
| 3,064
| 275
|
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
|
n = int(input())
t1, x1, y1=map(int, input().split())
if t1<x1+y1 or (x1+y1+t1)%2==1:
print("NO")
exit()
for i in range(n-1):
t2, x2, y2=map(int, input().split())
if t2<x2+y2 or (abs(x2-x1)+abs(y2-y1))>t2-t1 or (x2+y2+t2)%2==1:
print("NO")
exit()
print("YES")
|
s262289952
|
Accepted
| 384
| 3,064
| 275
|
n = int(input())
t1, x1, y1=map(int, input().split())
if t1<x1+y1 or (x1+y1+t1)%2==1:
print("No")
exit()
for i in range(n-1):
t2, x2, y2=map(int, input().split())
if t2<x2+y2 or (abs(x2-x1)+abs(y2-y1))>t2-t1 or (x2+y2+t2)%2==1:
print("No")
exit()
print("Yes")
|
s960018513
|
p03609
|
u501952592
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 25
|
We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
|
s = input()
print(s[::1])
|
s390510305
|
Accepted
| 18
| 2,940
| 52
|
X, t = map(int, input().split())
print(max(X - t,0))
|
s295626851
|
p03407
|
u203995947
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 94
|
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
|
a, b, c = map(int, input().split(' '))
if a + b >= c:
print('YES')
else:
print('NO')
|
s560342711
|
Accepted
| 17
| 2,940
| 94
|
a, b, c = map(int, input().split(' '))
if a + b >= c:
print('Yes')
else:
print('No')
|
s259276846
|
p02694
|
u141190115
| 2,000
| 1,048,576
|
Wrong Answer
| 21
| 9,104
| 181
|
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
import math
def main():
X = int(input())
money = 100
n = 0
while(money<=X):
n += 1
money = math.floor(money * 1.01)
print(n)
if __name__ == "__main__":
main()
pass
|
s434704913
|
Accepted
| 25
| 9,160
| 180
|
import math
def main():
X = int(input())
money = 100
n = 0
while(money<X):
n += 1
money = math.floor(money * 1.01)
print(n)
if __name__ == "__main__":
main()
pass
|
s566093619
|
p03693
|
u496280557
| 2,000
| 262,144
|
Wrong Answer
| 23
| 9,096
| 615
|
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?
|
r,g,b = map(int,input().split())
if(100 * r + 10 * g + b) % 4 == 0:
print('Yes')
else:
print('No')
|
s975706700
|
Accepted
| 26
| 9,176
| 661
|
r,g,b = map(int,input().split())
if 1 <= r <=9 and 1 <= g <=9 and 1 <= b <=9 and (100 * r + 10 * g + b) % 4 == 0:
print('YES')
else:
print('NO')
|
s363713650
|
p02260
|
u821624310
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,648
| 445
|
Write a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: SelectionSort(A) 1 for i = 0 to A.length-1 2 mini = i 3 for j = i to A.length-1 4 if A[j] < A[mini] 5 mini = j 6 swap A[i] and A[mini] Note that, indices for array elements are based on 0-origin. Your program should also print the number of swap operations defined in line 6 of the pseudocode in the case where i ≠ mini.
|
N = int(input())
A = list(map(int, input().split()))
cnt = 0
chge = 0
for i in range(N):
mn = A[i]
for j in range(i+1, N):
if mn >= A[j]:
mn = A[j]
chge = 1
if chge:
idx = A.index(mn)
A[idx] = A[i]
A[i] = mn
cnt += 1
chge = 0
for i in range(N):
if i == N - 1:
print(A[i])
else:
print(str(A[i]), end = " ")
print(cnt)
|
s908951884
|
Accepted
| 20
| 7,744
| 441
|
N = int(input())
A = [int(n) for n in input().split()]
cnt = 0
for i in range(N):
min_x = A[i]
exchange = "no"
for j in range(i+1, N):
if min_x > A[j]:
min_x = A[j]
index = j
exchange = "ok"
if exchange == "ok":
A[index] = A[i]
A[i] = min_x
cnt += 1
for i in range(N):
if i == N - 1:
print(A[i])
else:
print(A[i], end=" ")
print(cnt)
|
s033327623
|
p03854
|
u905582793
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,188
| 254
|
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()[::-1]
for i in range(10**5):
if s[:5]=="meard":
s=s[5:]
elif s[:7]=="ermeard":
s=s[7:]
elif s[:5]=="esare":
s=s[5:]
elif s[:6]=="resare":
s=s[6:]
elif s=="":
print("YES")
break
else:
print("NO")
break
|
s036727974
|
Accepted
| 24
| 6,516
| 109
|
import re
s = input()
if re.fullmatch(r"(dream|dreamer|erase|eraser)+",s):
print("YES")
else:
print("NO")
|
s625981833
|
p03067
|
u076773409
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 159
|
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
|
s = input()
a, b, c = [int(_) for _ in s.split()]
a, b, c = [_-a for _ in (a, b, c)]
if c * b > 0 and abs(b) < abs(c):
print("Yes")
else:
print("No")
|
s803066787
|
Accepted
| 17
| 2,940
| 159
|
s = input()
a, b, c = [int(_) for _ in s.split()]
a, b, c = [_-a for _ in (a, b, c)]
if b * c > 0 and abs(b) > abs(c):
print("Yes")
else:
print("No")
|
s262884099
|
p02749
|
u648212584
| 2,000
| 1,048,576
|
Wrong Answer
| 750
| 58,912
| 923
|
We have a tree with N vertices. The vertices are numbered 1 to N, and the i-th edge connects Vertex a_i and Vertex b_i. Takahashi loves the number 3. He is seeking a permutation p_1, p_2, \ldots , p_N of integers from 1 to N satisfying the following condition: * For every pair of vertices (i, j), if the distance between Vertex i and Vertex j is 3, the sum or product of p_i and p_j is a multiple of 3. Here the distance between Vertex i and Vertex j is the number of edges contained in the shortest path from Vertex i to Vertex j. Help Takahashi by finding a permutation that satisfies the condition.
|
import sys
input = sys.stdin.buffer.readline
from collections import deque
def main():
N = int(input())
edge = [[] for _ in range(N)]
for _ in range(N-1):
a,b = map(int,input().split())
edge[a-1].append(b-1)
edge[b-1].append(a-1)
for i in range(N):
if len(edge[i]) == 1:
start = i
break
rest = [[] for _ in range(3)]
go = [False for _ in range(N)]
rest[0].append(start)
go[start] = True
q = deque([start])
use = 1
while q:
now = q.popleft()
for fol in edge[now]:
if not go[fol]:
rest[use%3].append(fol)
go[fol] = True
q.append(fol)
use += 1
t = rest[0]+rest[1]+rest[2]
ans = [0 for _ in range(N)]
for x,num in enumerate(t):
ans[num] = x+1
print(*ans)
if __name__ == "__main__":
main()
|
s841468490
|
Accepted
| 924
| 58,868
| 1,784
|
import sys
input = sys.stdin.buffer.readline
from collections import deque
def main():
N = int(input())
edge = [[] for _ in range(N)]
for _ in range(N-1):
a,b = map(int,input().split())
edge[a-1].append(b-1)
edge[b-1].append(a-1)
use = [-1 for _ in range(N)]
d = [[0],[]]
use[0] = 0
q = deque([0])
while q:
now = q.popleft()
for fol in edge[now]:
if use[fol] == -1:
use[fol] = (use[now]+1)%2
q.append(fol)
d[use[fol]].append(fol)
ans = [0 for _ in range(N)]
b = [False for _ in range(N)]
if len(d[0]) <= N//3:
l = len(d[0])
for i in range(l):
ans[d[0][i]] = 3*i+3
b[3*i+2] = True
t = 0
for num in d[1]:
while b[t]:
t += 1
ans[num] = t+1
b[t] = True
elif len(d[1]) <= N//3:
l = len(d[1])
for i in range(l):
ans[d[1][i]] = 3*i+3
b[3*i+2] = True
t = 0
for num in d[0]:
while b[t]:
t += 1
ans[num] = t+1
b[t] = True
else:
l = len(d[0])
t = 0
for i in range(l):
if i < (N-1)//3+1:
ans[d[0][i]] = 3*i+1
b[3*i] = True
else:
ans[d[0][i]] = 3*t+3
b[3*t+2] = True
t += 1
l = len(d[1])
for i in range(l):
if i < (N-2)//3+1:
ans[d[1][i]] = 3*i+2
b[3*i+1] = True
else:
ans[d[1][i]] = 3*t+3
b[3*t+2] = True
t += 1
print(*ans)
if __name__ == "__main__":
main()
|
s135537441
|
p03370
|
u066455063
| 2,000
| 262,144
|
Time Limit Exceeded
| 2,104
| 3,060
| 152
|
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
|
N, X = map(int, input().split())
m = [int(i) for i in range(N)]
m.sort()
ans = 3
X -= sum(m)
while X >= m[0]:
X -= m[0]
ans += 1
print(ans)
|
s729210284
|
Accepted
| 18
| 2,940
| 182
|
N, X = map(int, input().split())
ans = N
m_list = []
for i in range(N):
m = int(input())
m_list.append(m)
m_list.sort()
X -= sum(m_list)
ans += X // m_list[0]
print(ans)
|
s128474006
|
p03353
|
u050428930
| 2,000
| 1,048,576
|
Wrong Answer
| 37
| 4,592
| 169
|
You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. Also, we say that substrings are different when they are different as strings. Let X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \neq y_{j}.
|
s=list(input())
k=int(input())
t=set({})
print(s)
for i in range(min(k,len(s))):
for j in range(len(s)-i):
t.add("".join(s[j:i+j+1]))
print(sorted(t)[k-1])
|
s749057854
|
Accepted
| 39
| 4,592
| 160
|
s=list(input())
k=int(input())
t=set({})
for i in range(min(k,len(s))):
for j in range(len(s)-i):
t.add("".join(s[j:i+j+1]))
print(sorted(t)[k-1])
|
s844205733
|
p03480
|
u799613351
| 2,000
| 262,144
|
Wrong Answer
| 2,114
| 112,876
| 393
|
You are given a string S consisting of `0` and `1`. Find the maximum integer K not greater than |S| such that we can turn all the characters of S into `0` by repeating the following operation some number of times. * Choose a contiguous segment [l,r] in S whose length is at least K (that is, r-l+1\geq K must be satisfied). For each integer i such that l\leq i\leq r, do the following: if S_i is `0`, replace it with `1`; if S_i is `1`, replace it with `0`.
|
S = input()
N = len(S)
def aaa():
s = [0]
for K in range(N, 1, -1):
new_s = []
for i in range(N-K+1):
a = ['0'] * (N - K)
a.insert(i, '1' * K)
sk = ''.join(a)
for c in s:
new_s.append(c ^ int(sk, 2))
s = list(set(new_s))
if int(S, 2) in s:
return K
return 1
print(aaa())
|
s548508644
|
Accepted
| 61
| 3,188
| 116
|
S = input()
N = len(S)
K = N
for i in range(1, N):
if S[i-1] != S[i]:
K = min(K, max(i, N-i))
print(K)
|
s642930112
|
p02669
|
u075595666
| 2,000
| 1,048,576
|
Wrong Answer
| 133
| 10,300
| 407
|
You start with the number 0 and you want to reach the number N. You can change the number, paying a certain amount of coins, with the following operations: * Multiply the number by 2, paying A coins. * Multiply the number by 3, paying B coins. * Multiply the number by 5, paying C coins. * Increase or decrease the number by 1, paying D coins. You can perform these operations in arbitrary order and an arbitrary number of times. What is the minimum number of coins you need to reach N? **You have to solve T testcases.**
|
import sys
sys.setrecursionlimit(10**9)
from functools import lru_cache
from math import ceil as C
t = int(input())
for _ in range(t):
n,a,b,c,d = map(int,input().split())
@lru_cache(None)
def f(k):
if k == 1:return d
if k == 0:return 0
return min(k*d,f(k//2)+a+k%2*d,f(C(k//2))+a+-k%2*d,f(k//3)+b+k%3*d,f(C(k//3))+b+-k%3*d,f(k//5)+c+k%5*d,f(C(k//5))+c+-k%5*d)
print(f(n))
|
s991432212
|
Accepted
| 225
| 11,324
| 386
|
import sys
sys.setrecursionlimit(10**9)
from functools import lru_cache
t = int(input())
for _ in range(t):
n,a,b,c,d = map(int,input().split())
@lru_cache(None)
def f(k):
if k == 1:return d
if k == 0:return 0
return min(k*d,f(k//5)+c+k%5*d,f(k//3)+b+k%3*d,f(k//2)+a+k%2*d,f((k+4)//5)+c+-k%5*d,f((k+2)//3)+b+-k%3*d,f((k+1)//2)+a+-k%2*d)
print(f(n))
|
s449511508
|
p02401
|
u146790816
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,600
| 173
|
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.
|
s=input().split()
a,b=map(int,(s[0],s[2]))
op=s[1]
if op=="+":
print(a + b)
elif op=="-":
print(a - b)
elif op=="*":
print(a * b)
elif op=="/":
print(a / b)
|
s994379338
|
Accepted
| 30
| 5,596
| 306
|
while True:
s=input().split()
op=s[1]
if not (op=="+" or op=="-" or op=="*" or op=="/"):
break
a=int(s[0])
b=int(s[2])
if op=="+":
print(a + b)
elif op=="-":
print(a - b)
elif op=="*":
print(a * b)
elif op=="/":
print(int(a / b))
|
s539462506
|
p03494
|
u703890795
| 2,000
| 262,144
|
Wrong Answer
| 19
| 2,940
| 224
|
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
|
N = int(input())
A = list(map(int, input().split()))
c = 0
f = True
while(True):
for i in range(N):
if A[i]%2 == 1:
f = False
if f:
for i in range(N):
A[i] /= 2
c += 1
else:
break
print(c)
|
s966971025
|
Accepted
| 19
| 2,940
| 222
|
N = int(input())
A = list(map(int, input().split()))
c = 0
f = True
while(True):
for i in range(N):
if A[i]%2 == 1:
f = False
if f:
for i in range(N):
A[i] /= 2
c += 1
else:
break
print(c)
|
s649095289
|
p03023
|
u368016155
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 33
|
Given an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees, but do not print units.
|
N = int(input())
print(180*(N-1))
|
s220743936
|
Accepted
| 18
| 2,940
| 33
|
N = int(input())
print(180*(N-2))
|
s092804682
|
p03494
|
u867069435
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 146
|
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.
|
import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i in a:
ans = min(ans, math.floor(math.log2(i)))
print(ans)
|
s264260313
|
Accepted
| 17
| 3,060
| 164
|
import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i in a:
ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1)
print(round(ans))
|
s901695769
|
p03673
|
u879870653
| 2,000
| 262,144
|
Wrong Answer
| 159
| 26,180
| 383
|
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b. The i-th operation is as follows: 1. Append a_i to the end of b. 2. Reverse the order of the elements in b. Find the sequence b obtained after these n operations.
|
N = int(input())
L = list(map(int,input().split()))
ANS = ["" for i in range(N)]
if N % 2 == 0 :
for i in range(N) :
if i % 2 == 0 :
ANS[(N+i)//2] = L[i]
else :
ANS[(N-i)//2] = L[i]
else :
for i in range(N) :
if i % 2 != 0 :
ANS[(N+i)//2] = L[i]
else :
ANS[(N-i)//2] = L[i]
print(ANS)
|
s975500275
|
Accepted
| 199
| 30,916
| 413
|
N = int(input())
L = list(map(int,input().split()))
ANS = ["" for i in range(N)]
if N % 2 == 0 :
for i in range(N) :
if i % 2 == 0 :
ANS[(N+i)//2] = str(L[i])
else :
ANS[(N-i)//2] = str(L[i])
else :
for i in range(N) :
if i % 2 != 0 :
ANS[(N+i)//2] = str(L[i])
else :
ANS[(N-i)//2] = str(L[i])
print(" ".join(ANS))
|
s186301344
|
p03815
|
u117629640
| 2,000
| 262,144
|
Wrong Answer
| 24
| 3,064
| 260
|
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7. Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation: * Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward. For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back. Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.
|
# -*- coding: utf-8 -*-
def main():
a = int(input())
ans = a % 11
if ans == 0:
print(int(a / 11) * 2)
elif ans > 6:
print(int(a / 11 * 2) + 2)
else:
print(int(a / 11 * 2) + 1)
if __name__ == '__main__':
main()
|
s757129790
|
Accepted
| 25
| 3,188
| 237
|
# -*- coding: utf-8 -*-
def main():
x = int(input())
ans = (x // 11) * 2
x %= 11
if x > 0:
if x > 6:
ans += 2
else:
ans += 1
print(ans)
if __name__ == '__main__':
main()
|
s587580265
|
p00206
|
u546285759
| 1,000
| 131,072
|
Wrong Answer
| 80
| 7,664
| 290
|
あなたは友人と旅行に行きたいと考えています。ところが、浪費癖のある友人はなかなか旅行費用を貯めることができません。友人が今の生活を続けていると、旅行に行くのはいつになってしまうか分かりません。そこで、早く旅行に行きたいあなたは、友人が計画的に貯蓄することを助けるプログラムを作成することにしました。 友人のある月のお小遣いを M 円、その月に使うお金を N 円とすると、その月は (M \- N) 円貯蓄されます。毎月の収支情報 M 、 N を入力とし、貯蓄額が旅行費用 L に達するのにかかる月数を出力するプログラムを作成してください。ただし、12 ヶ月を過ぎても貯蓄額が旅行費用に達しなかった場合はNA と出力してください。
|
while True:
L= int(input())
if L== 0: break
mn= [list(map(int, input().split())) for _ in range(12)]
ans=c=1
b= True
for m, n in mn:
ans+= m-n
if ans>= L:
print(c)
b= False
break
c+= 1
if b: print("NA")
|
s925245764
|
Accepted
| 70
| 7,744
| 290
|
while True:
L= int(input())
if L== 0: break
mn= [list(map(int, input().split())) for _ in range(12)]
ans=c=0
b= True
for m, n in mn:
ans+= m-n
c+= 1
if ans>= L:
print(c)
b= False
break
if b: print("NA")
|
s835054402
|
p03360
|
u503228842
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 97
|
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after K operations?
|
a,b,c = map(int,input().split())
k = int(input())
ans = max(a,b,c)*(2**(k+1))-(a+b+c)
print(ans)
|
s800659419
|
Accepted
| 17
| 2,940
| 95
|
a,b,c = map(int,input().split())
k = int(input())
ans = max(a,b,c)*(2**k-1)+(a+b+c)
print(ans)
|
s178862504
|
p03699
|
u028294979
| 2,000
| 262,144
|
Wrong Answer
| 21
| 3,316
| 375
|
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
|
N = 0
s = []
c = 0
total = 0
print('Input number of questions:')
N = int(input())
if N < 1 or N > 100 : quit()
for i in range(N):
s.append(input('Enter grades:'))
if int(s[i]) < 1 or int(s[i]) > 100 : quit()
for i in range(N):
total += int(s[i])
if total%10:
# print('True')
print(total)
else:
# print('False')
print(0)
|
s386069597
|
Accepted
| 18
| 3,060
| 319
|
N = int(input())
s = []
for _ in range(N):
s.append(int(input()))
if sum(s) % 10 != 0:
print(sum(s))
else:
min_s = 0
sorted_s = sorted(s, reverse=True)
for ss in sorted_s:
if ss % 10 != 0:
min_s = ss
if min_s == 0:
print(0)
else:
print(sum(s) - min_s)
|
s301707807
|
p03433
|
u602677143
| 2,000
| 262,144
|
Wrong Answer
| 20
| 3,316
| 85
|
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
n = int(input())
a = int(input())
if (n-a)%500==0:
print("Yes")
else:
print("No")
|
s255205335
|
Accepted
| 17
| 2,940
| 83
|
n = int(input())
a = int(input())
if a >= n%500:
print("Yes")
else:
print("No")
|
s806339110
|
p02255
|
u938045879
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,592
| 329
|
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())
ary = list(map(int, input().split(' ')))
def insertion_sort(array, n):
print(array)
for i in range(1,n):
v = array[i]
j = i-1
while(j>=0 and array[j] > v):
array[j+1] = array[j]
j -= 1
array[j+1] = v
print(array)
insertion_sort(ary, N)
|
s108864291
|
Accepted
| 20
| 5,604
| 430
|
N = int(input())
ary = list(map(int, input().split(' ')))
def insertion_sort(array, n):
print_out(array)
for i in range(1,n):
v = array[i]
j = i-1
while(j>=0 and array[j] > v):
array[j+1] = array[j]
j -= 1
array[j+1] = v
print_out(array)
def print_out(array):
array_str = [str(i) for i in array]
print(" ".join(array_str))
insertion_sort(ary, N)
|
s196168339
|
p03610
|
u994988729
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,188
| 28
|
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=input()
s=s[1::2]
print(s)
|
s769527389
|
Accepted
| 17
| 3,188
| 28
|
s=input()
s=s[0::2]
print(s)
|
s999758737
|
p03826
|
u396211450
| 2,000
| 262,144
|
Wrong Answer
| 28
| 9,104
| 52
|
There are two rectangles. The lengths of the vertical sides of the first rectangle are A, and the lengths of the horizontal sides of the first rectangle are B. The lengths of the vertical sides of the second rectangle are C, and the lengths of the horizontal sides of the second rectangle are D. Print the area of the rectangle with the larger area. If the two rectangles have equal areas, print that area.
|
a,b,c,d=map(int,input().split())
print(max(a*c,b*d))
|
s734687703
|
Accepted
| 28
| 9,148
| 52
|
a,b,c,d=map(int,input().split())
print(max(a*b,c*d))
|
s237594187
|
p00767
|
u197615397
| 8,000
| 131,072
|
Wrong Answer
| 270
| 5,592
| 335
|
Let us consider rectangles whose height, _h_ , and width, _w_ , are both integers. We call such rectangles _integral rectangles_. In this problem, we consider only wide integral rectangles, i.e., those with _w_ > _h_. We define the following ordering of wide integral rectangles. Given two wide integral rectangles, 1. The one shorter in its diagonal line is smaller, and 2. If the two have diagonal lines with the same length, the one shorter in its height is smaller. Given a wide integral rectangle, find the smallest wide integral rectangle bigger than the given one.
|
while True:
h, w = map(int, input().split())
if not h:
break
diagonal = h**2 + w**2
ans = []
append = ans.append
for y in range(1, 151):
for x in range(y+1, 151):
if x**2+y**2 > diagonal:
append((x**2+y**2, y, x))
break
print(*sorted(ans)[0][1:])
|
s202919380
|
Accepted
| 440
| 5,596
| 370
|
while True:
h, w = map(int, input().split())
if not h:
break
diagonal = h**2 + w**2
ans = []
append = ans.append
for y in range(1, 151):
for x in range(y+1, 151):
if x**2+y**2 > diagonal or x**2+y**2 == diagonal and y > h:
append((x**2+y**2, y, x))
break
print(*sorted(ans)[0][1:])
|
s157332622
|
p03695
|
u409757418
| 2,000
| 262,144
|
Wrong Answer
| 27
| 9,120
| 268
|
In AtCoder, a person who has participated in a contest receives a _color_ , which corresponds to the person's rating as follows: * Rating 1-399 : gray * Rating 400-799 : brown * Rating 800-1199 : green * Rating 1200-1599 : cyan * Rating 1600-1999 : blue * Rating 2000-2399 : yellow * Rating 2400-2799 : orange * Rating 2800-3199 : red Other than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not. Currently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i. Find the minimum and maximum possible numbers of different colors of the users.
|
n = int(input())
a = list(map(int,input().split()))
color = [0,0,0,0,0,0,0,0,0]
for ai in a:
if ai <= 3199:
rnk = ai // 400
color[rnk] += 1
else:
color[8] += 1
max_color = sum(color)
color2 = color[:8]
min_color = sum(color2)
print(min_color,max_color)
|
s349255430
|
Accepted
| 29
| 9,084
| 353
|
n = int(input())
a = list(map(int,input().split()))
color = [0,0,0,0,0,0,0,0,0]
if min(a) >= 3200:
print(1,len(a))
quit()
for ai in a:
if ai <= 3199:
rnk = ai // 400
color[rnk] += 1
else:
color[8] += 1
min_color = 0
for i in range(8):
if color[i] > 0:
min_color += 1
max_color = min_color + color[8]
print(min_color,max_color)
|
s790343036
|
p03448
|
u160659351
| 2,000
| 262,144
|
Wrong Answer
| 265
| 4,712
| 269
|
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())
comb = 0
for i in range(0,a+1):
for j in range(0,b+1):
for k in range(0,c+1):
total = int(500 * i + 100 * j + 50 * k)
if total == x:
comb += 1
print(i,j,k)
print(comb)
|
s664868980
|
Accepted
| 75
| 3,064
| 250
|
a = int(input())
b = int(input())
c = int(input())
x = int(input())
comb = 0
for i in range(0,a+1):
for j in range(0,b+1):
for k in range(0,c+1):
total = int(500 * i + 100 * j + 50 * k)
if total == x:
comb += 1
print(comb)
|
s284510490
|
p03351
|
u992759582
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 182
|
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
|
a,b,c,d = map(int,input().split())
list = [a,b,c]
list.sort(reverse=True)
for i in range(len(list)-1):
if list[i] - list[i+1] < d:
print('No')
exit()
print('Yes')
|
s238276911
|
Accepted
| 17
| 2,940
| 129
|
a,b,c,d = map(int,input().split())
if abs(a-c) <= d or (abs(a-b) <= d and abs(b-c) <= d):
print('Yes')
else:
print('No')
|
s498496935
|
p03999
|
u427344224
| 2,000
| 262,144
|
Wrong Answer
| 26
| 3,356
| 552
|
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion. All strings that can be obtained in this way can be evaluated as formulas. Evaluate all possible formulas, and print the sum of the results.
|
s = input()
s_split = [s[i] for i in range(len(s))]
result = 0
for i in range(2**(len(s)-1)):
b = bin(i)[2:]
b = b.zfill(len(s)-1)
tmp = s_split.copy()
for j in range(len(b)-1, -1, -1):
if b[j] == "1":
print(b, j)
tmp.insert(-j-1, "+")
before = ""
num = 0
for x in range(len(tmp)):
if tmp[x] == "+":
num += int(before)
before = ""
else:
before += tmp[x]
if len(before) != 0:
num += int(before)
result += num
print(result)
|
s112916657
|
Accepted
| 27
| 3,064
| 310
|
s = input()
s_split = [s[i] for i in range(len(s))]
result = 0
for i in range(2**(len(s)-1)):
b = bin(i)[2:]
b = b.zfill(len(s)-1)
tmp = s_split.copy()
for j in range(len(b)-1, -1, -1):
if b[j] == "1":
tmp.insert(-j-1, "+")
result += eval("".join(tmp))
print(result)
|
s037325600
|
p03448
|
u714300041
| 2,000
| 262,144
|
Wrong Answer
| 50
| 3,060
| 233
|
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())
output = 0
for a in range(A):
for b in range(B):
for c in range(C):
total = 500*a + 100*b + 50*c
if total == X:
output += 1
print(output)
|
s475998110
|
Accepted
| 55
| 3,060
| 240
|
A = int(input())
B = int(input())
C = int(input())
X = int(input())
output = 0
for a in range(A+1):
for b in range(B+1):
for c in range(C+1):
total = 500*a + 100*b + 50*c
if total == X:
output += 1
print(output)
|
s467143816
|
p02614
|
u131453093
| 1,000
| 1,048,576
|
Wrong Answer
| 39
| 9,360
| 530
|
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.
|
import copy
H, W, K = map(int, input().split())
ans = 0
grid = [["."] + list(input()) for _ in range(H)]
grid.insert(0, ["."] * (W + 1))
for i in range(H+1):
for j in range(W+1):
cnt = 0
grid_copy = copy.deepcopy(grid)
grid_copy[i] = ["|"] * (W+1)
for k in range(H+1):
grid_copy[k][j] = "|"
for l in range(H+1):
for m in range(W+1):
if grid_copy[l][m] == "#":
cnt += 1
if cnt == K:
ans += 1
print(ans)
|
s814042427
|
Accepted
| 49
| 9,204
| 467
|
h, w, k = map(int, input().split())
grid = [list(input()) for _ in range(h)]
cnt = 0
for rows in range(1 << h):
for cols in range(1 << w):
black = 0
for i in range(h):
if (rows >> i) & 1:
continue
for j in range(w):
if (cols >> j) & 1:
continue
if grid[i][j] == "#":
black += 1
if black == k:
cnt += 1
print(cnt)
|
s727594456
|
p02690
|
u537976628
| 2,000
| 1,048,576
|
Wrong Answer
| 35
| 9,164
| 487
|
Give a pair of integers (A, B) such that A^5-B^5 = X. It is guaranteed that there exists such a pair for the given integer X.
|
x = int(input())
a = 0
while True:
print(a)
for b in range(a):
if abs(a ** 5 - b ** 5) == abs(x):
if a ** 5 - b ** 5 == x:
print(a, b)
exit()
else:
print(-a, -b)
exit()
elif abs(a ** 5 + b ** 5) == abs(x):
if a ** 5 + b ** 5 == x:
print(a, -b)
exit()
else:
print(-a, b)
exit()
a += 1
|
s261169494
|
Accepted
| 37
| 9,164
| 474
|
x = int(input())
a = 0
while True:
for b in range(a):
if abs(a ** 5 - b ** 5) == abs(x):
if a ** 5 - b ** 5 == x:
print(a, b)
exit()
else:
print(-a, -b)
exit()
elif abs(a ** 5 + b ** 5) == abs(x):
if a ** 5 + b ** 5 == x:
print(a, -b)
exit()
else:
print(-a, b)
exit()
a += 1
|
s292584768
|
p03610
|
u733837151
| 2,000
| 262,144
|
Wrong Answer
| 47
| 9,608
| 111
|
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 = input()
s.split()
odd = []
for i in range(len(s)):
if i % 2 == 0:
odd.append(s[i])
print(odd)
|
s754846374
|
Accepted
| 43
| 9,136
| 136
|
s = input()
s.split()
odd = []
for i in range(len(s)):
if i % 2 == 0:
odd.append(s[i])
answer = ''.join(odd)
print(answer)
|
s874620151
|
p02613
|
u395356317
| 2,000
| 1,048,576
|
Wrong Answer
| 151
| 16,280
| 287
|
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())
s = [input()for i in range(n)]
c0 = 0
c1 = 0
c2 = 0
c3 = 0
for i in range(n):
if s[i] == 'AC':
c0 += 1
elif s[i] == 'WA':
c1 += 1
elif s[i] == 'TLE':
c2 += 1
else:
c3 += 1
print(f'AC×{c0}\nWA×{c1}\nTLE×{c2}\nRE×{c3}')
|
s576924228
|
Accepted
| 153
| 16,200
| 292
|
n = int(input())
s = [input()for i in range(n)]
c0 = 0
c1 = 0
c2 = 0
c3 = 0
for i in range(n):
if s[i] == 'AC':
c0 += 1
elif s[i] == 'WA':
c1 += 1
elif s[i] == 'TLE':
c2 += 1
else:
c3 += 1
print(f'AC x {c0}\nWA x {c1}\nTLE x {c2}\nRE x {c3}')
|
s894518722
|
p03456
|
u226198609
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 168
|
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
|
a,b=map(str,input().split())
n = int(a+b)
p = 1
for i in range(10):
n = n - p
p += 2
if n == 0:
print("Yes")
break
elif n < 0:
print("No")
break
|
s329914393
|
Accepted
| 17
| 2,940
| 169
|
a,b=map(str,input().split())
n = int(a+b)
p = 1
for i in range(500):
n = n - p
p += 2
if n == 0:
print("Yes")
break
elif n < 0:
print("No")
break
|
s089345672
|
p03067
|
u089376182
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 3,060
| 84
|
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
|
a, b, c = map(int, input().split())
print('Yes' if (a<=b<=c) or (a>=b>=c) else 'No')
|
s480037180
|
Accepted
| 17
| 2,940
| 85
|
a, b, c = map(int, input().split())
print('Yes' if (a<=c<=b) or (a>=c>=b) else 'No')
|
s976397338
|
p04011
|
u429029348
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 98
|
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=(int(input()) for i in range(4))
if n<=k:
ans=n*x
else:
ans=n*x+(n-k)*y
print(ans)
|
s997214165
|
Accepted
| 17
| 2,940
| 98
|
n,k,x,y=(int(input()) for i in range(4))
if n<=k:
ans=n*x
else:
ans=k*x+(n-k)*y
print(ans)
|
s217704545
|
p04043
|
u872056745
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 318
|
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.
|
s = input().split()
a = len(s[0])
b = len(s[1])
c = len(s[2])
count_5 = 0
if a == 5:
count_5 += 1
if b == 5:
count_5 += 1
if c == 5:
count_5 += 1
count_7 = 0
if a == 7:
count_7 += 1
if b == 7:
count_7 += 1
if c == 7:
count_7 += 1
if count_5 == 2 and count_7 == 1:
print("YES")
else:
print("NO")
|
s145630165
|
Accepted
| 17
| 3,064
| 318
|
s = input().split()
a = int(s[0])
b = int(s[1])
c = int(s[2])
count_5 = 0
if a == 5:
count_5 += 1
if b == 5:
count_5 += 1
if c == 5:
count_5 += 1
count_7 = 0
if a == 7:
count_7 += 1
if b == 7:
count_7 += 1
if c == 7:
count_7 += 1
if count_5 == 2 and count_7 == 1:
print("YES")
else:
print("NO")
|
s911115749
|
p03455
|
u556163371
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 82
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a, b = map(int, input().split())
if a*b%2==0:
print("EVEN")
else:
print("ODD")
|
s490190125
|
Accepted
| 17
| 2,940
| 80
|
a,b=map(int, input().split())
if a*b%2==0:
print("Even")
else:
print("Odd")
|
s133371909
|
p02831
|
u553070631
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 232
|
Takahashi is organizing a party. At the party, each guest will receive one or more snack pieces. Takahashi predicts that the number of guests at this party will be A or B. Find the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted. We assume that a piece cannot be divided and distributed to multiple guests.
|
a,b=sorted(map(int,input().split()))
def gcd(a,b):
if b==0:
return a
else:
return (gcd(b,a%b))
print(gcd(a,b)*a*b)
)
|
s559424434
|
Accepted
| 17
| 2,940
| 237
|
a,b=sorted(map(int,input().split()))
def gcd(a,b):
if b==0:
return a
else:
return (gcd(b,a%b))
print(int(a*b/gcd(a,b)))
|
s657638190
|
p03377
|
u970197315
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 162
|
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.
|
# ABC094 A - Cats and Dogs
a,b,x = map(int,input().split())
if a >= x:
print('NO')
else:
if a+b >= x:
print('Yes')
else:
print('NO')
|
s825968877
|
Accepted
| 17
| 2,940
| 114
|
# ABC094 A - Cats and Dogs
a,b,x = map(int,input().split())
if a <= x <= a + b:
print("YES")
else:
print("NO")
|
s111142916
|
p02412
|
u853619096
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,552
| 319
|
Write a program which identifies the number of combinations of three integers which satisfy the following conditions: * You should select three distinct integers from 1 to n. * A total sum of the three integers is x. For example, there are two combinations for n = 5 and x = 9. * 1 + 3 + 5 = 9 * 2 + 3 + 4 = 9
|
import itertools
while True:
n,x=map(int,input().split())
if n==0 and x==0:
break
a=[i for i in range(1,n+1)]
b=[]
for i in range(1,n+1):
b+=list(itertools.combinations(a,i))
c=[]
count=0
for i in b:
c=sum(i)
if c==x:
count+=1
print(count)
|
s097589609
|
Accepted
| 1,280
| 34,756
| 229
|
import itertools
while True:
n,x=map(int,input().split())
if n==0 and x==0:
break
z=list(range(1,n+1))
a=list(itertools.combinations(z,3))
b=[]
for i in a:
b+=[sum(i)]
print(b.count(x))
|
s492962701
|
p04029
|
u067694718
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 107
|
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?
|
a = ""
for i in input():
if(i == "B"):
if(a != ""):
a = a[:len(a)-1]
else:
a += i
print(a)
|
s964307700
|
Accepted
| 18
| 2,940
| 57
|
a = 0
for i in range(int(input())):
a += i + 1
print(a)
|
s152919591
|
p03471
|
u561113780
| 2,000
| 262,144
|
Wrong Answer
| 2,104
| 3,064
| 524
|
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.
|
def main():
num, yen_sum = map(int, input().split())
res = [-1, -1, -1]
for bill_10000 in range(num+1):
for bill_5000 in range(num-bill_10000+1):
for bill_1000 in range(num-bill_10000-bill_5000+1):
if bill_10000*10000 + bill_5000*5000 + bill_1000*1000 == yen_sum\
and bill_10000 + bill_5000 + bill_1000 == num:
res = [bill_10000, bill_5000, bill_1000]
break
print(res)
if __name__ == '__main__':
main()
|
s905113372
|
Accepted
| 762
| 3,064
| 525
|
def main():
num, yen_sum = map(int, input().split())
yen_sum /=1000
res = [-1, -1, -1]
for bill_10000 in range(num+1):
if bill_10000*10 + (num-bill_10000+1)*5 <= yen_sum:
continue
for bill_5000 in range(num-bill_10000+1):
bill_1000 = num - bill_10000 - bill_5000
if bill_10000*10 + bill_5000*5 + bill_1000*1 == yen_sum:
res = [bill_10000, bill_5000, bill_1000]
break
print(*res)
if __name__ == '__main__':
main()
|
s179643495
|
p02748
|
u672898046
| 2,000
| 1,048,576
|
Wrong Answer
| 25
| 9,124
| 418
|
You are visiting a large electronics store to buy a refrigerator and a microwave. The store sells A kinds of refrigerators and B kinds of microwaves. The i-th refrigerator ( 1 \le i \le A ) is sold at a_i yen (the currency of Japan), and the j-th microwave ( 1 \le j \le B ) is sold at b_j yen. You have M discount tickets. With the i-th ticket ( 1 \le i \le M ), you can get a discount of c_i yen from the total price when buying the x_i-th refrigerator and the y_i-th microwave together. Only one ticket can be used at a time. You are planning to buy one refrigerator and one microwave. Find the minimum amount of money required.
|
def resolve():
a, b, m = map(int, input().split())
a_list = sorted(list(map(int, input().split())))
b_list = sorted(list(map(int, input().split())))
min_total = min(a_list) + min(b_list)
for _ in range(m):
x, y, c = map(int, input().split())
a_c = a_list[x-1]
b_c = b_list[y-1]
if min_total > a_c + b_c - c:
min_total = a_c + b_c - c
print(min_total)
|
s353233380
|
Accepted
| 278
| 24,740
| 322
|
def resolve():
a, b, m = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
ans = min(a_list) + min(b_list)
for _ in range(m):
x, y, c = map(int, input().split())
ans = min(ans, a_list[x-1]+b_list[y-1]-c)
print(ans)
resolve()
|
s953207504
|
p02275
|
u254642509
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,640
| 756
|
Counting sort can be used for sorting elements in an array which each of the n input elements is an integer in the range 0 to k. The idea of counting sort is to determine, for each input element x, the number of elements less than x as C[x]. This information can be used to place element x directly into its position in the output array B. This scheme must be modified to handle the situation in which several elements have the same value. Please see the following pseudocode for the detail: Counting-Sort(A, B, k) 1 for i = 0 to k 2 do C[i] = 0 3 for j = 1 to length[A] 4 do C[A[j]] = C[A[j]]+1 5 /* C[i] now contains the number of elements equal to i */ 6 for i = 1 to k 7 do C[i] = C[i] + C[i-1] 8 /* C[i] now contains the number of elements less than or equal to i */ 9 for j = length[A] downto 1 10 do B[C[A[j]]] = A[j] 11 C[A[j]] = C[A[j]]-1 Write a program which sorts elements of given array ascending order based on the counting sort.
|
def InputData():
sequence_len = int(input())
sequence = [None] + [int(a) for a in input().split(" ")]
return sequence_len, sequence
def countingSort(sequence, k, sequence_len):
B = [None]*(sequence_len+1)
C = [0]*k
for j in range(1, sequence_len+1):
C[sequence[j]] += 1
for i in range(1, k):
C[i] = C[i] + C[i-1]
for j in range(sequence_len, 0, -1):
B[C[sequence[j]]] = sequence[j]
C[sequence[j]] -= 1
return B
def PrintOut(sequence):
print(' '.join( map(str, sequence)))
def main():
[sequence_len, sequence] = InputData()
sequence_out = countingSort(sequence, 10000, sequence_len)
PrintOut(sequence[1:])
if __name__=="__main__":
main()
|
s821137598
|
Accepted
| 2,050
| 256,220
| 760
|
def InputData():
sequence_len = int(input())
sequence = [None] + [int(a) for a in input().split(" ")]
return sequence_len, sequence
def countingSort(sequence, k, sequence_len):
B = [None]*(sequence_len+1)
C = [0]*k
for j in range(1, sequence_len+1):
C[sequence[j]] += 1
for i in range(1, k):
C[i] = C[i] + C[i-1]
for j in range(sequence_len, 0, -1):
B[C[sequence[j]]] = sequence[j]
C[sequence[j]] -= 1
return B
def PrintOut(sequence):
print(' '.join( map(str, sequence)))
def main():
[sequence_len, sequence] = InputData()
sequence_out = countingSort(sequence, 10000, sequence_len)
PrintOut(sequence_out[1:])
if __name__=="__main__":
main()
|
s244707448
|
p03556
|
u095021077
| 2,000
| 262,144
|
Wrong Answer
| 26
| 9,408
| 36
|
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
|
print((pow(int(input()), 1/2)%1)**2)
|
s624739954
|
Accepted
| 31
| 9,408
| 42
|
print(int((pow(int(input()), 1/2)//1)**2))
|
s641692114
|
p03139
|
u657994700
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 87
|
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.
|
# PROXY
list = [int(i) for i in input().split()]
print(min(list),abs(list[1]-list[2]))
|
s046097596
|
Accepted
| 17
| 2,940
| 140
|
# PROXY
list = [int(i) for i in input().split()]
print(min(list),(list[1] + list[2]) - list[0] if (list[1] + list[2]) - list[0] > 0 else 0)
|
s760812980
|
p02646
|
u752115287
| 2,000
| 1,048,576
|
Wrong Answer
| 22
| 9,192
| 261
|
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
|
a,v = list(map(int,input().split()))
b,w = list(map(int,input().split()))
t = int(input())
if (v - w > 0) and (a != b):
if abs(a-b) <= (v - w) * t:
print("Yes")
else:
print("No")
elif a == b:
print("Yes")
else:
print("No")
|
s991622642
|
Accepted
| 23
| 9,192
| 261
|
a,v = list(map(int,input().split()))
b,w = list(map(int,input().split()))
t = int(input())
if (v - w > 0) and (a != b):
if abs(a-b) <= (v - w) * t:
print("YES")
else:
print("NO")
elif a == b:
print("YES")
else:
print("NO")
|
s506060810
|
p03778
|
u003501233
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 78
|
AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
|
w,a,b=map(int,input().split())
if (a-b)<=w:
print(0)
else:
print((a-b)-w)
|
s657142392
|
Accepted
| 17
| 2,940
| 84
|
w,a,b=map(int,input().split())
if abs(a-b)<=w:
print(0)
else:
print(abs(a-b)-w)
|
s979104670
|
p03024
|
u259053514
| 2,000
| 1,048,576
|
Wrong Answer
| 23
| 3,444
| 359
|
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day. Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
|
# -*- coding: utf-8 -*-
import sys
import copy
sys.setrecursionlimit(1000000)
# input = sys.stdin.readline
S = input().rstrip()
win = 0
length = len(S)
for i in range(length):
if S[i] == 'o':
win += 1
win += 15 - length
if win >= 8:
print("Yes")
else:
print("No")
|
s244652846
|
Accepted
| 22
| 3,444
| 359
|
# -*- coding: utf-8 -*-
import sys
import copy
sys.setrecursionlimit(1000000)
# input = sys.stdin.readline
S = input().rstrip()
win = 0
length = len(S)
for i in range(length):
if S[i] == 'o':
win += 1
win += 15 - length
if win >= 8:
print("YES")
else:
print("NO")
|
s245815161
|
p03377
|
u371530330
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 97
|
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a,b,x = map(int, input().split())
if a+b >= x and a >= x :
print("YES")
else:
print("NO")
|
s948731474
|
Accepted
| 17
| 2,940
| 98
|
a,b,x = map(int, input().split())
if a+b >= x and x >= a :
print("YES")
else:
print("NO")
|
s155729583
|
p03591
|
u086503932
| 2,000
| 262,144
|
Wrong Answer
| 31
| 9,004
| 83
|
Ringo is giving a present to Snuke. Ringo has found out that Snuke loves _yakiniku_ (a Japanese term meaning grilled meat. _yaki_ : grilled, _niku_ : meat). He supposes that Snuke likes grilled things starting with `YAKI` in Japanese, and does not like other things. You are given a string S representing the Japanese name of Ringo's present to Snuke. Determine whether S starts with `YAKI`.
|
S = input()
if len(S) >= 4 and S[::4] == 'YAKI':
print('Yes')
else:
print('No')
|
s409035699
|
Accepted
| 27
| 8,984
| 82
|
S = input()
if len(S) >= 4 and S[:4] == 'YAKI':
print('Yes')
else:
print('No')
|
s274909005
|
p03131
|
u432586856
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,064
| 388
|
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the maximum possible number of biscuits in Snuke's pocket after K operations.
|
if __name__ == "__main__":
K,A,B = map(int,input().split())
if A > B:
print(1 + K)
elif B - A == 1:
print(1 + K)
else :
if K < A - 1:
print (1 + K)
else:
K -= A - 1
if K % 2 == 0:
print (A + (K / 2) * (B - A))
else:
print (A + ((K - 1) / 2) * (B - A) + 1)
|
s648438882
|
Accepted
| 17
| 3,060
| 450
|
if __name__ == "__main__":
K,A,B = map(int,input().split())
if B - A <= 2:
print(K + 1)
else :
if K <= A-1:
print(1 + K)
else:
rest = K - (A - 1)
if rest < 2:
print(1 + K)
else:
q,r = divmod(rest,2)
print(A + q * (B - A) + r)
|
s386187026
|
p03447
|
u227082700
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 65
|
You went shopping to buy cakes and donuts with X yen (the currency of Japan). First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop. How much do you have left after shopping?
|
x=int(input())
a=int(input())
b=int(input())
print(x-a--(x-a)//b)
|
s658784484
|
Accepted
| 18
| 2,940
| 47
|
print((int(input())-int(input()))%int(input()))
|
s981522818
|
p03005
|
u366928732
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 49
|
Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?
|
a, b = map(int, input().split())
print(a - b + 1)
|
s740224168
|
Accepted
| 17
| 2,940
| 79
|
a, b = map(int, input().split())
if b == 1:
print(0)
else:
print(a - b)
|
s246297084
|
p03455
|
u925406312
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 72
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a,b = map(int,input().split())
print("Even" if (a * b) % 2 else "Odd" )
|
s385295481
|
Accepted
| 17
| 2,940
| 77
|
a,b = map(int,input().split())
print("Even" if (a * b) % 2 == 0 else "Odd" )
|
s387076665
|
p03636
|
u242518667
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 65
|
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
|
s=input()
print(len(s[1:-1]))
print(s[0]+str(len(s[1:-1]))+s[-1])
|
s697414788
|
Accepted
| 18
| 2,940
| 45
|
s=input()
print(s[0]+str(len(s[1:-1]))+s[-1])
|
s638491990
|
p02854
|
u228223940
| 2,000
| 1,048,576
|
Wrong Answer
| 198
| 26,024
| 613
|
Takahashi, who works at DISCO, is standing before an iron bar. The bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters. Takahashi wanted to choose a notch and cut the bar at that point into two parts with the same length. However, this may not be possible as is, so he will do the following operations some number of times **before** he does the cut: * Choose one section and expand it, increasing its length by 1 millimeter. Doing this operation once costs 1 yen (the currency of Japan). * Choose one section of length at least 2 millimeters and shrink it, decreasing its length by 1 millimeter. Doing this operation once costs 1 yen. Find the minimum amount of money needed before cutting the bar into two parts with the same length.
|
n = int(input())
a = [int(i) for i in input().split()]
li = [0]*(n+1)
for i in range(n):
li[i+1] = li[i] + a[i]
#print(li[n]%2)
tmp = 10**18
if li[n] % 2 == 1:
li[n] += 1
for i in range(n+1):
#print(abs(li[i]-li[n]//2)<tmp)
if abs(li[i]-li[n]//2) < tmp:
tmp = abs(li[i]-li[n]//2)
else:
break
elif li[n] % 2 == 0:
for i in range(n+1):
#print(abs(li[i]-li[n]//2)<tmp)
if abs(li[i]-li[n]//2) < tmp:
tmp = abs(li[i]-li[n]//2)
else:
break
if li[n] % 2 == 0:
print(tmp)
else:
print(1+tmp*2)
|
s496139675
|
Accepted
| 211
| 26,060
| 292
|
n = int(input())
a = [int(i) for i in input().split()]
li = [0]*(n+1)
for i in range(n):
li[i+1] = li[i] + a[i]
#print(li)
li_sum = sum(a)
ans = 10**18
for i in range(n):
#print(ans)
if ans > abs(li_sum - 2*li[i]):
ans = abs(li_sum - 2*li[i])
print(ans)
|
s421458830
|
p04029
|
u058592821
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 33
|
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+1)/2)
|
s820848197
|
Accepted
| 16
| 2,940
| 34
|
n = int(input())
print(n*(n+1)//2)
|
s094231284
|
p02416
|
u382316013
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,496
| 67
|
Write a program which reads an integer and prints sum of its digits.
|
while True:
data = int(input())
if data == 0:
break
|
s951689261
|
Accepted
| 20
| 7,712
| 107
|
while True:
data = input()
if data[0] == '0':
break
print(sum([int(i) for i in data]))
|
s332959809
|
p03543
|
u841531687
| 2,000
| 262,144
|
Wrong Answer
| 20
| 3,316
| 41
|
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 = set(map(int, input()))
print(len(n))
|
s332807232
|
Accepted
| 17
| 2,940
| 72
|
n=input()
print("Yes" if n[0]==n[1]==n[2] or n[1]==n[2]==n[3] else "No")
|
s415706578
|
p03861
|
u811436126
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,060
| 70
|
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())
ans = b // x - a // x
print(ans)
|
s361683471
|
Accepted
| 17
| 2,940
| 76
|
a, b, x = map(int, input().split())
ans = b // x - (a - 1) // x
print(ans)
|
s860306193
|
p03407
|
u864900001
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 87
|
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
|
a, b, c = map(int, input().split())
if a+b > c:
print("No")
else:
print("Yes")
|
s933480863
|
Accepted
| 17
| 2,940
| 88
|
a, b, c = map(int, input().split())
if a+b >= c:
print("Yes")
else:
print("No")
|
s622223328
|
p04031
|
u039623862
| 2,000
| 262,144
|
Wrong Answer
| 40
| 3,064
| 201
|
Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2). Find the minimum total cost to achieve his objective.
|
import math
n=int(input())
a=map(int, input().split())
ave = sum(a)/n
if math.ceil(ave)-ave > ave-math.floor(ave):
t = math.floor(ave)
else:
t = math.ceil(ave)
print(sum([(t-x)**2 for x in a]))
|
s400262088
|
Accepted
| 39
| 3,064
| 232
|
import math
n=int(input())
a=list(map(int, input().split()))
ave = sum(a)/n
if math.ceil(ave)-ave > ave-math.floor(ave):
t = math.floor(ave)
else:
t = math.ceil(ave)
total = 0
for v in a:
total += (t-v) ** 2
print(total)
|
s892187326
|
p02408
|
u203222829
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,608
| 238
|
Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers). The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.
|
# coding: utf-8
suits = ['S', 'H', 'C', 'D']
cards = [(suit + str(i)) for i in range(1, 14) for suit in suits]
for _ in range(int(input())):
cards.remove(''.join(input().split()))
for trump in cards:
print(trump[0], trump[1:])
|
s170522807
|
Accepted
| 20
| 5,604
| 238
|
# coding: utf-8
suits = ['S', 'H', 'C', 'D']
cards = [(suit + str(i)) for suit in suits for i in range(1, 14)]
for _ in range(int(input())):
cards.remove(''.join(input().split()))
for trump in cards:
print(trump[0], trump[1:])
|
s475579496
|
p03592
|
u745514010
| 2,000
| 262,144
|
Wrong Answer
| 90
| 3,060
| 253
|
We have a grid with N rows and M columns of squares. Initially, all the squares are white. There is a button attached to each row and each column. When a button attached to a row is pressed, the colors of all the squares in that row are inverted; that is, white squares become black and vice versa. When a button attached to a column is pressed, the colors of all the squares in that column are inverted. Takahashi can freely press the buttons any number of times. Determine whether he can have exactly K black squares in the grid.
|
n, m, k = map(int, input().split())
if k == 0 or k == n * m:
print("Yes")
exit()
for i in range((n + 1) // 2):
for j in range((m + 1) // 2):
if i * j + (n - i) * (m - j) == k:
print("Yes")
exit()
print("No")
|
s348079432
|
Accepted
| 264
| 9,096
| 207
|
n, m, k = map(int, input().split())
for i in range(n + 1):
for j in range(m + 1):
black = i * (m - j) + (n - i) * j
if black == k:
print("Yes")
exit()
print("No")
|
s169667156
|
p02850
|
u086503932
| 2,000
| 1,048,576
|
Wrong Answer
| 637
| 40,856
| 827
|
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.
|
#!/usr/bin/env python3
from collections import deque
def main():
N = int(input())
adj = [[] for _ in range(N)]
for i in range(N-1):
a, b = map(lambda x: int(x)-1, input().split())
adj[a].append((b,i))
adj[b].append((a,i))
p = max([len(a) for a in adj])
ans = [-1] * (N-1)
visited = [-1] * N
ans[0] = 1
q = deque([0])
while q:
now = q.popleft()
tmp = 1
for v in adj[now]:
if visited[v[0]] < 0:
q.append(v[0])
ans[v[1]] = (tmp + 1) % p
tmp += 1
visited[v[0]] = 0
if ans[v[1]] == 0:
ans[v[1]] += p
else:
tmp = ans[v[1]]
print(p)
[print(a) for a in ans]
if __name__ == "__main__":
main()
|
s340446560
|
Accepted
| 642
| 40,856
| 904
|
#!/usr/bin/env python3
from collections import deque
def main():
N = int(input())
adj = [[] for _ in range(N)]
for i in range(N-1):
a, b = map(lambda x: int(x)-1, input().split())
adj[a].append((b,i))
adj[b].append((a,i))
p = max([len(a) for a in adj])
ans = [-1] * (N-1)
visited = [-1] * N
visited[0] = 0
q = deque([0])
while q:
now = q.popleft()
tmp = 0
for v in adj[now]:
if visited[v[0]] == 0:
tmp = ans[v[1]]
break
for v in adj[now]:
if visited[v[0]] < 0:
q.append(v[0])
ans[v[1]] = (tmp+1) % p
tmp += 1
visited[v[0]] = 0
if ans[v[1]] == 0:
ans[v[1]] += p
print(p)
[print(a) for a in ans]
if __name__ == "__main__":
main()
|
s617250699
|
p03970
|
u729707098
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 97
|
CODE FESTIVAL 2016 is going to be held. For the occasion, Mr. Takahashi decided to make a signboard. He intended to write `CODEFESTIVAL2016` on it, but he mistakenly wrote a different string S. Fortunately, the string he wrote was the correct length. So Mr. Takahashi decided to perform an operation that replaces a certain character with another in the minimum number of iterations, changing the string to `CODEFESTIVAL2016`. Find the minimum number of iterations for the rewrite operation.
|
s = input()
x,ans = "CODEFESTIBAL2016",0
for i in range(16):
if x[i]!=s[i]: ans += 1
print(ans)
|
s588190289
|
Accepted
| 17
| 2,940
| 98
|
s = input()
x,ans = "CODEFESTIVAL2016",0
for i in range(16):
if x[i]!=s[i]: ans += 1
print(ans)
|
s499973069
|
p04029
|
u863308734
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 46
|
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("{}".format(n*(n+1)/2))
|
s264274886
|
Accepted
| 17
| 2,940
| 52
|
n = int(input())
print("{}".format(int(n*(n+1)/2)))
|
s710144680
|
p03855
|
u171366497
| 2,000
| 262,144
|
Wrong Answer
| 2,116
| 212,548
| 1,263
|
There are N cities. There are also K roads and L railways, extending between the cities. The i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities. No two roads connect the same pair of cities. Similarly, no two railways connect the same pair of cities. We will say city A and B are _connected by roads_ if city B is reachable from city A by traversing some number of roads. Here, any city is considered to be connected to itself by roads. We will also define _connectivity by railways_ similarly. For each city, find the number of the cities connected to that city by both roads and railways.
|
n,k,l=map(int,input().split())
from collections import defaultdict
road=defaultdict(set)
metro=defaultdict(set)
for i in range(k):
p,q=map(int,input().split())
road[p]|={q,}
for j in range(l):
r,s=map(int,input().split())
metro[r]|={s,}
city={i for i in range(1,n+1)}
def maketree(n,target):
city={i for i in range(1,n+1)}
tree=[]
now=1
block={now,}
city-={now,}
block|=target[now]
count=0
while len(city)>0:
for i in target[now]:
block|=target[i]
city-={i,}
next=city & block
if len(next)>0:
now=next.pop()
block|=target[now]
city-={now,}
elif len(next)==0:
tree.append(block)
if len(city)!=0:
now=city.pop()
block={now,}
city-={now,}
block|=target[now]
if len(city)==0:tree.append(block)
return tree
roadtree=maketree(n,road)
metrotree=maketree(n,metro)
ans=[]
for i in roadtree:
for j in metrotree:
ans.append(i & j)
result=[1 for i in range(n)]
while len(ans)>0:
x=ans.pop()
for i in x:
result[i-1]=len(x)
res=''
for i in range(n):
res=res+str(result[i])+' '
|
s594160343
|
Accepted
| 863
| 79,116
| 1,002
|
import sys
input=sys.stdin.readline
N,K,L=map(int,input().split())
road=[tuple(map(int,input().split())) for _ in range(K)]
metro=[tuple(map(int,input().split())) for _ in range(L)]
inf=float('inf')
def Find(root,x):
if root[x]<0:
return x
if root[x]>=0:
root[x]=Find(root,root[x])
return root[x]
def UnionFind(N,branch):
root=[-1]*(N+1)
for a,b in branch:
aroot=Find(root,a)
broot=Find(root,b)
if aroot==broot:continue
elif root[aroot]<=root[broot]:
root[aroot]+=root[broot]
root[broot]=aroot
elif root[aroot]>root[broot]:
root[broot]+=root[aroot]
root[aroot]=broot
return root
r_root=UnionFind(N,road)
m_root=UnionFind(N,metro)
from collections import defaultdict
data=[]
cnt=defaultdict(int)
for i in range(1,N+1):
ri=Find(r_root,i)
mi=Find(m_root,i)
data.append((ri,mi))
cnt[(ri,mi)]+=1
ans=''
for d in data:
ans+=str(cnt[d])+' '
print(ans[:-1])
|
s697496064
|
p03494
|
u733167185
| 2,000
| 262,144
|
Wrong Answer
| 22
| 3,444
| 202
|
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.
|
import random
N = int(input())
A = random.sample(range(1000000), k=N)
c = 1000000
for i in range(len(A)):
tmp = 0
while A[i]%2 == 0:
tmp+=1
A[i] //= 2
c = min(c,tmp)
print(c)
|
s280987546
|
Accepted
| 18
| 2,940
| 186
|
N = int(input())
A = list(map(int,input().split()))
c = 1000000
for i in range(len(A)):
tmp = 0
while A[i]%2 == 0:
tmp += 1
A[i] //= 2
c = min(c,tmp)
print(c)
|
s931115611
|
p00148
|
u546285759
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,544
| 155
|
3年C組では、平成19年11月10日の体育祭で使用する「クラス旗」を、将来のクラス会の時にも使うことにしました。そこで「クラス旗」を保管する生徒を決めるために、先生が先日差し入れてくれた大量のキャンディーを使って次のようなゲームを行うことにしました。 * 各生徒は生徒番号の順に1個ずつキャンディーを取ります。 * 一巡してもキャンディーが残っていたら、最初の生徒番号の人から順々にキャンディーを取り続けます。 * 最後のキャンディーを取った人が「クラス旗」を保管する生徒になります。 3年C組のクラスの人数は 39 人です。彼らの生徒番号は 3C01 から 3C39 です。例えば、キャンディーの数が 50 個の場合、クラス全員が1個目のキャンディーを取り終えると、キャンディーの残りは 11 個となります。それを再び生徒番号順に取ると、最後の 1 個は、3C11 の生徒が取ることとなります。すなわち 3C11 の生徒が「クラス旗」を保管する生徒となります。 キャンディーの個数を入力とし、「クラス旗」を保管する生徒の生徒番号を出力するプログラムを作成してください。
|
while True:
try:
a = int(input())
except:
break
tmp = a - (a // 39) * 39
print("3C{:02d}".format(39 if tmp == 39 else tmp))
|
s597026022
|
Accepted
| 20
| 7,688
| 154
|
while True:
try:
a = int(input())
except:
break
tmp = a - (a // 39) * 39
print("3C{:02d}".format(tmp if tmp % 39 else 39))
|
s348537355
|
p03049
|
u442810826
| 2,000
| 1,048,576
|
Wrong Answer
| 33
| 3,700
| 260
|
Snuke has N strings. The i-th string is s_i. Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string.
|
N = int(input())
A = []
B = []
C = []
for i in range(N):
s = input()
if s[-1] == "A":
A.append(i)
if s[0] == "B":
B.append(i)
C.append(i)
elif s[0] == "B":
B.append(i)
print(len(A)*len(B)-len(C))
|
s791505841
|
Accepted
| 51
| 4,980
| 454
|
N = int(input())
A = []
B = []
ans = 0
for i in range(N):
s = input()
for j in range(len(s)-1):
if s[j:j+2] == "AB":
ans += 1
if s[0] == "B":
B.append(i)
if s[-1] == "A":
A.append(i)
A = set(A)
B = set(B)
if len(A) == len(B):
ans += len(A)
if len(A&B) == len(A) and len(A)>0:
ans -= 1
elif len(A)> len(B):
ans += len(B)
else:
ans += len(A)
print(ans)
|
s885018544
|
p03555
|
u729707098
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 99
|
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
|
a = input()
b = input()
if a[0]==b[2] and a[1]==b[1] and a[2]==b[0]: print("Yes")
else: print("No")
|
s728267524
|
Accepted
| 17
| 2,940
| 100
|
a = input()
b = input()
if a[0]==b[2] and a[1]==b[1] and a[2]==b[0]: print("YES")
else: print("NO")
|
s847460554
|
p03836
|
u209619667
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,188
| 784
|
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.
|
A = list(map(int, input().split()))
s_1 = ''
if (int(A[0]) < 0) and (int(A[2]) < 0):
a = abs(int(A[0])) - abs(int(A[2]))
elif (int(A[0]) < 0) and (int(A[2]) > 0):
a = abs(int(A[0])) + abs(int(A[2]))
else:
a = int(A[2]) - int(A[0])
if (int(A[1]) < 0) and (int(A[3]) < 0):
b = abs(int(A[1])) - abs(int(A[3]))
elif (int(A[1]) < 0) and (int(A[3]) > 0):
b = abs(int(A[1])) + abs(int(A[3]))
else:
b = int(A[3]) - int(A[1])
for i in range(a):
s_1 = s_1 + 'U'
for i in range(b):
s_1 = s_1 + 'R'
for i in range(a):
s_1 = s_1 + 'D'
for i in range(b):
s_1 = s_1 + 'L'
s_1 = s_1 + 'L'
for i in range(a+1):
s_1 = s_1 + 'U'
for i in range(b+1):
s_1 = s_1 + 'R'
s_1 = s_1 + 'D'
for i in range(a+1):
s_1 = s_1 + 'D'
for i in range(b+1):
s_1 = s_1 + 'L'
print(s_1)
|
s127246908
|
Accepted
| 19
| 3,188
| 825
|
A = list(map(int, input().split()))
s_1 = ''
if (int(A[0]) < 0) and (int(A[2]) < 0):
a = abs(int(A[0])) - abs(int(A[2]))
elif (int(A[0]) < 0) and (int(A[2]) > 0):
a = abs(int(A[0])) + abs(int(A[2]))
else:
a = int(A[2]) - int(A[0])
if (int(A[1]) < 0) and (int(A[3]) < 0):
b = abs(int(A[1])) - abs(int(A[3]))
elif (int(A[1]) < 0) and (int(A[3]) > 0):
b = abs(int(A[1])) + abs(int(A[3]))
else:
b = int(A[3]) - int(A[1])
for i in range(b):
s_1 = s_1 + 'U'
for i in range(a):
s_1 = s_1 + 'R'
for i in range(b):
s_1 = s_1 + 'D'
for i in range(a):
s_1 = s_1 + 'L'
s_1 = s_1 + 'L'
for i in range(b+1):
s_1 = s_1 + 'U'
for i in range(a+1):
s_1 = s_1 + 'R'
s_1 = s_1 + 'D'
s_1 = s_1 + 'R'
for i in range(b+1):
s_1 = s_1 + 'D'
for i in range(a+1):
s_1 = s_1 + 'L'
s_1 = s_1 + 'U'
print(s_1)
|
s034354057
|
p03599
|
u140251125
| 3,000
| 262,144
|
Wrong Answer
| 305
| 3,064
| 591
|
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.
|
# input
A, B, C, D, E, F = map(int, input().split())
temp = 0
ans1, ans2 = 0, 0
for i in range(31):
for j in range(31):
for k in range(101):
for l in range(101):
w = 100 * A * i + 100 * B * j
s = C * k + D * l
if w == 0:
break
if s > E * w:
break
if w + s > F:
break
if s / (w + s) > temp:
temp = s / (w + s)
ans1 = w + s
ans2 = s
print(ans1, ans2)
|
s497521679
|
Accepted
| 303
| 3,064
| 611
|
# input
A, B, C, D, E, F = map(int, input().split())
temp = 0
ans1, ans2 = 100 * A, 0
for i in range(31):
for j in range(31):
for k in range(101):
for l in range(101):
w = 100 * A * i + 100 * B * j
s = C * k + D * l
if w == 0:
break
if s > E * (A * i + B * j):
break
if w + s > F:
break
if s / (w + s) > temp:
temp = s / (w + s)
ans1 = w + s
ans2 = s
print(ans1, ans2)
|
s212513932
|
p03089
|
u361381049
| 2,000
| 1,048,576
|
Wrong Answer
| 27
| 8,848
| 147
|
Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.
|
N = int(input())
b = list(map(int, input().split()))
flg = True
for i in range(N):
b[i] -= 1
if b[i] > i:
print(-1)
exit()
|
s580059534
|
Accepted
| 29
| 9,012
| 378
|
N = int(input())
b = list(map(int, input().split()))
for i in range(N):
b[i] -= 1
lis = []
for i in range(N):
flg = False
for j in reversed(range(N-i)):
if b[j] == j:
lis.append(j+1)
del b[j]
flg = True
break
if flg == False:
print(-1)
exit()
for i in reversed(range(N)):
print(lis[i])
|
s377846368
|
p03693
|
u652737716
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 123
|
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?
|
r, g, b = [int(x) for x in input().split(" ")]
if (100 * r + 10 * g + b) % 4 == 0:
print("yes")
else:
print("no")
|
s516696265
|
Accepted
| 17
| 2,940
| 123
|
r, g, b = [int(x) for x in input().split(" ")]
if (100 * r + 10 * g + b) % 4 == 0:
print("YES")
else:
print("NO")
|
s364334255
|
p02409
|
u995990363
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,676
| 608
|
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.
|
# coding:utf-8
class FLOOR:
def __init__(self):
self.room = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
class BUILD:
def __init__(self):
self.floor = [FLOOR(), FLOOR(), FLOOR()]
all_rooms = [BUILD(), BUILD(), BUILD(), BUILD()]
# ??\???
n = int(input())
for i in range(n):
b, f, r, v = map(int, input().split())
all_rooms[b-1].floor[f-1].room[r-1] += v
for b in range(4):
for f in range(3):
display = []
for r in range(10):
display.append(str(all_rooms[b].floor[f].room[r]))
print(' '.join(display))
print('#'*20)
|
s396514393
|
Accepted
| 20
| 7,700
| 634
|
# coding:utf-8
class FLOOR:
def __init__(self):
self.room = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
class BUILD:
def __init__(self):
self.floor = [FLOOR(), FLOOR(), FLOOR()]
all_rooms = [BUILD(), BUILD(), BUILD(), BUILD()]
# ??\???
n = int(input())
for i in range(n):
b, f, r, v = map(int, input().split())
all_rooms[b-1].floor[f-1].room[r-1] += v
for b in range(4):
for f in range(3):
display = []
for r in range(10):
display.append(str(all_rooms[b].floor[f].room[r]))
print(' ' + ' '.join(display))
if (b < 3):
print('#'*20)
|
s730104524
|
p03523
|
u463655976
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,188
| 51
|
You are given a string S. Takahashi can insert the character `A` at any position in this string any number of times. Can he change S into `AKIHABARA`?
|
import re
print(re.match("A?KIHA?BA?RA?", input()))
|
s277207601
|
Accepted
| 19
| 3,188
| 73
|
import re
print("YES" if re.match("^A?KIHA?BA?RA?$", input()) else "NO")
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.