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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s412583221
|
p03494
|
u546074985
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 330 |
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.
|
if __name__ == '__main__':
N = int(input())
A = list(map(int, input().split(' ')))
print(N,A)
count = 0
while True:
A_b = [x%2 == 0 for x in A]
if not False in A_b:
A = list(map(lambda x: x//2, A))
count += 1
else:
print(count)
break
|
s578462161
|
Accepted
| 18 | 3,060 | 315 |
if __name__ == '__main__':
N = int(input())
A = list(map(int, input().split(' ')))
count = 0
while True:
A_b = [x%2 == 0 for x in A]
if not False in A_b:
A = list(map(lambda x: x//2, A))
count += 1
else:
print(count)
break
|
s319162717
|
p03963
|
u403331159
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 50 |
There are N balls placed in a row. AtCoDeer the deer is painting each of these in one of the K colors of his paint cans. For aesthetic reasons, any two adjacent balls must be painted in different colors. Find the number of the possible ways to paint the balls.
|
N,K=map(int,input().split())
print(K*((K-1)**N-1))
|
s590397031
|
Accepted
| 17 | 2,940 | 53 |
N,K=map(int,input().split())
print(K*((K-1)**(N-1)))
|
s953192850
|
p03469
|
u354847446
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 77 |
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.
|
s = str(input())
strlist = list(s)
strlist[3] = '8'
s = str(strlist)
print(s)
|
s778061932
|
Accepted
| 17 | 2,940 | 81 |
s = str(input())
strlist = list(s)
strlist[3] = '8'
s = ''.join(strlist)
print(s)
|
s804845767
|
p02844
|
u231122239
| 2,000 | 1,048,576 |
Wrong Answer
| 26 | 3,444 | 387 |
AtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code. The company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code. How many different PIN codes can he set this way? Both the lucky number and the PIN code may begin with a 0.
|
from itertools import groupby
N = int(input())
S = input()
S = ''.join([x[0] for x in groupby(S)])
ans = 0
for i in range(0, 1000):
num = str(i).zfill(3)
flag = True
_idx = 0
for s in num:
idx = S[_idx:].find(s)
if idx == -1:
flag = False
break
else:
_idx += idx + 1
if flag:
ans += 1
print(ans)
|
s531004678
|
Accepted
| 23 | 3,188 | 315 |
N = int(input())
S = input()
ans = 0
for i in range(0, 1000):
num = str(i).zfill(3)
flag = True
_idx = 0
for s in num:
idx = S[_idx:].find(s)
if idx == -1:
flag = False
break
else:
_idx += idx + 1
if flag:
ans += 1
print(ans)
|
s138851564
|
p03434
|
u362771726
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 206 |
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
|
n = input()
a = list(map(int, input().split()))
a.sort(reverse=True)
alice = 0
bob = 0
for i in range(len(a)):
if (i // 2) == 0:
alice += a[i]
else:
bob += a[i]
print(alice - bob)
|
s952239129
|
Accepted
| 17 | 3,060 | 206 |
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
alice = 0
bob = 0
for i in range(n):
if (i % 2) == 0:
alice += a[i]
else:
bob += a[i]
print(alice - bob)
|
s882606806
|
p03494
|
u137722467
| 2,000 | 262,144 |
Wrong Answer
| 20 | 2,940 | 182 |
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.
|
num = int(input())
a = list(map(int, input().split()))
count = 0
for i in a:
c = 0
while i != 0 and i % 2 == 0:
i /= 2
c += 1
if c >= count:
count = c
print(count)
|
s652271191
|
Accepted
| 20 | 2,940 | 178 |
num = int(input())
a = list(map(int, input().split()))
carray = []
for i in a:
c = 0
while i != 0 and i % 2 == 0:
i /= 2
c += 1
carray.append(c)
print(min(carray))
|
s968330674
|
p02697
|
u835534360
| 2,000 | 1,048,576 |
Wrong Answer
| 83 | 9,224 | 172 |
You are going to hold a competition of one-to-one game called AtCoder Janken. _(Janken is the Japanese name for Rock-paper-scissors.)_ N players will participate in this competition, and they are given distinct integers from 1 through N. The arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive). You cannot assign the same integer to multiple playing fields. The competition consists of N rounds, each of which proceeds as follows: * For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there. * Then, each player adds 1 to its integer. If it becomes N+1, change it to 1. You want to ensure that no player fights the same opponent more than once during the N rounds. Print an assignment of integers to the playing fields satisfying this condition. It can be proved that such an assignment always exists under the constraints given.
|
import sys
def main():
N,M=tuple(map(int,sys.stdin.readline().split()))
for i in range(M):
print(str(i+1)+' '+str(N-2+1+1-i))
if __name__=='__main__':main()
|
s571829452
|
Accepted
| 80 | 9,180 | 540 |
import sys
def main():
N,M=tuple(map(int,sys.stdin.readline().split()))
if M%2==1:
m1,m2=M//2,M//2+1
for i in range(m1):
l,r=i+1,M-i
print(str(l)+' '+str(r))
for i in range(m2):
l,r=M+1+i,2*M+1-i
print(str(l)+' '+str(r))
else:
m=M//2
for i in range(m):
l,r=i+1,M+1-i
print(str(l)+' '+str(r))
for i in range(m):
l,r=M+2+i,2*M+1-i
print(str(l)+' '+str(r))
if __name__=='__main__':main()
|
s503144828
|
p03478
|
u262481526
| 2,000 | 262,144 |
Wrong Answer
| 23 | 3,316 | 164 |
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())
arr = [i for i in range(1, N)]
k = 0
for j in arr:
if j / 10 + j % 10 >= A and j / 10 + j % 10 <= B:
k += j
print (k)
|
s441044792
|
Accepted
| 28 | 3,060 | 214 |
N, A, B = map(int, input().split())
ans = 0
for x in range(1, N + 1):
SUM = 0
num = x
while x > 0:
SUM += (x % 10)
x //= 10
if A <= SUM <= B:
ans += num
print(ans)
|
s004492743
|
p03740
|
u884982181
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 88 |
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.
|
x,y = map(int,input().split())
if abs(x-y) <= 1:
print("Alice")
else:
print("Brown")
|
s112973844
|
Accepted
| 17 | 2,940 | 91 |
x,y = map(int,input().split())
if abs(x-y) <= 1:
print("Brown")
else:
print("Alice")
|
s382417597
|
p03456
|
u210827208
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 140 |
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
|
a,b=map(int,input().split())
x=int(str(a)+str(b))
for i in range(1,101):
if i*i==x:
print('Yes')
else:
print('No')
|
s945877768
|
Accepted
| 18 | 2,940 | 127 |
a,b=map(int,input().split())
x=int(str(a)+str(b))
ans='No'
for i in range(1,400):
if i*i==x:
ans='Yes'
print(ans)
|
s599969117
|
p00952
|
u078042885
| 4,000 | 262,144 |
Wrong Answer
| 1,540 | 15,028 | 274 |
You have drawn a chart of a perfect binary tree, like one shown in Figure G.1. The figure shows a finite tree, but, if needed, you can add more nodes beneath the leaves, making the tree arbitrarily deeper. Figure G.1. A Perfect Binary Tree Chart Tree nodes are associated with their depths, defined recursively. The root has the depth of zero, and the child nodes of a node of depth d have their depths $d + 1$. You also have a pile of a certain number of medals, each engraved with some number. You want to know whether the medals can be placed on the tree chart satisfying the following conditions. * A medal engraved with $d$ should be on a node of depth $d$. * One tree node can accommodate at most one medal. * The path to the root from a node with a medal should not pass through another node with a medal. You have to place medals satisfying the above conditions, one by one, starting from the top of the pile down to its bottom. If there exists no placement of a medal satisfying the conditions, you have to throw it away and simply proceed to the next medal. You may have choices to place medals on different nodes. You want to find the best placement. When there are two or more placements satisfying the rule, one that places a medal upper in the pile is better. For example, when there are two placements of four medal, one that places only the top and the 2nd medal, and the other that places the top, the 3rd, and the 4th medal, the former is better. In Sample Input 1, you have a pile of six medals engraved with 2, 3, 1, 1, 4, and 2 again respectively, from top to bottom. * The first medal engraved with 2 can be placed, as shown in Figure G.2 (A). * Then the second medal engraved with 3 may be placed , as shown in Figure G.2 (B). * The third medal engraved with 1 cannot be placed if the second medal were placed as stated above, because both of the two nodes of depth 1 are along the path to the root from nodes already with a medal. Replacing the second medal satisfying the placement conditions, however, enables a placement shown in Figure G.2 (C). * The fourth medal, again engraved with 1, cannot be placed with any replacements of the three medals already placed satisfying the conditions. This medal is thus thrown away. * The fifth medal engraved with 4 can be placed as shown in of Figure G.2 (D). * The last medal engraved with 2 cannot be placed on any of the nodes with whatever replacements. Figure G.2. Medal Placements
|
c=p=0;b=[0]*1000000
for _ in range(int(input())):
x=int(input())
if (c==x and p!=x) or b[0]==1 or c>x:print('NO');continue
print('YES')
if x>=1000000:continue
p+=1;b[x]+=1
while b[x]>1:p-=1;b[x]-=2;b[x-1]+=1;x-=1
while b[c+1]==1 and c<999999:c+=1
|
s854805065
|
Accepted
| 3,710 | 15,120 | 274 |
c=p=0;b=[0]*1000000
for _ in range(int(input())):
x=int(input())
if (c==x and p!=x) or b[0]==1 or c>x:print('No');continue
print('Yes')
if x>=1000000:continue
p+=1;b[x]+=1
while b[x]>1:p-=1;b[x]-=2;b[x-1]+=1;x-=1
while b[c+1]==1 and c<999999:c+=1
|
s179827397
|
p03636
|
u728774856
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 163 |
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.
|
word = list(input())
rep_word = []
num_abb = len(word) - 2
rep_word.append(word[0])
rep_word.append(str(num_abb))
rep_word.append(word[-1])
print(''.join(word))
|
s617793896
|
Accepted
| 18 | 3,060 | 167 |
word = list(input())
rep_word = []
num_abb = len(word) - 2
rep_word.append(word[0])
rep_word.append(str(num_abb))
rep_word.append(word[-1])
print(''.join(rep_word))
|
s871684284
|
p02613
|
u938635664
| 2,000 | 1,048,576 |
Wrong Answer
| 152 | 9,204 | 312 |
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
S = input()
if S == 'AC':
ac += 1
elif S == 'WA':
wa += 1
elif S == 'TLE':
tle += 1
elif S == 'RE':
re += 1
print('AC * {}'.format(ac))
print('WA * {}'.format(wa))
print('TLE * {}'.format(tle))
print('RE * {}'.format(re))
|
s049939958
|
Accepted
| 153 | 9,208 | 312 |
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
S = input()
if S == 'AC':
ac += 1
elif S == 'WA':
wa += 1
elif S == 'TLE':
tle += 1
elif S == 'RE':
re += 1
print('AC x {}'.format(ac))
print('WA x {}'.format(wa))
print('TLE x {}'.format(tle))
print('RE x {}'.format(re))
|
s507841590
|
p03493
|
u077852398
| 2,000 | 262,144 |
Wrong Answer
| 21 | 8,952 | 72 |
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
|
s = input()
a = int(s.count('o'))
print(int(700+a*100))
|
s896540233
|
Accepted
| 26 | 9,060 | 113 |
number = list(map(int,input()))
a = 0
for i in number:
if i == 1:
a = a+1
print(a)
|
s994728202
|
p04043
|
u242358695
| 2,000 | 262,144 |
Wrong Answer
| 23 | 9,004 | 137 |
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.
|
queue=list(map(int,input().split()))
queue.sort()
if queue[0]==5 and queue[1]==5 and queue[2]==7:
print("Yes")
else:
print("No")
|
s800224370
|
Accepted
| 28 | 9,012 | 137 |
queue=list(map(int,input().split()))
queue.sort()
if queue[0]==5 and queue[1]==5 and queue[2]==7:
print("YES")
else:
print("NO")
|
s305350034
|
p02390
|
u695952004
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,504 | 96 |
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.
|
a = int(input())
h = a % (60 * 60)
m = (a % 60 * 60) % 60
s = a % 60
print(h, m, s, sep = ":")
|
s681493607
|
Accepted
| 20 | 7,668 | 113 |
s = int(input())
h = int(s / (60 * 60))
m = int((s % (60 * 60)) / 60)
s = int(s % 60)
print(h, m, s, sep = ":")
|
s387322937
|
p03997
|
u501451051
| 2,000 | 262,144 |
Wrong Answer
| 28 | 9,144 | 70 |
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 = int(input())
b = int(input())
h = int(input())
print(((a+b)*h)/2)
|
s239124608
|
Accepted
| 26 | 9,160 | 75 |
a = int(input())
b = int(input())
h = int(input())
print(int(((a+b)*h)/2))
|
s619849544
|
p03556
|
u919521780
| 2,000 | 262,144 |
Wrong Answer
| 23 | 2,940 | 90 |
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.
|
n = int(input())
ans = 0
while True:
if ans * ans >= n:
break
ans += 1
print(ans)
|
s949508386
|
Accepted
| 26 | 3,060 | 101 |
n = int(input())
ans = 0
while True:
if ans * ans > n:
break
ans += 1
print((ans-1)*(ans-1))
|
s547094499
|
p03730
|
u533885955
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 268 |
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())
def gcd(GCD1,GCD2):
x = min(GCD1,GCD2)
y = max(GCD1,GCD2)
if y%x == 0:
return x
else:
return gcd(x,y%x)
d=gcd(A,B)
if gcd(d,C) == 1:
print("No")
else:
print("Yes")
|
s101332744
|
Accepted
| 17 | 2,940 | 193 |
#B
A,B,C = map(int,input().split())
a = 0
flag = 0
for i in range(B+1):
a+=A
if a%B == C:
flag = 1
break
if flag == 0:
print("NO")
else:
print("YES")
|
s944592568
|
p03696
|
u402629484
| 2,000 | 262,144 |
Wrong Answer
| 20 | 4,340 | 300 |
You are given a string S of length N consisting of `(` and `)`. Your task is to insert some number of `(` and `)` into S to obtain a _correct bracket sequence_. Here, a correct bracket sequence is defined as follows: * `()` is a correct bracket sequence. * If X is a correct bracket sequence, the concatenation of `(`, X and `)` in this order is also a correct bracket sequence. * If X and Y are correct bracket sequences, the concatenation of X and Y in this order is also a correct bracket sequence. * Every correct bracket sequence can be derived from the rules above. Find the shortest correct bracket sequence that can be obtained. If there is more than one such sequence, find the lexicographically smallest one.
|
N = int(input())
S = input()
ans = []
st = 0
for c in S:
if c == '(':
st += 1
ans.append('(')
else:
if st > 0:
st -= 1
else:
ans.insert(0, '(')
ans.append(')')
print(*ans, sep='')
ans.extend(')' * st)
print(*ans, sep='')
|
s779004808
|
Accepted
| 18 | 3,060 | 278 |
N = int(input())
S = input()
ans = []
st = 0
for c in S:
if c == '(':
st += 1
ans.append('(')
else:
if st > 0:
st -= 1
else:
ans.insert(0, '(')
ans.append(')')
ans.extend(')' * st)
print(*ans, sep='')
|
s249602929
|
p02612
|
u188491371
| 2,000 | 1,048,576 |
Wrong Answer
| 33 | 9,148 | 32 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
N = int(input())
print(N % 1000)
|
s387093832
|
Accepted
| 30 | 9,156 | 76 |
N = int(input())
if N % 1000 == 0:
print(0)
else:
print(1000 - N % 1000)
|
s461605743
|
p03625
|
u172035535
| 2,000 | 262,144 |
Wrong Answer
| 60 | 18,600 | 280 |
We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.
|
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
ac = Counter(a)
cur_a = 0
cur_c = 0
res = 0
for a,c in ac.items():
if c < 2:
break
if cur_c == c:
res = max(res,cur_a*a)
cur_a = max(cur_a,a)
else:
cur_a = a
cur_c = c
print(res)
|
s581425951
|
Accepted
| 81 | 18,600 | 312 |
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
ac = Counter(a)
cur_a = 0
res = 0
# print(ac)
for a,c in ac.items():
# print(a,c)
if c < 2:
continue
else:
res = max(res,cur_a*a)
cur_a = max(cur_a,a)
if c >= 4:
res = max(res,a*a)
# print(cur_a,res)
print(res)
|
s975421029
|
p03457
|
u549383771
| 2,000 | 262,144 |
Wrong Answer
| 903 | 3,316 | 391 |
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
|
num = int( input())
check = 0
step_b = 0
x_b = 0
y_b = 0
for i in range(num):
step ,x ,y = map(int,input().split())
if ((x-x_b)+(y-y_b) - (step-step_b) > 0) or (((x-x_b)+(y-y_b) - (step - step_b))%2 == 1 ) :
check = 1
break
print(((x-x_b)+(y-y_b) - (step - step_b)))
x_b = x
y_b = y
step_b = step
if check == 0:
print('Yes')
else:
print('No')
|
s938088967
|
Accepted
| 354 | 3,064 | 358 |
#C - Traveling
num = int( input())
check = 0
step_b = 0
x_b = 0
y_b = 0
for i in range(num):
step ,x ,y = map(int,input().split())
if ((x-x_b)+(y-y_b) - (step-step_b) > 0) or (((x-x_b)+(y-y_b) - (step - step_b))%2 == 1) :
check = 1
break
x_b = x
y_b = y
step_b = step
if check == 0:
print('Yes')
else:
print('No')
|
s156156575
|
p03997
|
u056599756
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 56 |
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)
|
s182227569
|
Accepted
| 17 | 2,940 | 61 |
a,b,h=[int(input()) for i in range(3)]
print(int((a+b)*h/2))
|
s384931577
|
p03965
|
u941434715
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,188 | 91 |
AtCoDeer the deer and his friend TopCoDeer is playing a game. The game consists of N turns. In each turn, each player plays one of the two _gestures_ , _Rock_ and _Paper_ , as in Rock-paper-scissors, under the following condition: (※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock). Each player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors. _(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)_ With his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts. Plan AtCoDeer's gesture in each turn to maximize AtCoDeer's score. The gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is `g`, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in `p`, TopCoDeer will play Paper in the i-th turn.
|
#coding: utf-8
import math
s = input()
ans = math.ceil(len(s)/2) - s.count("p")
print(ans)
|
s229988180
|
Accepted
| 18 | 3,316 | 92 |
#coding: utf-8
import math
s = input()
ans = math.floor(len(s)/2) - s.count("p")
print(ans)
|
s982144664
|
p03007
|
u672475305
| 2,000 | 1,048,576 |
Wrong Answer
| 215 | 14,016 | 211 |
There are N integers, A_1, A_2, ..., A_N, written on a blackboard. We will repeat the following operation N-1 times so that we have only one integer on the blackboard. * Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y. Find the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.
|
n = int(input())
A = list(map(int,input().split()))
A.sort()
x = A[0]
for i in range(1, n-1):
y = A[i]
if x <= 0:
print(x, y)
else:
print(y, x)
x = x - y
else:
print(A[-1], x)
|
s146269219
|
Accepted
| 241 | 14,260 | 891 |
n = int(input())
A = list(map(int,input().split()))
A.sort()
ans = []
if min(A)>=0:
print(sum(A)-2*A[0])
for i in range(n):
if i==0:
x = A[i]
elif i==n-1:
print(A[i], x)
else:
print(x, A[i])
x -= A[i]
elif max(A)<=0:
A = A[::-1]
print(sum(A)*(-1)+2*A[0])
for i in range(n):
if i==0:
x = A[i]
else:
print(x, A[i])
x -= A[i]
else:
m,p = [], []
for a in A:
if a<0:
m.append(a)
else:
p.append(a)
print(sum(p)-sum(m))
m.sort()
p.sort()
x = m[0]
for i in range(len(p)-1):
print(x, p[i])
x -= p[i]
else:
print(p[-1], x)
x = p[-1] - x
for j in range(1, len(m)):
print(x, m[j])
x -= m[j]
|
s907136128
|
p03711
|
u617659131
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 150 |
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.
|
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
x,y = map(int, input().split())
if (x in a and b in a) or (x in b and y in b):
print("Yes")
else:
print("No")
|
s259949907
|
Accepted
| 17 | 3,060 | 150 |
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
x,y = map(int, input().split())
if (x in a and y in a) or (x in b and y in b):
print("Yes")
else:
print("No")
|
s976297258
|
p03813
|
u079022116
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 35 |
Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise. You are given Smeke's current rating, x. Print `ABC` if Smeke will participate in ABC, and print `ARC` otherwise.
|
if int(input()) >=1200:print('ARC')
|
s699956891
|
Accepted
| 17 | 2,940 | 53 |
if int(input()) >=1200:print('ARC')
else:print('ABC')
|
s882648470
|
p02612
|
u434587934
| 2,000 | 1,048,576 |
Wrong Answer
| 2,206 | 9,076 | 121 |
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.
|
num = int(input())
while True:
ans = num - 1000
if ans < 1000:
break
print(ans)
|
s944969888
|
Accepted
| 33 | 9,148 | 136 |
num = int(input())
i = 0
while True:
ans = 1000*i - num
i+=1
if ans >= 0:
break
print(ans)
|
s329079892
|
p02420
|
u179070318
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,588 | 130 |
Your task is to shuffle a deck of n cards, each of which is marked by a alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top of the deck. The deck of cards is represented by a string as follows. abcdeefab The first character and the last character correspond to the card located at the bottom of the deck and the card on the top of the deck respectively. For example, a shuffle with h = 4 to the above deck, moves the first 4 characters "abcd" to the end of the remaining characters "eefab", and generates the following deck: eefababcd You can repeat such shuffle operations. Write a program which reads a deck (a string) and a sequence of h, and prints the final state (a string).
|
string = input()
n = int(input())
for i in range(n):
h = int(input())
string = string[h:] + string[:h]
print(string)
|
s455173879
|
Accepted
| 20 | 5,596 | 202 |
while True:
string = input()
if string == '-':
break
n = int(input())
for i in range(n):
h = int(input())
string = string[h:] + string[:h]
print(string)
|
s861623948
|
p04030
|
u357949405
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 152 |
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
|
s = input()
ans = []
for c in s:
if (c == 'B'):
if (len(ans) > 0):
ans.pop(-1)
else:
ans.append(c)
print(str(ans))
|
s359233098
|
Accepted
| 17 | 3,064 | 156 |
s = input()
ans = []
for c in s:
if (c == 'B'):
if (len(ans) > 0):
ans.pop(-1)
else:
ans.append(c)
print(''.join(ans))
|
s113466825
|
p03556
|
u530383736
| 2,000 | 262,144 |
Wrong Answer
| 61 | 5,588 | 134 |
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.
|
# -*- coding: utf-8 -*-
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
N = int(input().strip())
print( int(N**(1/2)) )
|
s931870369
|
Accepted
| 34 | 5,076 | 137 |
# -*- coding: utf-8 -*-
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
N = int(input().strip())
print( int(N**(1/2))**2 )
|
s688070027
|
p03434
|
u531599639
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 162 |
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
|
N=int(input())
a=list(map(int, input().split()))
a.sort()
Alice=0
Bob=0
for i in range(N):
if i&2==0:
Alice += a[i]
else:
Bob += a[i]
print(Alice-Bob)
|
s504962777
|
Accepted
| 17 | 3,060 | 175 |
N=int(input())
a=list(map(int, input().split()))
a.sort(reverse=True)
Alice=0
Bob=0
for i in range(N):
if i%2==0:
Alice += a[i]
else:
Bob += a[i]
print(Alice-Bob)
|
s659901973
|
p02841
|
u227085629
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 107 |
In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019. Integers M_1, D_1, M_2, and D_2 will be given as input. It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1. Determine whether the date 2019-M_1-D_1 is the last day of a month.
|
a,b = map(int,input().split())
c,d = map(int,input().split())
if a != c:
print('Yes')
else:
print('No')
|
s097680740
|
Accepted
| 17 | 2,940 | 100 |
a,b = map(int,input().split())
c,d = map(int,input().split())
if a != c:
print(1)
else:
print(0)
|
s104185746
|
p03407
|
u485566817
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 89 |
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
|
a, b, c = map(int, input().split())
if c <= a + b:
print("YES")
else:
print("NO")
|
s236470067
|
Accepted
| 18 | 2,940 | 89 |
a, b, c = map(int, input().split())
if c <= a + b:
print("Yes")
else:
print("No")
|
s792513513
|
p03798
|
u931173291
| 2,000 | 262,144 |
Wrong Answer
| 172 | 4,976 | 5,719 |
Snuke, who loves animals, built a zoo. There are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle. The animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, and the animal numbered N is adjacent to the animals numbered N-1 and 1. There are two kinds of animals in this zoo: honest sheep that only speak the truth, and lying wolves that only tell lies. Snuke cannot tell the difference between these two species, and asked each animal the following question: "Are your neighbors of the same species?" The animal numbered i answered s_i. Here, if s_i is `o`, the animal said that the two neighboring animals are of the same species, and if s_i is `x`, the animal said that the two neighboring animals are of different species. More formally, a sheep answered `o` if the two neighboring animals are both sheep or both wolves, and answered `x` otherwise. Similarly, a wolf answered `x` if the two neighboring animals are both sheep or both wolves, and answered `o` otherwise. Snuke is wondering whether there is a valid assignment of species to the animals that is consistent with these responses. If there is such an assignment, show one such assignment. Otherwise, print `-1`.
|
n=int(input())
s = list(input())
l = list(0 for i in range(n))
l[0]='S'
l[1]='S'
for i in range(1,n-1):
if l[i]=='S':
if l[i-1]=='S':
if (s[i]=='○'):
s[i+1]='S'
else:
s[i+1]='W'
else:
if s[i]=='○':
s[i+1]='W'
else:
s[i+1]='S'
else:
if l[i-1]=='S':
if (s[i]=='○'):
s[i+1]='W'
else:
s[i+1]='S'
else:
if s[i]=='○':
s[i+1]='S'
else:
s[i+1]='W'
if l[n-1]=='S':
if l[n-2]=='S':
if (s[n-1]=='○'):
if s[0]=='S':
print(l)
exit
else:
if s[0]=='W':
print(l)
exit
else:
if s[n-1]=='○':
if s[0]=='W':
print(l)
exit
else:
if s[0]=='S':
print(l)
exit
else:
if l[n-2]=='S':
if (s[n-1]=='○'):
if s[0]=='W':
print(l)
exit
else:
if s[0]=='S':
print(l)
exit
else:
if s[n-1]=='○':
if s[0]=='S':
print(l)
exit
else:
if s[0]=='W':
print(l)
exit
l[0]='S'
l[1]='W'
for i in range(1,n-1):
if l[i]=='S':
if l[i-1]=='S':
if (s[i]=='○'):
s[i+1]='S'
else:
s[i+1]='W'
else:
if s[i]=='○':
s[i+1]='W'
else:
s[i+1]='S'
else:
if l[i-1]=='S':
if (s[i]=='○'):
s[i+1]='W'
else:
s[i+1]='S'
else:
if s[i]=='○':
s[i+1]='S'
else:
s[i+1]='W'
if l[n-1]=='S':
if l[n-2]=='S':
if (s[n-1]=='○'):
if s[0]=='S':
print(l)
exit
else:
if s[0]=='W':
print(l)
exit
else:
if s[n-1]=='○':
if s[0]=='W':
print(l)
exit
else:
if s[0]=='S':
print(l)
exit
else:
if l[n-2]=='S':
if (s[n-1]=='○'):
if s[0]=='W':
print(l)
exit
else:
if s[0]=='S':
print(l)
exit
else:
if s[n-1]=='○':
if s[0]=='S':
print(l)
exit
else:
if s[0]=='W':
print(l)
exit
l[0]='W'
l[1]='S'
for i in range(1,n-1):
if l[i]=='S':
if l[i-1]=='S':
if (s[i]=='○'):
s[i+1]='S'
else:
s[i+1]='W'
else:
if s[i]=='○':
s[i+1]='W'
else:
s[i+1]='S'
else:
if l[i-1]=='S':
if (s[i]=='○'):
s[i+1]='W'
else:
s[i+1]='S'
else:
if s[i]=='○':
s[i+1]='S'
else:
s[i+1]='W'
if l[n-1]=='S':
if l[n-2]=='S':
if (s[n-1]=='○'):
if s[0]=='S':
print(l)
exit
else:
if s[0]=='W':
print(l)
exit
else:
if s[n-1]=='○':
if s[0]=='W':
print(l)
exit
else:
if s[0]=='S':
print(l)
exit
else:
if l[n-2]=='S':
if (s[n-1]=='○'):
if s[0]=='W':
print(l)
exit
else:
if s[0]=='S':
print(l)
exit
else:
if s[n-1]=='○':
if s[0]=='S':
print(l)
exit
else:
if s[0]=='W':
print(l)
exit
l[0]='W'
l[1]='W'
for i in range(1,n-1):
if l[i]=='S':
if l[i-1]=='S':
if (s[i]=='○'):
s[i+1]='S'
else:
s[i+1]='W'
else:
if s[i]=='○':
s[i+1]='W'
else:
s[i+1]='S'
else:
if l[i-1]=='S':
if (s[i]=='○'):
s[i+1]='W'
else:
s[i+1]='S'
else:
if s[i]=='○':
s[i+1]='S'
else:
s[i+1]='W'
if l[n-1]=='S':
if l[n-2]=='S':
if (s[n-1]=='○'):
if s[0]=='S':
print(l)
exit
else:
if s[0]=='W':
print(l)
exit
else:
if s[n-1]=='○':
if s[0]=='W':
print(l)
exit
else:
if s[0]=='S':
print(l)
exit
else:
if l[n-2]=='S':
if (s[n-1]=='○'):
if s[0]=='W':
print(l)
exit
else:
if s[0]=='S':
print(l)
exit
else:
if s[n-1]=='○':
if s[0]=='S':
print(l)
exit
else:
if s[0]=='W':
print(l)
exit
|
s475928344
|
Accepted
| 201 | 5,156 | 14,910 |
import sys
n=int(input())
s = list(input())
l = list(0 for i in range(n))
l[0]='S'
l[1]='S'
for i in range(1,n-1):
if l[i]=='S':
if l[i-1]=='S':
if (s[i]=='o'):
l[i+1]='S'
else:
l[i+1]='W'
else:
if s[i]=='o':
l[i+1]='W'
else:
l[i+1]='S'
else:
if l[i-1]=='S':
if (s[i]=='o'):
l[i+1]='W'
else:
l[i+1]='S'
else:
if s[i]=='o':
l[i+1]='S'
else:
l[i+1]='W'
if l[n-1]=='S':
if l[n-2]=='S':
if (s[n-1]=='o'):
if l[0]=='S':
if s[0]=='o':
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[0]=='W':
if s[0]=='o':
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if s[n-1]=='o':
if l[0]=='W':
if s[0]=='o':
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[0]=='S':
if s[0]=='o':
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-2]=='S':
if (s[n-1]=='o'):
if l[0]=='W':
if s[0]=='o':
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[0]=='S':
if s[0]=='o':
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if s[n-1]=='o':
if l[0]=='S':
if s[0]=='o':
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[0]=='W':
if s[0]=='o':
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
l[0]='S'
l[1]='W'
for i in range(1,n-1):
if l[i]=='S':
if l[i-1]=='S':
if (s[i]=='o'):
l[i+1]='S'
else:
l[i+1]='W'
else:
if s[i]=='o':
l[i+1]='W'
else:
l[i+1]='S'
else:
if l[i-1]=='S':
if (s[i]=='o'):
l[i+1]='W'
else:
l[i+1]='S'
else:
if s[i]=='o':
l[i+1]='S'
else:
l[i+1]='W'
if l[n-1]=='S':
if l[n-2]=='S':
if (s[n-1]=='o'):
if l[0]=='S':
if s[0]=='o':
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[0]=='W':
if s[0]=='o':
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if s[n-1]=='o':
if l[0]=='W':
if s[0]=='o':
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[0]=='S':
if s[0]=='o':
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-2]=='S':
if (s[n-1]=='o'):
if l[0]=='W':
if s[0]=='o':
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[0]=='S':
if s[0]=='o':
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if s[n-1]=='o':
if l[0]=='S':
if s[0]=='o':
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[0]=='W':
if s[0]=='o':
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
l[0]='W'
l[1]='S'
for i in range(1,n-1):
if l[i]=='S':
if l[i-1]=='S':
if (s[i]=='o'):
l[i+1]='S'
else:
l[i+1]='W'
else:
if s[i]=='o':
l[i+1]='W'
else:
l[i+1]='S'
else:
if l[i-1]=='S':
if (s[i]=='o'):
l[i+1]='W'
else:
l[i+1]='S'
else:
if s[i]=='o':
l[i+1]='S'
else:
l[i+1]='W'
if l[n-1]=='S':
if l[n-2]=='S':
if (s[n-1]=='o'):
if l[0]=='S':
if s[0]=='o':
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[0]=='W':
if s[0]=='o':
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if s[n-1]=='o':
if l[0]=='W':
if s[0]=='o':
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[0]=='S':
if s[0]=='o':
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-2]=='S':
if (s[n-1]=='o'):
if l[0]=='W':
if s[0]=='o':
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[0]=='S':
if s[0]=='o':
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if s[n-1]=='o':
if l[0]=='S':
if s[0]=='o':
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[0]=='W':
if s[0]=='o':
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
l[0]='W'
l[1]='W'
for i in range(1,n-1):
if l[i]=='S':
if l[i-1]=='S':
if (s[i]=='o'):
l[i+1]='S'
else:
l[i+1]='W'
else:
if s[i]=='o':
l[i+1]='W'
else:
l[i+1]='S'
else:
if l[i-1]=='S':
if (s[i]=='o'):
l[i+1]='W'
else:
l[i+1]='S'
else:
if s[i]=='o':
l[i+1]='S'
else:
l[i+1]='W'
if l[n-1]=='S':
if l[n-2]=='S':
if (s[n-1]=='o'):
if l[0]=='S':
if s[0]=='o':
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[0]=='W':
if s[0]=='o':
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if s[n-1]=='o':
if l[0]=='W':
if s[0]=='o':
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[0]=='S':
if s[0]=='o':
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-2]=='S':
if (s[n-1]=='o'):
if l[0]=='W':
if s[0]=='o':
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[0]=='S':
if s[0]=='o':
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if s[n-1]=='o':
if l[0]=='S':
if s[0]=='o':
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[0]=='W':
if s[0]=='o':
if l[n-1]!=l[1]:
l=''.join(l)
print(l)
sys.exit()
else:
if l[n-1]==l[1]:
l=''.join(l)
print(l)
sys.exit()
print(-1)
|
s202307086
|
p02401
|
u193599711
| 1,000 | 131,072 |
Wrong Answer
| 30 | 6,724 | 238 |
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.
|
from sys import stdin
import sys
(a, op, b) = stdin.readline().split()
a = int(a)
b = int(b)
if op == "?":
sys.exit()
elif op == "+":
print(a + b)
elif op == "-":
print(a - b)
elif op == "*":
print(a * b)
elif op == "/":
print(a / b)
|
s947154249
|
Accepted
| 30 | 6,724 | 490 |
a_list = []
b_list = []
op_list = []
count = 0
while True:
a, op, b = (str(i) for i in input().split())
if op != '?':
a_list.append(int(a))
b_list.append(int(b))
op_list.append(op)
count += 1
else :
break
for i in range(0,count):
if op_list[i] == '+':
print(a_list[i] + b_list[i])
elif op_list[i] == '-':
print(a_list[i] - b_list[i])
elif op_list[i] == '*':
print(a_list[i] * b_list[i])
elif op_list[i] == '/':
print(a_list[i] // b_list[i])
|
s016243468
|
p02259
|
u368083894
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,596 | 381 |
Write a program of the Bubble Sort algorithm which sorts a sequence _A_ in ascending order. The algorithm should be based on the following pseudocode: BubbleSort(A) 1 for i = 0 to A.length-1 2 for j = A.length-1 downto i+1 3 if A[j] < A[j-1] 4 swap A[j] and A[j-1] Note that, indices for array elements are based on 0-origin. Your program should also print the number of swap operations defined in line 4 of the pseudocode.
|
def bubble_sort(a):
res = 0
for i in range(len(a)):
for j in range(len(a)-1, i, -1):
if a[j-1] > a[j]:
a[j], a[j-1] = a[j-1], a[j]
res += 1
return res
def main():
n = int(input())
a = list(map(int, input().split()))
ans = bubble_sort(a)
print(a)
print(ans)
if __name__ == '__main__':
main()
|
s681087760
|
Accepted
| 20 | 5,600 | 401 |
def bubble_sort(a):
res = 0
for i in range(len(a)):
for j in range(len(a)-1, i, -1):
if a[j-1] > a[j]:
a[j], a[j-1] = a[j-1], a[j]
res += 1
return res
def main():
n = int(input())
a = list(map(int, input().split()))
ans = bubble_sort(a)
print(' '.join(map(str, a)))
print(ans)
if __name__ == '__main__':
main()
|
s126773315
|
p03624
|
u548545174
| 2,000 | 262,144 |
Wrong Answer
| 25 | 3,892 | 202 |
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead.
|
S = input()
import string
alphas = sorted(set(string.ascii_letters.lower()))
for al in alphas:
if al in S:
alphas.remove(al)
else:
print(al)
break
else:
print('None')
|
s656593948
|
Accepted
| 32 | 3,960 | 167 |
import string
alphas = string.ascii_lowercase
S = input()
for al in alphas:
if al in S:
continue
else:
print(al)
exit()
print("None")
|
s107870116
|
p03545
|
u860546679
| 2,000 | 262,144 |
Wrong Answer
| 28 | 9,228 | 485 |
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.
|
x = input()
a=[int(x[0]), int(x[1]), int(x[2]), int(x[3])]
op=['+', '-']
for i in range(2):
for j in range(2):
for k in range(2):
ops = [op[i], op[j], op[k]]
tmp = a[0]
for l in range(3):
if ops[l]=='+':
tmp = tmp + a[l+1]
else:
tmp = tmp - a[l+1]
print(ops, tmp)
if tmp==7:
break
if tmp==7:
break
if tmp==7:
break
print(str(a[0])+ops[0]+str(a[1])+ops[1]+str(a[2])+ops[2]+str(a[3])+'=7')
|
s088413636
|
Accepted
| 30 | 9,172 | 463 |
x = input()
a=[int(x[0]), int(x[1]), int(x[2]), int(x[3])]
op=['+', '-']
for i in range(2):
for j in range(2):
for k in range(2):
ops = [op[i], op[j], op[k]]
tmp = a[0]
for l in range(3):
if ops[l]=='+':
tmp = tmp + a[l+1]
else:
tmp = tmp - a[l+1]
if tmp==7:
break
if tmp==7:
break
if tmp==7:
break
print(str(a[0])+ops[0]+str(a[1])+ops[1]+str(a[2])+ops[2]+str(a[3])+'=7')
|
s070629406
|
p02744
|
u236823931
| 2,000 | 1,048,576 |
Wrong Answer
| 1,776 | 413,128 | 184 |
In this problem, we only consider strings consisting of lowercase English letters. Strings s and t are said to be **isomorphic** when the following conditions are satisfied: * |s| = |t| holds. * For every pair i, j, one of the following holds: * s_i = s_j and t_i = t_j. * s_i \neq s_j and t_i \neq t_j. For example, `abcac` and `zyxzx` are isomorphic, while `abcac` and `ppppp` are not. A string s is said to be in **normal form** when the following condition is satisfied: * For every string t that is isomorphic to s, s \leq t holds. Here \leq denotes lexicographic comparison. For example, `abcac` is in normal form, but `zyxzx` is not since it is isomorphic to `abcac`, which is lexicographically smaller than `zyxzx`. You are given an integer N. Print all strings of length N that are in normal form, in lexicographically ascending order.
|
if __name__ == '__main__':
n = int(input())
r = lambda n: [''] if n <= 0 else [e + j for e in r(n - 1) for j in [chr(ord('a') + e) for e in range(n)]]
a = r(n)
print(a)
|
s797401474
|
Accepted
| 133 | 4,412 | 201 |
def rec(w, x, n):
if len(w) == n:
return print(w)
else:
for i in range(x + 1):
rec(w + chr(ord('a') + i), x + 1 if i == x else x, n)
n = int(input())
rec("", 0, n)
|
s483469451
|
p02612
|
u227585789
| 2,000 | 1,048,576 |
Wrong Answer
| 27 | 9,088 | 30 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n = int(input())
print(n%1000)
|
s447788454
|
Accepted
| 30 | 9,140 | 72 |
import math
n = int(input())
ans = math.ceil(n/1000)*1000 - n
print(ans)
|
s514523902
|
p03565
|
u590241855
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 336 |
E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One more thing he found is a sheet of paper with the following facts written on it: * Condition 1: The string S contains a string T as a contiguous substring. * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1. Print the string S. If such a string does not exist, print `UNRESTORABLE`.
|
s = input()
t = input()
s2 = s.replace('?', 'a')
ans = 'z' * 99
for i in range(len(s) - len(t)+1):
u = s2[0:i] + t + s2[i + len(t):]
ok = True
for x, y in zip(s2, t):
if x != y:
ok = False
break
if ok:
ans = min(ans, u)
if ans == 'z' * 99:
ans = 'UNRESTORABLE'
print(ans)
|
s012024171
|
Accepted
| 19 | 3,060 | 348 |
s = input()
t = input()
s2 = s.replace('?', 'a')
ans = 'z' * 99
for i in range(len(s) - len(t)+1):
u = s2[0:i] + t + s2[i + len(t):]
ok = True
for x, y in zip(s, u):
if x != '?' and x != y:
ok = False
break
if ok:
ans = min(ans, u)
if ans == 'z' * 99:
ans = 'UNRESTORABLE'
print(ans)
|
s397949481
|
p03612
|
u257974487
| 2,000 | 262,144 |
Wrong Answer
| 74 | 13,880 | 202 |
You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two **adjacent** elements in the permutation. You want to have p_i ≠ i for all 1≤i≤N. Find the minimum required number of operations to achieve this.
|
n = int(input())
p = list(map(int, input().split()))
k = 0
flag = False
for i in range(n):
if p[i] == i+1:
k += 1
if flag:
k -= 1
flag = False
else:
flag = True
print(k)
|
s774243426
|
Accepted
| 71 | 14,008 | 228 |
n = int(input())
p = list(map(int, input().split()))
k = 0
flag = False
for i in range(n):
if p[i] == i+1:
k += 1
if flag:
k -= 1
flag = False
else:
flag = True
else:
flag = False
print(k)
|
s106011666
|
p03861
|
u342042786
| 2,000 | 262,144 |
Wrong Answer
| 20 | 2,940 | 73 |
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
|
a, b, x = map(int, input().split())
dif = (b // x) - (a // x)
print(dif)
|
s321782916
|
Accepted
| 18 | 2,940 | 78 |
a, b, x = map(int, input().split())
dif = (b // x) - ((a - 1)// x)
print(dif)
|
s155893432
|
p02393
|
u395668439
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,608 | 58 |
Write a program which reads three integers, and prints them in ascending order.
|
arr = [int(i) for i in input().split()]
print(sorted(arr))
|
s658358442
|
Accepted
| 20 | 7,712 | 49 |
print(*sorted([int(i) for i in input().split()]))
|
s511271980
|
p02255
|
u064313887
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,596 | 289 |
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
|
def insertionSort(A,N):
for i in range(1,N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(A)
A = []
N = int(input())
A = list(map(int,input().split()))
print(A)
insertionSort(A,N)
|
s932271038
|
Accepted
| 30 | 5,976 | 356 |
N = int(input())
A = list(map(int,input().split()))
def show(nums):
for i in range(len(nums)):
if i != len(nums)-1:
print(nums[i],end=' ')
else:
print(nums[i])
show(A)
for i in range(1,N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
show(A)
|
s749362220
|
p03997
|
u663438907
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 74 |
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 = int(input())
b = int(input())
h = int(input())
print(h * (a + b) / 2)
|
s439219387
|
Accepted
| 17 | 2,940 | 80 |
a = int(input())
b = int(input())
h = int(input())
print(int(h * (a + b) / 2))
|
s872229430
|
p03386
|
u528720841
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 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())
for i in range(A,min(B+1,A+K)):
print(i)
for i in range(max(A+K,B-K),B+1):
print(i)
|
s104771120
|
Accepted
| 18 | 3,060 | 132 |
A, B, K = map(int, input().split())
for i in range(A,min(B+1,A+K)):
print(i)
for i in range(max(A+K,B-K+1),B+1):
print(i)
|
s118887188
|
p03657
|
u910756197
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 130 |
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.
|
a, b = map(int, input().split(" "))
if a % 3 == 0 or b % 3 == 0 or a + b % 3 == 0:
print("Possible")
else:
print("Impossible")
|
s754153078
|
Accepted
| 17 | 2,940 | 133 |
a, b = map(int, input().split(" "))
if a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0:
print("Possible")
else:
print("Impossible")
|
s188341943
|
p03731
|
u351527281
| 2,000 | 262,144 |
Wrong Answer
| 173 | 25,196 | 298 |
In a public bath, there is a shower which emits water for T seconds when the switch is pushed. If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds. N people will push the switch while passing by the shower. The i-th person will push the switch t_i seconds after the first person pushes it. How long will the shower emit water in total?
|
num,time = map(int, input().split())
times = [int(n) for n in input().split()]
start = 0
stop = time
total = 0
for i in range(1,num):
if times[i]<stop:
total += times[i]-times[i-1]
else:
total += stop-times[i-1]
stop = times[i]+time
total += times[-1]+time
print(total)
|
s655608400
|
Accepted
| 161 | 25,200 | 279 |
num,time = map(int, input().split())
times = [int(n) for n in input().split()]
stop = time
total = 0
for i in range(1,num):
if times[i]<=stop:
total += times[i]-times[i-1]
else:
total += stop-times[i-1]
stop = times[i]+time
total += time
print(total)
|
s907588607
|
p03054
|
u026788530
| 2,000 | 1,048,576 |
Wrong Answer
| 97 | 3,788 | 878 |
We have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left. On this grid, there is a piece, which is initially placed at square (s_r,s_c). Takahashi and Aoki will play a game, where each player has a string of length N. Takahashi's string is S, and Aoki's string is T. S and T both consist of four kinds of letters: `L`, `R`, `U` and `D`. The game consists of N steps. The i-th step proceeds as follows: * First, Takahashi performs a move. He either moves the piece in the direction of S_i, or does not move the piece. * Second, Aoki performs a move. He either moves the piece in the direction of T_i, or does not move the piece. Here, to move the piece in the direction of `L`, `R`, `U` and `D`, is to move the piece from square (r,c) to square (r,c-1), (r,c+1), (r-1,c) and (r+1,c), respectively. If the destination square does not exist, the piece is removed from the grid, and the game ends, even if less than N steps are done. Takahashi wants to remove the piece from the grid in one of the N steps. Aoki, on the other hand, wants to finish the N steps with the piece remaining on the grid. Determine if the piece will remain on the grid at the end of the game when both players play optimally.
|
H,W,N= [int(x) for x in input().split()]
Sr,Sc = [int(x) for x in input().split()]
S = input()
T = input()
def solve():
minu = Sr
maxd = Sr
maxr = Sc
minl = Sc
for i in range(N):
if T[i] == 'U':
minu -= 1
if minu == 0:
return "No"
if T[i] == 'D':
maxd += 1
if maxd == W+1:
return "No"
if T[i] == 'R':
maxr += 1
if maxr == H+1:
return "No"
if T[i] == 'L':
minl -= 1
if minl == 0:
return "No"
if T[i] == 'U' and minu > 1:
minu -= 1
if T[i] == 'D' and maxd < W:
maxd += 1
if T[i] == 'R' and maxr < H:
maxr += 1
if T[i] == 'L' and minl > 1:
minl -= 1
return "Yes"
print(solve())
|
s653138238
|
Accepted
| 126 | 3,888 | 913 |
def solve():
H,W,N= [int(x) for x in input().split()]
Sr,Sc = [int(x) for x in input().split()]
S = input()
T = input()
minu = Sr
maxd = Sr
maxr = Sc
minl = Sc
for i in range(N):
if S[i] == 'U':
minu -= 1
if minu == 0:
return "NO"
if S[i] == 'D':
maxd += 1
if maxd == H+1:
return "NO"
if S[i] == 'R':
maxr += 1
if maxr == W+1:
return "NO"
if S[i] == 'L':
minl -= 1
if minl == 0:
return "NO"
if T[i] == 'D' and minu < H:
minu += 1
if T[i] == 'U' and maxd > 1:
maxd -= 1
if T[i] == 'L' and maxr > 1:
maxr -= 1
if T[i] == 'R' and minl < W:
minl += 1
return "YES"
print(solve())
|
s115940502
|
p02402
|
u949338836
| 1,000 | 131,072 |
Wrong Answer
| 30 | 6,720 | 119 |
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.
|
#coding:utf-8
#1_4_D 2015.3.29
n = input()
data = list(map(int,input().split()))
print((min(data),max(data),sum(data)))
|
s568745187
|
Accepted
| 40 | 8,028 | 117 |
#coding:utf-8
#1_4_D 2015.3.29
n = input()
data = list(map(int,input().split()))
print(min(data),max(data),sum(data))
|
s698663427
|
p03543
|
u556589653
| 2,000 | 262,144 |
Wrong Answer
| 20 | 3,064 | 99 |
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
|
N = int(input())
L_2 = 2
L_1 = 1
for i in range(N-1):
K = L_1+L_2
L_2 = L_1
L_1 = K
print(K)
|
s205656076
|
Accepted
| 17 | 2,940 | 95 |
N = input()
if N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:
print("Yes")
else:
print("No")
|
s994692386
|
p02259
|
u914146430
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,604 | 283 |
Write a program of the Bubble Sort algorithm which sorts a sequence _A_ in ascending order. The algorithm should be based on the following pseudocode: BubbleSort(A) 1 for i = 0 to A.length-1 2 for j = A.length-1 downto i+1 3 if A[j] < A[j-1] 4 swap A[j] and A[j-1] Note that, indices for array elements are based on 0-origin. Your program should also print the number of swap operations defined in line 4 of the pseudocode.
|
n=int(input())
nums=list(map(int,input().split()))
k=0
for i in range(len(nums)-1):
for j in range(len(nums)-1,i,-1):
print(i,j)
if nums[j]<nums[j-1]:
nums[j],nums[j-1]=nums[j-1],nums[j]
print(nums)
k+=1
print(*nums)
print(k)
|
s231192266
|
Accepted
| 20 | 7,664 | 240 |
n=int(input())
nums=list(map(int,input().split()))
k=0
for i in range(len(nums)-1):
for j in range(len(nums)-1,i,-1):
if nums[j]<nums[j-1]:
nums[j],nums[j-1]=nums[j-1],nums[j]
k+=1
print(*nums)
print(k)
|
s380044187
|
p03369
|
u244633701
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 70 |
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen.
|
import sys
s = sys.stdin.readline()
print(700 + s.count('c') * 100)
|
s070104425
|
Accepted
| 17 | 2,940 | 72 |
import sys
s = sys.stdin.readline()
print(700 + s.count('o') * 100)
|
s852718850
|
p03860
|
u334712262
| 2,000 | 262,144 |
Wrong Answer
| 18 | 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')
|
s253071175
|
Accepted
| 17 | 2,940 | 36 |
print('A'+input().split()[1][0]+'C')
|
s315143029
|
p04029
|
u278143034
| 2,000 | 262,144 |
Wrong Answer
| 29 | 9,052 | 269 |
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())
Childencnt = 0
Candysum = 0
for Childrencnt in range(1, N):
Candysum == Candysum + Childrencnt
else:
print(Candysum)
|
s017592296
|
Accepted
| 23 | 9,104 | 271 |
N = int(input())
Childrencnt = 1
Candysum = 0
for Childrencnt in range(1, N+1):
Candysum = Candysum + Childrencnt
else:
print(Candysum)
|
s397645784
|
p03193
|
u721569287
| 2,000 | 1,048,576 |
Wrong Answer
| 21 | 3,060 | 220 |
There are N rectangular plate materials made of special metal called AtCoder Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically and B_i horizontally). Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are exactly H \times W. He is trying to obtain such a plate by choosing one of the N materials and cutting it if necessary. When cutting a material, the cuts must be parallel to one of the sides of the material. Also, the materials have fixed directions and cannot be rotated. For example, a 5 \times 3 material cannot be used as a 3 \times 5 plate. Out of the N materials, how many can produce an H \times W plate if properly cut?
|
n_boards, target_x, target_y = [int(i) for i in input().split(" ")]
boards = 0
for i in range(n_boards):
x, y =[int(k) for k in input().split(" ")]
if x <= target_x and y <= target_y:
boards += 1
print(boards)
|
s015603218
|
Accepted
| 23 | 3,060 | 194 |
n, h, w = [int(i) for i in input().split(" ")]
n_boards = 0
for k in range(n):
hi, wi = [int(i) for i in input().split(" ")]
if hi >= h and wi >= w:
n_boards += 1
print(n_boards)
|
s549772236
|
p03385
|
u580251201
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 189 |
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
|
abc = ["abc"[i] for i in range(3)]
raws = input()
target=[raws[i] for i in range(3)]
tmp = list(filter(lambda x:x in target, abc))
if len(tmp) == 3:
print("YES")
else:
print("NO")
|
s134848060
|
Accepted
| 17 | 2,940 | 190 |
abc = ["abc"[i] for i in range(3)]
raws = input()
target=[raws[i] for i in range(3)]
tmp = list(filter(lambda x:x in target, abc))
if len(tmp) == 3:
print("Yes")
else:
print("No")
|
s977232316
|
p03681
|
u351527281
| 2,000 | 262,144 |
Wrong Answer
| 703 | 5,176 | 270 |
Snuke has N dogs and M monkeys. He wants them to line up in a row. As a Japanese saying goes, these dogs and monkeys are on bad terms. _("ken'en no naka", literally "the relationship of dogs and monkeys", means a relationship of mutual hatred.)_ Snuke is trying to reconsile them, by arranging the animals so that there are neither two adjacent dogs nor two adjacent monkeys. How many such arrangements there are? Find the count modulo 10^9+7 (since animals cannot understand numbers larger than that). Here, dogs and monkeys are both distinguishable. Also, two arrangements that result from reversing each other are distinguished.
|
import math
n,m = map(int, input().split())
if abs(n-m) <= 1:
a = max(n,m)
b = min(n,m)
if a-b == 1:
print(math.factorial(a)*math.factorial(b)%(10**9+7))
else:
print(math.factorial(a)*math.factorial(b)*(a+1)%(10**9+7))
else:
print(0)
|
s419003270
|
Accepted
| 702 | 5,184 | 270 |
import math
n,m = map(int, input().split())
if abs(n-m) <= 1:
a = max(n,m)
b = min(n,m)
if a-b == 1:
print((math.factorial(a)*math.factorial(b))%(10**9+7))
else:
print((math.factorial(a)*math.factorial(b)*2)%(10**9+7))
else:
print(0)
|
s487697573
|
p03997
|
u717001163
| 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.
|
a=int(input())
b=int(input())
h=int(input())
print((a+b)*h/2)
|
s347567968
|
Accepted
| 20 | 3,316 | 66 |
a=int(input())
b=int(input())
h=int(input())
print(int((a+b)*h/2))
|
s246460742
|
p03836
|
u737724343
| 2,000 | 262,144 |
Wrong Answer
| 29 | 9,048 | 285 |
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
|
sx, sy, tx, ty = map(int, input().split())
vertical = ty - sy
side = tx - sx
cycle1 = "U" * vertical + "R" * side + "D" * vertical + "L" * side
print(cycle1)
cycle2 = "L" + "U" * (vertical + 1) + "R" * (side + 2) + "D" * (vertical + 2) + "L" * (side + 1) + "U"
print(cycle1 + cycle2)
|
s096406303
|
Accepted
| 28 | 9,148 | 283 |
sx, sy, tx, ty = map(int, input().split())
vertical = ty - sy
side = tx - sx
cycle1 = "U" * vertical + "R" * side + "D" * vertical + "L" * side
cycle2 = "L" + "U" * (vertical + 1) + "R" * (side + 1) + "D" + "R" + "D" * (vertical + 1) + "L" * (side + 1) + "U"
print(cycle1 + cycle2)
|
s718513646
|
p04043
|
u061674046
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 109 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
a = list(map(int,input().split()))
if a.count(5) == 2 and a.count(7) == 1:
print("yes")
else:
print("no")
|
s633303088
|
Accepted
| 18 | 2,940 | 109 |
a = list(map(int,input().split()))
if a.count(5) == 2 and a.count(7) == 1:
print("YES")
else:
print("NO")
|
s947974767
|
p03485
|
u970809473
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 47 |
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())
print(-(-a//b))
|
s134756352
|
Accepted
| 17 | 2,940 | 52 |
a,b = map(int, input().split())
print(-((-a-b)//2))
|
s281803094
|
p03605
|
u878138257
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 69 |
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
|
a = input()
if a[0]==9 or a[1]==9:
print("Yes")
else:
print("No")
|
s544413539
|
Accepted
| 17 | 2,940 | 92 |
a = str(input())
if a.count("9")==1 or a.count("9")==2:
print("Yes")
else:
print("No")
|
s241833441
|
p04043
|
u438085259
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 215 |
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())
l = [a,b,c]
five,seven = 0,0
for i in l:
if i == 5:
five += 1
elif i == 7:
seven += 1
if five == 2 and seven == 1:
print('yes')
else:
print('no')
|
s437566164
|
Accepted
| 23 | 3,444 | 198 |
l = map(int, input().split())
five,seven = 0,0
for i in l:
if i == 5:
five += 1
elif i == 7:
seven += 1
if five == 2 and seven == 1:
print('YES')
else:
print('NO')
|
s414367668
|
p03636
|
u845674689
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 72 |
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
|
s = input()
length = len(s)
ans = s[0] + str(length) + s[-1]
print(ans)
|
s511028549
|
Accepted
| 17 | 3,064 | 76 |
s = input()
length = len(s)
ans = s[0] + str(length - 2) + s[-1]
print(ans)
|
s219642752
|
p02271
|
u253463900
| 5,000 | 131,072 |
Wrong Answer
| 60 | 7,660 | 428 |
Write a program which reads a sequence _A_ of _n_ elements and an integer _M_ , and outputs "yes" if you can make _M_ by adding elements in _A_ , otherwise "no". You can use an element only once. You are given the sequence _A_ and _q_ questions where each question contains _M i_.
|
def solve(i,m,A):
global n
if m == 0 :
return True
elif i >= 0 :
return False
else:
return solve(i+1,m,A) or solve(i+1,m-A[i],A)
global n
n = int(input())
st = input()
A = list(map(int,st.split()))
# dont use q(num of ans patarn) dumping!
input()
st = input()
ans = list(map(int,st.split()))
for x in ans:
if(solve(0,x,A) == True):
print('yes')
else:
print('no')
|
s800166421
|
Accepted
| 30 | 7,716 | 417 |
is_able_make = [False]*2000
input()
A = [ int( val ) for val in input().rstrip().split( ' ' ) ]
q = int(input())
M = [ int( val ) for val in input().rstrip().split( ' ' ) ]
for i in A:
for j in range(2000-i,0,-1):
if is_able_make[j] == True:
is_able_make[i+j] = True
is_able_make[i] = True
for x in M:
if(is_able_make[x] == True):
print('yes')
else:
print('no')
|
s321303776
|
p03730
|
u633450100
| 2,000 | 262,144 |
Wrong Answer
| 29 | 9,104 | 126 |
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 = [int(i) for i in input().split()]
for i in range(1,B+1):
if A * i % B == C:
print("YES")
else:
print("NO")
|
s774068653
|
Accepted
| 27 | 9,100 | 190 |
A,B,C = [int(i) for i in input().split()]
D = max(A,B)
for i in range(1,D+1):
if A * i % B == C:
print("YES")
break
if A * i % B != C and i == D:
print("NO")
|
s086598967
|
p03471
|
u829796346
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 3,060 | 197 |
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
|
N, Y = map(int, input().split())
for x in range(N+1):
for y in range(N+1-x):
for z in range(N+1-x-y):
if x*10000+y*5000+z*1000 == Y:
print(x,y,z)
exit(0)
print(-1,-1,-1)
|
s953946474
|
Accepted
| 687 | 3,060 | 216 |
N, Y = map(int, input().split())
#print(N)
for x in range(N+1)[::-1]:
for y in range(N+1-x)[::-1]:
#print(x,y,N-x-y)
if x*10000+y*5000+(N-x-y)*1000 == Y:
print(x,y,N-x-y)
exit(0)
print(-1,-1,-1)
|
s839758749
|
p03409
|
u606045429
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 443 |
On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.
|
n = int(input())
red = []
for i in range(n):
red.append([int(j) for j in input().split()])
red.sort(key=lambda x : x[1], reverse=True)
print(red)
blue = []
for i in range(n):
blue.append([int(j) for j in input().split()])
blue.sort()
print(blue)
count = 0
for b in blue:
for r in red:
if r[0] < b[0]:
if r[1] < b[1]:
count += 1
red.remove(r)
break
print(count)
|
s778295686
|
Accepted
| 18 | 3,064 | 280 |
N, *I = map(int, open(0).read().split())
AB = set(zip(*[iter(I[:2 * N])] * 2))
CD = sorted(zip(*[iter(I[2 * N:])] * 2))
for c, d in CD:
ma = max(((a, b) for a, b in AB if a < c and b < d), key=lambda x: x[1], default=None)
if ma:
AB.remove(ma)
print(N - len(AB))
|
s505192448
|
p03795
|
u667024514
| 2,000 | 262,144 |
Wrong Answer
| 19 | 2,940 | 48 |
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.
|
a = int(input())
b = int(a/5)
print(800*a-200*b)
|
s969830995
|
Accepted
| 17 | 2,940 | 49 |
n = int(input())
print(n * 800 - (n // 15) * 200)
|
s833242617
|
p03673
|
u513081876
| 2,000 | 262,144 |
Wrong Answer
| 59 | 21,188 | 212 |
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b. The i-th operation is as follows: 1. Append a_i to the end of b. 2. Reverse the order of the elements in b. Find the sequence b obtained after these n operations.
|
n = int(input())
a = list(map(str, input().split()))
if n % 2 == 0:
ki = a[::2]
gu = a[1::2]
gu = gu[::-1]
ans = gu+ki
else:
ki = a[::2]
ki = ki[::-1]
gu = a[1::2]
ans = ki+gu
|
s914890468
|
Accepted
| 120 | 36,248 | 236 |
n = int(input())
a = [int(i) for i in input().split()]
if n % 2 == 0:
lis1 = a[::2]
lis2 = a[::-2]
ans = lis2 + lis1
else:
lis1 = a[::-2]
lis2 = a[1::2]
ans = lis1 + lis2
ans = map(str, ans)
print(' '.join(ans))
|
s701521138
|
p03447
|
u474270503
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 58 |
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%B-A)
|
s868184506
|
Accepted
| 17 | 2,940 | 60 |
X=int(input())
A=int(input())
B=int(input())
print((X-A)%B)
|
s882582174
|
p02612
|
u115927976
| 2,000 | 1,048,576 |
Wrong Answer
| 27 | 9,064 | 58 |
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())
ans = N-1000*((int)((N)/1000))
print(ans)
|
s363099560
|
Accepted
| 29 | 9,096 | 62 |
N = int(input())
ans = 1000*(1+(int)((N-1)/1000))-N
print(ans)
|
s572377481
|
p02601
|
u994543150
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 9,192 | 205 |
M-kun has the following three cards: * A red card with the integer A. * A green card with the integer B. * A blue card with the integer C. He is a genius magician who can do the following operation at most K times: * Choose one of the three cards and multiply the written integer by 2. His magic is successful if both of the following conditions are satisfied after the operations: * The integer on the green card is **strictly** greater than the integer on the red card. * The integer on the blue card is **strictly** greater than the integer on the green card. Determine whether the magic can be successful.
|
a,b,c=map(int,input().split())
k=int(input())
count=0
while a>=b:
b=b*2
count+=1
con=0
while b*count>=c:
c=c*2
con+=1
total=con+count
if total<=k:
print('Yes')
else:
print('No')
|
s195991982
|
Accepted
| 33 | 9,184 | 199 |
a,b,c=map(int,input().split())
k=int(input())
count=0
while a>=b:
b=b*2
count+=1
con=0
while b>=c:
c=c*2
con+=1
total=con+count
if total<=k:
print('Yes')
else:
print('No')
|
s616201429
|
p00002
|
u149199817
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,592 | 298 |
Write a program which computes the digit number of sum of two integers a and b.
|
# -*- coding: utf-8 -*-
import sys
def get_digits(n):
if n < 0:
n *= -1
return len(str(n))
def main():
data = []
for line in sys.stdin:
a, b = map(int, input().split())
digits = get_digits(a+b)
print(digits)
if __name__ == '__main__':
main()
|
s031935160
|
Accepted
| 30 | 7,676 | 295 |
# -*- coding: utf-8 -*-
import sys
def get_digits(n):
if n < 0:
n *= -1
return len(str(n))
def main():
data = []
for line in sys.stdin:
a, b = map(int, line.split())
digits = get_digits(a+b)
print(digits)
if __name__ == '__main__':
main()
|
s837514583
|
p02394
|
u316584871
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,588 | 119 |
Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.
|
W,H,x,y,r = map(int, input().split())
if (W-r <= x <= W+r and H-r <= y <= H+r):
print('Yes')
else:
print('No')
|
s093290487
|
Accepted
| 20 | 5,596 | 128 |
W,H,x,y,r = map(int, input().split())
if (0<= x-r and x+r <=W and 0<= y-r and y+r <= H):
print('Yes')
else:
print('No')
|
s602803344
|
p02399
|
u650790815
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,536 | 77 |
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
|
a,b = map(int,input().split())
print('{},{},{:.5f}'.format(int(a/b),a%b,a/b))
|
s986015716
|
Accepted
| 20 | 7,632 | 73 |
a,b = map(int,input().split())
print('{} {} {:.5f}'.format(a//b,a%b,a/b))
|
s913269217
|
p03719
|
u870297120
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 72 |
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
|
a, b, c = map(int, input().split())
print('YES' if a <= c <=b else 'NO')
|
s235598388
|
Accepted
| 17 | 2,940 | 72 |
a, b, c = map(int, input().split())
print('Yes' if a <= c <=b else 'No')
|
s098159594
|
p03644
|
u667084803
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 108 |
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.
|
import sys
N=int(input())
s=0
for i in range(6):
if N%2!=0:
print(2**s)
sys.exit()
s+=1
N=N//2
|
s462936986
|
Accepted
| 17 | 2,940 | 92 |
import sys
N=int(input())
for i in range(8):
if 2**i>N:
print(2**(i-1))
sys.exit()
|
s402560518
|
p03543
|
u479113369
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 251 |
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
|
a = int(input())
one = a // 1000
two = (a - one*1000) // 100
three = (a - one*1000 - two*100) // 10
four = a - one*1000 - two*100 -three*10
if two == three:
if two == one | two == three:
print("YES")
else:
print("NO")
else:
print("NO")
|
s206491809
|
Accepted
| 17 | 2,940 | 96 |
a = input()
if a[2] == a[1] == a[0] or a[2] == a[3] == a[1]:
print("Yes")
else:
print("No")
|
s629107696
|
p00005
|
u533681846
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,648 | 125 |
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b.
|
import math
while 1:
try:
a,b = map(int, input().split())
print(math.gcd(a,b))
except:
break
|
s423415805
|
Accepted
| 20 | 5,656 | 149 |
import math
while 1:
try:
a,b = map(int, input().split())
print(math.gcd(a,b), int(a*b/math.gcd(a,b)))
except:
break
|
s428885753
|
p00005
|
u776559258
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,580 | 141 |
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b.
|
def gcd(a,b):
if b==0:
return a
return gcd(b,a%b)
while True:
try:
a,b=[int(i) for i in input().split()]
except EOFError:
break
|
s012578797
|
Accepted
| 20 | 7,680 | 175 |
def gcd(a,b):
if b==0:
return a
return gcd(b,a%b)
while True:
try:
a,b=[int(i) for i in input().split()]
print(gcd(a,b),(a*b)//gcd(a,b))
except EOFError:
break
|
s078969323
|
p04043
|
u464205401
| 2,000 | 262,144 |
Wrong Answer
| 28 | 9,156 | 80 |
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 = sorted(list(map(int,input().split())))
print('Yes' if a==[5,5,7] else 'No')
|
s850010573
|
Accepted
| 27 | 9,152 | 80 |
a = sorted(list(map(int,input().split())))
print('YES' if a==[5,5,7] else 'NO')
|
s905903932
|
p03827
|
u686036872
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 140 |
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())
S = list(input())
m=0
sum=0
for i in S:
if i == "I":
sum+=1
else:
sum-=1
m=max(sum, 0)
print(m)
|
s107249213
|
Accepted
| 17 | 2,940 | 140 |
N = int(input())
S = list(input())
m=0
sum=0
for i in S:
if i == "I":
sum+=1
else:
sum-=1
m=max(sum, m)
print(m)
|
s984061428
|
p02390
|
u666221014
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,688 | 175 |
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.
|
all_time = int(input())
hour = all_time // 3600
minute = (all_time % 3600) % 60
second = (all_time % 3600) // 60
print( str(hour) + ":" + str(minute) + ":" + str(second) )
|
s940385335
|
Accepted
| 30 | 7,692 | 175 |
all_time = int(input())
hour = all_time // 3600
minute = (all_time % 3600) // 60
second = (all_time % 3600) % 60
print( str(hour) + ":" + str(minute) + ":" + str(second) )
|
s763945346
|
p03501
|
u516554284
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 48 |
You are parking at a parking lot. You can choose from the following two fee plans: * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours. * Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours.
|
n,a,b=map(int,input().split());print(max(n*a,b))
|
s595448997
|
Accepted
| 17 | 2,940 | 49 |
n,a,b=map(int,input().split());print(min(n*a,b))
|
s006482009
|
p03854
|
u827624348
| 2,000 | 262,144 |
Wrong Answer
| 146 | 3,188 | 474 |
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`.
|
def solve(S):
str_list = ["dream", "dreamer", "erase", "eraser"]
n = 0
while n < len(S):
for s in str_list:
if n:
if S[:-n].endswith(s):
n += len(s)
break
else:
if S.endswith(s):
n += len(s)
break
else:
return False
return True
S = input()
if solve(S):
print("Yes")
else:
print("No")
|
s070102613
|
Accepted
| 152 | 3,188 | 474 |
def solve(S):
str_list = ["dream", "dreamer", "erase", "eraser"]
n = 0
while n < len(S):
for s in str_list:
if n:
if S[:-n].endswith(s):
n += len(s)
break
else:
if S.endswith(s):
n += len(s)
break
else:
return False
return True
S = input()
if solve(S):
print("YES")
else:
print("NO")
|
s366615303
|
p02841
|
u535423069
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,064 | 748 |
In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019. Integers M_1, D_1, M_2, and D_2 will be given as input. It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1. Determine whether the date 2019-M_1-D_1 is the last day of a month.
|
# Created: Sat Mar 28 15:38:17 UTC 2020
import sys
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()
m, d = na()
m2, d2 = na()
if d + 1 != d2:
print("Yes")
else:
print("No")
|
s747791863
|
Accepted
| 18 | 3,064 | 741 |
# Created: Sat Mar 28 15:38:17 UTC 2020
import sys
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()
m, d = na()
m2, d2 = na()
if d + 1 != d2:
print(1)
else:
print(0)
|
s977834647
|
p03079
|
u113971909
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 47 |
You are given three integers A, B and C. Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
|
print('NYoes'[len(set(input().split()))==1::2])
|
s790576992
|
Accepted
| 19 | 2,940 | 48 |
print('NYoe s'[len(set(input().split()))==1::2])
|
s921894504
|
p03565
|
u411858517
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 21 |
E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One more thing he found is a sheet of paper with the following facts written on it: * Condition 1: The string S contains a string T as a contiguous substring. * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1. Print the string S. If such a string does not exist, print `UNRESTORABLE`.
|
print("UNRESTORABLE")
|
s938352966
|
Accepted
| 17 | 3,064 | 625 |
S = input()
T = input()
tmp = -1
for i in range(len(S) - len(T) + 1):
start = -1
for j in range(len(T)):
if S[i+j] == T[j] or S[i+j] == '?':
start = i
else:
start = -1
break
if start != -1:
tmp = i
if tmp == -1:
print('UNRESTORABLE')
else:
res = ''
count = 0
for i in range(len(S)):
if tmp <= i < tmp + len(T):
res += T[count]
count += 1
elif S[i] == '?':
res += 'a'
else:
res += S[i]
print(res)
|
s539645040
|
p03555
|
u266874640
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 119 |
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
|
c = [input() for i in range(2)]
a = "".join(list(reversed(c[0])))
if a == c[1]:
print("Yes")
else:
print("No")
|
s897836959
|
Accepted
| 18 | 2,940 | 119 |
c = [input() for i in range(2)]
a = "".join(list(reversed(c[0])))
if a == c[1]:
print("YES")
else:
print("NO")
|
s646708321
|
p03860
|
u129898499
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 43 |
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.
|
A,B,C = input().split()
print("A""B[0]""C")
|
s448663484
|
Accepted
| 17 | 2,940 | 71 |
A,B,C = input().split()
print("A",end="")
print(B[0],end="")
print("C")
|
s039434189
|
p03377
|
u626337957
| 2,000 | 262,144 |
Wrong Answer
| 20 | 3,060 | 95 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
A, B, X = map(int, input().split())
if A <= X and A+B >= X:
print('Yes')
else:
print('No')
|
s828500142
|
Accepted
| 21 | 3,060 | 96 |
A, B, X = map(int, input().split())
if A <= X and A+B >= X:
print('YES')
else:
print('NO')
|
s138311749
|
p02744
|
u754022296
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,188 | 192 |
In this problem, we only consider strings consisting of lowercase English letters. Strings s and t are said to be **isomorphic** when the following conditions are satisfied: * |s| = |t| holds. * For every pair i, j, one of the following holds: * s_i = s_j and t_i = t_j. * s_i \neq s_j and t_i \neq t_j. For example, `abcac` and `zyxzx` are isomorphic, while `abcac` and `ppppp` are not. A string s is said to be in **normal form** when the following condition is satisfied: * For every string t that is isomorphic to s, s \leq t holds. Here \leq denotes lexicographic comparison. For example, `abcac` is in normal form, but `zyxzx` is not since it is isomorphic to `abcac`, which is lexicographically smaller than `zyxzx`. You are given an integer N. Print all strings of length N that are in normal form, in lexicographically ascending order.
|
import sys
sys.setrecursionlimit(10**7)
n = int(input())
def dfs(s, mx):
if len(s) == n:
print(s)
else:
dfs(s+chr(ord("a")+mx), mx)
dfs(s+chr(ord("a")+mx+1), mx+1)
dfs("", 0)
|
s709467908
|
Accepted
| 130 | 4,404 | 220 |
import sys
sys.setrecursionlimit(10**7)
n = int(input())
def dfs(s, mx):
if len(s) == n:
print(s)
else:
for i in range(mx):
dfs(s+chr(ord("a")+i), mx)
dfs(s+chr(ord("a")+mx), mx+1)
dfs("a", 1)
|
s242177295
|
p03494
|
u507457124
| 2,000 | 262,144 |
Wrong Answer
| 29 | 9,156 | 263 |
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.
|
INPUT = list(map(int,input().split()))
def check_even(l):
return sum([i % 2 for i in INPUT]) == 0
check_even(INPUT)
count = 0
while True:
if check_even(INPUT):
INPUT = [i / 2 for i in INPUT]
count+=1
else:
break
print(count)
|
s511750288
|
Accepted
| 26 | 9,188 | 276 |
_ = input()
INPUT = list(map(int, input().split()))
def check_even(l):
return sum([i % 2 for i in INPUT]) == 0
check_even(INPUT)
count = 0
while True:
if check_even(INPUT):
INPUT = [i / 2 for i in INPUT]
count+=1
else:
break
print(count)
|
s169442166
|
p04012
|
u451017206
| 2,000 | 262,144 |
Wrong Answer
| 21 | 3,316 | 93 |
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
|
s = input()
from collections import Counter
print(all([v%2==0 for v in Counter(s).values()]))
|
s314264644
|
Accepted
| 21 | 3,316 | 123 |
s = input()
from collections import Counter
a=all([v%2==0 for v in Counter(s).values()])
if a:print('Yes')
else:print('No')
|
s022703678
|
p03644
|
u063073794
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 134 |
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())
saiko=0
for i in range(1,a+1):
count=0
for j in range(1,i+1):
if j%2==0:
count+=1
print(max(saiko,count))
|
s978951650
|
Accepted
| 18 | 2,940 | 144 |
a=int(input())
saiko=0
count=0
for j in range(1,a+1):
count=0
while j%2==0:
count+=1
j=j//2
saiko=max(saiko,count)
print(2**saiko)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.