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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s435271266
|
p03644
|
u893209854
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 75
|
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
|
N = int(input())
i = 0
while N % 2 == 0:
i += 1
N = N // 2
print(i)
|
s734316278
|
Accepted
| 17
| 2,940
| 69
|
N = int(input())
i = 0
while 2**i <= N:
i = i + 1
print(2**(i-1))
|
s157416214
|
p03434
|
u181769094
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 194
|
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
|
N=int(input())
list=list(map(int,input().split()))
list=sorted(list)[::-1]
print(list)
A=0
B=0
for i in range(0,len(list)):
if i%2==0:
A=A+list[i]
else:
B=B+list[i]
print(A-B)
|
s048850549
|
Accepted
| 17
| 3,060
| 182
|
N=int(input())
list=list(map(int,input().split()))
list=sorted(list)[::-1]
A=0
B=0
for i in range(0,len(list)):
if i%2==0:
A=A+list[i]
else:
B=B+list[i]
print(A-B)
|
s298125246
|
p03795
|
u631914718
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 241
|
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
|
n = int(input())
import sys
sys.setrecursionlimit(10000000)
def fa(n, memo=dict()):
if n==0 or n == 1:
return 1
elif n in memo.keys():
return memo[n]
else:
temp = fa(n-1)*n %int(10**9+7)
memo[n] = temp
return temp
print(fa(n))
|
s188913007
|
Accepted
| 21
| 3,316
| 41
|
n = int(input())
print(n*800 - n//15*200)
|
s903975065
|
p03023
|
u167908302
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 84
|
Given an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees, but do not print units.
|
#coding:utf-8
s = input()
if s.count('x') <= 7:
print('YES')
else:
print('NO')
|
s804662376
|
Accepted
| 17
| 2,940
| 48
|
#coding:utf-8
n = int(input())
print(180*(n-2))
|
s200541588
|
p02288
|
u159356473
| 2,000
| 131,072
|
Wrong Answer
| 30
| 7,772
| 611
|
A binary heap which satisfies max-heap property is called max-heap. In a max- heap, for every node $i$ other than the root, $A Write a program which reads an array and constructs a max-heap from the array based on the following pseudo code. $maxHeapify(A, i)$ move the value of $A[i]$ down to leaves to make a sub-tree of node $i$ a max-heap. Here, $H$ is the size of the heap. 1 maxHeapify(A, i) 2 l = left(i) 3 r = right(i) 4 // select the node which has the maximum value 5 if l ≤ H and A[l] > A[i] 6 largest = l 7 else 8 largest = i 9 if r ≤ H and A[r] > A[largest] 10 largest = r 11 12 if largest ≠ i // value of children is larger than that of i 13 swap A[i] and A[largest] 14 maxHeapify(A, largest) // call recursively The following procedure buildMaxHeap(A) makes $A$ a max-heap by performing maxHeapify in a bottom-up manner. 1 buildMaxHeap(A) 2 for i = H/2 downto 1 3 maxHeapify(A, i)
|
#coding:UTF-8
def maxHeapify(A,i,n):
print(i)
l=2*i
r=2*i+1
if l <=n and A[l]>A[i] :
largest=l
else:
largest=i
if r<=n and A[r]>A[largest]:
largest=r
if largest!=i:
A[i],A[largest]=A[largest],A[i]
maxHeapify(A,largest,n)
def MH(A,n):
for i in range(int(n/2),0,-1):
maxHeapify(A,i,n)
A.remove(-1)
for i in range(len(A)):
A[i]=str(A[i])
print(" "+" ".join(A))
if __name__=="__main__":
H=int(input())
A=input().split(" ")
for i in range(len(A)):
A[i]=int(A[i])
A=[-1]+A
MH(A,H)
|
s845696029
|
Accepted
| 850
| 49,492
| 598
|
#coding:UTF-8
def maxHeapify(A,i,n):
l=2*i
r=2*i+1
if l <=n and A[l]>A[i] :
largest=l
else:
largest=i
if r<=n and A[r]>A[largest]:
largest=r
if largest!=i:
A[i],A[largest]=A[largest],A[i]
maxHeapify(A,largest,n)
def MH(A,n):
for i in range(int(n/2),0,-1):
maxHeapify(A,i,n)
A.remove(-1)
for i in range(len(A)):
A[i]=str(A[i])
print(" "+" ".join(A))
if __name__=="__main__":
H=int(input())
A=input().split(" ")
for i in range(len(A)):
A[i]=int(A[i])
A=[-1]+A
MH(A,H)
|
s116446860
|
p03456
|
u534319350
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 159
|
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
|
import math
a,b = (str(i) for i in input().split())
c = a + b
c = int(c)
if c / math.sqrt(c) == math.sqrt(c):
print('自乗')
else:
print('複数')
|
s465529575
|
Accepted
| 18
| 2,940
| 141
|
import math
a,b = (str(i) for i in input().split())
c = a + b
c = int(c)
if c % math.sqrt(c) == 0:
print('Yes')
else:
print('No')
|
s768502350
|
p03759
|
u746419473
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 66
|
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())
print("Yes" if b-a==c-b else "No")
|
s343543424
|
Accepted
| 17
| 2,940
| 72
|
a,b,c=map(int,input().split())
print("YES" if b - a == c - b else "NO")
|
s395144050
|
p03563
|
u763881112
| 2,000
| 262,144
|
Wrong Answer
| 148
| 12,392
| 64
|
Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the contest is b. * Then, the new rating of the user will be the avarage of a and b. For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000. Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest. Find the performance required to achieve it.
|
import numpy as np
r=int(input())
g=int(input())
print(2*r-g)
|
s794303200
|
Accepted
| 148
| 12,392
| 64
|
import numpy as np
r=int(input())
g=int(input())
print(2*g-r)
|
s966891891
|
p02413
|
u896065593
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,644
| 663
|
Your task is to perform a simple table calculation. Write a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column.
|
r, c = map(int, input().split())
spreadSheet = [[0 for i in range(c + 1)] for j in range(r + 1)]
for i in range(0, r):
spreadSheet[i][:c] = map(int, input().split())
for i in range(0, r):
for j in range(0, c):
spreadSheet[i][c] += spreadSheet[i][j]
for i in range(0, c + 1):
for j in range(0, r):
spreadSheet[r][i] += spreadSheet[j][i]
print(spreadSheet)
|
s414240119
|
Accepted
| 50
| 8,788
| 863
|
r, c = map(int, input().split())
spreadSheet = [[0 for i in range(c + 1)] for j in range(r + 1)]
for i in range(0, r):
spreadSheet[i][:c] = map(int, input().split())
for i in range(0, r):
for j in range(0, c):
spreadSheet[i][c] += spreadSheet[i][j]
for i in range(0, c + 1):
for j in range(0, r):
spreadSheet[r][i] += spreadSheet[j][i]
for i in range(0, r + 1):
for j in range(0, c + 1):
print("{0}".format(spreadSheet[i][j]), end="")
if j != c:
print(" ",end="")
else:
print("")
|
s719935926
|
p03555
|
u809819902
| 2,000
| 262,144
|
Wrong Answer
| 27
| 8,896
| 76
|
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,b=list(input()),list(input())
a.reverse()
print("Yes" if a == b else "No")
|
s592877067
|
Accepted
| 25
| 8,992
| 76
|
a,b=list(input()),list(input())
a.reverse()
print("YES" if a == b else "NO")
|
s065717558
|
p02407
|
u660912567
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,648
| 87
|
Write a program which reads a sequence and prints it in the reverse order.
|
n = int(input())
num_li = list(map(int, input().split()))
print(list(reversed(num_li)))
|
s684645131
|
Accepted
| 30
| 7,640
| 81
|
n = int(input())
num_li = input().split()
print(' '.join(list(reversed(num_li))))
|
s501461601
|
p03494
|
u549161102
| 2,000
| 262,144
|
Time Limit Exceeded
| 2,104
| 2,940
| 146
|
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
|
N = input()
list = map(int, input().split())
count = 0
while all(a % 2 == 0 for a in list):
list = [a/2 for a in list]
count += 1
print(count)
|
s888978522
|
Accepted
| 19
| 3,060
| 152
|
N = input()
list = list(map(int, input().split()))
count = 0
while all(a % 2 == 0 for a in list):
list = [a/2 for a in list]
count += 1
print(count)
|
s655299137
|
p03890
|
u491550356
| 2,000
| 262,144
|
Wrong Answer
| 29
| 9,216
| 238
|
_Kode Festival_ is an anual contest where the hardest stone in the world is determined. (Kode is a Japanese word for "hardness".) This year, 2^N stones participated. The hardness of the i-th stone is A_i. In the contest, stones are thrown at each other in a knockout tournament. When two stones with hardness X and Y are thrown at each other, the following will happen: * When X > Y: The stone with hardness Y will be destroyed and eliminated. The hardness of the stone with hardness X will become X-Y. * When X = Y: One of the stones will be destroyed and eliminated. The hardness of the other stone will remain the same. * When X < Y: The stone with hardness X will be destroyed and eliminated. The hardness of the stone with hardness Y will become Y-X. The 2^N stones will fight in a knockout tournament as follows: 1. The following pairs will fight: (the 1-st stone versus the 2-nd stone), (the 3-rd stone versus the 4-th stone), ... 2. The following pairs will fight: (the winner of (1-st versus 2-nd) versus the winner of (3-rd versus 4-th)), (the winner of (5-th versus 6-th) versus the winner of (7-th versus 8-th)), ... 3. And so forth, until there is only one stone remaining. Determine the eventual hardness of the last stone remaining.
|
N = int(input())
A = [int(input()) for _ in range(N)]
while len(A) > 1:
B = []
i = 0
while i < len(A):
if A[i] == A[i+1]:
B.append(A[i])
else:
B.append(abs(A[i] - A[i+1]))
i += 2
A = B
print(A[0])
|
s954801231
|
Accepted
| 448
| 24,752
| 240
|
N = int(input())
A = [int(input()) for _ in range(2**N)]
while len(A) > 1:
B = []
i = 0
while i+1 < len(A):
if A[i] == A[i+1]:
B.append(A[i])
else:
B.append(abs(A[i] - A[i+1]))
i += 2
A = B
print(A[0])
|
s460776342
|
p03377
|
u583507988
| 2,000
| 262,144
|
Wrong Answer
| 27
| 9,160
| 82
|
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a, b, x = map(int, input().split())
if a+b>=x:
print('Yes')
else:
print('No')
|
s757904029
|
Accepted
| 23
| 9,128
| 91
|
a, b, x = map(int, input().split())
if a+b>=x and a<=x:
print('YES')
else:
print('NO')
|
s766966114
|
p03998
|
u013408661
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 642
|
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=list(input())
a.reverse()
b=list(input())
b.reverse()
c=list(input())
c.reverse()
turn=1
while 1:
if turn==1:
if len(a)==0:
print("A")
exit()
else:
k=a.pop()
if k=="A":
turn=1
elif k=="B":
turn=2
else:
turn=3
if turn==2:
if len(b)==0:
print("B")
exit()
else:
k=b.pop()
if k=="A":
turn=1
elif k=="B":
turn=2
else:
turn=3
if turn==3:
if len(c)==0:
print("C")
exit()
else:
k=c.pop()
if k=="A":
turn=1
elif k=="B":
turn=2
else:
turn=3
|
s294635965
|
Accepted
| 17
| 3,064
| 642
|
a=list(input())
a.reverse()
b=list(input())
b.reverse()
c=list(input())
c.reverse()
turn=1
while 1:
if turn==1:
if len(a)==0:
print("A")
exit()
else:
k=a.pop()
if k=="a":
turn=1
elif k=="b":
turn=2
else:
turn=3
if turn==2:
if len(b)==0:
print("B")
exit()
else:
k=b.pop()
if k=="a":
turn=1
elif k=="b":
turn=2
else:
turn=3
if turn==3:
if len(c)==0:
print("C")
exit()
else:
k=c.pop()
if k=="a":
turn=1
elif k=="b":
turn=2
else:
turn=3
|
s343948405
|
p03379
|
u261891508
| 2,000
| 262,144
|
Wrong Answer
| 337
| 25,620
| 139
|
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.
|
n=int(input())
x=list(map(int,input().split()))
x.sort()
for i in range(n):
if i<n//2:
print(x[n//2])
else:
print(x[(n//2)-1])
|
s657238309
|
Accepted
| 319
| 25,620
| 155
|
n=int(input())
x=list(map(int,input().split()))
xs=sorted(x)
a=xs[n//2]
b=xs[(n//2)-1]
for i in range(n):
if x[i]>=a:
print(b)
else:
print(a)
|
s027682801
|
p03698
|
u234189749
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 66
|
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
|
S = list(input())
print("Yes" if len(S) == len(set(S)) else "no")
|
s150732280
|
Accepted
| 17
| 2,940
| 66
|
S = list(input())
print("yes" if len(S) == len(set(S)) else "no")
|
s163797489
|
p03992
|
u541475502
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 39
|
This contest is `CODE FESTIVAL`. However, Mr. Takahashi always writes it `CODEFESTIVAL`, omitting the single space between `CODE` and `FESTIVAL`. So he has decided to make a program that puts the single space he omitted. You are given a string s with 12 letters. Output the string putting a single space between the first 4 letters and last 8 letters in the string s.
|
s = input()
print(s)
print(s[:4],s[4:])
|
s321600239
|
Accepted
| 17
| 2,940
| 30
|
s = input()
print(s[:4],s[4:])
|
s157932714
|
p04011
|
u941884460
| 2,000
| 262,144
|
Wrong Answer
| 19
| 2,940
| 144
|
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
|
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
sum = 0
for i in range(1,N+1):
if i <=K:
sum += X
else:
sum += Y
|
s125925240
|
Accepted
| 19
| 3,060
| 155
|
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
sum = 0
for i in range(1,N+1):
if i <=K:
sum += X
else:
sum += Y
print(sum)
|
s873485787
|
p03475
|
u013408661
| 3,000
| 262,144
|
Wrong Answer
| 85
| 3,064
| 301
|
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.
|
n=int(input())
c=[]
s=[]
f=[]
for i in range(n-1):
x,y,z=map(int,input().split())
c.append(x)
s.append(y)
f.append(z)
def needtime(t,i):
if s[i]>=t:
T=s[i]
else:
T=t+f[i]-(t-s[i])%f[i]
return T+c[i]
for i in range(n):
t=0
for j in range(i,n-1):
t=needtime(t,j)
print(t)
|
s172225307
|
Accepted
| 106
| 3,188
| 348
|
n=int(input())
c=[]
s=[]
f=[]
for i in range(n-1):
x,y,z=map(int,input().split())
c.append(x)
s.append(y)
f.append(z)
def needtime(t,i):
if s[i]>=t:
T=s[i]
else:
if (t-s[i])%f[i]==0:
T=t
else:
T=t+f[i]-(t-s[i])%f[i]
return T+c[i]
for i in range(n):
t=0
for j in range(i,n-1):
t=needtime(t,j)
print(t)
|
s296312760
|
p03371
|
u089376182
| 2,000
| 262,144
|
Wrong Answer
| 64
| 3,064
| 215
|
"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.
|
a,b,c,x,y = map(int, input().split())
costs = 0
while x>0 and y>0:
if a+b>2*c:
costs += 2*c
else:
costs = costs+a+b
x -= 1
y -= 1
if x>0:
if a<=2*c:
costs += x*a
else:
costs += x*2*c
|
s892143248
|
Accepted
| 74
| 9,108
| 342
|
a,b,c,x,y = map(int, input().split())
cost = 0
while x>0 or y>0:
if a+b>=2*c:
while x>0 and y>0:
cost += 2*c
x -= 1
y -= 1
if x>0:
if a>=2*c:
cost += 2*c
else:
cost += a
x -= 1
elif y>0:
if b>=2*c:
cost += 2*c
else:
cost += b
y -= 1
print(cost)
|
s359435199
|
p00135
|
u808429775
| 1,000
| 131,072
|
Wrong Answer
| 40
| 5,604
| 308
|
原始スローライフ主義組織「アカルイダ」から、いたずらの予告状が届きました。アカルイダといえば、要人の顔面にパイを投げつけたりするいたずらで有名ですが、最近では火薬を用いてレセプション会場にネズミ花火をまき散らすなど、より過激化してきました。予告状は次の文面です。 ---パソコン ヒトの時間を奪う。良くない。 時計の短い針と長い針 出会うころ、アカルイダ 正義行う。 スローライフ 偉大なり。 たどたどしくてよく解らないのですが、時計の短針と長針とが重なったころにいたずらを決行するという意味のようです。 このいたずらを警戒するため、時刻を入力として、短針と長針が近い場合は "alert"、遠い場合は "safe"、それ以外の場合は "warning" と出力するプログラムを作成してください。ただし、「近い」とは短針と長針の角度が 0° 以上 30° 未満の場合をいい、「遠い」とは 90° 以上 180° 以下の場合をいいます。なお、時刻は 00:00 以上 11:59 以下とします。
|
for _ in range(int(input())):
hour, minute = [int(item) for item in input().split(":")]
angle1 = hour * 5 * 6
angle2 = minute * 6
subtract = abs(angle1 - angle2)
if subtract < 30:
print("alert")
elif 90 <= subtract:
print("safe")
else:
print("warning")
|
s573870646
|
Accepted
| 30
| 5,616
| 360
|
for _ in range(int(input())):
hour, minute = [int(item) for item in input().split(":")]
angle1 = hour * 5 * 6 + minute * 0.5
angle2 = minute * 6
subtract = min(abs(angle1 - angle2), 360 - abs(angle1 - angle2))
if subtract < 30.0:
print("alert")
elif 90.0 <= subtract:
print("safe")
else:
print("warning")
|
s286650460
|
p03813
|
u612721349
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 39
|
Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise. You are given Smeke's current rating, x. Print `ABC` if Smeke will participate in ABC, and print `ARC` otherwise.
|
print(("ABC","ARC")[int(input())<1200])
|
s107490966
|
Accepted
| 17
| 2,940
| 38
|
print("AARBCC"[int(input())<1200::2])
|
s227999763
|
p03377
|
u331036636
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 78
|
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a,b,x = map(int,input().split())
print("Yes" if a < x and (a+b) > x else "No")
|
s290282197
|
Accepted
| 17
| 2,940
| 73
|
A,B,X = map(int,input().split())
print("YES" if A <= X <=(A+B) else "NO")
|
s167362122
|
p03672
|
u593567568
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 199
|
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.
|
S = input()
L = len(S)
ans = None
for i in range(1,L):
if (L - i) % 2 != 0:
continue
ns = S[:-i]
h = (L - i) // 2
m = ns[:h] + ns[:h]
if ns == m:
ans = ns
break
print(ans)
|
s551349135
|
Accepted
| 17
| 2,940
| 205
|
S = input()
L = len(S)
ans = None
for i in range(1,L):
if (L - i) % 2 != 0:
continue
ns = S[:-i]
h = (L - i) // 2
m = ns[:h] + ns[:h]
if ns == m:
ans = ns
break
print(len(ans))
|
s641075689
|
p03997
|
u401183062
| 2,000
| 262,144
|
Wrong Answer
| 26
| 9,040
| 145
|
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
def iroha():
a, b, c = [int(input()) for i in range(3)]
result = (a+b)*2 / 2
print(result)
if __name__ == "__main__":
iroha()
|
s058008606
|
Accepted
| 26
| 9,040
| 164
|
def iroha():
a, b, c = [int(input()) for i in range(3)]
num = (a+b)*c / 2
result = int(num)
print(result)
if __name__ == "__main__":
iroha()
|
s783054316
|
p03457
|
u678009529
| 2,000
| 262,144
|
Wrong Answer
| 406
| 27,300
| 192
|
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())
a = []
for i in range(n):
a.append(list(map(int, input().split())))
for i in a:
if i[0] < i[1] + i[2] or sum(i) % 2:
print("NO")
exit()
print("YES")
|
s142272742
|
Accepted
| 398
| 27,300
| 192
|
n = int(input())
a = []
for i in range(n):
a.append(list(map(int, input().split())))
for i in a:
if i[0] < i[1] + i[2] or sum(i) % 2:
print("No")
exit()
print("Yes")
|
s704831778
|
p02390
|
u650790815
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,472
| 74
|
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
|
S = int(input())
h = S%3600
m = S %3600 //60
s = S%60
print(h,m,s,sep=':')
|
s033198173
|
Accepted
| 20
| 7,648
| 75
|
S = int(input())
h = S //3600
m = S%3600 //60
s = S%60
print(h,m,s,sep=':')
|
s829952072
|
p03378
|
u898999125
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 131
|
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right. Initially, you are in Square X. You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N. However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0, Square X and Square N. Find the minimum cost incurred before reaching the goal.
|
n, m, x = map(int, input().split())
a=list(map(int, input().split()))
cost=0
for i in range(m):
if a[i]>x:
cost+1
print(cost)
|
s650082095
|
Accepted
| 17
| 3,060
| 188
|
n, m, x = map(int, input().split())
a=list(map(int, input().split()))
upcost=0
downcost=0
for i in range(m):
if a[i]>x:
upcost+=1
else:
downcost+=1
print(min(upcost, downcost))
|
s558160319
|
p02843
|
u399721252
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 175
|
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.)
|
n = int(input())
ans = 1
ng_list = [ (105*i, 100*(i+1)) for i in range(1,20) ]
print(ng_list)
for a, b in ng_list:
if a < n < b:
ans = 0
break
print(ans)
|
s362678436
|
Accepted
| 18
| 2,940
| 172
|
n = int(input())
ans = 1
ng_list = [(-1,100)] + [ (105*i, 100*(i+1)) for i in range(1,20) ]
for a, b in ng_list:
if a < n < b:
ans = 0
break
print(ans)
|
s403461189
|
p03369
|
u744034042
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 36
|
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen.
|
print(700 + int(input().count("o")))
|
s358785186
|
Accepted
| 17
| 2,940
| 42
|
print(700 + 100 * int(input().count("o")))
|
s209056957
|
p03351
|
u363768711
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 108
|
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())
e = abs(c - a)
f = abs(c - b)
print('Yes' if e<=d and f<=d else 'No')
|
s288104716
|
Accepted
| 17
| 3,060
| 136
|
a, b, c, d = map(int, input().split())
e = abs(b-a)
f = abs(c-b)
if (abs(c-a)<=d) or (e<=d and f<=d):
print('Yes')
else:
print('No')
|
s994965416
|
p03352
|
u357751375
| 2,000
| 1,048,576
|
Time Limit Exceeded
| 2,206
| 8,964
| 145
|
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.
|
x = int(input())
ans = 0
for i in range(1,1000):
for j in range(2,1000):
if i ** j <= x:
ans = max(ans,i ** j)
print(ans)
|
s835436810
|
Accepted
| 30
| 9,004
| 177
|
x = int(input())
ans = 0
for i in range(1,1000):
for j in range(2,1000):
if i ** j <= x:
ans = max(ans,i ** j)
else:
break
print(ans)
|
s696466765
|
p02255
|
u127167915
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,596
| 445
|
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
|
# -*- Coding: utf-8 -*-
def trace(A, N):
for i in range(int(N)-1):
print(A[i], end=' ')
print(A[int(N)-1])
def insertionSort(A, N):
for i in range(1, int(N)):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
trace(A, N)
if __name__ == '__main__':
N = input()
A = list(map(int, input().split()))
insertionSort(A, N)
|
s294540779
|
Accepted
| 20
| 5,980
| 465
|
# -*- Coding: utf-8 -*-
def trace(A, N):
for i in range(int(N)-1):
print(A[i], end=' ')
print(A[int(N)-1])
def insertionSort(A, N):
for i in range(1, int(N)):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
trace(A, N)
if __name__ == '__main__':
N = input()
A = list(map(int, input().split()))
trace(A, N)
insertionSort(A, N)
|
s385173254
|
p02255
|
u929986002
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,496
| 224
|
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
|
N = int(input())
#print(N)
card = input().split()
print(card)
for i in range(N):
v = card[i]
j = i - 1
while j >= 0 and card[j] > v:
card[j+1] = card[j]
j = j -1
card[j+1] = v
print(card)
|
s863154913
|
Accepted
| 30
| 7,668
| 381
|
N = int(input())
#print(N)
card = list(map(int, input().split()))
#print(card)
for i in range(N):
v = card[i]
j = i - 1
while j >= 0 and card[j] > v:
card[j+1] = card[j]
j = j -1
card[j+1] = v
#print(card)
card_str = ""
for k in range(N):
card_str += str(card[k])
card_str += " "
print(card_str[:-1])
|
s160281523
|
p02408
|
u144068724
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,600
| 213
|
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.
|
cards = []
mark = ["S","H","C","D"]
for i in (mark):
for j in range(1,14):
cards.append( i + " " + str(j) )
print(cards)
n = int(input())
for i in range(n):
a = input()
cards.remove(a)
print(a)
|
s536831435
|
Accepted
| 20
| 7,756
| 243
|
cards = list()
mark = ["S","H","C","D"]
for i in (mark):
for j in range(1,14):
cards.append( i + " " + str(j) )
n = int(input())
for i in range(n):
a = input()
cards.remove(a)
if len(cards) > 0:
print("\n" .join(cards))
|
s048696067
|
p03828
|
u033606236
| 2,000
| 262,144
|
Wrong Answer
| 1,575
| 465,140
| 384
|
You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7.
|
import math
import collections
import sys
sys.setrecursionlimit(500000)
def f(n,x,i):
if i == x:
return a
while n % i == 0:
a.append(i)
n //= i
return f(n,x,i+1)
a = []
n = int(input())
c = collections.Counter(f(math.factorial(n),n,2))
d = [i[1]+1 for i in c.items()]
ans = 1
for i in range(len(d)):
ans = (ans * d[i]) % 1000000007
print(ans)
|
s250256122
|
Accepted
| 38
| 3,316
| 425
|
import math
import collections
import sys
sys.setrecursionlimit(500000)
def f(n,i):
while i * i <= n:
if n % i == 0:
a.append(i)
n //= i
else:i += 1
if n != 1:
a.append(n)
return a
a = []
n = math.factorial(int(input()))
c = collections.Counter(f(n,2))
d = [i[1]+1 for i in c.items()]
ans = 1
for i in range(len(d)):
ans = (ans * d[i]) % 1000000007
print(ans)
|
s182231896
|
p02613
|
u207582576
| 2,000
| 1,048,576
|
Wrong Answer
| 164
| 16,344
| 321
|
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
N = int(input())
S = [input() for i in range(N)]
c0 = 0
c1 = 0
c2 = 0
c3 = 0
for i in range(N):
if S[i] == 'AC':
c0 += 1
elif S[i] == 'WA':
c1 += 1
elif S[i] == 'TLE':
c2 += 1
elif S[i] == 'RE':
c3 += 1
print('AC × %d' %c0)
print('WA × %d' %c1)
print('TLE × %d' %c2)
print('RE × %d' %c3)
|
s524982314
|
Accepted
| 158
| 16,184
| 317
|
N = int(input())
S = [input() for i in range(N)]
c0 = 0
c1 = 0
c2 = 0
c3 = 0
for i in range(N):
if S[i] == 'AC':
c0 += 1
elif S[i] == 'WA':
c1 += 1
elif S[i] == 'TLE':
c2 += 1
elif S[i] == 'RE':
c3 += 1
print('AC x %d' %c0)
print('WA x %d' %c1)
print('TLE x %d' %c2)
print('RE x %d' %c3)
|
s168580176
|
p03693
|
u128908475
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 105
|
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())
x = 100*r +10*g + b
if x % 4 == 0:
print('Yes')
else:
print('No')
|
s875148676
|
Accepted
| 18
| 2,940
| 105
|
r, g, b = map(int, input().split())
x = 100*r +10*g + b
if x % 4 == 0:
print('YES')
else:
print('NO')
|
s973974153
|
p03547
|
u612721349
| 2,000
| 262,144
|
Wrong Answer
| 19
| 2,940
| 27
|
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?
|
print(max(input().split()))
|
s693745618
|
Accepted
| 18
| 2,940
| 89
|
x,y=input().split()
print(*[[">", "=", "<"][i] for i in range(3) if [x>y, x==y, x<y][i]])
|
s791490697
|
p03471
|
u379720557
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 288
|
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
|
n, a = map(int, input().split())
flag = 0
for i in range(10):
for j in range(i, 10):
for k in range(j, 10):
if i*10000 + j*5000+ k*1000 == a:
x = i
y = j
z = k
flag = 1
break
if flag:
print(x, y, z)
else:
print(-1, -1, -1)
|
s916376353
|
Accepted
| 711
| 3,064
| 265
|
n, a = map(int, input().split())
flag = 0
for i in range(n+1):
for j in range(0, n-i+1):
if 10000*i + 5000*j + 1000*(n-i-j) == a:
x = i
y = j
z = n-i-j
flag = 1
break
if flag == 1:
print(x, y, z)
else:
print(-1,-1,-1)
|
s188047026
|
p02664
|
u566159623
| 2,000
| 1,048,576
|
Wrong Answer
| 147
| 10,776
| 348
|
For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
|
l = list(input())
n = len(l)
ans = 0
for i in range(n):
if l[i] == '?':
print(l[i])
if not i==0:
if l[i-1]=="P":
l[i] = "D"
continue
if not i==n-1:
if l[i+1] == "D":
l[i] = "P"
continue
l[i] = "D"
print("".join(l))
|
s090312728
|
Accepted
| 86
| 10,904
| 338
|
l = list(input())
n = len(l)
ans = 0
for i in reversed(range(n)):
if l[i] == '?':
if not i==0:
if l[i-1]=="P":
l[i] = "D"
continue
if not i==n-1:
if l[i+1] == "D":
l[i] = "P"
continue
l[i] = "D"
print("".join(l))
|
s560202119
|
p03712
|
u386089355
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 240
|
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.
|
h, w = map(int, input().split())
ls_a = [input() for _ in range(h)]
for i in range(h):
ls_a[i] = "#" + ls_a[i] + "#"
top = "#" * len(ls_a[0])
bottom = "#" * len(ls_a[0])
print(top)
for j in range(h):
print(ls_a[i])
print(bottom)
|
s934734414
|
Accepted
| 17
| 3,060
| 240
|
h, w = map(int, input().split())
ls_a = [input() for _ in range(h)]
for i in range(h):
ls_a[i] = "#" + ls_a[i] + "#"
top = "#" * len(ls_a[0])
bottom = "#" * len(ls_a[0])
print(top)
for j in range(h):
print(ls_a[j])
print(bottom)
|
s586723037
|
p03827
|
u514894322
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 161
|
You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).
|
n = int(input())
s = str(input())
x = 0
tmpmax = 0
for char in s:
if s == 'I':
x += 1
if x > tmpmax:
tmpmax = x
else:
x -= 1
print (tmpmax)
|
s267849662
|
Accepted
| 17
| 2,940
| 164
|
n = int(input())
s = str(input())
x = 0
tmpmax = 0
for char in s:
if char == 'I':
x += 1
if x > tmpmax:
tmpmax = x
else:
x -= 1
print (tmpmax)
|
s610498933
|
p03385
|
u654536970
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,060
| 85
|
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
|
alphabet = str(input())
if alphabet == "abc":
print("Yes")
else:
print("No")
|
s621292837
|
Accepted
| 17
| 2,940
| 118
|
alphabet = input()
if "a" in alphabet and "b" in alphabet and "c" in alphabet:
print("Yes")
else:
print("No")
|
s029363758
|
p03455
|
u634439390
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 102
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a, b = map(int, input().split())
if a % 2 != 0 or b % 2 != 0:
print('Odd')
else:
print('Even')
|
s728989042
|
Accepted
| 17
| 2,940
| 95
|
a, b = map(int, input().split())
if (a * b) % 2 != 0:
print('Odd')
else:
print('Even')
|
s612188520
|
p03545
|
u779170803
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,064
| 703
|
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
|
#input
S = list(input())
for i in range(len(S)):
S[i] = int(S[i])
#print(S)
L = len(S)
fugou = []
for i in range(2**(L-1)):
total = S[0]
#bin_i = bin(i)
moji = format(i,'b').zfill(4)
for k in range(1,L):
if int(moji[k]) == 1:
total = total + S[k]
else:
total = total - S[k]
#print(total)
if total == 7:
moji_answer = moji
print(moji_answer)
#print
for i in range(1,L):
if int(moji_answer[i]) == 1:
fugou_tandoku = "+"
else:
fugou_tandoku = "-"
fugou.append(fugou_tandoku)
print(S[0],fugou[0],S[1],fugou[1],S[2],fugou[2],S[3],'=7',sep='')
|
s664722927
|
Accepted
| 18
| 3,064
| 704
|
#input
S = list(input())
for i in range(len(S)):
S[i] = int(S[i])
#print(S)
L = len(S)
fugou = []
for i in range(2**(L-1)):
total = S[0]
#bin_i = bin(i)
moji = format(i,'b').zfill(4)
for k in range(1,L):
if int(moji[k]) == 1:
total = total + S[k]
else:
total = total - S[k]
#print(total)
if total == 7:
moji_answer = moji
#print
for i in range(1,L):
if int(moji_answer[i]) == 1:
fugou_tandoku = "+"
else:
fugou_tandoku = "-"
fugou.append(fugou_tandoku)
print(S[0],fugou[0],S[1],fugou[1],S[2],fugou[2],S[3],'=7',sep='')
|
s338154299
|
p03609
|
u785578220
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 40
|
We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
|
a,b=map(int, input().split())
print(b-a)
|
s765357812
|
Accepted
| 20
| 2,940
| 63
|
a,b=map(int, input().split())
if a-b<0:print(0)
else:print(a-b)
|
s283471092
|
p04035
|
u077291787
| 2,000
| 262,144
|
Wrong Answer
| 43
| 14,180
| 256
|
We have N pieces of ropes, numbered 1 through N. The length of piece i is a_i. At first, for each i (1≤i≤N-1), piece i and piece i+1 are tied at the ends, forming one long rope with N-1 knots. Snuke will try to untie all of the knots by performing the following operation repeatedly: * Choose a (connected) rope with a total length of at least L, then untie one of its knots. Is it possible to untie all of the N-1 knots by properly applying this operation? If the answer is positive, find one possible order to untie the knots.
|
# AGC002C - Knot Puzzle
def main():
N, L = tuple(map(int, input().split()))
A = tuple(map(int, input().split()))
if sum(A) < L:
print("Impossible")
if __name__ == "__main__":
main()
|
s500724159
|
Accepted
| 74
| 21,836
| 458
|
# AGC002C - Knot Puzzle
def main():
N, L, *A = map(int, open(0).read().split())
B = [i + j for i, j in zip(A, A[1:])]
x = max(B)
if x < L: # corner case
print("Impossible")
return
idx = B.index(x) + 1
# keep the biggest one until the end
ans = [i for i in range(1, idx)] + [i for i in range(N - 1, idx, -1)] + [idx]
print("Possible")
print("\n".join(map(str, ans)))
if __name__ == "__main__":
main()
|
s330636501
|
p03379
|
u214344212
| 2,000
| 262,144
|
Wrong Answer
| 319
| 25,620
| 310
|
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.
|
N=int(input())
X=list(map(int,input().split()))
Y=X
Y.sort()
a=Y[int((N-1)/2)]
b=Y[int((N+1)/2)]
for i in range(N):
if X[i]<a:
print(b)
elif X[i]>b:
print(a)
else:
if a==b:
print(a)
elif X[i]==a:
print(b)
else:
print(a)
|
s993678397
|
Accepted
| 332
| 25,224
| 301
|
N=int(input())
X=list(map(int,input().split()))
Y=[X[i] for i in range(N)]
Y.sort()
a=Y[int((N-1)/2)]
b=Y[int((N+1)/2)]
for i in range(N):
if X[i]<a:
print(b)
elif X[i]>b:
print(a)
else:
if X[i]==a:
print(b)
elif X[i]==b:
print(a)
|
s805656776
|
p03671
|
u483640741
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 106
|
Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
|
bell=list(map(int,input().split()))
bell=sorted(bell,reverse=True)
print(bell)
print(bell[1]+bell[2])
|
s349700150
|
Accepted
| 17
| 2,940
| 93
|
bell=list(map(int,input().split()))
bell=sorted(bell,reverse=True)
print(bell[1]+bell[2])
|
s672201550
|
p04012
|
u371467115
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 84
|
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
|
w=input()
s=set(w)
if (len(w)/len(s))%2==0:
print("Yes")
else:
print("No")
|
s290238118
|
Accepted
| 18
| 2,940
| 66
|
w=list(input())
w.sort()
print("Yes" if w[::2]==w[1::2] else "No")
|
s046220903
|
p03486
|
u685983477
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 146
|
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
|
s=list(input().rstrip())
t=list(input().rstrip())
s.sort()
t.sort()
if str(''.join(s))>=str(''.join(t)):
print("No")
else:
print("Yes")
|
s852980517
|
Accepted
| 17
| 2,940
| 158
|
s=list(input().rstrip())
t=list(input().rstrip())
s.sort()
t.sort(reverse=True)
if str(''.join(s))>=str(''.join(t)):
print("No")
else:
print("Yes")
|
s151018313
|
p02262
|
u177808190
| 6,000
| 131,072
|
Wrong Answer
| 20
| 5,608
| 640
|
Shell Sort is a generalization of [Insertion Sort](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A) to arrange a list of $n$ elements $A$. 1 insertionSort(A, n, g) 2 for i = g to n-1 3 v = A[i] 4 j = i - g 5 while j >= 0 && A[j] > v 6 A[j+g] = A[j] 7 j = j - g 8 cnt++ 9 A[j+g] = v 10 11 shellSort(A, n) 12 cnt = 0 13 m = ? 14 G[] = {?, ?,..., ?} 15 for i = 0 to m-1 16 insertionSort(A, n, G[i]) A function shellSort(A, n) performs a function insertionSort(A, n, g), which considers every $g$-th elements. Beginning with large values of $g$, it repeats the insertion sort with smaller $g$. Your task is to complete the above program by filling ?. Write a program which reads an integer $n$ and a sequence $A$, and prints $m$, $G_i (i = 0, 1, ..., m − 1)$ in the pseudo code and the sequence $A$ in ascending order. The output of your program must meet the following requirements: * $1 \leq m \leq 100$ * $0 \leq G_i \leq n$ * cnt does not exceed $\lceil n^{1.5}\rceil$
|
def iSort(A, n, g):
for i in range(g, n):
v = A[i]
j = i - g
c = 0
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j -= g
c += 1
A[j+g] = v
return c
def shellSort(A, n):
cnt = 0
G = [4, 3, 1]
m = len(G)
for num in G:
cnt += iSort(A, n, num)
return cnt, A, G
if __name__ == '__main__':
n = int(input())
hoge = list()
for _ in range(n):
hoge.append(int(input()))
cnt, hoge, G = shellSort(hoge, n)
print (len(G))
print (' '.join([str(x) for x in G]))
print (cnt)
for e in hoge:
print (e)
|
s812651017
|
Accepted
| 17,980
| 45,520
| 736
|
def iSort(A, n, g):
c = 0
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j -= g
c += 1
A[j+g] = v
return c
def shellSort(A, n):
cnt = 0
G = list()
h = 1
while True:
if h > n:
break
G.append(h)
h = 3*h + 1
G.reverse()
for num in G:
cnt += iSort(A, n, num)
return cnt, A, G
if __name__ == '__main__':
n = int(input())
hoge = list()
for _ in range(n):
hoge.append(int(input()))
cnt, hoge, G = shellSort(hoge, n)
print (len(G))
print (' '.join([str(x) for x in G]))
print (cnt)
for e in hoge:
print (e)
|
s053373649
|
p02646
|
u652569315
| 2,000
| 1,048,576
|
Wrong Answer
| 24
| 9,180
| 161
|
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
|
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
if v<=w:
print('NO')
else:
if a+v*t>=b+w*t:
print('Yes')
else:
print('No')
|
s458854344
|
Accepted
| 21
| 9,192
| 223
|
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
if v<=w:
print('NO')
else:
if a<b and (a+v*t)>=(b+w*t):
print('YES')
elif a>b and (a-v*t)<=(b-w*t):
print('YES')
else:
print('NO')
|
s048861825
|
p03448
|
u149551680
| 2,000
| 262,144
|
Wrong Answer
| 47
| 3,060
| 263
|
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
#A:500, B:100, C:50
A = int(input().strip())
B = int(input().strip())
C = int(input().strip())
X = int(input().strip())
count = 0
for a in range(A):
for b in range(B):
for c in range(C):
if a*500 + b*100 + c*50 == X:
count += 1
print(count)
|
s510583001
|
Accepted
| 50
| 3,060
| 269
|
A = int(input().strip())
B = int(input().strip())
C = int(input().strip())
X = int(input().strip())
count = 0
for a in range(A+1):
for b in range(B+1):
for c in range(C+1):
if a*500 + b*100 + c*50 == X:
count += 1
print(count)
|
s268732164
|
p03448
|
u131273629
| 2,000
| 262,144
|
Wrong Answer
| 50
| 3,060
| 196
|
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a):
for j in range(b):
for k in range(c):
if 500*a+100*b+50*c == x:
count += 1
print(count)
|
s985004302
|
Accepted
| 19
| 3,060
| 224
|
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a+1):
if 500*i>x: break
for j in range(b+1):
if 500*i+100*j > x: break
if x-500*i-100*j <= 50*c:
count += 1
print(count)
|
s616491973
|
p04045
|
u055687574
| 2,000
| 262,144
|
Wrong Answer
| 2,104
| 17,908
| 230
|
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money. Find the amount of money that she will hand to the cashier.
|
N, K = list(map(int, input().split()))
D = set(input().split())
num = {str(i) for i in range(10)} - D
while True:
print(set(str(N)))
if set(str(N)) == num:
ans = N
break
else:
N += 1
print(ans)
|
s250198887
|
Accepted
| 70
| 3,060
| 207
|
N, K = list(map(int, input().split()))
D = set(input().split())
num = {str(i) for i in range(10)} - D
while True:
if set(str(N)) <= num:
ans = N
break
else:
N += 1
print(ans)
|
s791956171
|
p03693
|
u246809151
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 113
|
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())
num = int(r+g+b)
if not num %4 == 0:
print('No')
else:
print('Yes')
|
s024643880
|
Accepted
| 17
| 2,940
| 125
|
r, g, b = map(int, input().split())
num = int(str(r)+str(g)+str(b))
if num %4 == 0:
print('YES')
else:
print('NO')
|
s018393628
|
p03555
|
u411858517
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 117
|
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.
|
l = input()
m = input()
res = 'Yes'
for i in range(3):
if l[i] != m[2-i]:
res = 'No'
print(res)
|
s646907875
|
Accepted
| 17
| 3,060
| 163
|
l = input()
m = input()
res = 'YES'
if l[0] != m[2]:
res = 'NO'
if l[1] != m[1]:
res = 'NO'
if l[2] != m[0]:
res = 'NO'
print(res)
|
s744690360
|
p02612
|
u014646120
| 2,000
| 1,048,576
|
Wrong Answer
| 27
| 9,088
| 79
|
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
N=int(input())
if (N%1000==0):
print (0)
else:
((((N//1000)+1)*1000)-N)
|
s413924336
|
Accepted
| 31
| 9,196
| 85
|
N=int(input())
if (N%1000==0):
print (0)
else:
print ((((N//1000)+1)*1000)-N)
|
s857767932
|
p04043
|
u041196979
| 2,000
| 262,144
|
Wrong Answer
| 19
| 2,940
| 164
|
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 == B == 5 and C == 7 or \
B == C == 5 and A == 7 or \
C == A == 5 and B == 7:
print("Yes")
else:
print("No")
|
s232006736
|
Accepted
| 17
| 2,940
| 164
|
A, B, C = map(int, input().split())
if A == B == 5 and C == 7 or \
B == C == 5 and A == 7 or \
C == A == 5 and B == 7:
print("YES")
else:
print("NO")
|
s174827362
|
p03455
|
u835482198
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 95
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a, b = map(int, input().split())
if (a * b) % 2 == 0:
print("Odd")
else:
print("Even")
|
s750733687
|
Accepted
| 17
| 2,940
| 95
|
a, b = map(int, input().split())
if (a * b) % 2 == 1:
print("Odd")
else:
print("Even")
|
s940711922
|
p03160
|
u123745130
| 2,000
| 1,048,576
|
Wrong Answer
| 114
| 13,928
| 275
|
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.
|
n = int(input())
aaa = list(map(int,input().split()))
def hantei(n,aaa):
dp = [0]*(n+1)
dp[0] = 0
dp[1] = abs(aaa[1]-aaa[0])
for i in range(n-2):
dp[i+2] = min(dp[i+1]+abs(aaa[i+2]-aaa[i+1]),dp[i]+abs(aaa[i+2]-aaa[i]))
return dp[n-1]
hantei(n,aaa)
|
s017757873
|
Accepted
| 112
| 13,980
| 263
|
n = int(input())
aaa = list(map(int,input().split()))
def hantei(n,aaa):
dp = [0]*(n+1)
dp[0] = 0
dp[1] = abs(aaa[1]-aaa[0])
for i in range(n-2):
dp[i+2] = min(dp[i+1]+abs(aaa[i+2]-aaa[i+1]),dp[i]+abs(aaa[i+2]-aaa[i]))
return dp[n-1]
print(hantei(n,aaa))
|
s727470170
|
p03623
|
u558836062
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 106
|
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
|
x,a,b = map(int,input().split())
d1 = abs(x-a)
d2 = abs(x-b)
if d1 > d2:
print('A')
else:
print('B')
|
s783483934
|
Accepted
| 17
| 2,940
| 106
|
x,a,b = map(int,input().split())
d1 = abs(x-a)
d2 = abs(x-b)
if d1 > d2:
print('B')
else:
print('A')
|
s891351605
|
p02390
|
u148628801
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,544
| 85
|
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
|
S = int(input())
h = S // 3600
S -= h * 3600
m = S // 60
S -= 60 * m
print(h, m, S)
|
s995525666
|
Accepted
| 20
| 7,688
| 107
|
S = int(input())
h = S // 3600
S -= h * 3600
m = S // 60
S -= 60 * m
print(":".join(map(str, [h, m, S])))
|
s295957404
|
p02390
|
u150984829
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,604
| 53
|
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
|
s=int(input())
print(f'{s/3600%60} {s/60%60} {s%60}')
|
s675828491
|
Accepted
| 20
| 5,580
| 52
|
s=int(input())
print(s//3600,s//60%60,s%60,sep=':')
|
s274147700
|
p03605
|
u382431597
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 58
|
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
|
n=input()
print("Yes" if n[0] == 9 or n[1] == 9 else "No")
|
s776692006
|
Accepted
| 17
| 2,940
| 62
|
n=input()
print("Yes" if n[0] == "9" or n[1] == "9" else "No")
|
s702800810
|
p03543
|
u111202730
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 274
|
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**?
|
x = input()
x = int(x)
answer = []
for p in range(2, 10):
for i in range(1, 32):
if i**p > x:
answer.append((i-1)**p)
break
elif pow(i, p) == x:
answer.append(i**p)
break
print(answer)
print(max(answer))
|
s897993535
|
Accepted
| 17
| 2,940
| 227
|
N = int(input())
thu = N // 1000
cto = (N - 1000*thu) // 100
ten = (N - 1000*thu - 100*cto) // 10
one = N % 10
if (one == ten == cto) or (ten == cto == thu) or (one ==ten == cto == thu):
print("Yes")
else:
print("No")
|
s751984045
|
p02831
|
u242580186
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 170
|
Takahashi is organizing a party. At the party, each guest will receive one or more snack pieces. Takahashi predicts that the number of guests at this party will be A or B. Find the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted. We assume that a piece cannot be divided and distributed to multiple guests.
|
def yukurid(a,b):
if a>b:
a,b = b,a
while b%a != 0:
a,b = b%a,a
return int(a)
A,B = map(int, input().split())
x = yukurid(A,B)
print(A*B/x)
|
s420905811
|
Accepted
| 26
| 9,108
| 308
|
import sys
import time
import math
def inpl():
return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------
A, B = map(int, input().split())
print(A*B // math.gcd(A,B))
# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)
|
s964414092
|
p03836
|
u652057333
| 2,000
| 262,144
|
Wrong Answer
| 25
| 3,064
| 466
|
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
|
sx, sy, tx, ty = map(int, input().split())
out = ""
def p(s):
global out
out += s
for i in range(ty-sy):
p("U")
for i in range(tx-sx):
p("R")
for i in range(ty-sy):
p("D")
for i in range(tx-sx):
p("L")
p("L")
for i in range(ty-sy+1):
p("U")
for i in range(tx-sx+1):
p("R")
for i in range(ty-sy+1):
p("D")
for i in range(tx-sx+1):
p("L")
p("U")
print(out)
|
s583584883
|
Accepted
| 25
| 3,064
| 479
|
sx, sy, tx, ty = map(int, input().split())
out = ""
def p(s):
global out
out += s
for i in range(ty-sy):
p("U")
for i in range(tx-sx):
p("R")
for i in range(ty-sy):
p("D")
for i in range(tx-sx):
p("L")
p("L")
for i in range(ty-sy+1):
p("U")
for i in range(tx-sx+1):
p("R")
p("D")
p("R")
for i in range(ty-sy+1):
p("D")
for i in range(tx-sx+1):
p("L")
p("U")
print(out)
|
s445840744
|
p02646
|
u626228246
| 2,000
| 1,048,576
|
Wrong Answer
| 25
| 9,164
| 123
|
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
|
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())
print("YES" if (T*(W-V)) >= (A-B) else "NO")
|
s091571583
|
Accepted
| 23
| 9,180
| 158
|
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())
if W == V:
print("NO")
else:
print("YES" if (T*(V-W)) >= abs(A-B) else "NO")
|
s332591234
|
p03693
|
u251662327
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 134
|
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())
number1 = str(r+g+b)
number2 = int(number1)
if number2%4 == 0:
print("YES")
else:
print("NO")
|
s676142046
|
Accepted
| 17
| 2,940
| 153
|
r,g,b = map(int,input().split())
1 <= r <= 9
1 <= g <= 9
1 <= b <= 9
number1 = r*100 + g*10 + b
if number1%4 == 0:
print("YES")
else:
print("NO")
|
s540327337
|
p03455
|
u355154595
| 2,000
| 262,144
|
Wrong Answer
| 30
| 8,976
| 80
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a,b=map(int,input().split())
if (a+b)%2==0:
print('Even')
else:
print('Odd')
|
s295885307
|
Accepted
| 26
| 9,076
| 81
|
a,b=map(int,input().split())
if (a*b)%2==0:
print('Even')
else:
print('Odd')
|
s368135588
|
p03698
|
u739843002
| 2,000
| 262,144
|
Wrong Answer
| 27
| 9,100
| 85
|
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
|
s = list(input())
t = list(set(s))
print("Yes") if len(s) == len(t) else print("No")
|
s623299297
|
Accepted
| 30
| 9,048
| 86
|
s = list(input())
t = list(set(s))
print("yes") if len(s) == len(t) else print("no")
|
s228797807
|
p03796
|
u594956556
| 2,000
| 262,144
|
Wrong Answer
| 36
| 2,940
| 94
|
Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
|
N = int(input())
MOD = 1000000007
power = 1
for i in range(1, N+1):
power = power * i % MOD
|
s350074768
|
Accepted
| 36
| 2,940
| 107
|
N = int(input())
MOD = 1000000007
power = 1
for i in range(1, N+1):
power = power * i % MOD
print(power)
|
s510338919
|
p03434
|
u546853743
| 2,000
| 262,144
|
Wrong Answer
| 33
| 8,984
| 100
|
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
|
n=int(input())
a=list(map(int,input().split()))
s=0
a.reverse()
s=sum(a[::2])-sum(a[1::2])
print(s)
|
s398549720
|
Accepted
| 25
| 9,016
| 104
|
n=int(input())
a=list(map(int,input().split()))
s=0
a.sort()
s=sum(a[:n:2])-sum(a[1:n:2])
print(abs(s))
|
s628893208
|
p03361
|
u985596066
| 2,000
| 262,144
|
Wrong Answer
| 35
| 3,296
| 656
|
We have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= `#`, and to make Square (i, j) white when s_{i, j}= `.`. However, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black. Determine if square1001 can achieve his objective.
|
H, W=map (int, input().split(' '))
z=[]
for i in range(H):
z.append(list(str(input())))
dx = [ 0, -1, 1, 0, ]
dy = [ 1, 0, 0, -1, ]
for h in range(H):
for w in range(W):
if z[h][w] == '#':
p=0
for i in range(4):
x = w + dx[i]
y = h + dy[i]
if x < 0 or y <0 or x > W-1 or y >H-1:
continue
print("x:"+str(x)+" y:"+str(y))
if z[y][x]=="#":
p+=1
if p==0:
print('No')
exit()
print('Yes')
|
s166706000
|
Accepted
| 26
| 3,064
| 591
|
H, W=map (int, input().split(' '))
z=[]
for i in range(H):
z.append(list(str(input())))
dx = [ 0, -1, 1, 0, ]
dy = [ 1, 0, 0, -1, ]
for h in range(H):
for w in range(W):
if z[h][w] == '#':
p=0
for i in range(4):
x = w + dx[i]
y = h + dy[i]
if x < 0 or y <0 or x > W-1 or y >H-1:
continue
if z[y][x]=="#":
p+=1
if p==0:
print('No')
exit()
print('Yes')
|
s343781219
|
p03485
|
u918770092
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 105
|
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())
x = (a + b) / 2
if type(x) == int:
print(x)
else :
print(int(x) + 1)
|
s629522570
|
Accepted
| 17
| 2,940
| 55
|
a, b = map(int, input().split())
print((a + b + 1)// 2)
|
s461774603
|
p02663
|
u273339216
| 2,000
| 1,048,576
|
Wrong Answer
| 23
| 9,168
| 141
|
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?
|
h1, m1, h2, m2, k = map(int, input().split())
h = h2 - h1
m = m2 - m1
if m < 0:
h = h - 1
m = 60 - m
total = h + m
print(total - k)
|
s153332346
|
Accepted
| 21
| 9,172
| 143
|
h1, m1, h2, m2, k = map(int, input().split())
h = (h2 - h1)*60
m = m2 - m1
if m < 0:
h = h - 60
m = 60 + m
total = h + m
print(total-k)
|
s137319791
|
p03095
|
u187205913
| 2,000
| 1,048,576
|
Wrong Answer
| 20
| 3,188
| 186
|
You are given a string S of length N. Among its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings. Here, a subsequence of a string is a concatenation of **one or more** characters from the string without changing the order.
|
n = int(input())
s = input()
a = list('abcdefghijklmnopqrstuvwxyz')
cnt = [0]*26
for i,a_ in enumerate(a):
cnt[i] += s.count(a_)
ans = 1
for cnt_ in cnt:
ans *= cnt_
print(ans-1)
|
s892717191
|
Accepted
| 20
| 3,188
| 199
|
n = int(input())
s = input()
a = list('abcdefghijklmnopqrstuvwxyz')
cnt = [0]*26
for i,a_ in enumerate(a):
cnt[i] += s.count(a_)+1
ans = 1
for cnt_ in cnt:
ans *= cnt_
print(ans%int(1e9+7)-1)
|
s462836500
|
p03958
|
u548624367
| 1,000
| 262,144
|
Wrong Answer
| 27
| 9,044
| 92
|
There are K pieces of cakes. Mr. Takahashi would like to eat one cake per day, taking K days to eat them all. There are T types of cake, and the number of the cakes of type i (1 ≤ i ≤ T) is a_i. Eating the same type of cake two days in a row would be no fun, so Mr. Takahashi would like to decide the order for eating cakes that minimizes the number of days on which he has to eat the same type of cake as the day before. Compute the minimum number of days on which the same type of cake as the previous day will be eaten.
|
N,K = map(int,input().split())
A = list(map(int,input().split()))
print(max(2*max(A)-K-1,0))
|
s733763346
|
Accepted
| 29
| 9,096
| 92
|
K,T = map(int,input().split())
A = list(map(int,input().split()))
print(max(2*max(A)-K-1,0))
|
s522601446
|
p04043
|
u806392288
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 121
|
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(str,input().split())
haiku = A+B+C
if haiku == ("755" or "575" or "557") :
print("YES")
else:
print("NO")
|
s395261525
|
Accepted
| 17
| 2,940
| 198
|
A,B,C = map(str,input().split())
haiku = A+B+C
flag = 0
if haiku == "755":
flag = 1
elif haiku == "575":
flag = 1
elif haiku == "557":
flag = 1
else:
print("NO")
if flag == 1:
print("YES")
|
s285476858
|
p03997
|
u094191970
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 79
|
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
roop_num = 3
a,b,h = [int(input()) for i in range(roop_num)]
print((a+b)*h*0.5)
|
s802302235
|
Accepted
| 17
| 2,940
| 62
|
a=int(input())
b=int(input())
h=int(input())
print((a+b)*h//2)
|
s160004524
|
p03475
|
u772180901
| 3,000
| 262,144
|
Wrong Answer
| 35
| 3,188
| 284
|
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.
|
n = int(input())
arr = [list(map(int,input().split())) for _ in range(n - 1)]
ans = []
time = 0
print(arr)
for i,j in enumerate(arr):
for k in arr[i+1:]:
time += k[0]
sum_ = sum(j[:-1]) + time
ans.append(sum_)
time = 0
ans.append(0)
for i in ans:
print(i)
|
s861492878
|
Accepted
| 97
| 3,188
| 384
|
n = int(input())
data = [list(map(int,input().split())) for _ in range(n - 1)]
time = [0] * n
for i,arr in enumerate(data):
for k in range(i+1):
if arr[1] > time[k]:
time[k] = arr[0] + arr[1]
elif time[k] % arr[2] == 0:
time[k] += arr[0]
else:
time[k] += arr[2] - (time[k] % arr[2]) + arr[0]
for i in time:
print(i)
|
s859580296
|
p03455
|
u077291787
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 121
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
# ABC086A - Product
a, b = list(map(int, input().rstrip().split()))
print("Even" if a % 2 == 0 and b % 2 == 0 else "Odd")
|
s546077013
|
Accepted
| 17
| 2,940
| 120
|
# ABC086A - Product
a, b = list(map(int, input().rstrip().split()))
print("Even" if a % 2 == 0 or b % 2 == 0 else "Odd")
|
s294864208
|
p03438
|
u480847874
| 2,000
| 262,144
|
Wrong Answer
| 22
| 4,596
| 266
|
You are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N. Determine if we can repeat the following operation zero or more times so that the sequences a and b become equal. Operation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two actions **simultaneously** : * Add 2 to a_i. * Add 1 to b_j.
|
def main():
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
print(sum(a), sum(b))
if a == b:
return print('Yes')
if sum(a) > sum(b):
return print('No')
return print('Yes')
main()
|
s560816814
|
Accepted
| 25
| 4,596
| 492
|
def after_exp():
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
count = sum(b) - sum(a)
if count < 0: return print('No')
if a == b: return print('Yes')
Amove = 0
Bmove = 0
for i in range(N):
if a[i] > b[i]:
Amove += a[i] - b[i]
else:
Bmove += (b[i] - a[i]) //2
if Amove > Bmove:
return print('No')
else:
return print('Yes')
# main()
after_exp()
|
s818264309
|
p03502
|
u693524218
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 163
|
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number.
|
N = int(input())
B = N
X = []
while B > 0:
X.append(B%10)
B //= 10
print(X)
print(B)
if N % sum(X) == 0:
print("Yes")
else:
print("No")
|
s021202943
|
Accepted
| 17
| 2,940
| 137
|
N = int(input())
B = N
X = []
while B > 0:
X.append(B%10)
B //= 10
if N % sum(X) == 0:
print("Yes")
else:
print("No")
|
s544291179
|
p03693
|
u864047888
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 87
|
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
|
a,b,c=map(int,input().split())
if 100*a+10*b+c%4==0:
print('YES')
else:
print('NO')
|
s488925107
|
Accepted
| 17
| 2,940
| 89
|
a,b,c=map(int,input().split())
if (100*a+10*b+c)%4==0:
print('YES')
else:
print('NO')
|
s241432421
|
p03448
|
u242393873
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 164
|
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i in a:
ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1)
print(round(ans))
|
s597555020
|
Accepted
| 51
| 3,060
| 217
|
a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in range(a+1):
for j in range(b+1):
for k in range(c+1):
if i * 500 + j * 100 + k * 50 == x:
ans += 1
print(ans)
|
s484524908
|
p00723
|
u124909914
| 1,000
| 131,072
|
Wrong Answer
| 280
| 6,804
| 377
|
RJ Freight, a Japanese railroad company for freight operations has recently constructed exchange lines at Hazawa, Yokohama. The layout of the lines is shown in Figure B-1. Figure B-1: Layout of the exchange lines A freight train consists of 2 to 72 freight cars. There are 26 types of freight cars, which are denoted by 26 lowercase letters from "a" to "z". The cars of the same type are indistinguishable from each other, and each car's direction doesn't matter either. Thus, a string of lowercase letters of length 2 to 72 is sufficient to completely express the configuration of a train. Upon arrival at the exchange lines, a train is divided into two sub-trains at an arbitrary position (prior to entering the storage lines). Each of the sub- trains may have its direction reversed (using the reversal line). Finally, the two sub-trains are connected in either order to form the final configuration. Note that the reversal operation is optional for each of the sub-trains. For example, if the arrival configuration is "abcd", the train is split into two sub-trains of either 3:1, 2:2 or 1:3 cars. For each of the splitting, possible final configurations are as follows ("+" indicates final concatenation position): [3:1] abc+d cba+d d+abc d+cba [2:2] ab+cd ab+dc ba+cd ba+dc cd+ab cd+ba dc+ab dc+ba [1:3] a+bcd a+dcb bcd+a dcb+a Excluding duplicates, 12 distinct configurations are possible. Given an arrival configuration, answer the number of distinct configurations which can be constructed using the exchange lines described above.
|
ls = []
def add(t):
if t not in ls:
ls.append(t)
n = int(input())
for i in range(n):
t = input()[:-1]
ls = [t]
for j in range(1,len(t)):
f, b = t[:j], t[j:]
add(f+b[::-1])
add(f[::-1]+b)
add(f[::-1]+b[::-1])
add(b+f)
add(b+f[::-1])
add(b[::-1]+f)
add(b[::-1]+f[::-1])
print(len(ls))
|
s419699644
|
Accepted
| 280
| 6,780
| 372
|
ls = []
def add(t):
if t not in ls:
ls.append(t)
n = int(input())
for i in range(n):
t = input()
ls = [t]
for j in range(1,len(t)):
f, b = t[:j], t[j:]
add(f+b[::-1])
add(f[::-1]+b)
add(f[::-1]+b[::-1])
add(b+f)
add(b+f[::-1])
add(b[::-1]+f)
add(b[::-1]+f[::-1])
print(len(ls))
|
s019906795
|
p02397
|
u669360983
| 1,000
| 131,072
|
Wrong Answer
| 30
| 6,720
| 107
|
Write a program which reads two integers x and y, and prints them in ascending order.
|
x=1
y=1
while x!=0 and y!=0 :
x,y=map(int, input().split(" "))
if y<x :
k=x
x=y
y=k
print(x,"",+y)
|
s722042929
|
Accepted
| 50
| 6,724
| 122
|
x=1
y=1
while True :
x,y=map(int, input().split(" "))
if x==0 and y==0 :
break
if y<x :
k=x
x=y
y=k
print(x,y)
|
s595588440
|
p02615
|
u949315872
| 2,000
| 1,048,576
|
Wrong Answer
| 128
| 31,416
| 153
|
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())
list =list(map(int, input().split()))
list.sort(reverse=True)
ans = 0
for i in range(n):
ans += list[i]
ans -= list[0]
print(ans)
|
s181839445
|
Accepted
| 131
| 31,572
| 258
|
n = int(input())
A =list(map(int, input().split()))
A.sort(reverse=True)
ans = 0
if n % 2 == 0:
for i in range(n//2):
ans += 2* A[i]
ans -= A[0]
else:
for i in range((n-1)//2):
ans += 2*A[i]
ans -= A[0]
ans += A[(n-1)//2]
print(ans)
|
s641299670
|
p03574
|
u555947166
| 2,000
| 262,144
|
Wrong Answer
| 21
| 3,188
| 987
|
You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process.
|
H, W = list(map(int, input().split()))
rows = [input() for i in range(H)]
grid = [list(row) for row in rows]
'''generating a grid expanded by '&'. For example,
&&&&&
#.# &#.#&
### -> &###&
##. &##.&
&&&&&
'''
expanded_grid = [list('&' * (W + 2))]
for row in rows:
expanded_grid.append(list('&' + row + '&'))
expanded_grid.append(list('&' * (W + 2)))
for i in range(H):
for j in range(W):
if (grid[i])[j] == '.':
EightPiece = [
(expanded_grid[i])[j],
(expanded_grid[i])[j+1],
(expanded_grid[i])[j + 2],
(expanded_grid[i+1])[j],
(expanded_grid[i])[j+2],
(expanded_grid[i+2])[j],
(expanded_grid[i+2])[j],
(expanded_grid[i+2])[j],
]
(grid[i])[j] = str(EightPiece.count('#'))
for row_in_the_form_of_list in grid:
print(''.join(row_in_the_form_of_list))
|
s946650824
|
Accepted
| 21
| 3,188
| 994
|
H, W = list(map(int, input().split()))
rows = [input() for i in range(H)]
grid = [list(row) for row in rows]
'''generating a grid expanded by '&'. For example,
&&&&&
#.# &#.#&
### -> &###&
##. &##.&
&&&&&
'''
expanded_grid = [list('&' * (W + 2))]
for row in rows:
expanded_grid.append(list('&' + row + '&'))
expanded_grid.append(list('&' * (W + 2)))
for i in range(H):
for j in range(W):
if (grid[i])[j] == '.':
EightPiece = [
(expanded_grid[i])[j],
(expanded_grid[i])[j+1],
(expanded_grid[i])[j + 2],
(expanded_grid[i+1])[j],
(expanded_grid[i+1])[j+2],
(expanded_grid[i+2])[j],
(expanded_grid[i+2])[j+1],
(expanded_grid[i+2])[j+2],
]
(grid[i])[j] = str(EightPiece.count('#'))
for row_in_the_form_of_list in grid:
print(''.join(row_in_the_form_of_list))
|
s959753475
|
p03672
|
u619785253
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 200
|
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.
|
s = list(input())
l = len(s)//2
l2 = 0
ans = 0
print(s)
for i in range(1,len(s)//2):
s2 = s[0:-2*i]
print(s2)
l2 = len(s2)//2
if s2[0:l2]==s2[l2:]:
ans = len(s2)
break
print (ans)
|
s693805137
|
Accepted
| 17
| 3,060
| 202
|
s = list(input())
l = len(s)//2
l2 = 0
ans = 0
#print(s)
for i in range(1,len(s)//2):
s2 = s[0:-2*i]
#print(s2)
l2 = len(s2)//2
if s2[0:l2]==s2[l2:]:
ans = len(s2)
break
print (ans)
|
s717293041
|
p02613
|
u525796732
| 2,000
| 1,048,576
|
Wrong Answer
| 83
| 10,476
| 586
|
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.
|
import sys
import math
import fractions
from collections import defaultdict
stdin = sys.stdin
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
N=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(N):
S=ns()
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))
|
s328628096
|
Accepted
| 84
| 10,476
| 582
|
import sys
import math
import fractions
from collections import defaultdict
stdin = sys.stdin
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
N=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(N):
S=ns()
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))
|
s278948944
|
p03738
|
u414877092
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 332
|
You are given two positive integers A and B. Compare the magnitudes of these numbers.
|
a=input()
b=input()
if len(a)>len(b):
print("GREATER")
exit()
elif len(a)<len(b):
print("LESS")
exit()
else:
for i in range(len(a)):
if a[i]>b[i]:
print("GRATER")
exit()
elif a[i]<b[i]:
print("LESS")
exit()
print("EQUAL")
|
s717314261
|
Accepted
| 17
| 3,064
| 307
|
a=input()
b=input()
if len(a)>len(b):
print("GREATER")
exit()
elif len(a)<len(b):
print("LESS")
exit()
else:
for i in range(len(a)):
if a[i]>b[i]:
print("GREATER")
exit()
elif a[i]<b[i]:
print("LESS")
exit()
print("EQUAL")
|
s976654373
|
p03160
|
u201856486
| 2,000
| 1,048,576
|
Wrong Answer
| 104
| 13,716
| 4,870
|
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
|
import sys
# import math
# import itertools
# import numpy as np
# import collections
"""Template"""
class IP:
def __init__(self):
self.input = sys.stdin.readline
def I(self):
return int(self.input())
def S(self):
return self.input()
def IL(self):
return list(map(int, self.input().split()))
def SL(self):
return list(map(str, self.input().split()))
def ILS(self, n):
return [int(self.input()) for _ in range(n)]
def SLS(self, n):
return [self.input() for _ in range(n)]
def SILS(self, n):
return [self.IL() for _ in range(n)]
def SSLS(self, n):
return [self.SL() for _ in range(n)]
class Idea:
def __init__(self):
pass
def HF(self, p):
return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))
def Bfs2(self, a):
# https://blog.rossywhite.com/2018/08/06/bit-search/
value = []
for i in range(1 << len(a)):
output = []
for j in range(len(a)):
if self.bit_o(i, j):
# output.append(a[j])
output.append(a[j])
value.append([format(i, 'b').zfill(16), sum(output)])
value.sort(key=lambda x: x[1])
bin = [value[k][0] for k in range(len(value))]
val = [value[k][1] for k in range(len(value))]
return bin, val
def S(self, s, r=0, m=-1):
r = bool(r)
if m == -1:
s.sort(reverse=r)
else:
s.sort(reverse=r, key=lambda x: x[m])
def bit_n(self, a, b):
return bool((a >> b & 1) > 0)
def bit_o(self, a, b):
return bool(((a >> b) & 1) == 1)
def ceil(self, x, y):
return -(-x // y)
def ave(self, a):
return sum(a) / len(a)
def gcd(self, x, y):
if y == 0:
return x
else:
return self.gcd(y, x % y)
def main():
r, e, p = range, enumerate, print
ip = IP()
id = Idea()
mod = 10 ** 9 + 7
n = ip.I()
h = ip.IL()
dp = [0] * n
dp[1] = abs(h[0] - h[1])
for i in r(2, n):
dp[i] = min(abs(h[i] - h[i - 1]) + h[i - 1], abs(h[i] - h[i - 2]) + h[i - 2])
print(dp[-1])
main()
|
s376909402
|
Accepted
| 133
| 13,876
| 158
|
n,*h=map(int,open(0).read().split());d=[0]*n;d[1]=abs(h[1]-h[0])
for i in range(2,n):
d[i]=min(d[i-1]+abs(h[i]-h[i-1]),d[i-2]+abs(h[i]-h[i-2]))
print(d[-1])
|
s634916541
|
p03919
|
u379702654
| 2,000
| 262,144
|
Wrong Answer
| 28
| 3,828
| 428
|
There is a grid with H rows and W columns. The square at the i-th row and j-th column contains a string S_{i,j} of length 5. The rows are labeled with the numbers from 1 through H, and the columns are labeled with the uppercase English letters from `A` through the W-th letter of the alphabet. Exactly one of the squares in the grid contains the string `snuke`. Find this square and report its location. For example, the square at the 6-th row and 8-th column should be reported as `H6`.
|
from string import ascii_uppercase
def row_label(i):
return str(i + 1)
def col_label(j):
return ascii_uppercase[j]
def solve(s_list):
for (i, j) in zip(range(h), range(w)):
if s_list[i][j] == 'snuke':
return col_label(j) + row_label(i)
if __name__ == '__main__':
(h, w) = (int(_) for _ in input().split())
s_list = [list(input().split()) for _ in range(h)]
print(solve(s_list))
|
s937737754
|
Accepted
| 25
| 3,772
| 442
|
from string import ascii_uppercase
def row_label(i):
return str(i + 1)
def col_label(j):
return ascii_uppercase[j]
def solve(s_list):
for i in range(h):
for j in range(w):
if s_list[i][j] == 'snuke':
return col_label(j) + row_label(i)
if __name__ == '__main__':
(h, w) = (int(_) for _ in input().split())
s_list = [list(input().split()) for _ in range(h)]
print(solve(s_list))
|
s268541774
|
p03377
|
u162019547
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 93
|
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a, b, x = map(int, input().split())
if x >= a and x < a+b:
print('Yes')
else:
print('No')
|
s122571251
|
Accepted
| 17
| 2,940
| 94
|
a, b, x = map(int, input().split())
if x >= a and x <= a+b:
print('YES')
else:
print('NO')
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.