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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s589679710
|
p03380
|
u638282348
| 2,000 | 262,144 |
Wrong Answer
| 477 | 33,976 | 275 |
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.
|
from bisect import bisect_left
from scipy.misc import comb
N = int(input())
A = sorted(map(int, input().split()))
if N == 2:
print(*A[::-1])
quit()
n = A.pop()
idx = bisect_left(A, n // 2)
print(n, (A[idx] if comb(n, A[idx]) > comb(n, A[idx - 1]) else A[idx - 1]))
|
s020209460
|
Accepted
| 240 | 23,840 | 197 |
import numpy as np
N = int(input())
M, *A = sorted(map(int, input().split()), reverse=True)
if N == 2:
print(M, *A)
quit()
print(M, A[np.abs(np.array(A, dtype=np.int64) - M / 2).argmin()])
|
s707238686
|
p02646
|
u520276780
| 2,000 | 1,048,576 |
Wrong Answer
| 19 | 9,036 | 134 |
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
|
a,v=map(int, input().split())
b,w=map(int, input().split())
t=int(input())
if abs(v-w)*t>abs(a-b):
print("NO")
else:
print("YES")
|
s823591300
|
Accepted
| 24 | 9,076 | 132 |
a,v=map(int, input().split())
b,w=map(int, input().split())
t=int(input())
if (v-w)*t<abs(a-b):
print("NO")
else:
print("YES")
|
s628640245
|
p03474
|
u924308178
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 272 |
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
|
A,B = list(map(int,input().split(" ")))
S = input()
for i in range(len(S)):
if i==A:
if S[i]!="-":
print("No")
exit()
else:
if not ord('0')<=i<=ord('9'):
print("No")
exit()
print("Yes")
|
s768664973
|
Accepted
| 17 | 2,940 | 286 |
A,B = list(map(int,input().split(" ")))
S = input()
for i in range(len(S)):
if i==A:
if S[i]!="-":
print("No")
exit()
else:
if not ord('0')<=ord(str(S[i]))<=ord('9'):
print("No")
exit()
print("Yes")
|
s837065032
|
p03644
|
u016622494
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 88 |
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
|
A = int(input())
list=[]
for i in range(0, A+1 , 2):
list.append(i)
print(list[-1])
|
s376740690
|
Accepted
| 17 | 2,940 | 95 |
N = int(input())
answer = 1
while answer*2 <= N:
answer *= 2
#print(answer)
print(answer)
|
s813067106
|
p02399
|
u043968625
| 1,000 | 131,072 |
Wrong Answer
| 40 | 7,764 | 109 |
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
|
a,b =[int(i) for i in input().split()]
#a=3
#b=2
A=[a//b,a%b,a/b]
print("{0} {1} {2}".format(A[0],A[1],A[2]))
|
s733581772
|
Accepted
| 50 | 7,772 | 122 |
a,b =[int(i) for i in input().split()]
#a=2
#b=100000009
A=[a//b,a%b,a/b]
print("{0} {1} {2:.5f}".format(A[0],A[1],A[2]))
|
s142225538
|
p03493
|
u650682486
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 39 |
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
|
s = list(input())
print(s,s.count('1'))
|
s385818730
|
Accepted
| 17 | 2,940 | 37 |
s = list(input())
print(s.count('1'))
|
s383027143
|
p02613
|
u484048830
| 2,000 | 1,048,576 |
Wrong Answer
| 149 | 9,196 | 248 |
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
t=int(input())
ac=0
wa=0
tle=0
re=0
for _ in range(t):
s=input()
if(s=="AC"):
ac+=1
elif(s=="WA"):
wa+=1
elif(s=="TLE"):
tle+=1
else:
re+=1
print("AC X ",ac)
print("WA X ",wa)
print("TLE X ",tle)
print("RE X ",re)
|
s065615669
|
Accepted
| 146 | 9,200 | 236 |
t=int(input())
ac=0
wa=0
tle=0
re=0
for _ in range(t):
s=input()
if(s=="AC"):
ac+=1
elif(s=="WA"):
wa+=1
elif(s=="TLE"):
tle+=1
else:
re+=1
print("AC x",ac)
print("WA x",wa)
print("TLE x",tle)
print("RE x",re)
|
s096681668
|
p04043
|
u857547702
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 96 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
a,b,c=map(int,input().split())
if a==5 and b==7 and c==5:
print('YES')
else:
print('NO')
|
s638238021
|
Accepted
| 17 | 2,940 | 119 |
a=list(map(int,input().split()))
b=sorted(a)
if b[0]==5 and b[1]==5 and b[2]==7:
print('YES')
else:
print('NO')
|
s117677056
|
p02401
|
u203222829
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,592 | 226 |
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.
|
a, op, b = map(str, input().split())
if op == '+':
print(int(a) + int(b))
elif op == '-':
print(int(a) - int(b))
elif op == '*':
print(int(a) * int(b))
elif op == '/':
print(int(a) // int(b))
else:
exit()
|
s624995087
|
Accepted
| 20 | 5,592 | 287 |
while True:
a, op, b = map(str, input().split())
if op == '+':
print(int(a) + int(b))
elif op == '-':
print(int(a) - int(b))
elif op == '*':
print(int(a) * int(b))
elif op == '/':
print(int(a) // int(b))
else:
exit()
|
s769479628
|
p03026
|
u450339194
| 2,000 | 1,048,576 |
Wrong Answer
| 73 | 5,620 | 462 |
You are given a tree with N vertices 1,2,\ldots,N, and positive integers c_1,c_2,\ldots,c_N. The i-th edge in the tree (1 \leq i \leq N-1) connects Vertex a_i and Vertex b_i. We will write a positive integer on each vertex in T and calculate our _score_ as follows: * On each edge, write the smaller of the integers written on the two endpoints. * Let our score be the sum of the integers written on all the edges. Find the maximum possible score when we write each of c_1,c_2,\ldots,c_N on one vertex in T, and show one way to achieve it. If an integer occurs multiple times in c_1,c_2,\ldots,c_N, we must use it that number of times.
|
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()
N = n()
M = 0
ds = [None] * N
ranks = [0] * N
for i in range(N-1):
a, b = nl()
ranks[a-1] += 1
ranks[b-1] += 1
cs = sorted(nl())
M = sum(cs[:-1])
ranks = [[i, ranks[i]] for i in range(N)]
ranks = sorted(ranks, key=lambda r: r[1])
for i in range(N):
ds[ranks[i][0]] = cs[i]
print(M)
print(' '.join([str(d) for d in ds]))
|
s600706940
|
Accepted
| 110 | 9,472 | 749 |
import heapq
from collections import defaultdict
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()
N = n()
M = 0
ds = [None] * N
edges = defaultdict(set)
ranks = [0] * N
for i in range(N-1):
a, b = nl()
edges[a-1].add(b-1)
edges[b-1].add(a-1)
ranks[a-1] += 1
ranks[b-1] += 1
cs = sorted(nl())
M = sum(cs[:-1])
h = []
for i in range(N):
heapq.heappush(h, (ranks[i], i))
for i in range(N):
rank, node = heapq.heappop(h)
ds[node] = cs[i]
for next_node in edges[node]:
ranks[next_node] -= 1
heapq.heappush(h, (ranks[next_node], next_node))
edges[next_node].remove(node)
print(M)
print(' '.join([str(d) for d in ds]))
|
s560289556
|
p02578
|
u952968889
| 2,000 | 1,048,576 |
Wrong Answer
| 123 | 32,140 | 168 |
N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool. Find the minimum total height of the stools needed to meet this goal.
|
N = int(input())
A = list(map(int, input().split()))
s = 0
if N==1:
print(0)
exit()
for i,a in enumerate(A):
if i==0:
continue
s+=(a<A[i-1])*a
print(s)
|
s352522686
|
Accepted
| 153 | 32,000 | 213 |
N = int(input())
A = list(map(int, input().split()))
s = 0
if N==1:
print(0)
exit()
for i,a in enumerate(A):
if i==0:
continue
tmp = A[i-1] - a
if tmp>0:
A[i] = A[i-1]
s += tmp
print(s)
|
s885943123
|
p03495
|
u257974487
| 2,000 | 262,144 |
Wrong Answer
| 2,105 | 25,588 | 719 |
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them.
|
N, K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
print(A)
a = 0
b = 0
B = [A[0]]
s = 200001
t = 0
u = 0
for k in range(N):
if not A[k] in B:
B.append(A[k])
a += 1
for i in range(N):
if A.count(A[i]) > u:
u = A.count(A[i])
v = A[i]
if A.count(A[i]) < s:
s = A.count(A[i])
t = A[i]
while a >= K:
a -= 1
b += 1
for i in range(N):
for j in range(N):
if A[j] == t:
A[j] = s
if A.count(A[i]) > u:
u = A.count(A[i])
v = A[i]
if A.count(A[i]) < s:
s = A.count(A[i])
t = A[i]
print(b)
|
s727570792
|
Accepted
| 105 | 20,416 | 127 |
N,K=map(int,input().split())
B = [0] * (N)
for a in map(int,input().split()):
B[a-1] += 1
B=sorted(B)[::-1]
print(sum(B[K:]))
|
s246592101
|
p03545
|
u947327691
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 327 |
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
|
n=input()
op_cnt=len(n)-1
for i in range(2**op_cnt):
op=["-"]*op_cnt
for j in range(op_cnt):
if ((i >> j)&1):
op[j]="+"
formula=""
for p_n, p_o in zip(n, op + [""]):
formula += (p_n + p_o)
print(formula)
if eval(formula) == 7:
print(formula + "=7")
break
|
s097249183
|
Accepted
| 17 | 3,060 | 304 |
n=input()
op_cnt=len(n)-1
for i in range(2**op_cnt):
op=["-"]*op_cnt
for j in range(op_cnt):
if ((i >> j)&1):
op[j]="+"
formula=""
for p_n, p_o in zip(n, op + [""]):
formula += (p_n + p_o)
if eval(formula) == 7:
print(formula + "=7")
break
|
s848310450
|
p00002
|
u842823276
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,564 | 88 |
Write a program which computes the digit number of sum of two integers a and b.
|
import sys
for line in sys.stdin:
a, b = map(str, line.split())
print(len(a+b))
|
s545314988
|
Accepted
| 30 | 5,600 | 93 |
import sys
for line in sys.stdin:
a, b = map(int, line.split())
print(len(str(a+b)))
|
s431613235
|
p04029
|
u306142032
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 72 |
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())
sum = 0
for i in range(n):
sum += i
print(sum)
|
s184548423
|
Accepted
| 17 | 2,940 | 74 |
n = int(input())
sum = 0
for i in range(n+1):
sum += i
print(sum)
|
s270183996
|
p03080
|
u167908302
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 232 |
There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat.
|
# coding: utf-8
N = int(input())
s = list(input())
red = 0
blue = 0
for i in range(N):
print(i)
if s[i] == 'R':
red += 1
elif s[i] == 'B':
blue += 1
if red > blue:
print('Yes')
else:
print('No')
|
s546641203
|
Accepted
| 17 | 2,940 | 220 |
# coding: utf-8
N = int(input())
s = list(input())
red = 0
blue = 0
for i in range(N):
if s[i] == 'R':
red += 1
elif s[i] == 'B':
blue += 1
if red > blue:
print('Yes')
else:
print('No')
|
s981236954
|
p02417
|
u758382323
| 1,000 | 131,072 |
Wrong Answer
| 40 | 6,692 | 225 |
Write a program which counts and reports the number of each alphabetical letter. Ignore the case of characters.
|
import sys
import string
count = {k : 0 for k in string.ascii_lowercase}
print(count)
for c in sys.stdin.read().lower():
if c.islower():
count[c] = count[c] + 1
for k, v in count.items():
print(f"{k} : {v}")
|
s125381964
|
Accepted
| 40 | 6,696 | 218 |
import sys
import string
count = {k : 0 for k in string.ascii_lowercase}
for c in list(sys.stdin.read().lower()):
if c.islower():
count[c] = count[c] + 1
for k, v in count.items():
print(f"{k} : {v}")
|
s547082980
|
p03860
|
u077898957
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 32 |
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.
|
s = input()
print('A'+s[0]+'C')
|
s353810598
|
Accepted
| 17 | 2,940 | 62 |
a,b,c = map(str,input().split())
print(a[0],b[0],c[0],sep='')
|
s591599686
|
p03408
|
u729133443
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 118 |
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen. Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.) At most how much can he earn on balance? Note that the same string may be written on multiple cards.
|
I=lambda:[input()for _ in[0]*int(input())];s=I();t=I();c=0
for i in set(t):a=t.count(i)-s.count(i);c+=a*(a>0)
print(c)
|
s764101459
|
Accepted
| 17 | 2,940 | 72 |
n,*s=open(0);print(max(0,*[s.count(i)-s[int(n):].count(i)*2for i in s]))
|
s037720627
|
p03779
|
u790877102
| 2,000 | 262,144 |
Wrong Answer
| 30 | 2,940 | 93 |
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.
|
x = int(input())
t =0
for i in range(10**5):
t += 1
if x< (i*(i+1)//2):
break
print(t)
|
s463991904
|
Accepted
| 31 | 2,940 | 97 |
x = int(input())
t =0
for i in range(10**5):
t += 1
if x< (i*(i+1)//2)+1:
break
print(t-1)
|
s746601167
|
p03740
|
u533084327
| 2,000 | 262,144 |
Wrong Answer
| 336 | 21,656 | 388 |
Alice and Brown loves games. Today, they will play the following game. In this game, there are two piles initially consisting of X and Y stones, respectively. Alice and Bob alternately perform the following operation, starting from Alice: * Take 2i stones from one of the piles. Then, throw away i of them, and put the remaining i in the other pile. Here, the integer i (1≤i) can be freely chosen as long as there is a sufficient number of stones in the pile. The player who becomes unable to perform the operation, loses the game. Given X and Y, determine the winner of the game, assuming that both players play optimally.
|
import numpy as np
Z = list(map(int,input().split()))
Z = np.sort(Z)[::-1]
#print(Z)
count = 0
if Z[0]==1 or Z[0]==0:
print ('Brown')
else:
while Z[0] != 1:
Z[1] += int(Z[0]/2)
Z[0] -= int(Z[0]/2)*2
Z = np.sort(Z)[::-1]
count += 1
print (Z)
if (count%2) == 1:
print ('Alice')
else: print ('Brown')
|
s309810253
|
Accepted
| 149 | 12,504 | 454 |
import numpy as np
X,Y = list(map(int,input().split()))
if np.abs(X-Y)<=1:
print('Brown')
else:
print('Alice')
|
s180759463
|
p00553
|
u327546577
| 8,000 | 262,144 |
Wrong Answer
| 20 | 5,592 | 155 |
JOI 君は食事の準備のため,A ℃の肉を電子レンジで B ℃まで温めようとしている. 肉は温度が 0 ℃未満のとき凍っている. また,温度が 0 ℃より高いとき凍っていない. 温度がちょうど 0 ℃のときの肉の状態は,凍っている場合と,凍っていない場合の両方があり得る. JOI 君は,肉の加熱にかかる時間は以下のようになると仮定して,肉を温めるのにかかる時間を見積もることにした. * 肉が凍っていて,その温度が 0 ℃より小さいとき: C 秒で 1 ℃温まる. * 肉が凍っていて,その温度がちょうど 0 ℃のとき: D 秒で肉が解凍され,凍っていない状態になる. * 肉が凍っていないとき: E 秒で 1 ℃温まる. この見積もりにおいて,肉を B ℃にするのに何秒かかるかを求めよ.
|
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
t = 0
if A < 0:
t += C * abs(A) + D
t += E * (B - A)
print(t)
|
s086554940
|
Accepted
| 20 | 5,588 | 163 |
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
t = 0
if A < 0:
t += C * abs(A) + D
t += E * (B - max(0, A))
print(t)
|
s358841838
|
p03436
|
u062189367
| 2,000 | 262,144 |
Wrong Answer
| 27 | 3,316 | 833 |
We have an H \times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j). Snuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares. Before Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game. When the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares. The color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is `.`; if square (i, j) is initially painted by black, s_{i, j} is `#`.
|
from collections import deque
h, w = map(int, input().split())
maze = [list(input()) for a in range(h)]
visited = [[0]*w for a in range(h)]
dy = [0,1,0,-1]
dx = [1,0,-1,0]
def bfs():
que = deque([])
que.append((0,0))
visited[0][0]=0
while que:
p = que.popleft()
if p[0]==h-1 and p[1]==w-1:
break
for i in range(4):
ny = p[0]+dy[i]
nx = p[1]+dx[i]
if 0<=ny<h and 0 <=nx<w and maze[ny][nx]=='.' and visited[ny][nx]==0:
visited[ny][nx]=visited[p[0]][p[1]]+1
que.append((ny,nx))
return visited[h-1][w-1]
ans = bfs()
if ans == 0:
print(-1)
else:
cnt = 0
for i in range(h):
for j in range(w):
if maze[i][j]=='#':
cnt +=1
print(h*w-cnt-ans+1)
|
s552741622
|
Accepted
| 28 | 3,316 | 833 |
from collections import deque
h, w = map(int, input().split())
maze = [list(input()) for a in range(h)]
visited = [[0]*w for a in range(h)]
dy = [0,1,0,-1]
dx = [1,0,-1,0]
def bfs():
que = deque([])
que.append((0,0))
visited[0][0]=0
while que:
p = que.popleft()
if p[0]==h-1 and p[1]==w-1:
break
for i in range(4):
ny = p[0]+dy[i]
nx = p[1]+dx[i]
if 0<=ny<h and 0 <=nx<w and maze[ny][nx]=='.' and visited[ny][nx]==0:
visited[ny][nx]=visited[p[0]][p[1]]+1
que.append((ny,nx))
return visited[h-1][w-1]
ans = bfs()
if ans == 0:
print(-1)
else:
cnt = 0
for i in range(h):
for j in range(w):
if maze[i][j]=='#':
cnt +=1
print(h*w-cnt-ans-1)
|
s703388943
|
p03680
|
u189487046
| 2,000 | 262,144 |
Wrong Answer
| 282 | 7,888 | 250 |
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i. When Button i is not lighten up, nothing will happen by pressing it. Initially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up. Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.
|
n = int(input())
buttons = []
for _ in range(n):
buttons.append(int(input()))
light = buttons[0]
for i in range(n):
print(buttons[light-1])
if light == 2:
print(i+1)
break
light = buttons[light-1]
else:
print(-1)
|
s341234646
|
Accepted
| 202 | 7,080 | 238 |
n = int(input())
buttons = [0 for _ in range(n)]
for i in range(n):
buttons[i] = int(input())
light = buttons[0]
for i in range(n):
if light == 2:
print(i+1)
break
light = buttons[light-1]
else:
print(-1)
|
s282132899
|
p03456
|
u823044869
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 136 |
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
|
import math
a, b = input().split()
result_sqrt = math.sqrt(int(a+b))
if result_sqrt**2 == int(a+b):
print('yes')
else:
print('no')
|
s949505596
|
Accepted
| 17 | 2,940 | 110 |
import math
a, b = input().split()
if math.sqrt(int(a+b)).is_integer():
print("Yes")
else:
print("No")
|
s430626452
|
p03854
|
u609738635
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,188 | 261 |
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
|
# -*- coding: utf-8 -*-
def solve(S):
S.replace("eraser", "").replace("erase", "").replace("dream", "").replace("dreamer", "")
if(S==""):
print("YES")
else:
print("NO")
if __name__ == '__main__':
S = input()
solve(S)
|
s288079478
|
Accepted
| 18 | 3,188 | 266 |
# -*- coding: utf-8 -*-
def solve(S):
s = S.replace("eraser", "").replace("erase", "").replace("dreamer", "").replace("dream", "")
if(s==""):
print("YES")
else:
print("NO")
if __name__ == '__main__':
S = input()
solve(S)
|
s607003463
|
p03400
|
u112002050
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 178 |
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces. Find the number of chocolate pieces prepared at the beginning of the camp.
|
N = int(input())
D, X = map(int, input().split())
A = [int(input()) for _ in range(N)]
answer = X
for a in A:
print(D // a + 1)
answer += (D - 1) // a + 1
print(answer)
|
s786283988
|
Accepted
| 18 | 2,940 | 156 |
N = int(input())
D, X = map(int, input().split())
A = [int(input()) for _ in range(N)]
answer = X
for a in A:
answer += (D - 1) // a + 1
print(answer)
|
s480591614
|
p02396
|
u344890307
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,608 | 121 |
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.
|
i=1
for x in [int(x) for x in input().split()]:
if x != 0:
print('Case {0}: {1}'.format(i,x))
i += 1
|
s852234674
|
Accepted
| 150 | 5,604 | 140 |
i=1
while True:
x = int(input().strip())
if x==0:
break
else:
print('Case {0}: {1}'.format(i,x))
i += 1
|
s958006053
|
p02742
|
u189056821
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 119 |
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
|
h, w=map(int,input().split())
if w % 2 == 0:
print(int(h * w / 2))
else:
print(int(h * w / 2) + int(w /2))
|
s796790777
|
Accepted
| 17 | 2,940 | 240 |
h, w=map(int,input().split())
if (w == 1) | (h == 1):
print(1)
elif h % 2 == 0:
print(int(h * w / 2))
elif h % 2 == 1 & w % 2 == 1:
print(int((h - 1) * w / 2) + int(w / 2) + 1)
else:
print(int((h - 1) * w / 2) + int(w / 2))
|
s594747779
|
p03545
|
u186542450
| 2,000 | 262,144 |
Wrong Answer
| 36 | 4,464 | 360 |
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
|
import random
import sys
str = input()
print(str)
def retop():
if(random.uniform(0, 1) > 0.5):
return "+"
return "-"
for i in range(100):
formula = (str[0] + retop() + str[1] + retop() + str[2] + retop() + str[3])
if eval(formula) == 7:
print(formula)
sys.exit()
|
s258340618
|
Accepted
| 31 | 3,952 | 356 |
import random
import sys
str = input()
def retop():
if(random.uniform(0, 1) > 0.5):
return "+"
return "-"
for i in range(100):
formula = (str[0] + retop() + str[1] + retop() + str[2] + retop() + str[3])
if eval(formula) == 7:
print(formula + "=7")
sys.exit()
|
s422035031
|
p03943
|
u336564899
| 2,000 | 262,144 |
Wrong Answer
| 26 | 9,052 | 213 |
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
l = list(map(int, input().split()))
l.sort()
if l[0] + l[1] == l[2]:
print("YES")
else:
print("NO")
|
s094829245
|
Accepted
| 27 | 9,180 | 213 |
l = list(map(int, input().split()))
l.sort()
if l[0] + l[1] == l[2]:
print("Yes")
else:
print("No")
|
s877735444
|
p03494
|
u801701525
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 145 |
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 = map(int, input().split())
count = 0
for a in A:
if a%2==0:
count+=1
else:
print(count)
break
|
s380579530
|
Accepted
| 18 | 2,940 | 171 |
def calc(n):
ans = 0
while n%2 == 0:
ans+=1
n/=2
return ans
N = int(input())
A = map(int,input().split())
ans = min(map(calc, A))
print(ans)
|
s357730852
|
p03150
|
u764600134
| 2,000 | 1,048,576 |
Wrong Answer
| 19 | 3,188 | 267 |
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
|
import re
def solve(S):
patterns = ['^.*keyence$', '^k.*eyence$', '^ke.*yence$', '^key.*ence$',
'^keye.*nce$', '^keyen.*ce$', '^keyenc.*e$', '^keyence.*$']
for p in patterns:
if re.match(p, S):
return 'YES'
return 'NO'
|
s785482122
|
Accepted
| 17 | 3,064 | 468 |
# -*- coding: utf-8 -*-
import sys
def solve(S):
l = len('keyence')
diff = len(S) - l
if diff < 0:
return 'NO'
for i in range(len(S)):
t = S[:i] + S[i+diff:]
if t == 'keyence':
return 'YES'
return 'NO'
def main(args):
S = input()
ans = solve(S)
print(ans)
if __name__ == '__main__':
main(sys.argv[1:])
|
s718774430
|
p00774
|
u797673668
| 8,000 | 131,072 |
Wrong Answer
| 130 | 7,728 | 903 |
We are playing a puzzle. An upright board with _H_ rows by 5 columns of cells, as shown in the figure below, is used in this puzzle. A stone engraved with a digit, one of 1 through 9, is placed in each of the cells. When three or more stones in horizontally adjacent cells are engraved with the same digit, the stones will disappear. If there are stones in the cells above the cell with a disappeared stone, the stones in the above cells will drop down, filling the vacancy. The puzzle proceeds taking the following steps. 1. When three or more stones in horizontally adjacent cells are engraved with the same digit, the stones will disappear. Disappearances of all such groups of stones take place simultaneously. 2. When stones are in the cells above the emptied cells, these stones drop down so that the emptied cells are filled. 3. After the completion of all stone drops, if one or more groups of stones satisfy the disappearance condition, repeat by returning to the step 1. The score of this puzzle is the sum of the digits on the disappeared stones. Write a program that calculates the score of given configurations of stones.
|
from itertools import zip_longest
while True:
n = int(input())
if not n:
break
field = [list(map(int, input().split())) for _ in range(n)]
field.reverse()
score = 0
while True:
no_more_disappear = True
for y, row in enumerate(field):
for i, stone in enumerate(row):
if stone is None:
continue
cnt = 1
for stone2 in row[i + 1:]:
if stone != stone2:
break
cnt += 1
if cnt >= 3:
row[i:i + cnt] = [None] * cnt
score += stone * cnt
no_more_disappear = False
if no_more_disappear:
break
fieldT = map(lambda row: filter(None, row), zip(*field))
field = map(list, zip_longest(*fieldT))
print(score)
|
s978148203
|
Accepted
| 150 | 7,828 | 899 |
from itertools import zip_longest
while True:
n = int(input())
if not n:
break
field = [list(map(int, input().split())) for _ in range(n)]
field.reverse()
score = 0
while True:
no_more_disappear = True
for row in field:
for i, stone in enumerate(row[:3]):
if stone is None:
continue
cnt = 1
for stone2 in row[i + 1:]:
if stone != stone2:
break
cnt += 1
if cnt >= 3:
row[i:i + cnt] = [None] * cnt
score += stone * cnt
no_more_disappear = False
if no_more_disappear:
break
fieldT = map(lambda row: filter(None, row), zip(*field))
field = list(map(list, zip_longest(*fieldT)))
print(score)
|
s348360146
|
p02578
|
u800058906
| 2,000 | 1,048,576 |
Wrong Answer
| 214 | 32,180 | 170 |
N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool. Find the minimum total height of the stools needed to meet this goal.
|
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(1,n):
diff=a[i]-a[i-1]
if diff<0:
ans+=-diff
a[i]=a[i]-diff
print(diff)
print(ans)
|
s951301697
|
Accepted
| 149 | 32,232 | 154 |
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(1,n):
diff=a[i]-a[i-1]
if diff<0:
ans+=-diff
a[i]=a[i]-diff
print(ans)
|
s902319935
|
p02408
|
u957680575
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,668 | 445 |
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.
|
A = [[i for i in range(1 ,14)] for j in range(4)]
a = int(input())
print(A)
for i in range(a):
b,c = map(str,input().split())
c=int(c)
if b=="S":
A[0].remove(c)
if b=="H":
A[1].remove(c)
if b=="C":
A[2].remove(c)
if b=="D":
A[3].remove(c)
def name(number,name):
x=A[number]
x=map(str,x)
print("%s " %name+("\n%s " %name).join(x))
name(0,"S")
name(1,"H")
name(2,"C")
name(3,"D")
|
s779874444
|
Accepted
| 30 | 7,732 | 502 |
A = [[i for i in range(1 ,14)] for j in range(4)]
a = int(input())
for i in range(a):
b,c = map(str,input().split())
c=int(c)
if b=="S":
A[0].remove(c)
if b=="H":
A[1].remove(c)
if b=="C":
A[2].remove(c)
if b=="D":
A[3].remove(c)
def name(number,name):
if A[number]==[]:
pass
else:
x=A[number]
x=map(str,x)
print("%s " %name+("\n%s " %name).join(x))
name(0,"S")
name(1,"H")
name(2,"C")
name(3,"D")
|
s673979070
|
p03860
|
u403832169
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 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")
|
s485321599
|
Accepted
| 20 | 2,940 | 25 |
print("A"+input()[8]+"C")
|
s433709812
|
p02401
|
u962381052
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,412 | 111 |
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.
|
while True:
a, op, b = input().split()
if op == '?':
break
eval('print({})'.format(a+op+b))
|
s654958360
|
Accepted
| 30 | 7,588 | 259 |
while True:
a, op, b = input().split()
a = int(a)
b = int(b)
if op == '+':
print(a + b)
elif op == '-':
print(a - b)
elif op == '*':
print(a * b)
elif op == '/':
print(a // b)
else:
break
|
s228820811
|
p02850
|
u334712262
| 2,000 | 1,048,576 |
Wrong Answer
| 2,105 | 67,456 | 1,908 |
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.
|
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1
def read_int():
return int(input())
def read_int_n():
return list(map(int, input().split()))
def read_float():
return float(input())
def read_float_n():
return list(map(float, input().split()))
def read_str():
return input().strip()
def read_str_n():
return list(map(str, input().split()))
def error_print(*args):
print(*args, file=sys.stderr)
def mt(f):
import time
def wrap(*args, **kwargs):
s = time.time()
ret = f(*args, **kwargs)
e = time.time()
error_print(e - s, 'sec')
return ret
return wrap
@mt
def slv(N, AB):
g = defaultdict(list)
for a, b in AB:
g[a].append(b)
g[b].append(a)
v = -1
for k in g:
if len(g[k]) == 1:
v = k
break
s = [(v, 1)]
done = set([v])
K = 0
ans = {}
while s:
u, c = s.pop()
used = set([c])
for v in g[u]:
if v not in done:
c = 1
while c in used:
c += 1
K = max(K, c)
used.add(c)
s.append((v, c))
i, j = min(u, v), max(u, v)
ans[(i, j)] = c
done.add(v)
print(K)
for a, b in AB:
print(ans[(a, b)])
# return ans
def main():
N = read_int()
AB = [read_int_n() for _ in range(N-1)]
(slv(N, AB))
if __name__ == '__main__':
main()
|
s496511168
|
Accepted
| 652 | 67,416 | 1,803 |
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1
def read_int():
return int(input())
def read_int_n():
return list(map(int, input().split()))
def read_float():
return float(input())
def read_float_n():
return list(map(float, input().split()))
def read_str():
return input().strip()
def read_str_n():
return list(map(str, input().split()))
def error_print(*args):
print(*args, file=sys.stderr)
def mt(f):
import time
def wrap(*args, **kwargs):
s = time.time()
ret = f(*args, **kwargs)
e = time.time()
error_print(e - s, 'sec')
return ret
return wrap
@mt
def slv(N, AB):
g = defaultdict(list)
for a, b in AB:
g[a].append(b)
g[b].append(a)
s = [(1, -1)]
done = set([1])
K = 1
ans = {}
while s:
u, c = s.pop()
used = set([c])
c = 1
for v in g[u]:
if v in done:
continue
while c in used:
c += 1
K = max(K, c)
used.add(c)
s.append((v, c))
i, j = min(u, v), max(u, v)
ans[(i, j)] = c
done.add(v)
print(K)
for a, b in AB:
print(ans[(a, b)])
# return ans
def main():
N = read_int()
AB = [read_int_n() for _ in range(N-1)]
(slv(N, AB))
if __name__ == '__main__':
main()
|
s410287363
|
p02396
|
u661529494
| 1,000 | 131,072 |
Wrong Answer
| 60 | 7,500 | 115 |
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.
|
import sys
cnt=1
while 1:
x=sys.stdin.readline().strip()
if x=='0':
break;
print("Case %d %s"%(cnt,x))
cnt+=1
|
s483941379
|
Accepted
| 60 | 7,512 | 117 |
import sys
cnt=1
while 1:
x=sys.stdin.readline().strip()
if x== '0':
break;
print("Case %d: %s"%(cnt,x))
cnt+=1
|
s928695238
|
p03494
|
u699699071
| 2,000 | 262,144 |
Wrong Answer
| 24 | 3,488 | 414 |
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.
|
loop = int(input())
kokuban=[int(x) for x in input().split()]
print(kokuban)
flag=False
result =0
while(flag==False) :
for index,obj in enumerate(kokuban) :
print(int(obj))
if int(obj)%2 == 0:
kokuban[index]= int(obj)//2
# print(obj)
else:
flag=True
if flag==False :
# print("flag_false")
result +=1
print("result is ",result)
|
s385252955
|
Accepted
| 19 | 2,940 | 306 |
loop = int(input())
kokuban=[int(x) for x in input().split()]
flag=False
result =0
while(flag==False) :
for index,obj in enumerate(kokuban) :
if int(obj)%2 == 0:
kokuban[index]= int(obj)//2
else:
flag=True
if flag==False :
result +=1
print(result)
|
s971750715
|
p03386
|
u479937725
| 2,000 | 262,144 |
Wrong Answer
| 2,239 | 938,348 | 128 |
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
|
A,B,K = map(int,input().split())
L = []
for n in range(A,B+1):
L.append(n)
ans = set(L[:K]+L[-K:])
print(*ans,sep="\n")
|
s948777474
|
Accepted
| 36 | 9,148 | 197 |
A,B,K = map(int,input().split())
L = []
M = []
for n in range(A,min(A+K,B+1)):
L.append(n)
for n in range(max(A,B-K),B+1):
M.append(n)
L = sorted(set(L[:K]+M[-K:]))
print(*L,sep="\n")
|
s605433394
|
p03067
|
u655048024
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 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())
if(B>=A)and(C>=B):
print("YES")
else:
print("NO")
|
s796136264
|
Accepted
| 17 | 2,940 | 104 |
A,B,C = map(int,input().split())
if((C>A)and(B>C))or((A>C)and(C>B)):
print("Yes")
else:
print("No")
|
s279850287
|
p02266
|
u007270338
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,588 | 1,490 |
Your task is to simulate a flood damage. For a given cross-section diagram, reports areas of flooded sections. Assume that rain is falling endlessly in the region and the water overflowing from the region is falling in the sea at the both sides. For example, for the above cross-section diagram, the rain will create floods which have areas of 4, 2, 1, 19 and 9 respectively.
|
#coding:utf-8
data = input()
xmax = len(data)
data_list = list(data)
data_list.reverse()
reverse_data = []
for sig in data_list:
if sig == "\\":
reverse_data.append("/")
elif sig == "/":
reverse_data.append("\\")
else:
reverse_data.append(sig)
reverse_data = "".join(reverse_data)
def partialSqu(h, sig):
if sig == "\\":
squ = h + 1/2
h += 1
elif sig == "/":
squ = h - 1/2
h -= 1
elif sig == "_":
squ = h
return squ, h
x_squ_dict = {}
cnt = 0
sw, x, h, totalSqu = 0, 0, 0, 0
for sig in data:
if sw == 0 and sig == "\\":
sw = 1
if sw == 1 :
squ, h = partialSqu(h, sig)
totalSqu += squ
if h == 0:
x_squ_dict[x] = totalSqu
totalSqu = 0
sw = 0
cnt += 1
x += 1
keys = x_squ_dict.keys()
sw, x, h, totalSqu = 0, 0, 0, 0
for sig in reverse_data:
x += 1
if sw == 0 and sig == "\\" and (xmax - x) not in keys:
sw = 1
if sw == 1 :
squ, h = partialSqu(h, sig)
totalSqu += squ
if h == 0:
x_squ_dict[xmax - x] = totalSqu
totalSqu = 0
sw = 0
cnt += 1
print(cnt)
keys = x_squ_dict.keys()
num = len(keys)
keys = list(keys)
keys.sort()
squ_list = []
for key in keys:
squ_list.append(x_squ_dict[key])
squ_list.insert(0,num)
squ_list = " ".join([str(int(num)) for num in squ_list])
print(squ_list)
|
s280414537
|
Accepted
| 50 | 6,200 | 1,466 |
#coding:utf-8
data = input()
xmax = len(data)
data_list = list(data)
data_list.reverse()
reverse_data = []
for sig in data_list:
if sig == "\\":
reverse_data.append("/")
elif sig == "/":
reverse_data.append("\\")
else:
reverse_data.append(sig)
reverse_data = "".join(reverse_data)
def partialSqu(h, sig):
if sig == "\\":
squ = h + 1/2
h += 1
elif sig == "/":
squ = h - 1/2
h -= 1
elif sig == "_":
squ = h
return squ, h
x_squ_dict = {}
cnt = 0
sw, x, h, totalSqu = 0, 0, 0, 0
for sig in data:
x += 1
if sw == 0 and sig == "\\":
sw = 1
if sw == 1 :
squ, h = partialSqu(h, sig)
totalSqu += squ
if h == 0:
x_squ_dict[x] = totalSqu
totalSqu = 0
sw = 0
keys = x_squ_dict.keys()
sw, x, h, totalSqu = 0, 0, 0, 0
for sig in reverse_data:
x += 1
if sw == 0 and sig == "\\" :
sw = 1
x_p = xmax - x +1
if sw == 1 :
squ, h = partialSqu(h, sig)
totalSqu += squ
if h == 0:
x_squ_dict[x_p] = totalSqu
totalSqu = 0
sw = 0
keys = x_squ_dict.keys()
keys = list(keys)
keys.sort()
squ_list = []
for key in keys:
squ_list.append(x_squ_dict[key])
a = int(sum(squ_list))
print(a)
squ_list.insert(0,len(keys))
squ_list = " ".join([str(int(num)) for num in squ_list])
print(squ_list)
|
s015317099
|
p03697
|
u287431190
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 79 |
You are given two integers A and B as the input. Output the value of A + B. However, if A + B is 10 or greater, output `error` instead.
|
a,b = map(int, input().split())
if (a+b)<9:
print(a+b)
else:
print('error')
|
s840595812
|
Accepted
| 17 | 2,940 | 80 |
a,b = map(int, input().split())
if (a+b)<=9:
print(a+b)
else:
print('error')
|
s981794365
|
p03470
|
u482933792
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 75 |
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
|
N = int(input())
lst = list(map(int,input().split()))
print(len(set(lst)))
|
s301093676
|
Accepted
| 17 | 2,940 | 71 |
N = int(input())
print(len(set(map(int,[input() for i in range(N)]))))
|
s017982749
|
p03131
|
u176645218
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,060 | 213 |
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the maximum possible number of biscuits in Snuke's pocket after K operations.
|
K,A,B = map(int,input().split(' '))
ans = 0
if B <= A + 2:
ans = 1+K
else:
if K <= A:
ans = 1+K
else:
K -= A-1
print(K)
if K % 2 == 1:
ans += 1
K -= 1
N = K//2
ans += A+(B-A)*N
print(ans)
|
s961987976
|
Accepted
| 18 | 2,940 | 204 |
K,A,B = map(int,input().split(' '))
ans = 0
if B <= A + 2:
ans = 1+K
else:
if K <= A:
ans = 1 + K
else:
K -= A-1
if K % 2 == 1:
ans += 1
K -= 1
N = K//2
ans += A+(B-A)*N
print(ans)
|
s294480187
|
p03477
|
u846652026
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 103 |
A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan. Print `Left` if the balance scale tips to the left; print `Balanced` if it balances; print `Right` if it tips to the right.
|
a,b,c,d=map(int, input().split())
print("left" if a+b > c+d else "Balanced" if a+b == c+d else "Right")
|
s726382574
|
Accepted
| 17 | 2,940 | 103 |
a,b,c,d=map(int, input().split())
print("Left" if a+b > c+d else "Balanced" if a+b == c+d else "Right")
|
s846572208
|
p03477
|
u137808818
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 100 |
A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan. Print `Left` if the balance scale tips to the left; print `Balanced` if it balances; print `Right` if it tips to the right.
|
a,b,c,d = map(int,input().split())
print('left' if a+b>c+d else 'Right' if a+b<c+d else 'Balanced')
|
s953608285
|
Accepted
| 17 | 2,940 | 100 |
a,b,c,d = map(int,input().split())
print('Left' if a+b>c+d else 'Right' if a+b<c+d else 'Balanced')
|
s480379089
|
p03795
|
u318861481
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 105 |
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
|
#!/usr/bin/python3
n = input()
x = 800 * int(n)
y = 200 * int(int(n) / 15)
print(x)
print(y)
print(x-y)
|
s680886243
|
Accepted
| 17 | 2,940 | 88 |
#!/usr/bin/python3
n = input()
x = 800 * int(n)
y = 200 * int(int(n) / 15)
print(x-y)
|
s224668247
|
p02392
|
u444997287
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,516 | 134 |
Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No".
|
n = input().split()
if int(n[0]) > int(n[1]):
if int(n[1]) > int(n[2]):
print('Yes')
else:
print('No')
else:
print('No')
|
s502164096
|
Accepted
| 20 | 7,648 | 134 |
n = input().split()
if int(n[0]) < int(n[1]):
if int(n[1]) < int(n[2]):
print('Yes')
else:
print('No')
else:
print('No')
|
s029029637
|
p03730
|
u374082254
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 125 |
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
|
A, B, C = map(int, input().split())
result = "NO"
for i in range(B):
if C == A % B:
print("YES")
print(result)
|
s218222426
|
Accepted
| 18 | 2,940 | 138 |
A, B, C = map(int, input().split())
result = "NO"
for i in range(1, B+1):
if C == ((i*A) % B):
result = "YES"
print(result)
|
s343372499
|
p03338
|
u934246119
| 2,000 | 1,048,576 |
Wrong Answer
| 70 | 3,060 | 335 |
You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.
|
n = int(input())
s = input()
n1 = []
for i in range(n):
s1 = set()
for j in range(i):
for k in range(i+1, n):
# print(i, j, k, s[j], s[k])
if s[j] == s[k] and set(s[j]).issubset(s1) is False:
s1.add(s[j])
n1.append(len(s1))
print(max(n1))
|
s058229923
|
Accepted
| 72 | 3,060 | 337 |
n = int(input())
s = input()
n1 = []
for i in range(n):
s1 = set()
for j in range(i+1):
for k in range(i+1, n):
# print(i, j, k, s[j], s[k])
if s[j] == s[k] and set(s[j]).issubset(s1) is False:
s1.add(s[j])
n1.append(len(s1))
print(max(n1))
|
s558607268
|
p03447
|
u526818929
| 2,000 | 262,144 |
Wrong Answer
| 24 | 9,100 | 69 |
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 + B))
|
s801827775
|
Accepted
| 31 | 9,064 | 68 |
X = int(input())
A = int(input())
B = int(input())
print((X -A) % B)
|
s179580688
|
p02390
|
u604774382
| 1,000 | 131,072 |
Wrong Answer
| 30 | 6,744 | 86 |
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
|
S=int( input() )
h=S/3600
S=S%3600
m=S/60
s=S%60
print( "{}:{}:{}".format( h, m, s ) )
|
s850711002
|
Accepted
| 30 | 6,736 | 124 |
#coding:utf-8
S=int( input() )
h=int( S/3600)
S=int( S%3600)
m=int( S/60)
s=int( S%60)
print( "{}:{}:{}".format( h, m, s ) )
|
s289382358
|
p03827
|
u183840468
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 113 |
You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).
|
n = int(input())
l = input()
ans = 0
for i in l:
if i == 'D':
ans -= 1
else:
ans += 1
print(ans)
|
s116937996
|
Accepted
| 17 | 2,940 | 158 |
n = int(input())
l = input()
ans = 0
max_ans = 0
for i in l:
if i == 'D':
ans -= 1
else:
ans += 1
max_ans = max(ans,max_ans)
print(max_ans)
|
s392971531
|
p03679
|
u668352391
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 154 |
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(lambda x: int(x), input().split())
if b <= a:
print('delicious')
elif b > a and x <= b - a:
print('safe')
else:
print('dangerous')
|
s102999013
|
Accepted
| 17 | 2,940 | 144 |
x, a, b = map(lambda x: int(x), input().split())
if b <= a:
print('delicious')
elif x >= b - a:
print('safe')
else:
print('dangerous')
|
s414628373
|
p03997
|
u465152652
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 97 |
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
num = [input() for i in range(3)]
result = (int(num[0])+int(num[1]))*int(num[2])/2
print(result)
|
s915357620
|
Accepted
| 17 | 2,940 | 64 |
a,b,h = [int(input()) for i in range(3)]
print(int((a + b)*h/2))
|
s662762274
|
p03361
|
u227476288
| 2,000 | 262,144 |
Wrong Answer
| 23 | 3,188 | 872 |
We have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= `#`, and to make Square (i, j) white when s_{i, j}= `.`. However, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black. Determine if square1001 can achieve his objective.
|
#ABC 096 C - Grid Repainting 2
H, W = map(int, input().split())
S = [input() for i in range(H)]
s = [[0] * (W+2) for i in range(H+2)]
for h in range(H):
for w in range(W):
s[h+1][w+1] = S[h][w]
print(s)
c = [[0] * (W+2) for i in range(H+2)]
for h in range(1,H+1):
for w in range(1,W+1):
if s[h][w] == '#':
if s[h][w-1] == '#':
c[h][w] += 1
c[h][w-1] +=1
if s[h][w+1] == '#':
c[h][w] += 1
c[h][w+1] +=1
if s[h+1][w] == '#':
c[h][w] += 1
c[h+1][w] +=1
if s[h-1][w] == '#':
c[h-1][w] += 1
c[h-1][w] +=1
for h in range(1,H+1):
for w in range(1,W+1):
if s[h][w] == '#':
if c[h][w] == 0:
print('No')
exit()
print('Yes')
|
s325247525
|
Accepted
| 23 | 3,192 | 863 |
#ABC 096 C - Grid Repainting 2
H, W = map(int, input().split())
S = [input() for i in range(H)]
s = [[0] * (W+2) for i in range(H+2)]
for h in range(H):
for w in range(W):
s[h+1][w+1] = S[h][w]
c = [[0] * (W+2) for i in range(H+2)]
for h in range(1,H+1):
for w in range(1,W+1):
if s[h][w] == '#':
if s[h][w-1] == '#':
c[h][w] += 1
c[h][w-1] +=1
if s[h][w+1] == '#':
c[h][w] += 1
c[h][w+1] +=1
if s[h+1][w] == '#':
c[h][w] += 1
c[h+1][w] +=1
if s[h-1][w] == '#':
c[h-1][w] += 1
c[h-1][w] +=1
for h in range(1,H+1):
for w in range(1,W+1):
if s[h][w] == '#':
if c[h][w] == 0:
print('No')
exit()
print('Yes')
|
s386390321
|
p02612
|
u518818546
| 2,000 | 1,048,576 |
Wrong Answer
| 26 | 9,080 | 64 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n = int(input())
if n % 1000:
print(0)
else:
print(n % 1000)
|
s753252418
|
Accepted
| 30 | 9,176 | 74 |
n = int(input())
if n % 1000 == 0:
print(0)
else:
print(1000 - n%1000)
|
s190148278
|
p00003
|
u821624310
| 1,000 | 131,072 |
Wrong Answer
| 40 | 7,528 | 201 |
Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so.
|
N = int(input())
for i in range(N):
a, b, c = map(int, input().split())
sort = sorted([a, b, c])
if sort[0]**2 + sort[1]**2 == sort[2]**2:
print("Yes")
else:
print("No")
|
s371524511
|
Accepted
| 40 | 7,600 | 201 |
N = int(input())
for i in range(N):
a, b, c = map(int, input().split())
sort = sorted([a, b, c])
if sort[0]**2 + sort[1]**2 == sort[2]**2:
print("YES")
else:
print("NO")
|
s091139033
|
p03945
|
u360515075
| 2,000 | 262,144 |
Wrong Answer
| 37 | 3,188 | 93 |
Two foxes Jiro and Saburo are playing a game called _1D Reversi_. This game is played on a board, using black and white stones. On the board, stones are placed in a row, and each player places a new stone to either end of the row. Similarly to the original game of Reversi, when a white stone is placed, all black stones between the new white stone and another white stone, turn into white stones, and vice versa. In the middle of a game, something came up and Saburo has to leave the game. The state of the board at this point is described by a string S. There are |S| (the length of S) stones on the board, and each character in S represents the color of the i-th (1 ≦ i ≦ |S|) stone from the left. If the i-th character in S is `B`, it means that the color of the corresponding stone on the board is black. Similarly, if the i-th character in S is `W`, it means that the color of the corresponding stone is white. Jiro wants all stones on the board to be of the same color. For this purpose, he will place new stones on the board according to the rules. Find the minimum number of new stones that he needs to place.
|
S = input()
p = S[0]
ans = 0
for i in range(1, len(S)):
if S[i] != p: ans += 1
print (ans)
|
s197344367
|
Accepted
| 45 | 3,188 | 104 |
S = input()
p = S[0]
ans = 0
for i in range(1, len(S)):
if S[i] != p: ans += 1
p = S[i]
print (ans)
|
s927187437
|
p03556
|
u697696097
| 2,000 | 262,144 |
Wrong Answer
| 23 | 2,940 | 106 |
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.
|
import sys
n=int(input())
x=1
while 1:
tmp=x*x
if tmp > n:
print(x*x)
sys.exit()
x+=1
|
s661263340
|
Accepted
| 26 | 3,060 | 111 |
import sys
n=int(input())
x=1
while 1:
tmp=(x+1)*(x+1)
if tmp > n:
print(x*x)
sys.exit()
x+=1
|
s895672872
|
p03636
|
u137808818
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 51 |
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.
|
n = input()
s = len(n) - 2
print(n[0]+ 's' + n[-1])
|
s645536405
|
Accepted
| 17 | 2,940 | 55 |
n = input()
s = len(n) - 2
print(n[0]+ str(s) + n[-1])
|
s613626068
|
p03623
|
u992287017
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 148 |
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|.
|
if __name__ == '__main__':
X, A, B = [int(i) for i in range(3)]
if abs(A - X) < abs(B - X):
print('A')
else:
print('B')
|
s212602594
|
Accepted
| 17 | 2,940 | 155 |
if __name__ == '__main__':
X, A, B = [int(i) for i in input().split()]
if abs(X - A) < abs(X - B):
print('A')
else:
print('B')
|
s700041571
|
p02388
|
u828399801
| 1,000 | 131,072 |
Wrong Answer
| 40 | 7,540 | 48 |
Write a program which calculates the cube of a given integer x.
|
# coding: utf-8
a = input()
print(int(a)*int(a))
|
s010025434
|
Accepted
| 20 | 7,596 | 55 |
# coding: utf-8
a = input()
print(int(a)*int(a)*int(a))
|
s773523749
|
p03713
|
u140251125
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 657 |
There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}.
|
import math
# input
H, W = map(int, input().split())
if H > W:
temp = H
H = W
W = temp
ans0 = (W % 3 != 0) * H
blue_H = math.floor(H / 2)
i = math.floor((W * blue_H) / (H + blue_H))
ans1 = math.ceil(H / 2) * (W - i) - H * i
red_H = math.ceil(H / 2)
i = math.ceil((W * red_H) / (H + red_H))
ans2 = H * i - math.floor(H / 2) * (W - i)
blue_W = math.floor(W / 2)
i = math.floor((H * blue_W) / (W + blue_W))
ans3 = math.ceil(W / 2) * (H - i) - W * i
red_W = math.ceil(W / 2)
i = math.ceil((H * red_W) / (W + red_W))
ans4 = W * i - math.floor(W / 2) * (H - i)
ans = min(ans0, ans1, ans2, ans3, ans4)
print(ans)
|
s977546487
|
Accepted
| 18 | 3,064 | 640 |
import math
# input
H, W = map(int, input().split())
ans0 = (W % 3 != 0) * H
ans1 = W * (H % 3 != 0)
blue_H = math.floor(H / 2)
i = math.floor((W * blue_H) / (H + blue_H))
ans2 = math.ceil(H / 2) * (W - i) - H * i
red_H = math.ceil(H / 2)
i = math.ceil((W * red_H) / (H + red_H))
ans3 = H * i - math.floor(H / 2) * (W - i)
blue_W = math.floor(W / 2)
i = math.floor((H * blue_W) / (W + blue_W))
ans4 = math.ceil(W / 2) * (H - i) - W * i
red_W = math.ceil(W / 2)
i = math.ceil((H * red_W) / (W + red_W))
ans5 = W * i - math.floor(W / 2) * (H - i)
ans = min(ans0, ans1, ans2, ans3, ans4, ans5)
print(ans)
|
s449581555
|
p03478
|
u911276694
| 2,000 | 262,144 |
Wrong Answer
| 50 | 3,064 | 220 |
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
|
N,A,B=map(int,input().split())
ssum=0
for i in range(1,N-1):
listi=[0,0,0,0,0]
temp=i
for j in range(5):
listi[j]=temp%10
temp=(temp-temp%10)/10
sumi=sum(listi)
if(sumi>=A and sumi<=B):
ssum=ssum+i
print(ssum)
|
s029274398
|
Accepted
| 50 | 3,064 | 220 |
N,A,B=map(int,input().split())
ssum=0
for i in range(1,N+1):
listi=[0,0,0,0,0]
temp=i
for j in range(5):
listi[j]=temp%10
temp=(temp-temp%10)/10
sumi=sum(listi)
if(sumi>=A and sumi<=B):
ssum=ssum+i
print(ssum)
|
s167604832
|
p03713
|
u223133214
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 635 |
There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}.
|
H, W = map(int, input().split())
ans = float('inf')
a, b, c, d = 0, 0, 0, 0
if H % 2 == 0:
c, d = H / 2, H / 2
else:
c, d = H // 2, H // 2 + 1
a = W // 3
b = W - a
if a != 0:
pqr = [a * H, b * c, b * d]
ans = max(pqr) - min(pqr)
a = W // 3 + 1
b = W - a
pqr = [a * H, b * c, b * d]
ans = min(ans, max(pqr) - min(pqr))
H, W = W, H
if H % 2 == 0:
c, d = H / 2, H / 2
else:
c, d = H // 2, H // 2 + 1
a = W // 3
b = W - a
if a != 0:
pqr = [a * H, b * c, b * d]
ans = min(ans, max(pqr) - min(pqr))
a = W // 3 + 1
b = W - a
pqr = [a * H, b * c, b * d]
ans = min(ans, max(pqr) - min(pqr))
print(int(ans))
|
s429486928
|
Accepted
| 17 | 3,064 | 669 |
H, W = map(int, input().split())
if H % 3 == 0 or W % 3 == 0:
print(0)
exit()
ans = float('inf')
a, b, c, d = 0, 0, 0, 0
if H % 2 == 0:
c, d = H / 2, H / 2
else:
c, d = H // 2, H // 2 + 1
for i in range(-2, 3):
a = W // 3 + i
b = W - a
if a > 0 and b > 0:
pqr = [a * H, b * c, b * d]
ans = min(ans, max(pqr) - min(pqr))
ans = min(ans, H)
H, W = W, H
if H % 2 == 0:
c, d = H / 2, H / 2
else:
c, d = H // 2, H // 2 + 1
for i in range(-2, 3):
a = W // 3 + i
b = W - a
if a > 0 and b > 0:
pqr = [a * H, b * c, b * d]
ans = min(ans, max(pqr) - min(pqr))
ans = min(ans, H)
print(int(ans))
|
s020298964
|
p03852
|
u796789068
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 446 |
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`.
|
S=input()
n=0
#print(S)
while S[:]!=S[:n]:
if S[n:n+5]=="dream" or S[n:n+8]=="dreamera":
n+=5 #dream
elif S[n:n+7]=="dreamer" and S[n+7]!="a":
n+=7 #dreamer
elif S[n:n+5]=="erase" and S[n+6]!="eraser":
n+=5
elif S[n:n+6]=="eraser" and S[n+6]!="a":
n+=6 r
#elif S[:]==S[:n-1]:
#print("YES")
#exit()
else:
print("NO")
exit()
else:
print("YES")
|
s523764583
|
Accepted
| 17 | 2,940 | 108 |
c=input()
if c=="a" or c=="e" or c=="i" or c=="o" or c=="u":
print("vowel")
else:
print("consonant")
|
s875313179
|
p02796
|
u067983636
| 2,000 | 1,048,576 |
Wrong Answer
| 293 | 24,712 | 637 |
In a factory, there are N robots placed on a number line. Robot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative. We want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect. Here, for each i (1 \leq i \leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints. Find the maximum number of robots that we can keep.
|
import sys
import itertools
input = sys.stdin.readline
def read_values():
return map(int, input().split())
def read_list():
return list(read_values())
def read_lists(N):
return [read_list() for n in range(N)]
def f(A):
min_num = A[0] + A[-1]
def main():
N = int(input())
R = []
for _ in range(N):
X, L = map(int, input().split())
R.append((X - L, X + L))
R.sort(key=lambda l: l[1])
print(R)
res = 0
T = None
for r in R:
if T is None or r[0] >= T:
T = r[1]
res += 1
print(res)
if __name__ == "__main__":
main()
|
s092146231
|
Accepted
| 219 | 19,440 | 624 |
import sys
import itertools
input = sys.stdin.readline
def read_values():
return map(int, input().split())
def read_list():
return list(read_values())
def read_lists(N):
return [read_list() for n in range(N)]
def f(A):
min_num = A[0] + A[-1]
def main():
N = int(input())
R = []
for _ in range(N):
X, L = map(int, input().split())
R.append((X - L, X + L))
R.sort(key=lambda l: l[1])
res = 0
T = None
for r in R:
if T is None or r[0] >= T:
T = r[1]
res += 1
print(res)
if __name__ == "__main__":
main()
|
s078656589
|
p03997
|
u371409687
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 55 |
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a,b,h=[int(input()) for i in range(3)]
print((a+b)*h/2)
|
s156019594
|
Accepted
| 17 | 2,940 | 62 |
a=int(input())
b=int(input())
h=int(input())
print((a+b)*h//2)
|
s116390602
|
p01733
|
u509278866
| 2,000 | 262,144 |
Wrong Answer
| 390 | 26,736 | 1,057 |
The input is formatted as follows. N x_1 y_1 w_1 x_2 y_2 w_2 : : x_N y_N w_N The first line contains a single integer N (1 ≤ N ≤ 10^5) indicating the number of the fox lairs in the forest. Each of the next N lines contains three integers x_i, y_i (|x_i|,\, |y_i| ≤ 10^9) and w_i (1 ≤ w_i ≤ 10^4), which represent there are w_i foxes at the point (x_i, y_i). It is guaranteed that all points are mutually different.
|
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def main():
n = I()
a = [LI() for _ in range(n)]
xi = min(map(lambda x: x[0],a))
xa = max(map(lambda x: x[0],a))
yi = min(map(lambda x: x[1],a))
ya = max(map(lambda x: x[1],a))
s = sum(map(lambda x: x[2], a))
if s == 0:
return '0 / 1'
t = (xa-xi) * (ya-yi)
g = fractions.gcd(s,t)
return '{} / {}'.format(s//g,t//g)
print(main())
|
s129553766
|
Accepted
| 710 | 114,676 | 949 |
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def main():
n = I()
a = [LI() for _ in range(n)]
d = collections.defaultdict(int)
for x,y,w in a:
for i in range(2):
for j in range(2):
d[(x+i,y+j)] += w
r = max(d.values())
return '{} / 1'.format(r)
print(main())
|
s172327425
|
p02796
|
u023229441
| 2,000 | 1,048,576 |
Wrong Answer
| 317 | 26,284 | 245 |
In a factory, there are N robots placed on a number line. Robot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative. We want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect. Here, for each i (1 \leq i \leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints. Find the maximum number of robots that we can keep.
|
n=int(input())
A=[[] for i in range(n)]
for i in range(n):
x,l=map(int,input().split())
A[i]=[x-l,x+l]
A=sorted(A, key=lambda x :x[1])
last=0
ans=0
for i in range(n):
if last<=A[i][0]:
ans+=1
last=A[i][1]
print(ans)
|
s657364386
|
Accepted
| 336 | 26,180 | 268 |
n=int(input())
A=[[] for i in range(n)]
for i in range(n):
x,l=map(int,input().split())
A[i]=[x-l,x+l]
A=sorted(A, key=lambda x :x[1])
#print(A)
ans=0
last=-float("INF")
for i in range(n):
if last<=A[i][0]:
ans+=1
last=A[i][1]
print(ans)
|
s990873710
|
p02694
|
u549161102
| 2,000 | 1,048,576 |
Wrong Answer
| 23 | 9,184 | 100 |
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
X = int(input())
count = 0
hun = 100
while X >= hun:
count += 1
hun = int(hun*1.01)
print(count)
|
s106084598
|
Accepted
| 24 | 9,164 | 99 |
X = int(input())
count = 0
hun = 100
while X > hun:
count += 1
hun = int(hun*1.01)
print(count)
|
s473843211
|
p03644
|
u682730715
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 61 |
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
|
n = int(input())
if n % 2 == 0:
print(n)
else:
print(n-1)
|
s769615525
|
Accepted
| 17 | 3,060 | 179 |
n = int(input())
if n >= 64:
print(64)
elif n >= 32:
print(32)
elif n >= 16:
print(16)
elif n >= 8:
print(8)
elif n>=4:
print(4)
elif n >= 2:
print(2)
else:
print(1)
|
s912475403
|
p03399
|
u556371693
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 84 |
You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
|
a=int(input())
b=int(input())
c=int(input())
d=int(input())
print(max(a,b)+max(c,d))
|
s327206504
|
Accepted
| 18 | 2,940 | 85 |
a=int(input())
b=int(input())
c=int(input())
d=int(input())
print(min(a,b)+min(c,d))
|
s152911404
|
p02865
|
u135847648
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 64 |
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
|
n = int(input())
if n % 2:
print(n//2-1)
else:
print(n//2)
|
s944604358
|
Accepted
| 17 | 2,940 | 69 |
n = int(input())
if n % 2 == 0:
print(n//2-1)
else:
print(n//2)
|
s506591296
|
p03377
|
u133356863
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 73 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a,b,x=map(int,input().split())
print('Yes' if a+b>=x and a<=x else 'No')
|
s978376111
|
Accepted
| 18 | 2,940 | 72 |
a,b,x=map(int,input().split())
print('YES' if a+b>=x and a<=x else 'NO')
|
s145708466
|
p03251
|
u957957759
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 252 |
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
|
n,m,x,y=map(int,input().split())
s=list(map(int,input().split()))
t=list(map(int,input().split()))
c=0
max_x=max(s)
min_y=min(t)
for i in range(x+1,y+1):
if i>max_x and i<=min_y:
c+=1
if c>0:
print('No war')
else:
print('War')
|
s035809147
|
Accepted
| 17 | 3,060 | 252 |
n,m,x,y=map(int,input().split())
s=list(map(int,input().split()))
t=list(map(int,input().split()))
c=0
max_x=max(s)
min_y=min(t)
for i in range(x+1,y+1):
if i>max_x and i<=min_y:
c+=1
if c>0:
print('No War')
else:
print('War')
|
s383771908
|
p03485
|
u914330401
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 116 |
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
a, b = map(int, input().split())
if a % 2 != 0 and b % 2 != 0:
print(int((a+b)/2) + 1)
else:
print(int((a+b)/2))
|
s885437920
|
Accepted
| 20 | 3,316 | 174 |
a, b = map(int, input().split())
if a % 2 != 0 and b % 2 == 0:
print(int((a+b)/2) + 1)
elif a % 2 == 0 and b % 2 != 0:
print(int((a+b)/2) + 1)
else:
print(int((a+b)/2))
|
s578680049
|
p03712
|
u482969053
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 165 |
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
|
def solve():
H, W = list(map(int, input().split()))
print("#"*(W+2))
for i in range(H):
print("*" + input() + "#")
print("#"*(W+2))
solve()
|
s168736293
|
Accepted
| 18 | 2,940 | 165 |
def solve():
H, W = list(map(int, input().split()))
print("#"*(W+2))
for i in range(H):
print("#" + input() + "#")
print("#"*(W+2))
solve()
|
s371616268
|
p02742
|
u455077015
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 186 |
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
|
def ceildiv(a, b):
return -(-a // b)
h, w = map(int, input().split())
if (h==1 or w==1):
print(1)
else:
print(ceildiv(h,2)*ceildiv(w,2) + (ceildiv(h,2)-1)*(ceildiv(w,2)-1))
|
s634084534
|
Accepted
| 17 | 3,060 | 214 |
def ceildiv(a, b):
return -(-a // b)
h, w = map(int, input().split())
if (h==1 or w==1):
print(1)
else:
r0 = ceildiv(w,2)
r1 = w//2
r0s = ceildiv(h,2)
r1s = h//2
print(r0*r0s + r1*r1s)
|
s983734007
|
p03111
|
u303059352
| 2,000 | 1,048,576 |
Wrong Answer
| 192 | 3,676 | 1,317 |
You have N bamboos. The lengths (in centimeters) of these are l_1, l_2, ..., l_N, respectively. Your objective is to use some of these bamboos (possibly all) to obtain three bamboos of length A, B, C. For that, you can use the following three kinds of magics any number: * Extension Magic: Consumes 1 _MP_ (magic point). Choose one bamboo and increase its length by 1. * Shortening Magic: Consumes 1 MP. Choose one bamboo of length at least 2 and decrease its length by 1. * Composition Magic: Consumes 10 MP. Choose two bamboos and combine them into one bamboo. The length of this new bamboo is equal to the sum of the lengths of the two bamboos combined. (Afterwards, further magics can be used on this bamboo.) At least how much MP is needed to achieve the objective?
|
import os
import math
from itertools import permutations
import functools as func
INF, MOD = float("inf"), 1e9 + 7
MAX, MIN = -INF, INF
dx1, dy1, dx2, dy2 = [-1, 0, 1, 0], [0, -1, 0, 1], [-1, 0, 1, -1, 1, -1, 0, 1], [-1, -1, -1, 0, 0, 1, 1, 1]
def get_int():
return int(input())
def get_int_list():
return list(map(int, input().split()))
while(True):
try:
n, a, b, c = get_int_list()
l = [get_int() for _ in range(n)]
ans = 1000000000000
for take in permutations(l, n):
take = list(take)
cnt = 0
i = 3
while abs(take[0] - a) > 10:
if i >= n:
break
take[0] += take[i]
i += 1
cnt += 10
cnt += abs(take[0] - a)
while abs(take[1] - b) > 10:
if i >= n:
break
take[1] += take[i]
i += 1
cnt += 10
cnt += abs(take[1] - b)
while abs(take[2] - c) > 10:
if i >= n:
break
take[2] += take[i]
i += 1
cnt += 10
cnt += abs(take[2] - c)
ans = min(ans, cnt)
print(ans)
except EOFError:
exit()
|
s219369147
|
Accepted
| 300 | 3,188 | 2,082 |
from itertools import permutations
def get_int():
return int(input())
def get_int_list():
return list(map(int, input().split()))
while(True):
try:
n, a, b, c = get_int_list()
l = [get_int() for _ in range(n)]
ans = 1000000000000
for take in permutations(l, n):
#print(take)
take = list(take)
cnt = 0
i = 3
while True:
if i >= n:
break
if abs(take[2] - a) < 10:
break
if take[2] > a:
break
if abs(take[2] + take[i] - a) >= abs(take[2] - a):
break
if take[i] <= 10:
break
take[2] += take[i]
i += 1
cnt += 10
cnt += abs(take[2] - a)
#print(take[2])
while True:
if i >= n:
break
if abs(take[1] - b) < 10:
break
if take[1] > b:
break
if abs(take[1] + take[i] - b) >= abs(take[1] - b):
break
if take[i] <= 10:
break
take[1] += take[i]
i += 1
cnt += 10
cnt += abs(take[1] - b)
#print(take[1])
while True:
if i >= n:
break
if abs(take[0] - c) < 10:
break
if take[0] > c:
break
if abs(take[0] + take[i] - c) >= abs(take[0] - c):
break
if take[i] <= 10:
break
take[0] += take[i]
i += 1
cnt += 10
cnt += abs(take[0] - c)
#print(take[0])
ans = min(ans, cnt)
# print(take[0], take[1], take[2])
print(ans)
except EOFError:
exit()
|
s345510483
|
p03543
|
u516242950
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 176 |
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**?
|
judge = 0
kazu = list(input())
for k in range(1, len(kazu)):
if kazu[k - 1] == kazu[k]:
judge += 1
else:
judge = 0
if judge >= 3:
print('Yes')
else:
print('No')
|
s214730606
|
Accepted
| 17 | 3,060 | 140 |
kazu = list(input())
if kazu[0] == kazu[1] == kazu[2]:
print('Yes')
elif kazu[1] == kazu[2] == kazu[3]:
print('Yes')
else:
print('No')
|
s814732668
|
p03472
|
u819688111
| 2,000 | 262,144 |
Wrong Answer
| 462 | 12,392 | 717 |
You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, …, Katana N, and can perform the following two kinds of attacks in any order: * Wield one of the katana you have. When you wield Katana i (1 ≤ i ≤ N), the monster receives a_i points of damage. The same katana can be wielded any number of times. * Throw one of the katana you have. When you throw Katana i (1 ≤ i ≤ N) at the monster, it receives b_i points of damage, and you lose the katana. That is, you can no longer wield or throw that katana. The monster will vanish when the total damage it has received is H points or more. At least how many attacks do you need in order to vanish it in total?
|
import re
import math
def comb(n, r):
if n == 0 or r == 0:
return 1
return int(comb(n, r-1) * (n-r+1) / r)
if __name__ == '__main__':
N, H = [int(x) for x in input().split()]
A = []
B = []
for i in range(N):
ta, tb = [int(x) for x in input().split()]
A.append(ta)
B.append(tb)
B = sorted(B)
B.reverse()
maxA = max(A)
cntAtk = 0
dmg = 0
for b in B:
if b <= maxA:
break
cntAtk += 1
dmg += b
print('atk B', b)
if dmg >= H:
print(cntAtk)
exit()
print('throwed', dmg, H)
print('maxA', maxA)
cntAtk += math.ceil((H-dmg) / maxA)
print(cntAtk)
|
s693333289
|
Accepted
| 371 | 12,276 | 638 |
import re
import math
def comb(n, r):
if n == 0 or r == 0:
return 1
return int(comb(n, r-1) * (n-r+1) / r)
if __name__ == '__main__':
N, H = [int(x) for x in input().split()]
A = []
B = []
for i in range(N):
ta, tb = [int(x) for x in input().split()]
A.append(ta)
B.append(tb)
B = sorted(B)
B.reverse()
maxA = max(A)
cntAtk = 0
dmg = 0
for b in B:
if b <= maxA:
break
cntAtk += 1
dmg += b
if dmg >= H:
print(cntAtk)
exit()
cntAtk += math.ceil((H-dmg) / maxA)
print(cntAtk)
|
s018886149
|
p02742
|
u586368075
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 144 |
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
|
H, W = map(int, input().split())
if H == 1 or W == 1:
print(1)
else:
count = W // 2 * H
if H & 1:
count += (H + 1) // 2
print(count)
|
s598127794
|
Accepted
| 18 | 2,940 | 145 |
H, W = map(int, input().split())
if H == 1 or W == 1:
print(1)
else:
count = W // 2 * H
if W & 1:
count += (H + 1) // 2
print(count)
|
s878061277
|
p03997
|
u519849839
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 61 |
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
x,y,h=int(input()),int(input()),int(input())
print((x+y)*h/2)
|
s051145897
|
Accepted
| 17 | 2,940 | 66 |
x,y,h=int(input()),int(input()),int(input())
print(int((x+y)*h/2))
|
s057294004
|
p02613
|
u901144784
| 2,000 | 1,048,576 |
Wrong Answer
| 150 | 9,204 | 232 |
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())
c1,c2,c3,c4=0,0,0,0
for i in range(n):
s=input()
if(s=='AC'):
c1+=1
elif(s=='WA'):
c2+=1
elif(s=='TLE'):
c3+=1
else:
c4+=1
print('AC X',c1)
print('WA X',c2)
print('TLE X',c3)
print('RE X',c4)
|
s331727678
|
Accepted
| 147 | 9,216 | 268 |
n=int(input())
c1,c2,c3,c4=0,0,0,0
for i in range(n):
s=input()
if(s=='AC'):
c1+=1
elif(s=='WA'):
c2+=1
elif(s=='TLE'):
c3+=1
else:
c4+=1
print('AC x'+' '+str(c1))
print('WA x'+' '+str(c2))
print('TLE x'+' '+str(c3))
print('RE x'+' '+str(c4))
|
s314730622
|
p03567
|
u504715104
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 76 |
Snuke built an online judge to hold a programming contest. When a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring. (The judge can return any two-character substring of S.) Determine whether the judge can return the string `AC` as the verdict to a program.
|
x=input()
y='AC'
if x in y==True:
print('Yes')
else:
print('No')
|
s728850713
|
Accepted
| 19 | 2,940 | 80 |
x=input()
y='AC'
if (y in x) ==True:
print('Yes')
else:
print('No')
|
s628228633
|
p02613
|
u263261672
| 2,000 | 1,048,576 |
Wrong Answer
| 151 | 9,204 | 499 |
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())
inputList = []
countAC=0
countWA=0
countTLE=0
countRE=0
for i in range(0,N):
val = input()
# inputList.append(val)
if val=="AC":
countAC=countAC+1
elif val=="WA":
countWA=countWA+1
elif val=="TLE":
countTLE=countTLE+1
elif val=="RE":
countRE=countRE+1
print("AC × "+str(countAC))
print("WA × "+str(countWA))
print("TLE × "+str(countTLE))
print("RE × "+str(countRE))
|
s567451691
|
Accepted
| 153 | 9,208 | 486 |
N = int(input())
countAC=0
countWA=0
countTLE=0
countRE=0
for i in range(0,N):
val = input()
if val=="AC":
countAC=countAC+1
elif val=="WA":
countWA=countWA+1
elif val=="TLE":
countTLE=countTLE+1
elif val=="RE":
countRE=countRE+1
else:
break
print("AC x "+str(countAC))
print("WA x "+str(countWA))
print("TLE x "+str(countTLE))
print("RE x "+str(countRE))
|
s995847003
|
p03385
|
u512138205
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 98 |
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().split()
if 'a' in s and 'b' in s and 'c' in s:
print('Yes')
else:
print('No')
|
s506187352
|
Accepted
| 17 | 2,940 | 96 |
s = list(input())
if 'a' in s and 'b' in s and 'c' in s:
print('Yes')
else:
print('No')
|
s744740420
|
p02843
|
u613637815
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 97 |
AtCoder Mart sells 1000000 of each of the six items below: * Riceballs, priced at 100 yen (the currency of Japan) each * Sandwiches, priced at 101 yen each * Cookies, priced at 102 yen each * Cakes, priced at 103 yen each * Candies, priced at 104 yen each * Computers, priced at 105 yen each Takahashi wants to buy some of them that cost exactly X yen in total. Determine whether this is possible. (Ignore consumption tax.)
|
x = int(input())
c = x // 100
if 100*c <= x and x <= 105*c:
print(105*c)
exit(0)
print(0)
|
s920433857
|
Accepted
| 17 | 2,940 | 93 |
x = int(input())
c = x // 100
if 100*c <= x and x <= 105*c:
print(1)
exit(0)
print(0)
|
s076114855
|
p03606
|
u503052349
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,188 | 186 |
Joisino is working as a receptionist at a theater. The theater has 100000 seats, numbered from 1 to 100000. According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive). How many people are sitting at the theater now?
|
N= int(input())
n=[[]]
ans=0
ans1=0
ans2=0
for i in range(N):
n.append(input().split())
for j in range(1,N+1):
#print(n[j][0])
ans+=int(n[j][1])-int(n[j][0])
print(ans)
|
s293269674
|
Accepted
| 19 | 3,188 | 180 |
N= int(input())
n=[[]]
ans=0
for i in range(N):
n.append(input().split())
for j in range(1,N+1):
#print(n[j][0])
ans+=int(n[j][1])-int(n[j][0])
ans+=1
print(ans)
|
s046830538
|
p02678
|
u091307273
| 2,000 | 1,048,576 |
Wrong Answer
| 700 | 56,816 | 797 |
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
|
def main():
n, m = (int(i) for i in input().split())
graph = { i: [] for i in range(1, n+1) }
for i in range(m):
src, dst = (int(i) for i in input().split())
graph[src].append(dst)
graph[dst].append(src)
def bfs():
st = [1]
visited = set([1])
pptr = { }
while st:
room = st.pop()
for dest_room in graph[room]:
if dest_room in visited:
continue
st.append(dest_room)
visited.add(dest_room)
pptr[dest_room] = room
return pptr
pptr = bfs()
print(pptr)
if len(pptr) != n-1:
print('No')
else:
print('Yes')
for i in range(2, n + 1):
print(pptr[i])
main()
|
s305500201
|
Accepted
| 1,415 | 50,324 | 767 |
def main():
n, m = (int(i) for i in input().split())
graph = { i: [] for i in range(1, n+1) }
for i in range(m):
src, dst = (int(i) for i in input().split())
graph[src].append(dst)
graph[dst].append(src)
def bfs():
st = [1]
pptr = { 1: 0 }
while st:
room = st.pop(0)
for dest_room in graph[room]:
if dest_room in pptr:
continue
st.append(dest_room)
pptr[dest_room] = room
return pptr
pptr = bfs()
if len(pptr) != n:
print('No')
else:
print('Yes')
for i in sorted(pptr.keys()):
if i == 1:
continue
print(pptr[i])
main()
|
s694435217
|
p03089
|
u170183831
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,064 | 364 |
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()))
ret = [-1] * n
ng = False
for i in range(n):
p = n - i - 1
found = False
for j in range(B[p] - 1, min(n, n - (p - B[p] + 2) + 1)):
if ret[j] < 0:
ret[j] = B[p]
found = True
break
if not found:
ng = True
break
if ng:
print(-1)
else:
for i in range(n):
print(ret[i])
|
s535426470
|
Accepted
| 18 | 3,064 | 372 |
n = int(input())
B = list(map(int, input().split()))
ret = []
enabled = True
def get_latest():
for i in range(len(B)):
if len(B) - i == B[len(B) - i - 1]:
break
else:
global enabled
enabled = False
ret.append(B.pop(len(B) - i - 1))
if B:
get_latest()
get_latest()
if enabled:
for i in range(n):
print(ret[n - i - 1])
else:
print(-1)
|
s268466759
|
p03777
|
u427690532
| 2,000 | 262,144 |
Wrong Answer
| 24 | 9,172 | 183 |
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or Dishonest_. In this game, an honest player always tells the truth, and an dishonest player always tell lies. You are given two characters a and b as the input. Each of them is either `H` or `D`, and carries the following information: If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`, AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that TopCoDeer is dishonest. Given this information, determine whether TopCoDeer is honest.
|
S =input('入力:').replace("H","0")
S = S.replace('D','1')
S_list = list(map(int,S.split()))
if S_list[0] ^ S_list[1] == 0 :
result = "H"
else:
result = "D"
print(result)
|
s016416983
|
Accepted
| 24 | 8,948 | 172 |
S =input().replace("H","0")
S = S.replace('D','1')
S_list = list(map(int,S.split()))
if S_list[0] ^ S_list[1] == 0 :
result = "H"
else:
result = "D"
print(result)
|
s412967031
|
p03456
|
u417014669
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 134 |
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 =input().split()
ab=int(a+b)
for i in range(int(ab**0.5)+10):
if i**2==ab:
print("Yes")
else:
print("No")
|
s992750059
|
Accepted
| 17 | 3,064 | 225 |
a,b=map(int,input().split())
a = str(a)
b = str(b)
ab=int(a+b)
flag=0
for i in range(int(ab**0.5)+3):
if i**2==ab:
print('Yes')
flag+=1
if flag==0 and (i==int(ab**0.5)+2):
print('No')
|
s523902794
|
p03372
|
u906501980
| 2,000 | 262,144 |
Wrong Answer
| 557 | 37,864 | 444 |
"Teishi-zushi", a Japanese restaurant, is a plain restaurant with only one round counter. The outer circumference of the counter is C meters. Customers cannot go inside the counter. Nakahashi entered Teishi-zushi, and he was guided to the counter. Now, there are N pieces of sushi (vinegared rice with seafood and so on) on the counter. The distance measured clockwise from the point where Nakahashi is standing to the point where the i-th sushi is placed, is x_i meters. Also, the i-th sushi has a nutritive value of v_i kilocalories. Nakahashi can freely walk around the circumference of the counter. When he reach a point where a sushi is placed, he can eat that sushi and take in its nutrition (naturally, the sushi disappears). However, while walking, he consumes 1 kilocalories per meter. Whenever he is satisfied, he can leave the restaurant from any place (he does not have to return to the initial place). On balance, at most how much nutrition can he take in before he leaves? That is, what is the maximum possible value of the total nutrition taken in minus the total energy consumed? Assume that there are no other customers, and no new sushi will be added to the counter. Also, since Nakahashi has plenty of nutrition in his body, assume that no matter how much he walks and consumes energy, he never dies from hunger.
|
N, C = map(int, input().split())
xy = [[int(i) for i in input().split()] for _ in range(N)]
out = 0
def m(xx):
sum = 0
c = [0]
rc = [0]
for x, cal in xx:
sum += cal
c.append(max(c[-1], sum - x))
rc.append(max(rc[-1], sum - 2 * x))
return c, rc
r, rr = m(xy)
l, lr = m(xy[::-1])
for w, wr in zip(r, lr[::-1]):
out = max(out, w+wr)
for w, wr in zip(l, rr[::-1]):
out = max(out, w+wr)
print(out)
|
s737926703
|
Accepted
| 459 | 44,772 | 854 |
def main():
n, c = map(int, input().split())
xv = [list(map(int, input().split())) for _ in range(n)]
v, left_max, right_max = 0, 0, 0
gl = [None]*n
gr = [None]*n
_2oas = [None]*(n+1)
_2obs = [None]*(n+1)
_2oas[0], _2obs[0] = 0, 0
ans = 0
for i, (xi, vi) in enumerate(xv, 1):
v += vi
left = v - xi
if left_max < left:
left_max = left
gl[n-i] = left_max
_2oas[i] = v - 2*xi
v = 0
for i, (xi, vi) in enumerate(xv[::-1], 1):
v += vi
right = v - c + xi
if right_max < right:
right_max = right
gr[n-i] = right_max
_2obs[i] = v - 2*(c - xi)
for oa, _2ob, ob, _2oa in zip(gl, _2obs[:n], gr, _2oas[:n]):
ans = max(ans, _2oa+ob, _2ob+oa)
print(ans)
if __name__ == "__main__":
main()
|
s436644347
|
p03607
|
u478266845
| 2,000 | 262,144 |
Wrong Answer
| 222 | 15,076 | 217 |
You are playing the following game with Joisino. * Initially, you have a blank sheet of paper. * Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times. * Then, you are asked a question: How many numbers are written on the sheet now? The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?
|
n = int(input())
dic = {}
for i in range(n):
a = int(input())
if dic.get(a) is None:
dic[a] = 1
else:
dic[a] += 1 %2
val = list(dic.values())
ans = int(sum(val))
print(ans)
|
s605142621
|
Accepted
| 240 | 15,068 | 226 |
n = int(input())
dic = {}
for i in range(n):
a = int(input())
if dic.get(a) is None:
dic[a] = 1
else:
dic[a] = (dic[a] + 1)%2
val = list(dic.values())
ans = int(sum(val))
print(ans)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.