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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s593485247
|
p03455
|
u674722380
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 103
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a, b = map(int, input().split())
c = a * b
if c % 2 == 0 :
print("Odd")
else:
print("Even")
|
s704076423
|
Accepted
| 17
| 2,940
| 103
|
a, b = map(int, input().split())
c = a * b
if c % 2 == 0 :
print("Even")
else:
print("Odd")
|
s525506314
|
p02694
|
u589969467
| 2,000
| 1,048,576
|
Wrong Answer
| 25
| 9,100
| 86
|
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
n = int(input())
kane = 100
i = 0
while kane>=n:
i += 1
kane = int(kane * 1.01)
|
s856780920
|
Accepted
| 33
| 9,144
| 100
|
x = int(input())
money = 100
i = 0
while money<x:
i += 1
money = (money * 101)//100
print(i)
|
s947556564
|
p03543
|
u288948615
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 127
|
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**?
|
nums = [int(n) for n in input()]
for i in range(2):
if set(nums[i:i+3:]) == 1:
print('Yes')
break
else:
print('No')
|
s337153219
|
Accepted
| 17
| 2,940
| 138
|
nums = [int(n) for n in input()]
for i in range(2):
if len(set(nums[i:i+3:])) == 1:
print('Yes')
break
else:
print('No')
|
s551311033
|
p03360
|
u220345792
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 124
|
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after K operations?
|
A, B, C = map(int, input().split())
K = int(input())
ans = 0
ans = A + B + C + max(A, B, C) * (K - 1) *2
print(int(ans))
|
s227129546
|
Accepted
| 17
| 2,940
| 145
|
A, B, C = map(int, input().split())
K = int(input())
ans = 0
max_num = max(A, B, C)
ans = A + B + C + max_num * 2**K -max_num
print(int(ans))
|
s444008240
|
p03141
|
u539517139
| 2,000
| 1,048,576
|
Wrong Answer
| 358
| 7,848
| 145
|
There are N dishes of cuisine placed in front of Takahashi and Aoki. For convenience, we call these dishes Dish 1, Dish 2, ..., Dish N. When Takahashi eats Dish i, he earns A_i points of _happiness_ ; when Aoki eats Dish i, she earns B_i points of happiness. Starting from Takahashi, they alternately choose one dish and eat it, until there is no more dish to eat. Here, both of them choose dishes so that the following value is maximized: "the sum of the happiness he/she will earn in the end" minus "the sum of the happiness the other person will earn in the end". Find the value: "the sum of the happiness Takahashi earns in the end" minus "the sum of the happiness Aoki earns in the end".
|
n=int(input())
s=[0]*n
t=0
for i in range(n):
a,b=map(int,input().split())
s[i]=a+b
t+=b
s.sort()
s=s[::-1]
print(sum(s[:n//2+(n%2==1)])-t)
|
s276816241
|
Accepted
| 357
| 7,848
| 134
|
n=int(input())
s=[0]*n
t=0
for i in range(n):
a,b=map(int,input().split())
s[i]=a+b
t+=b
s.sort()
s=s[::-1]
print(sum(s[::2])-t)
|
s809888281
|
p03455
|
u314050667
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 75
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a, b = map(int,input().split())
print("Odd") if (a*b)%2 else print("Evev")
|
s194150104
|
Accepted
| 17
| 2,940
| 75
|
a, b = map(int,input().split())
print("Odd") if (a*b)%2 else print("Even")
|
s306990688
|
p03605
|
u732061897
| 2,000
| 262,144
|
Wrong Answer
| 26
| 8,948
| 78
|
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
|
N = input()
if N[0] == 9 or N[1] == 9:
print('Yes')
else:
print('No')
|
s007026278
|
Accepted
| 26
| 9,028
| 82
|
N = input()
if N[0] == '9' or N[1] == '9':
print('Yes')
else:
print('No')
|
s031442281
|
p03943
|
u306142032
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 111
|
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
a,b,c = map(int, input().split())
if a+b == c or b+c == a or c+a == b:
print("YES")
else:
print("NO")
|
s067790234
|
Accepted
| 19
| 3,060
| 111
|
a,b,c = map(int, input().split())
if a+b == c or b+c == a or c+a == b:
print("Yes")
else:
print("No")
|
s541089436
|
p02854
|
u760961723
| 2,000
| 1,048,576
|
Wrong Answer
| 122
| 26,220
| 430
|
Takahashi, who works at DISCO, is standing before an iron bar. The bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters. Takahashi wanted to choose a notch and cut the bar at that point into two parts with the same length. However, this may not be possible as is, so he will do the following operations some number of times **before** he does the cut: * Choose one section and expand it, increasing its length by 1 millimeter. Doing this operation once costs 1 yen (the currency of Japan). * Choose one section of length at least 2 millimeters and shrink it, decreasing its length by 1 millimeter. Doing this operation once costs 1 yen. Find the minimum amount of money needed before cutting the bar into two parts with the same length.
|
N = int(input())
A = list(map(int,input().split()))
almost_half = sum(A)/2
former = 0
for n in range(N):
former += A[n]
if former == almost_half:
print(0)
break
if former > almost_half:
if n == 0:
print(abs(A[0]-sum(A[1:])))
break
elif n == N-1:
print(abs(A[n]-sum(A[:n])))
break
else:
print(min(abs(sum(A[n:])-sum(A[:n])),abs(sum(A[n-1:])-sum(A[:n-1]))))
break
|
s870530305
|
Accepted
| 124
| 26,056
| 598
|
N = int(input())
A = list(map(int,input().split()))
almost_half = sum(A)/2
former = 0
for n in range(N):
former += A[n]
if former == almost_half:
print(0)
break
if former > almost_half:
if n == 0:
#print("case01",n,former)
print(abs(A[0]-sum(A[1:])))
break
elif n == N-1:
#print("case02",n,former)
print(abs(A[n]-sum(A[:n])))
break
else:
#print("case03",n,former)
#print(abs(sum(A[n:])-sum(A[:n])),abs(sum(A[n+1:])-sum(A[:n+1])))
print(min(abs(sum(A[n:])-sum(A[:n])),abs(sum(A[n+1:])-sum(A[:n+1]))))
break
|
s089802001
|
p03457
|
u610232423
| 2,000
| 262,144
|
Wrong Answer
| 910
| 3,188
| 348
|
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
|
n=input()
x1=0
y1=0
t1=0
success=True
for i in range(int(n)):
t,x,y = map(int,input().split())
w = abs(x - x1) + abs(y - y1)
print(w)
if w > abs(t - t1):
success=False
break
if w % 2 != abs(t -t1) % 2:
success=False
break
x1 = x
y1 = y
t1 = t
print("Yes") if success else print("No")
|
s844182583
|
Accepted
| 377
| 3,064
| 336
|
n=input()
x1=0
y1=0
t1=0
success=True
for i in range(int(n)):
t,x,y = map(int,input().split())
w = abs(x - x1) + abs(y - y1)
if w > abs(t - t1):
success=False
break
if w % 2 != abs(t -t1) % 2:
success=False
break
x1 = x
y1 = y
t1 = t
print("Yes") if success else print("No")
|
s723800632
|
p03998
|
u513900925
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,188
| 586
|
Alice, Bob and Charlie are playing _Card Game for Three_ , as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * If the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says `a`, Alice takes the next turn.) * If the current player's deck is empty, the game ends and the current player wins the game. You are given the initial decks of the players. More specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way. Determine the winner of the game.
|
a = input()
b = input()
c = input()
d = a + b + c
def turn(x ,a_hand ,b_hand ,c_hand):
if not a_hand:
print("A")
return
if not b_hand:
print("B")
return
if not c_hand:
print("C")
return
if x == "a":
x = a_hand[0]
a_hand = a_hand[1:]
turn(x , a_hand , b_hand , c_hand)
elif x == "b":
x = b_hand[0]
b_hand = b_hand[1:]
turn(x , a_hand , b_hand , c_hand)
else:
x = c_hand[0]
c_hand = c_hand[1:]
turn(x , a_hand , b_hand , c_hand)
turn("a",a,b,c)
|
s997463104
|
Accepted
| 17
| 3,188
| 609
|
a = input()
b = input()
c = input()
def turn(x ,a_hand ,b_hand ,c_hand):
if not a_hand and x == "a":
print("A")
return
if not b_hand and x =="b":
print("B")
return
if not c_hand and x =="c":
print("C")
return
if x == "a":
x = a_hand[0]
a_hand = a_hand[1:]
turn(x , a_hand , b_hand , c_hand)
elif x == "b":
x = b_hand[0]
b_hand = b_hand[1:]
turn(x , a_hand , b_hand , c_hand)
else:
x = c_hand[0]
c_hand = c_hand[1:]
turn(x , a_hand , b_hand , c_hand)
turn("a",a,b,c)
|
s956779295
|
p03485
|
u333731247
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 51
|
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(int((a+b)/2)+1)
|
s694195839
|
Accepted
| 17
| 2,940
| 101
|
a,b=map(int,input().split())
if (a+b)%2==0:
print(int((a+b)/2))
else :
print(int((a+b)/2)+1)
|
s927136021
|
p02613
|
u945375934
| 2,000
| 1,048,576
|
Wrong Answer
| 146
| 9,096
| 330
|
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, wa, tle, re = 0, 0, 0, 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 × " + str(ac))
print("WA × " + str(wa))
print("TLE × " + str(tle))
print("RE × " + str(re))
|
s379660858
|
Accepted
| 148
| 9,152
| 326
|
n = int(input())
ac, wa, tle, re = 0, 0, 0, 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 " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))
|
s877664786
|
p03973
|
u731028462
| 2,000
| 262,144
|
Wrong Answer
| 304
| 7,084
| 234
|
N people are waiting in a single line in front of the Takahashi Store. The cash on hand of the i-th person from the front of the line is a positive integer A_i. Mr. Takahashi, the shop owner, has decided on the following scheme: He picks a product, sets a positive integer P indicating its price, and shows this product to customers in order, starting from the front of the line. This step is repeated as described below. At each step, when a product is shown to a customer, if price P is equal to or less than the cash held by that customer at the time, the customer buys the product and Mr. Takahashi ends the current step. That is, the cash held by the first customer in line with cash equal to or greater than P decreases by P, and the next step begins. Mr. Takahashi can set the value of positive integer P independently at each step. He would like to sell as many products as possible. However, if a customer were to end up with 0 cash on hand after a purchase, that person would not have the fare to go home. Customers not being able to go home would be a problem for Mr. Takahashi, so he does not want anyone to end up with 0 cash. Help out Mr. Takahashi by writing a program that determines the maximum number of products he can sell, when the initial cash in possession of each customer is given.
|
n = int(input())
a = []
for i in range(n):
a.append(int(input()))
count = max(a[0]-1,0)
index = 2
for i in range(1,n):
if a[i] > index:
count += (a[i] - 1) / index
if a[i] == index:
index += 1
print(count)
|
s674235865
|
Accepted
| 282
| 7,848
| 232
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n = int(input())
arr = [int(input()) for i in range(n)]
count = arr[0]-1
m = 2
for a in arr[1:]:
if a > m:
count += (a - 1) // m
if a == m:
m += 1
print(count)
|
s352320573
|
p03605
|
u729133443
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 32
|
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?
|
print('YNeos'['9'in input()::2])
|
s886343351
|
Accepted
| 27
| 9,020
| 33
|
print('NYoe s'['9'in input()::2])
|
s065661949
|
p03456
|
u747220349
| 2,000
| 262,144
|
Wrong Answer
| 2,104
| 18,992
| 141
|
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.
|
s=int("".join(map(str,input().split())))
i=1
while i<s:
if s==i*2:
print("Yes")
else:
i=i+1
else:
print("No")
|
s989152867
|
Accepted
| 55
| 2,940
| 156
|
s=int("".join(map(str,input().split())))
i=1
while i<s:
if s==i**2:
print("Yes")
break
else:
i=i+1
else:
print("No")
|
s660881855
|
p02613
|
u068142202
| 2,000
| 1,048,576
|
Wrong Answer
| 32
| 9,156
| 96
|
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())
if n % 1000 == 0:
print("0")
else:
print(((n // 1000) + 1) * 1000 - n)
|
s645076024
|
Accepted
| 143
| 16,608
| 258
|
import collections
n = int(input())
s = [input() for _ in range(n)]
s_count = collections.Counter(s)
print("AC x {}".format(s_count["AC"]))
print("WA x {}".format(s_count["WA"]))
print("TLE x {}".format(s_count["TLE"]))
print("RE x {}".format(s_count["RE"]))
|
s669838713
|
p03456
|
u279229189
| 2,000
| 262,144
|
Wrong Answer
| 21
| 4,088
| 203
|
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.
|
lists=[input() for i in range(1)]
num = int(lists[0].split(" ")[0] + lists[0].split(" ")[1])
dct = {str(i * i): "A" for i in range(0, 10000, 1)}
if str(num) in dct:
print("yes")
else:
print("no")
|
s304949692
|
Accepted
| 21
| 4,088
| 203
|
lists=[input() for i in range(1)]
num = int(lists[0].split(" ")[0] + lists[0].split(" ")[1])
dct = {str(i * i): "A" for i in range(0, 10000, 1)}
if str(num) in dct:
print("Yes")
else:
print("No")
|
s328930872
|
p03433
|
u330176731
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 99
|
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
n = [int(input()) for n in range(2)]
if n[0] % 500 == n[1]:
print('Yes')
else:
print('No')
|
s202883952
|
Accepted
| 20
| 2,940
| 51
|
print(['Yes','No'][int(input())%500>int(input())])
|
s047360311
|
p03680
|
u672494157
| 2,000
| 262,144
|
Wrong Answer
| 22
| 3,700
| 657
|
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i. When Button i is not lighten up, nothing will happen by pressing it. Initially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up. Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.
|
import functools
def inputs(num_of_input):
ins = [input() for i in range(num_of_input)]
return ins
def solve(inputs):
a = list(map(lambda x: int(x), inputs))
a[1] = -1
return wh(a, 2, 0)
def wh(a, search, count):
counts = []
if search == 1:
return count
for i, value in enumerate(a):
if value == search:
counts.append(wh(a, i + 1, count + 1))
counts_ignore_minus = list(filter(lambda x: x != -1, counts))
if len(counts_ignore_minus) == 0:
return -1
min = counts_ignore_minus[0]
for c in counts_ignore_minus:
if min > c:
min = c
return min
|
s618961070
|
Accepted
| 181
| 13,980
| 502
|
import functools
def inputs(num_of_input):
ins = [input() for i in range(num_of_input)]
return ins
def solve(inputs):
a = list(map(lambda x: int(x), inputs))
count = 0
light = 1
N = len(a)
while 1:
next_light = a[light - 1]
count += 1
if next_light == 2:
return count
elif count > N:
return -1
light = next_light
if __name__ == "__main__":
N = int(input())
ret = solve(inputs(N))
print(ret)
|
s905452453
|
p03050
|
u054556734
| 2,000
| 1,048,576
|
Wrong Answer
| 158
| 3,324
| 149
|
Snuke received a positive integer N from Takahashi. A positive integer m is called a _favorite number_ when the following condition is satisfied: * The quotient and remainder of N divided by m are equal, that is, \lfloor \frac{N}{m} \rfloor = N \bmod m holds. Find all favorite numbers and print the sum of those.
|
import math as m
n = int(input())
ans = 0
for i in range(1,m.ceil(m.sqrt(n))):
if n%i==0: ans += n//i -1; print(i)
print(ans)
|
s528272149
|
Accepted
| 170
| 2,940
| 202
|
import math as m
n = int(input())
ans = 0
for i in range(1,m.ceil(m.sqrt(n))):
if n%i==0:
if n//i == i+1 : break
ans += n//i -1
if n in [1,2]: ans = 0
print(ans)
|
s658605096
|
p02678
|
u711295009
| 2,000
| 1,048,576
|
Wrong Answer
| 1,448
| 40,172
| 845
|
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
|
class queue:
listQ = []
def push(self, x):
self.listQ.append(x)
def pop(self):
a = self.listQ[0]
del self.listQ[0]
return a
def length(self):
return len(self.listQ)
n, m = map(int, input().split())
nodeMap = {}
doneL = [0]*(n+1)
doneL[1] = -1
for i in range(m):
a, b = map(int, input().split())
if a in nodeMap:
nodeMap[a].append(b)
else:
nodeMap[a] = [b]
if b in nodeMap:
nodeMap[b].append(a)
else:
nodeMap[b] = [a]
q = queue()
q.push(1)
while q.length():
poped = q.pop()
popedL = nodeMap[poped]
for r in popedL:
print(r)
if doneL[r] != 0:
pass
else:
doneL[r] = poped
q.push(r)
print("Yes")
for r in doneL:
if r <= 0:
pass
else:
print(r)
|
s593011186
|
Accepted
| 1,467
| 40,008
| 828
|
class queue:
listQ = []
def push(self, x):
self.listQ.append(x)
def pop(self):
a = self.listQ[0]
del self.listQ[0]
return a
def length(self):
return len(self.listQ)
n, m = map(int, input().split())
nodeMap = {}
doneL = [0]*(n+1)
doneL[1] = -1
for i in range(m):
a, b = map(int, input().split())
if a in nodeMap:
nodeMap[a].append(b)
else:
nodeMap[a] = [b]
if b in nodeMap:
nodeMap[b].append(a)
else:
nodeMap[b] = [a]
q = queue()
q.push(1)
while q.length():
poped = q.pop()
popedL = nodeMap[poped]
for r in popedL:
if doneL[r] != 0:
pass
else:
doneL[r] = poped
q.push(r)
print("Yes")
for r in doneL:
if r <= 0:
pass
else:
print(r)
|
s526044520
|
p03351
|
u939757770
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 139
|
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
|
a,b,c,d=map(int,input().split())
if abs(c-a)<=d:
print("Yes")
elif abs(a-b)<=d and abs(b-c)<=0:
print("Yes")
else:
print("No")
|
s709923481
|
Accepted
| 17
| 3,060
| 139
|
a,b,c,d=map(int,input().split())
if abs(c-a)<=d:
print("Yes")
elif abs(a-b)<=d and abs(b-c)<=d:
print("Yes")
else:
print("No")
|
s306033033
|
p02663
|
u883674141
| 2,000
| 1,048,576
|
Wrong Answer
| 22
| 9,168
| 130
|
In this problem, we use the 24-hour clock. Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study for K consecutive minutes while he is up. What is the length of the period in which he can start studying?
|
a = list(map(int,input().split()))
x = a[0]*60 + a[1]
y = a[2]*60 + a[3]
z = x - y
r = z - a[4]
if r <= 0:
r = 0
print(r)
|
s069696446
|
Accepted
| 21
| 9,164
| 108
|
a = list(map(int,input().split()))
x = a[0]*60 + a[1]
y = a[2]*60 + a[3]
z = y - x
r = z - a[4]
print(r)
|
s735820126
|
p02843
|
u626228246
| 2,000
| 1,048,576
|
Wrong Answer
| 31
| 9,108
| 86
|
AtCoder Mart sells 1000000 of each of the six items below: * Riceballs, priced at 100 yen (the currency of Japan) each * Sandwiches, priced at 101 yen each * Cookies, priced at 102 yen each * Cakes, priced at 103 yen each * Candies, priced at 104 yen each * Computers, priced at 105 yen each Takahashi wants to buy some of them that cost exactly X yen in total. Determine whether this is possible. (Ignore consumption tax.)
|
x = int(input())
n = x//100
x -= n*100
if 5*n >= x:
print("Yes")
else:
print("No")
|
s961670472
|
Accepted
| 31
| 9,160
| 83
|
x = int(input())
n = x//100
x -= n*100
if 5*n >= x:
print("1")
else:
print("0")
|
s470380825
|
p03475
|
u059210959
| 3,000
| 262,144
|
Wrong Answer
| 477
| 24,472
| 919
|
A railroad running from west to east in Atcoder Kingdom is now complete. There are N stations on the railroad, numbered 1 through N from west to east. Tomorrow, the opening ceremony of the railroad will take place. On this railroad, for each integer i such that 1≤i≤N-1, there will be trains that run from Station i to Station i+1 in C_i seconds. No other trains will be operated. The first train from Station i to Station i+1 will depart Station i S_i seconds after the ceremony begins. Thereafter, there will be a train that departs Station i every F_i seconds. Here, it is guaranteed that F_i divides S_i. That is, for each Time t satisfying S_i≤t and t%F_i=0, there will be a train that departs Station i t seconds after the ceremony begins and arrives at Station i+1 t+C_i seconds after the ceremony begins, where A%B denotes A modulo B, and there will be no other trains. For each i, find the earliest possible time we can reach Station N if we are at Station i when the ceremony begins, ignoring the time needed to change trains.
|
# encoding:utf-8
import copy
import numpy as np
import random
N = int(input())
n = N
C = []
S = []
F = []
for i in range(n-1):
c,s,f = map(int, input().split())
C.append(c)
S.append(s)
F.append(f)
answer = []
for i in list(reversed(range(n))):
if i == n-1:
answer.append(0)
elif i == n-2:
answer.insert(0,C[i]+S[i])
else:
to_next_station = C[i]+S[i]
if to_next_station > S[i+1]:
if to_next_station % F[i+1] == 0:
to_goal = to_next_station+answer[0]-S[i+1]
else:
to_goal = ((to_next_station//F[i+1])+1)*F[i+1]+answer[0]-S[i+1]
to_goal = min(to_goal,answer[0])
elif to_next_station == S[i+1]:
to_goal =to_next_station+answer[0]-C[i+1]
else:
to_goal = answer[0]
# print(to_goal)
answer.insert(0,to_goal)
for i in answer:
print(i)
|
s509696286
|
Accepted
| 238
| 13,520
| 632
|
# encoding:utf-8
import copy
import numpy as np
import random
N = int(input())
n = N
C = []
S = []
F = []
for i in range(n-1):
c,s,f = map(int, input().split())
C.append(c)
S.append(s)
F.append(f)
answer = []
for i in range(n-1):
to_goal = C[i] + S[i]
for j in range(i+1,n-1):
if to_goal >= S[j]:
if to_goal % F[j] == 0:
to_goal += C[j]
else:
to_goal = ((to_goal//F[j])+1)*F[j]+C[j]
elif to_goal < S[j]:
to_goal = S[j]+C[j]
answer.append(to_goal)
answer.append(0)
for i in range(len(answer)):
print(answer[i])
|
s641789637
|
p03719
|
u729133443
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 60
|
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('YNeos'[a<c or c>b::2])
|
s743725816
|
Accepted
| 26
| 8,968
| 58
|
a,b,c=map(int,input().split())
print('NYoe s'[a<=c<=b::2])
|
s000355991
|
p02381
|
u179070318
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,644
| 176
|
You have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn. The variance α2 is defined by α2 = (∑n _i_ =1(s _i_ \- m)2)/n where m is an average of si. The standard deviation of the scores is the square root of their variance.
|
n = int(input())
scores = [int(x) for x in input().split()]
ave = sum(scores)/n
resi = 0
for s in scores:
resi += (s-ave)**2
sd = (resi/n)**0.5
print('{:.6f}'.format(sd))
|
s254442229
|
Accepted
| 20
| 5,684
| 253
|
while True:
n = int(input())
if n == 0:
break
else:
score = [int(x) for x in input().split()]
a = 0
m = sum(score)/n
for s in score:
a += (s-m)**2
a = (a/n)**0.5
print('{:.8f}'.format(a))
|
s725125659
|
p04031
|
u503901534
| 2,000
| 262,144
|
Wrong Answer
| 21
| 3,060
| 263
|
Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2). Find the minimum total cost to achieve his objective.
|
n = int(input())
nlist= list(map(int,input().split()))
nmax = max(nlist)
nmin = min(nlist)
costs = []
for i in range(len(nlist)):
p = 0
for j in range(len(nlist)):
p = p + (nlist[i]-nlist[j]) ** 2
costs.append(p)
print(min(costs))
|
s402252587
|
Accepted
| 25
| 3,060
| 259
|
n = int(input())
nlist= list(map(int,input().split()))
nmax = max(nlist)
nmin = min(nlist)
costs = []
for i in range(nmin,nmax + 1):
p = 0
for j in range(len(nlist)):
p = p + (i-nlist[j]) ** 2
costs.append(p)
print(min(costs))
|
s580453896
|
p03854
|
u343128979
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,188
| 256
|
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 main():
S = input()
T = 'dream', 'dreamer', 'erase', 'eraser'
for t in T:
print(t)
S = S.strip(t)
if len(S) > 0:
ans = 'NO'
else:
ans = 'YES'
print(ans)
if __name__ == '__main__':
main()
|
s681678797
|
Accepted
| 71
| 3,188
| 463
|
def main():
S = input()
S = S[::-1]
_T = 'dreamer', 'dream', 'eraser', 'erase'
T = []
for t in _T:
T.append(t[::-1])
i = 0
while 1:
temp = []
bool = True
for t in T:
if S[:len(t)] == t:
S = S[len(t):]
bool = False
if bool:
break
if len(S) > 0:
print('NO')
else:
print('YES')
if __name__ == '__main__':
main()
|
s803999062
|
p02534
|
u720603143
| 2,000
| 1,048,576
|
Wrong Answer
| 26
| 9,016
| 27
|
You are given an integer K. Print the string obtained by repeating the string `ACL` K times and concatenating them. For example, if K = 3, print `ACLACLACL`.
|
print("abc" * int(input()))
|
s708225942
|
Accepted
| 28
| 9,144
| 27
|
print("ACL" * int(input()))
|
s705261875
|
p03435
|
u036340997
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 285
|
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j. Determine if he is correct.
|
c = []
for i in range(3):
c.append(list(map(int, input().split())))
d = []
for i in range(3):
sum = 0
d.append([])
for j in range(3):
sum += c[i][j]
for j in range(3):
d[i].append(c[i][j] - sum/3)
if d[0]==d[1] and d[1]==d[2]:
print('Yes')
else:
print('No')
|
s608949024
|
Accepted
| 17
| 3,064
| 347
|
c = []
for i in range(3):
c.append(list(map(int, input().split())))
d = []
for i in range(3):
sum = 0
d.append([])
for j in range(3):
sum += c[i][j]
for j in range(3):
d[i].append(3*c[i][j] - sum)
for i in range(3):
if d[0][i]==d[1][i] and d[0][i]==d[2][i]:
pass
else:
print('No')
break
else:
print('Yes')
|
s746499998
|
p02268
|
u826549974
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,596
| 527
|
You are given a sequence of _n_ integers S and a sequence of different _q_ integers T. Write a program which outputs C, the number of integers in T which are also in the set S.
|
def half(a,b,low,high):
if(low > high):
return 0
c = int((low+high)/2)
if(a[c] == b):
return 1
elif(a[c] < b):
return half(a,b,c,high-1)
elif(a[c] > b):
return half(a,b,low+1,c)
else:
return 1
#############################
n = int(input())
s = list(map(int,input().split()))
q = int(input())
r = list(map(int,input().split()))
cou = 0
for i in range(q):
cou += half(s,r[i],0,len(s))
print(cou)
|
s287509913
|
Accepted
| 500
| 16,712
| 498
|
############################
def half(a,b,low,high):
if(low > high):
return 0
c = int((low+high)/2)
if(a[c] == b):
return 1
elif(a[c] < b):
return half(a,b,c+1,high)
elif(a[c] > b):
return half(a,b,low,c-1)
#############################
n = int(input())
s = list(map(int,input().split()))
q = int(input())
r = list(map(int,input().split()))
cou = 0
for i in range(q):
cou += half(s,r[i],0,n-1)
print(cou)
|
s816228262
|
p03565
|
u254871849
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 501
|
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`.
|
from sys import stdin
s, t = stdin.read().split()
s = list(s)
possible_indexes = []
for i in range(len(s) - len(t) + 1):
substring = s[i: i+len(t)]
for j in range(len(t)):
if substring[j] == t[j] or substring[j] == '?': continue
else: break
else:
possible_indexes.append(i)
if not possible_indexes: print('UNRESTORABLE'); exit()
ma = max(possible_indexes)
for j in range(len(t)):
s[ma+j] = t[j]
print(s)
s = ''.join(s)
s = s.replace('?', 'a')
print(s)
|
s032328711
|
Accepted
| 17
| 3,064
| 482
|
import sys
s, t = sys.stdin.read().split()
n = len(s); m = len(t)
s = list(s)
def main():
for i in range(n - m, -1, -1):
for j in range(m):
if t[j] != s[i+j] != '?':
break
else:
for j in range(m):
s[i+j] = t[j]
for i in range(n):
if s[i] == '?': s[i] = 'a'
print(''.join(s))
return
print('UNRESTORABLE')
if __name__ == '__main__':
main()
|
s046030384
|
p03370
|
u089376182
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 156
|
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
|
n, x = map(int, input().split())
material_list = []
for i in range(n):
m = int(input())
x -= m
material_list.append(m)
print(x//min(material_list))
|
s854522652
|
Accepted
| 17
| 3,060
| 158
|
n, x = map(int, input().split())
material_list = []
for i in range(n):
m = int(input())
x -= m
material_list.append(m)
print(x//min(material_list)+n)
|
s953029263
|
p02659
|
u965397031
| 2,000
| 1,048,576
|
Wrong Answer
| 29
| 9,144
| 90
|
Compute A \times B, truncate its fractional part, and print the result as an integer.
|
a, b = input().split()
a = int(a)
b = float(b)
print(b)
import math
print(math.floor(a*b))
|
s702125913
|
Accepted
| 34
| 10,052
| 105
|
from decimal import Decimal
from math import floor
a, b = map(Decimal, input().split())
print(floor(a*b))
|
s771623367
|
p03759
|
u228223940
| 2,000
| 262,144
|
Wrong Answer
| 29
| 9,032
| 82
|
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
|
a,b,c = map(int,input().split())
if b-a == c-a:
print('YES')
else:
print('NO')
|
s325079905
|
Accepted
| 29
| 9,100
| 82
|
a,b,c = map(int,input().split())
if b-a == c-b:
print('YES')
else:
print('NO')
|
s393436808
|
p03635
|
u598684283
| 2,000
| 262,144
|
Wrong Answer
| 25
| 9,112
| 52
|
In _K-city_ , there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?
|
a,b = map(int, input().split())
print(a - 1 * b - 1)
|
s807037153
|
Accepted
| 25
| 9,100
| 56
|
a,b = map(int, input().split())
print((a - 1) * (b - 1))
|
s348722166
|
p03457
|
u081784777
| 2,000
| 262,144
|
Wrong Answer
| 334
| 3,060
| 200
|
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
|
n = int(input())
flag = 0
for _ in range(n):
t, x, y = map(int, input().split())
if t%2 == (x+y)%2 and t >= (x+y):
continue
else:
flag = 1
print('YES') if not flag else print('NO')
|
s498784847
|
Accepted
| 331
| 3,060
| 200
|
n = int(input())
flag = 0
for _ in range(n):
t, x, y = map(int, input().split())
if t%2 == (x+y)%2 and t >= (x+y):
continue
else:
flag = 1
print('Yes') if not flag else print('No')
|
s208460580
|
p03129
|
u698176039
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 91
|
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
|
N,K = map(int,input().split())
if (N+1)/2 > K:
print('Yes')
else:
print('No')
|
s476141501
|
Accepted
| 19
| 3,060
| 92
|
N,K = map(int,input().split())
if (N+1)/2 >= K:
print('YES')
else:
print('NO')
|
s655975113
|
p02409
|
u193453446
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,680
| 505
|
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left. Assume that initially no person lives in the building.
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
rooms = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
number = int(input())
for n in range(number):
inp = input().split(" ")
b = int(inp[0]) - 1
f = int(inp[1]) - 1
r = int(inp[2]) - 1
v = int(inp[3])
rooms[b][f][r] += v
for b in range(4):
if b > 0:
print("##########")
for f in range(3):
for r in range(10):
print(rooms[b][f][r], end = "")
print()
|
s581189196
|
Accepted
| 20
| 7,676
| 478
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
rooms = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
number = int(input())
for n in range(number):
inp = input().split(" ")
b = int(inp[0]) - 1
f = int(inp[1]) - 1
r = int(inp[2]) - 1
v = int(inp[3])
rooms[b][f][r] += v
for b in range(4):
if b > 0:
print("####################")
for f in range(3):
print(""," ".join(map(str,rooms[b][f])))
|
s511020806
|
p02972
|
u025501820
| 2,000
| 1,048,576
|
Wrong Answer
| 2,109
| 20,688
| 403
|
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
|
import numpy as np
N = int(input())
a = list(map(int, input().split()))
box = np.array([0 for _ in range(N + 1)])
for i in range(1, N + 1)[:: -1]:
k = 1
sum = 0
while i * k <= N:
sum += box[i * k]
k += 1
if sum % 2 != a[i - 1]:
box[i] = 1
box = box[1:]
if np.count_nonzero(box) > 0:
ans = " ".join([str(i) for i in box[box > 0]])
else:
ans = 0
print(ans)
|
s536141653
|
Accepted
| 889
| 19,896
| 381
|
N = int(input())
a = list(map(int, input().split()))
box = [0 for _ in range(N + 1)]
ans = []
for i in range(1, N + 1)[:: -1]:
k = 1
my_sum = 0
while i * k <= N:
my_sum += box[i * k]
k += 1
if my_sum % 2 != a[i - 1]:
box[i] = 1
ans.append(i)
if len(ans) > 0:
print(len(ans))
print(" ".join(map(str, ans)))
else:
print(0)
|
s937325408
|
p03024
|
u517152997
| 2,000
| 1,048,576
|
Wrong Answer
| 388
| 21,636
| 244
|
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day. Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
|
# -*- coding: utf-8 -*-
#
import math
import sys
import itertools
import numpy as np
#
sumo = list(input())
lose = 0
for i in range(len(sumo)):
if sumo[i] == 'x':
lose += 1
if lose >= 8:
print("No")
else:
print("Yes")
|
s534877894
|
Accepted
| 148
| 12,408
| 244
|
# -*- coding: utf-8 -*-
#
import math
import sys
import itertools
import numpy as np
#
sumo = list(input())
lose = 0
for i in range(len(sumo)):
if sumo[i] == 'x':
lose += 1
if lose >= 8:
print("NO")
else:
print("YES")
|
s271171993
|
p03544
|
u798675549
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 918
|
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2)
|
print([2,1,3,4,7,11,18,29,47,76,123,199,322,521,843,1364,2207,3571,5778,9349,15127,24476,39603,64079,103682,167761,271443,439204,710647,1149851,1860498,3010349,4870847,7881196,12752043,20633239,33385282,54018521,87403803,141422324,228826127,370248451,599074578,969323029,1568397607,2537720636,4106118243,6643838879,10749957122,17393796001,28143753123,45537549124,73681302247,119218851371,192900153618,312119004989,505019158607,817138163596,1322157322203,2139295485799,3461452808002,5600748293801,9062201101803,14662949395604,23725150497407,38388099893011,62113250390418,100501350283429,162614600673847,263115950957276,425730551631123,688846502588399,1114577054219522,1803423556807921,2918000611027443,4721424167835364,7639424778862807,12360848946698171,20000273725560978,32361122672259149,52361396397820127,84722519070079276,137083915467899403,221806434537978679,358890350005878082,580696784543856761][int(input())-1])
|
s269401430
|
Accepted
| 17
| 3,188
| 935
|
print([2,1,3,4,7,11,18,29,47,76,123,199,322,521,843,1364,2207,3571,5778,9349,15127,24476,39603,64079,103682,167761,271443,439204,710647,1149851,1860498,3010349,4870847,7881196,12752043,20633239,33385282,54018521,87403803,141422324,228826127,370248451,599074578,969323029,1568397607,2537720636,4106118243,6643838879,10749957122,17393796001,28143753123,45537549124,73681302247,119218851371,192900153618,312119004989,505019158607,817138163596,1322157322203,2139295485799,3461452808002,5600748293801,9062201101803,14662949395604,23725150497407,38388099893011,62113250390418,100501350283429,162614600673847,263115950957276,425730551631123,688846502588399,1114577054219522,1803423556807921,2918000611027443,4721424167835364,7639424778862807,12360848946698171,20000273725560978,32361122672259149,52361396397820127,84722519070079276,137083915467899403,221806434537978679,358890350005878082,580696784543856761,939587134549734843][int(input())])
|
s665712401
|
p03693
|
u691896522
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 101
|
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
|
k = "".join(list((input().split())))
k = int(k)
if k % 4 == 0:
print("Yes")
else:
print("No")
|
s323449316
|
Accepted
| 17
| 2,940
| 101
|
k = "".join(list((input().split())))
k = int(k)
if k % 4 == 0:
print("YES")
else:
print("NO")
|
s179110827
|
p02678
|
u494058663
| 2,000
| 1,048,576
|
Wrong Answer
| 679
| 35,152
| 516
|
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
|
from collections import deque
import copy
n,m = map(int,input().split())
Map = [[]for i in range(n)]
for i in range(m):
a,b = map(int,input().split())
Map[a-1].append(b-1)
Map[b-1].append(a-1)
Visited = [False for i in range(n)]
depth = [0 for i in range(n)]
q = deque()
q.append(0)
while q:
st = q.popleft()
for i in Map[st]:
if Visited[i]==True:
continue
depth[i] = depth[st]+1
Visited[i] = True
q.append(i)
for i in range(1,n):
print(depth[i])
|
s855372421
|
Accepted
| 798
| 38,740
| 709
|
from collections import deque
import copy
n,m = map(int,input().split())
Map = [[]for i in range(n)]
for i in range(m):
a,b = map(int,input().split())
Map[a-1].append(b-1)
Map[b-1].append(a-1)
Visited = [False for i in range(n)]
depth = [0 for i in range(n)]
q = deque()
q.append(0)
while q:
st = q.popleft()
for i in Map[st]:
if Visited[i]==True:
continue
depth[i] = depth[st]+1
Visited[i] = True
q.append(i)
ans = []
depth[0] = 0
for i in range(1,n):
for j in Map[i]:
if depth[i]-1==depth[j]:
ans.append(j+1)
break
if len(ans)==0:
print('No')
else:
print('Yes')
for i in ans:
print(i)
|
s219324092
|
p03636
|
u949315872
| 2,000
| 262,144
|
Wrong Answer
| 26
| 9,096
| 134
|
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
|
import sys
input = sys.stdin.readline
#-------------
S = input()
#-------------
S = list(S)
n = len(S)
print(S[0] + str(n-2) + S[n-1])
|
s057331967
|
Accepted
| 24
| 8,952
| 81
|
S = input()
#-------------
S = list(S)
n = len(S)
print(S[0] + str(n-2) + S[n-1])
|
s139893124
|
p02743
|
u610326327
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 2,940
| 125
|
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?
|
import math
abc = input().split(' ')
a = abc[0]
b = abc[1]
c = abc[2]
if a + b < c:
print('Yes')
else:
print('No')
|
s370673956
|
Accepted
| 34
| 5,076
| 227
|
import decimal
import math
abc = input().split(' ')
a = int(abc[0])
b = int(abc[1])
c = int(abc[2])
if decimal.Decimal(a).sqrt() + decimal.Decimal(b).sqrt() < decimal.Decimal(c).sqrt():
print('Yes')
else:
print('No')
|
s094475435
|
p03478
|
u572271833
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 235
|
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).
|
### coding: UTF-8
#import math
#import random as rd
#import numpy as np
#n,a,b=map(int,input().split( ))
n=100
a=4
b=16
s=0
for i in range(n):
line=list(map(int,str(i+1)))
if sum(line)>=a and sum(line)<=b:
s+=i+1
|
s941555057
|
Accepted
| 38
| 3,060
| 229
|
### coding: UTF-8
#import math
#import random as rd
#import numpy as np
n,a,b=map(int,input().split( ))
s=0
for i in range(n):
line=list(map(int,str(i+1)))
if sum(line)>=a and sum(line)<=b:
s+=i+1
print(s)
|
s661244255
|
p03689
|
u556812955
| 2,000
| 262,144
|
Wrong Answer
| 130
| 3,828
| 384
|
You are given four integers: H, W, h and w (1 ≤ h ≤ H, 1 ≤ w ≤ W). Determine whether there exists a matrix such that all of the following conditions are held, and construct one such matrix if the answer is positive: * The matrix has H rows and W columns. * Each element of the matrix is an integer between -10^9 and 10^9 (inclusive). * The sum of all the elements of the matrix is positive. * The sum of all the elements within every subrectangle with h rows and w columns in the matrix is negative.
|
H, W, h, w = map(int, input().split())
if H % h == 0 or W % w == 0:
print("No")
exit(0)
blocks = (H//h) * (W//w)
left = H * W - blocks * h * w
offset = blocks // left + 1
v = [offset, -offset * h * w - 1]
print("Yes")
for i in range(H):
a = []
for j in range(W):
a.append(v[1 if i % h == h-1 and j % w == w-1 else 0])
print(" ".join(list(map(str, a))))
|
s857897167
|
Accepted
| 142
| 4,084
| 391
|
H, W, h, w = map(int, input().split())
if H % h == 0 and W % w == 0:
print("No")
exit(0)
blocks = (H//h) * (W//w)
left = H * W - blocks * h * w
offset = blocks // left + 1
v = [offset, -offset * (h * w - 1) - 1]
print("Yes")
for i in range(H):
a = []
for j in range(W):
a.append(v[1 if i % h == h-1 and j % w == w-1 else 0])
print(" ".join(list(map(str, a))))
|
s306550331
|
p03469
|
u538956308
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 30
|
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 = input()
S[3]=="8"
print(S)
|
s636395539
|
Accepted
| 17
| 2,940
| 31
|
s = input()
print('2018'+s[4:])
|
s108580123
|
p03558
|
u411537765
| 2,000
| 262,144
|
Time Limit Exceeded
| 2,104
| 3,272
| 216
|
Find the smallest possible sum of the digits in the decimal notation of a positive multiple of K.
|
n = input()
def get_sum(n):
s = str(n)
arr = list(map(int, list(s)))
return sum(arr)
ans = get_sum(n)
i = 1
for i in range(1, 10000):
m = get_sum(n * i)
if ans > m:
ans = m
print(ans)
|
s842962953
|
Accepted
| 118
| 6,084
| 487
|
import collections
def ans(n):
dist = [10 ** 5] * n
dist[1] = 1
d = collections.deque()
d.append(1)
while not d.count == 0:
u = d.popleft()
if u == 0:
return dist[u]
if dist[u] < dist[(u * 10) % n]:
dist[(u * 10) % n] = dist[u]
d.appendleft((u * 10) % n)
if dist[u] < dist[(u + 1) % n]:
dist[(u + 1) % n] = dist[u] + 1
d.append((u + 1) % n)
n = int(input())
print(ans(n))
|
s377047659
|
p03371
|
u170849169
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 388
|
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.
|
if __name__ == '__main__':
A, B, C, X, Y = list(map(int, input().split()))
if A + B < 2 * C:
print(1)
print(A * X + B * Y)
else:
if X == Y:
print(2)
print(C * 2 * X)
elif X < Y:
print(3)
print(X * C * 2 + B * (Y - X))
else:
print(4)
print(Y * C * 2 + A * (X - Y))
|
s155486127
|
Accepted
| 19
| 3,060
| 429
|
if __name__ == '__main__':
A, B, C, X, Y = list(map(int, input().split()))
if A + B <= 2 * C:
# print(1)
print(A * X + B * Y)
else:
if X == Y:
# print(2)
print(C * 2 * X)
elif X < Y:
# print(3)
print(min(X * C * 2 + B * (Y - X), C * 2 * Y))
else:
# print(4)
print(min(Y * C * 2 + A * (X - Y), C * 2 * X))
|
s311247057
|
p03693
|
u544050502
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 64
|
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
|
s=int(input().replace(" ",""))
print("YES" if s//4==0 else "NO")
|
s703178498
|
Accepted
| 18
| 2,940
| 49
|
s=int(input()[::2])
print("NO" if s%4 else "YES")
|
s315271873
|
p01981
|
u998437062
| 8,000
| 262,144
|
Wrong Answer
| 20
| 5,592
| 218
|
平成31年4月30日をもって現行の元号である平成が終了し,その翌日より新しい元号が始まることになった.平成最後の日の翌日は新元号元年5月1日になる. ACM-ICPC OB/OGの会 (Japanese Alumni Group; JAG) が開発するシステムでは,日付が和暦(元号とそれに続く年数によって年を表現する日本の暦)を用いて "平成 _y_ 年 _m_ 月 _d_ 日" という形式でデータベースに保存されている.この保存形式は変更することができないため,JAGは元号が変更されないと仮定して和暦で表した日付をデータベースに保存し,出力の際に日付を正しい元号を用いた形式に変換することにした. あなたの仕事はJAGのデータベースに保存されている日付を,平成または新元号を用いた日付に変換するプログラムを書くことである.新元号はまだ発表されていないため,"?" を用いて表すことにする.
|
while True:
line = input()
if line == '#':
exit()
g = line.split()[0]
y, m, d = map(int, line.split()[1:])
if y > 31:
g = '?'
elif m > 4:
g = '?'
print(g, y, m, d)
|
s489470964
|
Accepted
| 30
| 5,596
| 224
|
while True:
line = input()
if line == '#':
exit()
g = line.split()[0]
y, m, d = map(int, line.split()[1:])
if y > 31 or y >= 31 and m >= 5:
g = '?'
y -= 30
print(g, y, m, d)
|
s118892603
|
p02612
|
u416011173
| 2,000
| 1,048,576
|
Wrong Answer
| 27
| 9,136
| 123
|
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.
|
# -*- coding: utf-8 -*-
N = int(input())
ans = N % 1000
print(ans)
|
s383287435
|
Accepted
| 26
| 9,180
| 501
|
# -*- coding: utf-8 -*-
def get_input() -> int:
N = int(input())
return N
def main(N: int) -> None:
ans = (1000 - (N % 1000)) % 1000
print(ans)
if __name__ == "__main__":
N = get_input()
main(N)
|
s049498533
|
p02259
|
u547492399
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,752
| 411
|
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 bubbleSort(A, N):
swap_count = 0
flag = True
while flag:
flag = False
for j in range(N-1, 0, -1):
if A[j] < A[j-1]:
A[j], A[j-1] = A[j-1], A[j]
flag = True
swap_count += 1
print(A)
return swap_count
n = int(input())
A = list(map(int, input().split()))
count = bubbleSort(A,n)
print(*A)
print(count)
|
s038321743
|
Accepted
| 20
| 7,760
| 386
|
def bubbleSort(A, N):
swap_count = 0
flag = True
while flag:
flag = False
for j in range(N-1, 0, -1):
if A[j] < A[j-1]:
A[j], A[j-1] = A[j-1], A[j]
flag = True
swap_count += 1
return swap_count
n = int(input())
A = list(map(int, input().split()))
count = bubbleSort(A,n)
print(*A)
print(count)
|
s869691751
|
p02615
|
u813993459
| 2,000
| 1,048,576
|
Wrong Answer
| 120
| 31,548
| 73
|
Quickly after finishing the tutorial of the online game _ATChat_ , you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the **friendliness** of Player i is A_i. The N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere. When each player, except the first one to arrive, arrives at the place, the player gets **comfort** equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0. What is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?
|
input()
a=list(map(int,input().split()))
a.sort(reverse=True)
sum(a[:-1])
|
s698750373
|
Accepted
| 218
| 35,452
| 283
|
input()
a=list(map(int,input().split()))
a.sort(reverse=True)
import collections
count=len(a)
ans=0
c = collections.Counter(a)
for i in c.keys():
tmp = c[i]*2
if count<=tmp:
ans+=i*count
break
else:
ans+=i*tmp
count-=tmp
print(ans-max(a))
|
s542649415
|
p03599
|
u151785909
| 3,000
| 262,144
|
Wrong Answer
| 426
| 4,996
| 574
|
Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations. * Operation 1: Pour 100A grams of water into the beaker. * Operation 2: Pour 100B grams of water into the beaker. * Operation 3: Put C grams of sugar into the beaker. * Operation 4: Put D grams of sugar into the beaker. In our experimental environment, E grams of sugar can dissolve into 100 grams of water. Snuke will make sugar water with the highest possible density. The beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker. Find the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it. If there is more than one candidate, any of them will be accepted. We remind you that the sugar water that contains a grams of water and b grams of sugar is \frac{100b}{a + b} percent. Also, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.
|
a,b,c,d,e,f = map(int, input().split())
s_max = f*e//(e+100)
w_max = f//(e+100)
s=[]
w=[]
max = 0
ans = []
for i in range(s_max//c+1):
for j in range(s_max//d+1):
if c*i + d*j <= s_max:
s.append(c*i + d*j)
for i in range(w_max//a+1):
for j in range(w_max//b+1):
if 0<a*i + b*j <= w_max:
w.append(a*i + b*j)
for i in range(len(s)):
for j in range(len(w)):
if s[i]/(w[j]*100+s[i])<=e/(e+100) and s[i]/(w[j]*100+s[i])>max:
max = s[i]/(w[j]*100+s[i])
ans = [w[j]*100+s[i],s[i]]
print(ans)
|
s771554621
|
Accepted
| 1,266
| 5,060
| 609
|
a,b,c,d,e,f = map(int, input().split())
s_max = f*e//(e+100)
w_max = f//100
s=[]
w=[]
max = 0
ans = [100*a,0]
for i in range(s_max//c+1):
for j in range(s_max//d+1):
if c*i + d*j <= s_max:
s.append(c*i + d*j)
for i in range(w_max//a+1):
for j in range(w_max//b+1):
if 0<a*i + b*j <= w_max:
w.append(a*i + b*j)
for i in range(len(s)):
for j in range(len(w)):
if s[i]/(w[j]*100+s[i])<=e/(e+100) and s[i]/(w[j]*100+s[i])>=max and w[j]*100+s[i]<=f:
max = s[i]/(w[j]*100+s[i])
ans = [w[j]*100+s[i],s[i]]
print(ans[0],ans[1])
|
s845393661
|
p03130
|
u970198631
| 2,000
| 1,048,576
|
Wrong Answer
| 28
| 9,044
| 245
|
There are four towns, numbered 1,2,3 and 4. Also, there are three roads. The i-th road connects different towns a_i and b_i bidirectionally. No two roads connect the same pair of towns. Other than these roads, there is no way to travel between these towns, but any town can be reached from any other town using these roads. Determine if we can visit all the towns by traversing each of the roads exactly once.
|
list1 =[]
total =0
for i in range(3):
MM = input().split()
a = int(MM[0])
b = int(MM[1])
list1.append(a)
list1.append(b)
for i in range(5):
x = list1.count(i)
if x >2:
total +=1
if total == 0:
print('Yes')
else:
print('No')
|
s384265228
|
Accepted
| 29
| 9,116
| 245
|
list1 =[]
total =0
for i in range(3):
MM = input().split()
a = int(MM[0])
b = int(MM[1])
list1.append(a)
list1.append(b)
for i in range(5):
x = list1.count(i)
if x >2:
total +=1
if total == 0:
print('YES')
else:
print('NO')
|
s936112946
|
p03698
|
u931636178
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 74
|
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
|
s = list(input())
if s == list(set(s)):
print("yes")
else:
print("no")
|
s814791154
|
Accepted
| 18
| 2,940
| 84
|
s = list(input())
if len(s) == len(list(set(s))):
print("yes")
else:
print("no")
|
s666649914
|
p02615
|
u731467249
| 2,000
| 1,048,576
|
Wrong Answer
| 174
| 31,612
| 140
|
Quickly after finishing the tutorial of the online game _ATChat_ , you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the **friendliness** of Player i is A_i. The N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere. When each player, except the first one to arrive, arrives at the place, the player gets **comfort** equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0. What is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?
|
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
print(A)
ans = 0
for i in range(N - 1):
ans += A[i]
print(ans)
|
s087227418
|
Accepted
| 146
| 31,360
| 346
|
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
# print(A)
ans = A[0]
if N >= 3:
a = (N - 2) // 2
b = (N - 2) % 2
# print(a)
# print(b)
if b == 0:
for i in range(a):
ans += (A[i+1] * 2)
else:
for i in range(a):
ans += (A[i+1] * 2)
ans += A[a+1]
print(ans)
|
s602350925
|
p03555
|
u811202694
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 114
|
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
|
a = input()
b = input()
if a[0] == b[2] and a[1] == b[1] and b[0] == a[2]:
print("Yes")
else:
print("No")
|
s855806822
|
Accepted
| 17
| 2,940
| 114
|
a = input()
b = input()
if a[0] == b[2] and a[1] == b[1] and b[0] == a[2]:
print("YES")
else:
print("NO")
|
s291914927
|
p02402
|
u300641790
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,416
| 111
|
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.
|
hoge = int(input())
l = [int(i) for i in input().split()]
mx = max(l)
mn = min(l)
sm = sum(l)
print(mx,mn,sm)
|
s287952835
|
Accepted
| 20
| 8,612
| 111
|
hoge = int(input())
l = [int(i) for i in input().split()]
mn = min(l)
mx = max(l)
sm = sum(l)
print(mn,mx,sm)
|
s637393798
|
p03730
|
u129978636
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 168
|
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())
for i in range(1,101):
if((a * i) % b == c):
print('YES')
exit()
else:
print('NO')
exit()
|
s614565765
|
Accepted
| 18
| 3,060
| 156
|
a, b, c = map( int, input().split())
for i in range(1,101):
if((a * i) % b == c):
print('YES')
exit()
else:
print('NO')
exit()
|
s935856539
|
p02261
|
u203261375
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,604
| 634
|
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).
|
def bubble_sort(A):
for i in range(len(A)):
for j in range(len(A) - 1, i, -1):
if int(A[j][1]) < int(A[j - 1][1]):
A[j], A[j - 1] = A[j - 1], A[j]
return A
def selection_sort(A):
n = len(A)
for i in range(n):
mini = i
for j in range(i, n):
if int(A[j][1]) < int(A[mini][1]):
mini = j
if mini != i:
A[i], A[mini] = A[mini], A[i]
return A
n = int(input())
A = input().split()
B = bubble_sort(A)
C = selection_sort(A)
print(B)
print('Stable')
print(C)
if B == C:
print('Stable')
else:
print('Not stable')
|
s559364614
|
Accepted
| 30
| 6,344
| 726
|
from copy import copy
def bubble_sort(org_A):
A = copy(org_A)
for i in range(len(A)):
for j in range(len(A) - 1, i, -1):
if int(A[j][1]) < int(A[j - 1][1]):
A[j], A[j - 1] = A[j - 1], A[j]
return A
def selection_sort(org_A):
A = copy(org_A)
n = len(A)
for i in range(n):
mini = i
for j in range(i, n):
if int(A[j][1]) < int(A[mini][1]):
mini = j
if mini != i:
A[i], A[mini] = A[mini], A[i]
return A
n = int(input())
A = input().split()
B = bubble_sort(A)
C = selection_sort(A)
print(' '.join(B))
print('Stable')
print(' '.join(C))
if B == C:
print('Stable')
else:
print('Not stable')
|
s026435634
|
p02612
|
u657786757
| 2,000
| 1,048,576
|
Wrong Answer
| 129
| 27,172
| 426
|
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.
|
import sys
import numpy as np
import math
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache
def main():
n = int(input())
print(n%1000)
return 0
if __name__ == "__main__":
main()
|
s933758796
|
Accepted
| 121
| 27,172
| 501
|
import sys
import numpy as np
import math
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache
def main():
n = int(input())
if n % 1000 == 0:
print('0')
else:
print((n // 1000 + 1) * 1000 - n)
return 0
if __name__ == "__main__":
main()
|
s081065911
|
p02408
|
u340503368
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,584
| 229
|
Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers). The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.
|
count = int(input())
cards = []
for i in range(count):
cards.append(input())
capitals = "SHCD"
for j in capitals:
for k in range(1,14):
if (j + " " + str(k)) in cards == False:
print(j + " " + str(k))
|
s968236183
|
Accepted
| 20
| 5,592
| 231
|
count = int(input())
cards = []
for i in range(count):
cards.append(input())
capitals = "SHCD"
for j in capitals:
for k in range(1,14):
if ((j + " " + str(k)) in cards) == False:
print(j + " " + str(k))
|
s352158352
|
p02259
|
u963402991
| 1,000
| 131,072
|
Wrong Answer
| 40
| 7,624
| 244
|
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 BubbleSort(A,n):
for i in range(n):
for j in range(n-1,i,-1):
if A[j] < A[j-1]:
A[j], A[j-1] = A[j-1], A[j]
return A
n = int(input())
A = [int(input()) for i in range(n)]
print (BubbleSort(A,n))
|
s577653690
|
Accepted
| 30
| 7,668
| 324
|
n = int(input())
numbers = list(map(int, input().split(" ")))
cnt = 0
for i in range(n):
for j in range(n - 1, i, -1):
if numbers[j] < numbers[j - 1]:
numbers[j],numbers[j - 1] = numbers[j - 1], numbers[j]
cnt += 1
numbers = map(str, numbers)
print(" ".join(numbers))
print(cnt)
|
s253682492
|
p03693
|
u297399512
| 2,000
| 262,144
|
Wrong Answer
| 24
| 9,156
| 127
|
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
|
r, g, b = map(int, input().split())
answer = r * 100 + g * 10 + b
if answer % 4 == 0:
print('Yes')
else:
print('No')
|
s939879657
|
Accepted
| 28
| 9,028
| 127
|
r, g, b = map(int, input().split())
answer = r * 100 + g * 10 + b
if answer % 4 == 0:
print('YES')
else:
print('NO')
|
s233907607
|
p02612
|
u623814058
| 2,000
| 1,048,576
|
Wrong Answer
| 24
| 9,152
| 24
|
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.
|
print(int(input())%1000)
|
s346323521
|
Accepted
| 27
| 9,104
| 50
|
N=int(input())%1000
print(0 if not(N) else 1000-N)
|
s941029390
|
p03698
|
u382639013
| 2,000
| 262,144
|
Wrong Answer
| 31
| 9,264
| 195
|
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
|
S = input()
import collections
c = collections.Counter(list(S))
ans = "yes"
for i in c.values():
print(i)
if i == 1:
pass
else:
ans = "no"
break
print(ans)
|
s058696854
|
Accepted
| 26
| 9,240
| 182
|
S = input()
import collections
c = collections.Counter(list(S))
ans = "yes"
for i in c.values():
if i == 1:
pass
else:
ans = "no"
break
print(ans)
|
s026215412
|
p03436
|
u773265208
| 2,000
| 262,144
|
Wrong Answer
| 25
| 3,316
| 1,091
|
We have an H \times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j). Snuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares. Before Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game. When the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares. The color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is `.`; if square (i, j) is initially painted by black, s_{i, j} is `#`.
|
from collections import deque
H,W = map(int,input().split())
c =[]
c.append(['#' for _ in range(W+2)])
ans = [[0 for _ in range(W+2)]for _ in range(H+2)]
score = 0
for i in range(H):
tmp = list('#'+input()+'#')
c.append(tmp)
for j in range(W+2):
if tmp[j] == '.':
score += 1
c.append(['#' for _ in range(W+2)])
q = deque()
def bfs(x,y):
q.append([x,y])
while q:
x,y = q.popleft()
if [x,y] == [W,H]:
return ans[H][W]
if c[y][x-1] == '.':
q.append([x-1,y])
ans[y][x-1] = ans[y][x] + 1
c[y][x-1] = '#'
if c[y][x+1] == '.':
q.append([x+1,y])
ans[y][x+1] = ans[y][x] + 1
c[y][x+1] = '#'
if c[y-1][x] == '.':
q.append([x,y-1])
ans[y-1][x] = ans[y][x] + 1
c[y-1][x] = '#'
if c[y+1][x] == '.':
q.append([x,y+1])
ans[y+1][x] = ans[y][x] + 1
c[y+1][x] = '#'
return -1
tmp = bfs(1,1)
if tmp == -1:
print(-1)
else:
print(score - bfs(1,1) - 1)
|
s191003497
|
Accepted
| 25
| 3,444
| 1,086
|
from collections import deque
H,W = map(int,input().split())
c =[]
c.append(['#' for _ in range(W+2)])
ans = [[0 for _ in range(W+2)]for _ in range(H+2)]
score = 0
for i in range(H):
tmp = list('#'+input()+'#')
c.append(tmp)
for j in range(W+2):
if tmp[j] == '.':
score += 1
c.append(['#' for _ in range(W+2)])
q = deque()
def bfs(x,y):
q.append([x,y])
while q:
x,y = q.popleft()
if [x,y] == [W,H]:
return ans[H][W]
if c[y][x-1] == '.':
q.append([x-1,y])
ans[y][x-1] = ans[y][x] + 1
c[y][x-1] = '#'
if c[y][x+1] == '.':
q.append([x+1,y])
ans[y][x+1] = ans[y][x] + 1
c[y][x+1] = '#'
if c[y-1][x] == '.':
q.append([x,y-1])
ans[y-1][x] = ans[y][x] + 1
c[y-1][x] = '#'
if c[y+1][x] == '.':
q.append([x,y+1])
ans[y+1][x] = ans[y][x] + 1
c[y+1][x] = '#'
return -1
tmp = bfs(1,1)
if tmp == -1:
print(-1)
else:
print(score - tmp - 1)
|
s259446344
|
p02281
|
u777299405
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,700
| 832
|
Binary trees are defined recursively. A binary tree _T_ is a structure defined on a finite set of nodes that either * contains no nodes, or * is composed of three disjoint sets of nodes: \- a root node. \- a binary tree called its left subtree. \- a binary tree called its right subtree. Your task is to write a program which perform tree walks (systematically traverse all nodes in a tree) based on the following algorithms: 1. Print the root, the left subtree and right subtree (preorder). 2. Print the left subtree, the root and right subtree (inorder). 3. Print the left subtree, right subtree and the root (postorder). Here, the given binary tree consists of _n_ nodes and evey node has a unique ID from 0 to _n_ -1.
|
n = int(input())
tree = [0] * n
root = set(range(n))
for i in range(n):
node_id, left, right = map(int, input().split())
tree[node_id] = (left, right)
root -= {left, right}
root_node = root.pop()
def preorder(i):
if i == -1:
return
(left, right) = tree[i]
yield i
yield from preorder(left)
yield from preorder(right)
def inorder(i):
if i == -1:
return
(left, right) = tree[i]
yield from inorder(left)
yield i
yield from inorder(right)
def postorder(i):
if i == -1:
return
(left, right) = tree[i]
yield from postorder(left)
yield from postorder(right)
yield i
print("preorder\n ", end="")
print(*preorder(root_node))
print("inorder\n ", end="")
print(*inorder(root_node))
print("postorder\n ", end="")
print(*postorder(root_node))
|
s617632377
|
Accepted
| 20
| 7,776
| 832
|
n = int(input())
tree = [0] * n
root = set(range(n))
for i in range(n):
node_id, left, right = map(int, input().split())
tree[node_id] = (left, right)
root -= {left, right}
root_node = root.pop()
def preorder(i):
if i == -1:
return
(left, right) = tree[i]
yield i
yield from preorder(left)
yield from preorder(right)
def inorder(i):
if i == -1:
return
(left, right) = tree[i]
yield from inorder(left)
yield i
yield from inorder(right)
def postorder(i):
if i == -1:
return
(left, right) = tree[i]
yield from postorder(left)
yield from postorder(right)
yield i
print("Preorder\n ", end="")
print(*preorder(root_node))
print("Inorder\n ", end="")
print(*inorder(root_node))
print("Postorder\n ", end="")
print(*postorder(root_node))
|
s235248337
|
p03555
|
u445404615
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 123
|
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
|
c1 = input()
c2 = input()
if c1[0] == c2[2] and c1[1] == c2[1] and c1[2] == c2[0]:
print('Yes')
else:
print('No')
|
s997532053
|
Accepted
| 17
| 2,940
| 123
|
c1 = input()
c2 = input()
if c1[0] == c2[2] and c1[1] == c2[1] and c1[2] == c2[0]:
print('YES')
else:
print('NO')
|
s868622839
|
p03469
|
u379424722
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 59
|
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.
|
N = list(input())
N[3] = "7"
date = ''.join(N)
print(date)
|
s523696148
|
Accepted
| 17
| 2,940
| 58
|
N = list(input())
N[3] = "8"
date = ''.join(N)
print(date)
|
s244389501
|
p03815
|
u252828980
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 87
|
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7. Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation: * Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward. For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back. Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.
|
n = int(input())
if n%11 != 0:
print(n//11*2+1)
elif n%11 == 0:
print(n//11*2)
|
s801477879
|
Accepted
| 18
| 2,940
| 123
|
n = int(input())
if n%11 >=7:
print(n//11*2+2)
elif n%11 >= 1:
print(n//11*2+1)
elif n%11 == 0:
print(n//11*2)
|
s168323947
|
p03943
|
u134712256
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 76
|
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
s = list(map(int,input().split()))
print("Yes" if s[0]+s[1]==s[2] else "No")
|
s271341653
|
Accepted
| 17
| 2,940
| 85
|
s = list(map(int,input().split()))
s.sort()
print("Yes" if s[0]+s[1]==s[2] else "No")
|
s755722127
|
p03854
|
u210827208
| 2,000
| 262,144
|
Wrong Answer
| 30
| 3,188
| 324
|
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
|
s=input()
s=s[::-1]
X=['maerd','remaerd','esare','resare']
ans='Yes'
i=0
while i<=len(s)-5:
if s[i:i+5] in X:
i+=5
else:
if s[i:i+6] in X:
i+=6
else:
if s[i:i+7] in X:
i+=7
else:
ans='No'
break
print(ans)
|
s356987865
|
Accepted
| 30
| 3,188
| 324
|
s=input()
s=s[::-1]
X=['maerd','remaerd','esare','resare']
ans='YES'
i=0
while i<=len(s)-5:
if s[i:i+5] in X:
i+=5
else:
if s[i:i+6] in X:
i+=6
else:
if s[i:i+7] in X:
i+=7
else:
ans='NO'
break
print(ans)
|
s148747825
|
p02610
|
u595952233
| 2,000
| 1,048,576
|
Wrong Answer
| 708
| 46,716
| 1,037
|
We have N camels numbered 1,2,\ldots,N. Snuke has decided to make them line up in a row. The happiness of Camel i will be L_i if it is among the K_i frontmost camels, and R_i otherwise. Snuke wants to maximize the total happiness of the camels. Find the maximum possible total happiness of the camel. Solve this problem for each of the T test cases given.
|
import heapq
def greedy(limit, n):
ans = 0
hq = []
for i in range(n-1, -1, -1):
for item in limit[i]:
heapq.heappush(hq, -item)
if hq:
ans += -heapq.heappop(hq)
return ans
def solve():
n = int(input())
left = []
limit_l = [[] for i in range(n)]
l_cnt = 0
right = []
limit_r = [[] for i in range(n)]
r_cnt = 0
ans = 0
for i in range(n):
k, l, r = map(int, input().split())
ans += min(l, r)
if l > r:
limit_l[k-1].append(l-r)
l_cnt+=1
else:
if n-k-1 > 0:
limit_r[n-k-1].append(r-l)
else:
pass
r_cnt+=1
ans += greedy(limit_l, n)
ans += greedy(limit_r, n)
print(ans)
return
t = int(input())
for i in range(t):
solve()
|
s846156085
|
Accepted
| 723
| 46,736
| 1,038
|
import heapq
def greedy(limit, n):
ans = 0
hq = []
for i in range(n-1, -1, -1):
for item in limit[i]:
heapq.heappush(hq, -item)
if hq:
ans += -heapq.heappop(hq)
return ans
def solve():
n = int(input())
left = []
limit_l = [[] for i in range(n)]
l_cnt = 0
right = []
limit_r = [[] for i in range(n)]
r_cnt = 0
ans = 0
for i in range(n):
k, l, r = map(int, input().split())
ans += min(l, r)
if l > r:
limit_l[k-1].append(l-r)
l_cnt+=1
else:
if n-k-1 >= 0:
limit_r[n-k-1].append(r-l)
else:
pass
r_cnt+=1
ans += greedy(limit_l, n)
ans += greedy(limit_r, n)
print(ans)
return
t = int(input())
for i in range(t):
solve()
|
s533959945
|
p03534
|
u785578220
| 2,000
| 262,144
|
Wrong Answer
| 27
| 4,340
| 138
|
Snuke has a string S consisting of three kinds of letters: `a`, `b` and `c`. He has a phobia for palindromes, and wants to permute the characters in S so that S will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible.
|
import collections
a=list(input())
c=collections.Counter(a)
t = sorted(list(c.values()))
if t[-1] - t[0] > 1:print("YES")
else:print("NO")
|
s570786544
|
Accepted
| 19
| 3,188
| 135
|
s = input()
a, b, c = [s.count(i) for i in 'abc']
if max(a, b, c) - min(a, b, c) not in [0, 1]:
print('NO')
else:
print('YES')
|
s839323984
|
p03377
|
u393881437
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 77
|
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 = ['a','b','c']
s = list(input())
s.sort()
print('Yes' if a == s else 'No')
|
s700515664
|
Accepted
| 17
| 2,940
| 140
|
a,b,x = list(map(int,input().split()))
if a > x:
print('NO')
else:
if a+b >= x:
print('YES')
else:
print('NO')
|
s775774122
|
p03524
|
u185948224
| 2,000
| 262,144
|
Wrong Answer
| 33
| 9,456
| 158
|
Snuke has a string S consisting of three kinds of letters: `a`, `b` and `c`. He has a phobia for palindromes, and wants to permute the characters in S so that S will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible.
|
from collections import Counter
s = input()
cnt = list(Counter(s).values())
if len(cnt) < 3: cnt.append(0)
print('Yes' if max(cnt) - min(cnt) <= 1 else 'No')
|
s263262595
|
Accepted
| 37
| 9,316
| 158
|
from collections import Counter
s = input()
cnt = list(Counter(s).values())
if len(cnt) < 3: cnt.append(0)
print('YES' if max(cnt) - min(cnt) <= 1 else 'NO')
|
s254164926
|
p03067
|
u219417113
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 105
|
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
|
a,b,c=map(int,input().split())
if (a>b and b>c) or (a<b and b<c):
print("Yes")
else:
print("No")
|
s138758373
|
Accepted
| 17
| 2,940
| 106
|
a,b,c=map(int,input().split())
if (a>c and b<c) or (a<c and b>c):
print("Yes")
else:
print("No")
|
s655501840
|
p04044
|
u941794834
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 142
|
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
|
n,b=list(map(int,input().split()))
a=[]
for i in range(n-1):
x=input()
a.append(x[:-1])
a.append(input())
a.sort()
print("".join(a))
|
s135908542
|
Accepted
| 17
| 3,060
| 93
|
n, l = map(int, input().split())
a = [input() for i in range(n)]
a.sort()
print("".join(a))
|
s119493354
|
p03565
|
u996672406
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 690
|
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 = list(input())
slen = len(s)
t = list(input())
tlen = len(t)
box = []
phase = 0
def check(wh, phase=1):
if wh + phase >= slen:
return False
if s[wh + phase] == "?" or s[wh + phase] == t[phase]:
if phase + 1 == tlen:
return True
return check(wh, phase + 1)
return False
def ume(arr):
tmp = [e for e in arr]
for i, e in enumerate(arr):
if e == "?":
tmp[i] = "a"
return tmp
for i, e in enumerate(s):
if e == t[0]:
print("ge")
if check(i):
box.append(ume(s[:i] + t + s[i + tlen:]))
if not box:
print("UNRESTORABLE")
else:
box.sort
print("".join(box[0]))
|
s526998670
|
Accepted
| 18
| 3,064
| 630
|
s = list(input())
slen = len(s)
t = list(input())
tlen = len(t)
box = []
def check(wh, phase=0):
if wh + phase >= slen:
return False
if s[wh + phase] == "?" or s[wh + phase] == t[phase]:
if phase + 1 == tlen:
return True
return check(wh, phase + 1)
return False
def ume(arr):
tmp = [e for e in arr]
for i, e in enumerate(arr):
if e == "?":
tmp[i] = "a"
return tmp
for i, e in enumerate(s):
if check(i):
box.append(ume(s[:i] + t + s[i + tlen:]))
if not box:
print("UNRESTORABLE")
else:
box.sort
print("".join(box[-1]))
|
s045205673
|
p03544
|
u626468554
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 226
|
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2)
|
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))
n = int(input())
li = [0 for i in range(100)]
li[0]=2
li[1]=1
for i in range(n-1):
li[i+2]=li[i+1]+li[i]
print(li[-1])
#print(li)
|
s976144595
|
Accepted
| 17
| 2,940
| 225
|
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))
n = int(input())
li = [0 for i in range(100)]
li[0]=2
li[1]=1
for i in range(n-1):
li[i+2]=li[i+1]+li[i]
print(li[n])
#print(li)
|
s810839121
|
p03712
|
u319818856
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 232
|
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
|
def picture_frame(H: int, W: int, A: list)->list:
return ['#' * (W+2)] + ['#' + s + '#' for s in A] + ['#' * (W+2)]
if __name__ == "__main__":
H = 0
H, W = map(int, input().split())
A = [input() for _ in range(H)]
|
s523833808
|
Accepted
| 18
| 3,060
| 291
|
def picture_frame(H: int, W: int, A: list)->list:
return ['#' * (W+2)] + ['#' + s + '#' for s in A] + ['#' * (W+2)]
if __name__ == "__main__":
H = 0
H, W = map(int, input().split())
A = [input() for _ in range(H)]
ans = picture_frame(H, W, A)
print('\n'.join(ans))
|
s304270533
|
p03400
|
u924828749
| 2,000
| 262,144
|
Wrong Answer
| 25
| 9,180
| 233
|
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces. Find the number of chocolate pieces prepared at the beginning of the camp.
|
n = int(input())
d,x = [int(t) for t in input().split()]
a = []
for i in range(n):
a.append(int(input()))
res = 0
for i in range(n):
c = a[i]
res += 1
while c < d:
res += 1
c += a[i]
print(i,res)
res += x
print(res)
|
s616807193
|
Accepted
| 28
| 9,184
| 218
|
n = int(input())
d,x = [int(t) for t in input().split()]
a = []
for i in range(n):
a.append(int(input()))
res = 0
for i in range(n):
c = a[i]
res += 1
while c < d:
res += 1
c += a[i]
res += x
print(res)
|
s577973963
|
p03547
|
u923279197
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 379
|
In programming, hexadecimal notation is often used. In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters `A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12, 13, 14 and 15, respectively. In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`, `C`, `D`, `E` or `F`. When X and Y are seen as hexadecimal numbers, which is larger?
|
def changer(x):
if x=='A':
return 1
elif x=='B':
return 2
elif x=='C':
return 3
elif x=='D':
return 4
elif x=='E':
return 5
elif x=='F':
return 6
else:
return 0
a,b=map(str,input().split())
if changer(a)>changer(b):
print('<')
elif changer(a)==changer(b):
print('=')
else:
print('>')
|
s592444696
|
Accepted
| 18
| 3,060
| 379
|
def changer(x):
if x=='A':
return 1
elif x=='B':
return 2
elif x=='C':
return 3
elif x=='D':
return 4
elif x=='E':
return 5
elif x=='F':
return 6
else:
return 0
a,b=map(str,input().split())
if changer(a)>changer(b):
print('>')
elif changer(a)==changer(b):
print('=')
else:
print('<')
|
s787199708
|
p03386
|
u367130284
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 64
|
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 s in range(a,a+k):
print(s)
|
s569469140
|
Accepted
| 18
| 3,064
| 94
|
a,b,k=map(int,input().split());r=range(a,b+1)
for i in sorted(set(r[:k])|set(r[-k:])):print(i)
|
s229361334
|
p03080
|
u100409377
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 156
|
There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat.
|
N=int(input())
r,b=0,0
X=[x for x in input()]
for x in X:
if x=='R':
r+=1
else:
b+=1
if b>r:
print('Yes')
else:
print('No')
|
s013526954
|
Accepted
| 17
| 2,940
| 156
|
N=int(input())
r,b=0,0
X=[x for x in input()]
for x in X:
if x=='R':
r+=1
else:
b+=1
if r>b:
print('Yes')
else:
print('No')
|
s094387174
|
p04043
|
u063346608
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 197
|
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
A,B,C = map(int,input().split())
if A == 5 and B == 5 and C == 7:
print("Yes")
elif B == 5 and C == 5 and A == 7:
print("Yes")
elif C == 5 and A == 5 and B == 7:
print("Yes")
else:
print("No")
|
s260421120
|
Accepted
| 17
| 3,060
| 197
|
A,B,C = map(int,input().split())
if A == 5 and B == 5 and C == 7:
print("YES")
elif B == 5 and C == 5 and A == 7:
print("YES")
elif C == 5 and A == 5 and B == 7:
print("YES")
else:
print("NO")
|
s061016939
|
p00387
|
u435226340
| 1,000
| 262,144
|
Wrong Answer
| 20
| 5,592
| 51
|
Yae joins a journey plan, in which parties will be held several times during the itinerary. She wants to participate in all of them and will carry several dresses with her. But the number of dresses she can carry with her may be smaller than that of the party opportunities. In that case, she has to wear some of her dresses more than once. Fashion-conscious Yae wants to avoid that. At least, she wants to reduce the maximum number of times she has to wear the same dress as far as possible. Given the number of dresses and frequency of parties, make a program to determine how she can reduce the maximum frequency of wearing the most reused dress.
|
A, B = map(int, input().split())
print((B+A-1)/A)
|
s715801637
|
Accepted
| 20
| 5,580
| 52
|
A, B = map(int, input().split())
print((B+A-1)//A)
|
s303866320
|
p03352
|
u396210538
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 3,060
| 235
|
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
|
# from sys import stdin
import math
X = int(input())
ans = 0
for i in range(int(math.sqrt(X))+1):
for x in range(11):
print(i,x)
if i**x < X and i**x > ans:
ans = i**x
print(ans)
|
s777342391
|
Accepted
| 17
| 2,940
| 238
|
# from sys import stdin
import math
X = int(input())
ans = 0
for i in range(int(math.sqrt(X))+1):
for x in range(11):
# print(i,x)
if i**x <= X and i**x > ans:
ans = i**x
print(ans)
|
s969534706
|
p03400
|
u816552564
| 2,000
| 262,144
|
Wrong Answer
| 26
| 9,048
| 119
|
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces. Find the number of chocolate pieces prepared at the beginning of the camp.
|
N = int(input())
D,X = input().split()
x = 0
for n in range(N):
An = int(input())
x += 1+(N-1)//An
print(str(x)+X)
|
s168483791
|
Accepted
| 28
| 9,092
| 130
|
N = int(input())
D,X = input().split()
x = 0
for n in range(N):
An = int(input())
x += 1+(int(D)-1)//An
c = x+int(X)
print(c)
|
s006160887
|
p03160
|
u192042624
| 2,000
| 1,048,576
|
Wrong Answer
| 108
| 14,588
| 390
|
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
|
#frog
N = int(input())
h = list(map(int,input().split()))
dp = [10000000000000] * N
dp[0] = 0
def dpf():
for i in range(1,N):
x = abs( h[i] - h[i-1] ) + dp[i-1]
y = abs( h[i] - h[i-2] ) + dp[i-2]
if x >=y:
dp[i] = y
else:
dp[i] = x
def solve():
dpf()
print(dp)
print(dp[N-1])
if __name__ == "__main__":
solve()
|
s685414187
|
Accepted
| 96
| 13,976
| 376
|
#frog
N = int(input())
h = list(map(int,input().split()))
dp = [10000000000000] * N
dp[0] = 0
def dpf():
for i in range(1,N):
x = abs( h[i] - h[i-1] ) + dp[i-1]
y = abs( h[i] - h[i-2] ) + dp[i-2]
if x >=y:
dp[i] = y
else:
dp[i] = x
def solve():
dpf()
print(dp[N-1])
if __name__ == "__main__":
solve()
|
s229587162
|
p03544
|
u597455618
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 111
|
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2)
|
n = int(input())
l_1 = 2; l_2 = 1;l_n = 3
for i in range(n):
l_1, l_2, l_n = l_2, l_n, (l_1 + l_2)
print(l_1)
|
s885366829
|
Accepted
| 18
| 2,940
| 112
|
n = int(input())
l_0 = 2; l_1 = 1; l_n = 3
for i in range(n):
l_0, l_1, l_n = l_1, l_n, (l_1 + l_n)
print(l_0)
|
s248346598
|
p03814
|
u662430503
| 2,000
| 262,144
|
Wrong Answer
| 34
| 3,516
| 204
|
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.
|
def main():
s=input()
start=0
end=len(s)
for i in range(0,len(s)):
if s[i]=='A':
start=i
break
for i in range(1,len(s)):
if s[-i]=='Z':
end=len(s)-i
break
main()
|
s627131755
|
Accepted
| 32
| 3,512
| 225
|
def main():
s=input()
start=0
end=len(s)
for i in range(0,len(s)):
if s[i]=='A':
start=i
break
for i in range(1,len(s)):
if s[-i]=='Z':
end=len(s)-i
break
print(end-start+1)
main()
|
s309890300
|
p03379
|
u405660020
| 2,000
| 262,144
|
Wrong Answer
| 370
| 26,756
| 283
|
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N.
|
from sys import stdin
input = stdin.readline
n = int(input())
x = list(map(int, input().split()))
x_sorted=sorted(x)
c = (x_sorted[n//2-1]+x_sorted[n//2])/2
print(x_sorted)
for i in range(n):
if x[i]>=c:
print(x_sorted[n//2-1])
else:
print(x_sorted[n//2])
|
s698141391
|
Accepted
| 340
| 25,572
| 267
|
from sys import stdin
input = stdin.readline
n = int(input())
x = list(map(int, input().split()))
x_sorted=sorted(x)
c = (x_sorted[n//2-1]+x_sorted[n//2])/2
for i in range(n):
if x[i]>=c:
print(x_sorted[n//2-1])
else:
print(x_sorted[n//2])
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.