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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s903471955
|
p03719
|
u218984487
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 97 |
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())
if a <= c and b >= c:
print("YES")
else:
print("NO")
|
s454008434
|
Accepted
| 17 | 2,940 | 97 |
a, b, c = map(int, input().split())
if a <= c and b >= c:
print("Yes")
else:
print("No")
|
s045277997
|
p02281
|
u113295414
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,608 | 658 |
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 = [[] for i in range(n)]
for i in range(n):
id, left, right = map(int, input().split())
tree[id] = [left, right]
def preoder(id):
if id == -1:
return
print(' ' + str(id), end='')
preoder(tree[id][0])
preoder(tree[id][1])
def inorder(id):
if id == -1:
return
inorder(tree[id][0])
print(' ' + str(id), end='')
inorder(tree[id][1])
def postorder(id):
if id == -1:
return
postorder(tree[id][0])
postorder(tree[id][1])
print(' ' + str(id), end='')
print('Preoder')
preoder(0)
print('')
print('Inorder')
inorder(0)
print('')
print('Postorder')
postorder(0)
|
s328944268
|
Accepted
| 20 | 5,616 | 899 |
n = int(input())
tree = [[-1, -1, True] for i in range(n)]
for i in range(n):
id, left, right = map(int, input().split())
if left != -1:
tree[id][0] = left
tree[left][2] = False
if right != -1:
tree[id][1] = right
tree[right][2] = False
def preoder(id):
if id == -1:
return
print(' ' + str(id), end='')
preoder(tree[id][0])
preoder(tree[id][1])
def inorder(id):
if id == -1:
return
inorder(tree[id][0])
print(' ' + str(id), end='')
inorder(tree[id][1])
def postorder(id):
if id == -1:
return
postorder(tree[id][0])
postorder(tree[id][1])
print(' ' + str(id), end='')
root = 0
for i, node in enumerate(tree):
if node[2] == True:
root = i
print('Preorder')
preoder(root)
print('')
print('Inorder')
inorder(root)
print('')
print('Postorder')
postorder(root)
print('')
|
s605133484
|
p02613
|
u575956662
| 2,000 | 1,048,576 |
Wrong Answer
| 149 | 9,208 | 345 |
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())
word_list = ['AC','WA','TLE','RE']
A = 0
W = 0
T = 0
R = 0
for i in range(n):
s = input()
if s == 'AC':
A = A + 1
elif s == 'WA':
W = W + 1
elif s == 'TLE':
T = T + 1
else:
R = R + 1
Ans_list = [A,W,T,R]
for i in range(4):
print(str(word_list[i])+ ' × '+ str(Ans_list[i]))
|
s950432546
|
Accepted
| 149 | 9,212 | 344 |
n=int(input())
word_list = ['AC','WA','TLE','RE']
A = 0
W = 0
T = 0
R = 0
for i in range(n):
s = input()
if s == 'AC':
A = A + 1
elif s == 'WA':
W = W + 1
elif s == 'TLE':
T = T + 1
else:
R = R + 1
Ans_list = [A,W,T,R]
for i in range(4):
print(str(word_list[i])+ ' x '+ str(Ans_list[i]))
|
s246785062
|
p02413
|
u957680575
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,660 | 163 |
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())
for i in range(r):
a=list(map(int,input().split()))
a_str=map(str,a)
print(" ".join(a_str)+" "+str(sum(a)))
|
s360263851
|
Accepted
| 20 | 7,764 | 333 |
r, c = map(int,input().split())
b=[]
for i in range(r):
a=list(map(int,input().split()))
a.append(sum(a))
b.append(a)
a=map(str,a)
print(" ".join(a))
d=[]
for i in range(c+1):
cs=[]
for j in range(r):
cs.append(b[j][i])
d.append(sum(cs))
d=map(str,d)
print(" ".join(d))
|
s455725626
|
p02694
|
u163353866
| 2,000 | 1,048,576 |
Wrong Answer
| 23 | 9,100 | 100 |
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
import math
X=float(input())
i=0
y= 100
while X >= y:
i=i+1
y=y*1.01
y=math.floor(y)
print(i)
|
s165699469
|
Accepted
| 23 | 9,172 | 173 |
import math
import sys
X=int(input())
i=0
y= 100
if X==y:
print(i)
sys.exit()
while X > y:
i=i+1
y=y*1.01
y=math.floor(y)
if X==y:
print(i)
sys.exit()
print(i)
|
s049460248
|
p02261
|
u024203289
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,608 | 1,212 |
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).
|
N = int(input())
C1 = list(input().split())
C2 = C1[:]
def get_card_suit(card):
return card[:1]
def get_card_value(card):
return card[1:]
def bubble_sort(card):
r_exists = True
while r_exists == True:
r_exists = False
i = N - 1
while i >= 1:
if get_card_value(card[i]) < get_card_value(card[i - 1]):
card[i], card[i - 1] = card[i - 1], card[i]
r_exists = True
i -= 1
def select_sort(card):
i = 0
while i < N:
min_j = i
j = i
while j < N:
if get_card_value(card[j]) < get_card_value(card[min_j]):
min_j = j
j += 1
card[i], card[min_j] = card[min_j], card[i]
i += 1
def output(card):
s = ''
for x in card:
s = s + str(x) + ' '
print(s.rstrip())
def is_stable():
i = 0
while i < N:
if get_card_suit(C1[i]) != get_card_suit(C2[i]):
return False
i += 1
return True
bubble_sort(C1)
select_sort(C2)
output(C1)
print('Stable')
output(C2)
if is_stable() == True:
print('Stable')
else:
print('Not Stable')
|
s322304375
|
Accepted
| 20 | 5,608 | 1,212 |
N = int(input())
C1 = list(input().split())
C2 = C1[:]
def get_card_suit(card):
return card[:1]
def get_card_value(card):
return card[1:]
def bubble_sort(card):
r_exists = True
while r_exists == True:
r_exists = False
i = N - 1
while i >= 1:
if get_card_value(card[i]) < get_card_value(card[i - 1]):
card[i], card[i - 1] = card[i - 1], card[i]
r_exists = True
i -= 1
def select_sort(card):
i = 0
while i < N:
min_j = i
j = i
while j < N:
if get_card_value(card[j]) < get_card_value(card[min_j]):
min_j = j
j += 1
card[i], card[min_j] = card[min_j], card[i]
i += 1
def output(card):
s = ''
for x in card:
s = s + str(x) + ' '
print(s.rstrip())
def is_stable():
i = 0
while i < N:
if get_card_suit(C1[i]) != get_card_suit(C2[i]):
return False
i += 1
return True
bubble_sort(C1)
select_sort(C2)
output(C1)
print('Stable')
output(C2)
if is_stable() == True:
print('Stable')
else:
print('Not stable')
|
s140598321
|
p03047
|
u514299323
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 53 |
Snuke has N integers: 1,2,\ldots,N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers?
|
N,K = map(int,input().split())
ans = K-N+1
print(ans)
|
s703777252
|
Accepted
| 18 | 2,940 | 53 |
N,K = map(int,input().split())
ans = N-K+1
print(ans)
|
s924351855
|
p03643
|
u917558625
| 2,000 | 262,144 |
Wrong Answer
| 27 | 8,944 | 22 |
This contest, _AtCoder Beginner Contest_ , is abbreviated as _ABC_. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer.
|
N=input()
print(N[3:])
|
s331874861
|
Accepted
| 31 | 9,060 | 20 |
print('ABC'+input())
|
s384909425
|
p03377
|
u238956837
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 107 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a,b,x = map(int, input().split())
if a > x:
print('No')
elif a+b < x:
print('Yes')
else:
print('No')
|
s776378224
|
Accepted
| 18 | 2,940 | 107 |
a,b,x = map(int, input().split())
if a > x:
print('NO')
elif a+b < x:
print('NO')
else:
print('YES')
|
s092066186
|
p03971
|
u532141811
| 2,000 | 262,144 |
Wrong Answer
| 122 | 4,016 | 370 |
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these. Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests. * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B. * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students. A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these. Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass.
|
N, A, B = map(int, input().split())
s = input()
x = A + B
cnt = 1
rank = 1
for i in range(N):
y = s[i : i+1]
if cnt <= x:
if y == "a":
print("yes")
cnt += 1
elif y == "b" and rank <= B:
print("yes")
cnt += 1
rank += 1
else:
print("No")
else:
print("No")
|
s478797232
|
Accepted
| 118 | 4,016 | 370 |
N, A, B = map(int, input().split())
s = input()
x = A + B
cnt = 1
rank = 1
for i in range(N):
y = s[i : i+1]
if cnt <= x:
if y == "a":
print("Yes")
cnt += 1
elif y == "b" and rank <= B:
print("Yes")
cnt += 1
rank += 1
else:
print("No")
else:
print("No")
|
s362947452
|
p02603
|
u149235455
| 2,000 | 1,048,576 |
Wrong Answer
| 34 | 9,116 | 463 |
To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives. He is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows: * A_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day. In the i-th day, M-kun can make the following trade **any number of times** (possibly zero), **within the amount of money and stocks that he has at the time**. * Buy stock: Pay A_i yen and receive one stock. * Sell stock: Sell one stock for A_i yen. What is the maximum possible amount of money that M-kun can have in the end by trading optimally?
|
import sys
input=sys.stdin.readline
n=int(input())
arr=list(map(int,input().split()))
have=0
ans=0
rate=0
for i in range(n-1):
#print(have)
if(have!=0):
if(arr[i+1]<arr[i]):
ans+=have*(arr[i]-rate)
have=0
else:
if(arr[i+1]>arr[i]):
have=1000//arr[i]
rate=arr[i]
#print(have)
if(have!=0):
ans+=have*(arr[-1]-rate)
have=0
print(ans+1000)
|
s461503994
|
Accepted
| 31 | 9,104 | 474 |
import sys
input=sys.stdin.readline
n=int(input())
arr=list(map(int,input().split()))
have=0
ans=1000
rate=0
for i in range(n-1):
if(have!=0):
if(arr[i+1]<arr[i]):
ans+=have*(arr[i]-rate)
have=0
else:
if(arr[i+1]>arr[i]):
have=ans//arr[i]
rate=arr[i]
#print(have,ans,rate)
#print(have)
if(have!=0):
ans+=have*(arr[-1]-rate)
have=0
print(ans)
|
s488579649
|
p03696
|
u606045429
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 290 |
You are given a string S of length N consisting of `(` and `)`. Your task is to insert some number of `(` and `)` into S to obtain a _correct bracket sequence_. Here, a correct bracket sequence is defined as follows: * `()` is a correct bracket sequence. * If X is a correct bracket sequence, the concatenation of `(`, X and `)` in this order is also a correct bracket sequence. * If X and Y are correct bracket sequences, the concatenation of X and Y in this order is also a correct bracket sequence. * Every correct bracket sequence can be derived from the rules above. Find the shortest correct bracket sequence that can be obtained. If there is more than one such sequence, find the lexicographically smallest one.
|
N, S = open(0)
cnt = left = 0
for s in S:
if s == "(":
cnt += 1
else:
cnt -= 1
if cnt < 0:
left = max(left, -cnt)
S = "(" * left + S
right = 0
for s in S:
if s == "(":
right += 1
else:
right -= 1
S = S + ")" * right
print(S)
|
s745812879
|
Accepted
| 17 | 3,060 | 312 |
N, S = open(0)
S = S.strip()
cnt = left = 0
for s in S:
if s == "(":
cnt += 1
else:
cnt -= 1
if cnt < 0:
left = max(left, -cnt)
S = "(" * left + S
right = 0
for s in S:
if s == "(":
right += 1
else:
right -= 1
S = S + ")" * right
print(S)
|
s881003127
|
p03141
|
u923712635
| 2,000 | 1,048,576 |
Wrong Answer
| 527 | 26,024 | 431 |
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".
|
from operator import itemgetter
N = int(input())
dish = [[0 for _ in range(3)] for _ in range(N)]
Takahashi = []
Aoki = []
for i in range(N):
dish[i][0],dish[i][1] = [int(x) for x in input().split()]
dish[i][2] = dish[i][0]+dish[i][1]
dish.sort(key=itemgetter(2),reverse=True)
for i in range(int(N/2)):
Takahashi.append(dish[2*i][0])
if(2*i<=N-2):
Aoki.append(dish[2*i+1][1])
print(sum(Takahashi)-sum(Aoki))
|
s137547896
|
Accepted
| 597 | 33,120 | 411 |
N = int(input())
dish = [[0 for _ in range(3)] for _ in range(N)]
Takahashi = []
Aoki = []
for i in range(N):
dish[i][0],dish[i][1] = [int(x) for x in input().split()]
dish[i][2] = dish[i][0]+dish[i][1]
dish.sort(key=lambda x:(x[2],x[0],x[1]),reverse=True)
for i in range(N):
if(i%2==0):
Takahashi.append(dish[i][0])
else:
Aoki.append(dish[i][1])
print(sum(Takahashi)-sum(Aoki))
|
s237327026
|
p02865
|
u088989565
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 2,940 | 63 |
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
|
N = int(input())
if(N%2==0):
print(N/2-1)
else:
print(N//2)
|
s751397398
|
Accepted
| 21 | 3,316 | 64 |
N = int(input())
if(N%2==0):
print(N//2-1)
else:
print(N//2)
|
s064862157
|
p03377
|
u311379832
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 97 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
A, B, X = map(int,input().split())
if A > X or A + B < X:
print('No')
else:
print('Yes')
|
s522884059
|
Accepted
| 17 | 2,940 | 97 |
A, B, X = map(int,input().split())
if A > X or A + B < X:
print('NO')
else:
print('YES')
|
s707770055
|
p03565
|
u135847648
| 2,000 | 262,144 |
Wrong Answer
| 20 | 3,188 | 540 |
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`.
|
import re
s = input().replace('?', '.')
t = input()
print("s,t:", s, t)
for i in range(len(s) - len(t), -1, -1):
if re.match(s[i:i + len(t)], t):
#print(s[i:i + len(t)], t)
s = s.replace('.', 'a')
print(s[:i] + t + s[i + len(t):])
exit()
print('UNRESTORABLE')
|
s064724676
|
Accepted
| 20 | 3,188 | 541 |
import re
s = input().replace('?', '.')
t = input()
#print("s,t:", s, t)
for i in range(len(s) - len(t), -1, -1):
if re.match(s[i:i + len(t)], t):
#print(s[i:i + len(t)], t)
s = s.replace('.', 'a')
print(s[:i] + t + s[i + len(t):])
exit()
print('UNRESTORABLE')
|
s717001569
|
p02613
|
u166849422
| 2,000 | 1,048,576 |
Wrong Answer
| 149 | 9,212 | 269 |
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())
wa = 0
ac = 0
tle = 0
re = 0
for i in range(n):
x = input()
if x == "RE": re+=1
if x == "TLE": tle+=1
if x == "AC": ac+=1
if x == "WA": wa+=1
print("AC × "+str(ac))
print("WA × "+str(wa))
print("TLE × "+str(tle))
print("RE × "+str(re))
|
s673704896
|
Accepted
| 149 | 9,208 | 265 |
n = int(input())
wa = 0
ac = 0
tle = 0
re = 0
for i in range(n):
x = input()
if x == "RE": re+=1
if x == "TLE": tle+=1
if x == "AC": ac+=1
if x == "WA": wa+=1
print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))
|
s901014310
|
p04046
|
u994521204
| 2,000 | 262,144 |
Wrong Answer
| 983 | 22,892 | 480 |
We have a large square grid with H rows and W columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the bottom-right cell. However, she cannot enter the cells in the intersection of the bottom A rows and the leftmost B columns. (That is, there are A×B forbidden cells.) There is no restriction on entering the other cells. Find the number of ways she can travel to the bottom-right cell. Since this number can be extremely large, print the number modulo 10^9+7.
|
H, W, A, B = map(int, input().split())
mod=10**9+7
N=H+W+1
bikkuri=[0 for i in range(N)]
bikkuri[0]=1
for i in range(1,N):
bikkuri[i] = (i * bikkuri[i-1])%mod
gyaku=[0 for i in range(N)]
gyaku[0]=1
for i in range(1, N):
gyaku[i]=pow(bikkuri[i], mod-2, mod)
def comb(n,r):
return bikkuri[n]*gyaku[n-r]*gyaku[r]%mod
def homb(n,r):
return comb(n+r,r)%mod
dame = []
for i in range(B):
dame.append(homb(H-A-1, i) * homb(W-1-i,A-1))
ans = homb(W-1, H-1) - sum(dame)
|
s730117021
|
Accepted
| 997 | 22,864 | 504 |
#ABC042D
H, W, A, B = map(int, input().split())
mod=10**9+7
N=H+W+1
bikkuri=[0 for i in range(N)]
bikkuri[0]=1
for i in range(1,N):
bikkuri[i] = (i * bikkuri[i-1])%mod
gyaku=[0 for i in range(N)]
gyaku[0]=1
for i in range(1, N):
gyaku[i]=pow(bikkuri[i], mod-2, mod)
def comb(n,r):
return bikkuri[n]*gyaku[n-r]*gyaku[r]%mod
def homb(n,r):
return comb(n+r,r)%mod
dame = []
for i in range(B):
dame.append(homb(H-A-1, i) * homb(W-1-i,A-1))
ans = homb(W-1, H-1) - sum(dame)
print(ans%mod)
|
s758995018
|
p03997
|
u677393869
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 61 |
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a=int(input())
b=int(input())
h=int(input())
print((a+b)*h/2)
|
s643972535
|
Accepted
| 18 | 2,940 | 70 |
a=int(input())
b=int(input())
h=int(input())
s=(a+b)*h/2
print(int(s))
|
s425286739
|
p03387
|
u819710930
| 2,000 | 262,144 |
Time Limit Exceeded
| 2,104 | 7,280 | 223 |
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.
|
l=sorted(map(int,input().split()))
cnt=0
while l[2]-l[1]>1 or l[2]-l[0]>1:
print(0)
if l[2]-1>l[0]: l[1]+=2
else: l[1]+=2
cnt+=1
if l[0]==l[1]==l[2]: print(cnt)
elif l[1]==l[0]:print(cnt+1)
else:print(cnt+2)
|
s494809122
|
Accepted
| 17 | 3,064 | 210 |
l=sorted(map(int,input().split()))
cnt=0
while l[2]-l[1]>1 or l[2]-l[0]>1:
if l[2]-1>l[0]: l[0]+=2
else: l[1]+=2
cnt+=1
if l[0]==l[1]==l[2]: print(cnt)
elif l[1]==l[0]:print(cnt+1)
else:print(cnt+2)
|
s474205656
|
p03352
|
u708255304
| 2,000 | 1,048,576 |
Time Limit Exceeded
| 2,106 | 2,940 | 158 |
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 = []
for i in range(1000):
for j in range(1000):
if i**j > X:
continue
ans.append(i**j)
print(max(ans))
|
s929097628
|
Accepted
| 21 | 2,940 | 162 |
X = int(input())
ans = []
for i in range(1, 1000):
for j in range(2, 11):
if i**j > X:
continue
ans.append(i**j)
print(max(ans))
|
s138391061
|
p03997
|
u473023730
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 62 |
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a=int(input())
b=int(input())
h=int(input())
print((a+b)*h/2)
|
s813457710
|
Accepted
| 17 | 2,940 | 67 |
a=int(input())
b=int(input())
h=int(input())
print(int((a+b)*h/2))
|
s789553024
|
p03401
|
u745087332
| 2,000 | 262,144 |
Wrong Answer
| 196 | 14,172 | 485 |
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled.
|
# coding:utf-8
INF = float('inf')
def inpl(): return list(map(int, input().split()))
N = int(input())
A = inpl()
B = [abs(0 - A[0])]
for i in range(1, N):
B.append(abs(A[i - 1] - A[i]))
else:
B.append(abs(A[-1] - 0))
total = sum(B)
print(B)
for i in range(N - 1):
if A[i] <= 0 <= A[i + 1]:
print(total - 2 * B[i])
elif A[i] >= 0 >= A[i + 1]:
print(total - 2 * B[i])
else:
print(total)
else:
print(total - sum(B[-2:]) + abs(A[-2]))
|
s963065762
|
Accepted
| 256 | 14,052 | 651 |
# coding:utf-8
import sys
INF = float('inf')
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
n = II()
A = [0] + LI() + [0]
C = [0]
for a1, a2 in zip(A[:-1], A[1:]):
C.append(C[-1] + abs(a2 - a1))
for i in range(1, n + 1):
if A[i - 1] <= A[i] <= A[i + 1]:
print(C[-1])
elif A[i - 1] >= A[i] >= A[i + 1]:
print(C[-1])
else:
print(C[-1] - 2 * min(abs(A[i] - A[i - 1]), abs(A[i] - A[i + 1])))
|
s918876127
|
p03564
|
u178432859
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 120 |
Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value: * Operation A: The displayed value is doubled. * Operation B: The displayed value increases by K. Square1001 needs to perform these operations N times in total. Find the minimum possible value displayed in the board after N operations.
|
n = int(input())
k = int(input())
for i in range(n):
if n*2 < n+k:
n = n*2
else:
n += k
print(n)
|
s152301033
|
Accepted
| 17 | 2,940 | 127 |
n = int(input())
k = int(input())
x = 1
for i in range(n):
if x*2 < x+k:
x = x*2
else:
x += k
print(x)
|
s165698330
|
p03477
|
u612975321
| 2,000 | 262,144 |
Wrong Answer
| 29 | 9,068 | 138 |
A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan. Print `Left` if the balance scale tips to the left; print `Balanced` if it balances; print `Right` if it tips to the right.
|
a, b, c, d = map(int,input().split())
if a + b > c + d:
print('Left')
if a + b < c + d:
print('Right')
else:
print('Balanced')
|
s244713580
|
Accepted
| 31 | 9,092 | 140 |
a, b, c, d = map(int,input().split())
if a + b > c + d:
print('Left')
elif a + b < c + d:
print('Right')
else:
print('Balanced')
|
s771385735
|
p02842
|
u729133443
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 48 |
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer). Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer. If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.
|
n=int(input())+1;print(n%27%14and n//1.08or':(')
|
s499803418
|
Accepted
| 17 | 2,940 | 54 |
n=int(input())*25;m=(n+24)//27;print((m,':(')[m*27<n])
|
s737490663
|
p02645
|
u255898796
| 2,000 | 1,048,576 |
Wrong Answer
| 28 | 9,056 | 24 |
When you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters. You have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him.
|
a = input()
print(a[:2])
|
s167050107
|
Accepted
| 25 | 8,660 | 37 |
a = input()
print(a[0] + a[1] + a[2])
|
s776984757
|
p03485
|
u795733769
| 2,000 | 262,144 |
Wrong Answer
| 25 | 9,092 | 58 |
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-1)/2
print(x)
|
s289336023
|
Accepted
| 23 | 9,028 | 60 |
a, b = map(int, input().split())
x = (a+b+2-1)//2
print(x)
|
s567794151
|
p03455
|
u489829763
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 97 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a, b= (int(x) for x in input().split( ))
if (a*b)%2==0:
print('even')
else:
print('odd')
|
s261591591
|
Accepted
| 17 | 2,940 | 82 |
a,b=map(int,input().split())
if a*b%2==0:
print("Even")
else:
print("Odd")
|
s902101698
|
p03251
|
u002459665
| 2,000 | 1,048,576 |
Wrong Answer
| 20 | 3,060 | 400 |
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
|
def main():
n, m, x, y = map(int, input().split())
dx = map(int, input().split())
dy = map(int, input().split())
max_x = max(list(dx))
min_y = min(list(dy))
z = x + 1
while z <= y:
if z > max_x and z <= min_y:
print("No War", z)
# print("No War")
exit()
z += 1
print("War")
if __name__ == '__main__':
main()
|
s566468888
|
Accepted
| 18 | 3,064 | 683 |
def main():
n, m, x, y = map(int, input().split())
dx = map(int, input().split())
dy = map(int, input().split())
max_x = max(list(dx))
min_y = min(list(dy))
z = x + 1
while z <= y:
if z > max_x and z <= min_y:
print("No War")
exit()
z += 1
print("War")
def main2():
n, m, x, y = map(int, input().split())
dx = map(int, input().split())
dy = map(int, input().split())
dx = list(dx)
dy = list(dy)
dx.append(x)
dy.append(y)
if max(dx) < min(dy):
print("No War")
else:
print("War")
if __name__ == '__main__':
main2()
|
s091802017
|
p03730
|
u202188504
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 129 |
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()
print('No')
|
s702273472
|
Accepted
| 17 | 2,940 | 129 |
A, B, C = map(int, input().split())
for i in range(1, 101):
if (A*i)%B == C:
print('YES')
exit()
print('NO')
|
s431045917
|
p03543
|
u754651673
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 124 |
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
|
N = input()
if N[0] == N[1] == [2]:
print("Yes")
elif N[1] == N[2] == N[3]:
print("Yes")
else:
print("No")
|
s424762677
|
Accepted
| 18 | 3,188 | 1,062 |
N = input()
#print(i)
#N = str(i)
if N[0] == N[1] == N[2] == '1':
print('Yes')
elif N[0] == N[1] == N[2] == '2':
print('Yes')
elif N[0] == N[1] == N[2] == '3':
print('Yes')
elif N[0] == N[1] == N[2] == '4':
print('Yes')
elif N[0] == N[1] == N[2] == '5':
print('Yes')
elif N[0] == N[1] == N[2] == '6':
print('Yes')
elif N[0] == N[1] == N[2] == '7':
print('Yes')
elif N[0] == N[1] == N[2] == '8':
print('Yes')
elif N[0] == N[1] == N[2] == '9':
print('Yes')
elif N[1] == N[2] == N[3] == '0':
print('Yes')
elif N[1] == N[2] == N[3] == '1':
print('Yes')
elif N[1] == N[2] == N[3] == '2':
print('Yes')
elif N[1] == N[2] == N[3] == '3':
print('Yes')
elif N[1] == N[2] == N[3] == '4':
print('Yes')
elif N[1] == N[2] == N[3] == '5':
print('Yes')
elif N[1] == N[2] == N[3] == '6':
print('Yes')
elif N[1] == N[2] == N[3] == '7':
print('Yes')
elif N[1] == N[2] == N[3] == '8':
print('Yes')
elif N[1] == N[2] == N[3] == '9':
print('Yes')
else:
print('No')
|
s112900130
|
p02646
|
u532549251
| 2,000 | 1,048,576 |
Wrong Answer
| 24 | 9,172 | 367 |
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.
|
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#[0]*n
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
c = a + (v*t)
d = b + (w*t)
if c >= d:
print("Yes")
else :
print("No")
|
s307400750
|
Accepted
| 29 | 10,004 | 459 |
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#[0]*n
import math
from decimal import *
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
c = abs(Decimal(b) - Decimal(a))
d = (Decimal(v)*Decimal(t) - Decimal(w)*Decimal(t))
if d >= c:
print("YES")
else :
print("NO")
|
s786991201
|
p03370
|
u662613022
| 2,000 | 262,144 |
Wrong Answer
| 34 | 3,064 | 231 |
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())
li = [int(input()) for i in range(N)]
count = 0
flag = True
mi = 1000
for i in li:
X -= i
count += 1
mi = min(mi,i)
while(flag):
X -= mi
count += 1
if X <= 0:
flag = False
print(count)
|
s113750911
|
Accepted
| 35 | 3,064 | 240 |
N,X = map(int,input().split())
li = [int(input()) for i in range(N)]
count = 0
flag = True
mi = 1000
for i in li:
X -= i
count += 1
mi = min(mi,i)
while(flag):
X -= mi
if X < 0:
flag = False
break
count += 1
print(count)
|
s245957324
|
p03720
|
u633914031
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 211 |
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
|
N,M=map(int, input().split())
result=[]
for i in range(N):
result.append(0)
for j in range(M):
print(j)
a,b=map(int, input().split())
result[a-1]+=1
result[b-1]+=1
for k in range(N):
print(result[k])
|
s473743291
|
Accepted
| 17 | 3,060 | 200 |
N,M=map(int, input().split())
result=[]
for i in range(N):
result.append(0)
for j in range(M):
a,b=map(int, input().split())
result[a-1]+=1
result[b-1]+=1
for k in range(N):
print(result[k])
|
s110495257
|
p03889
|
u052499405
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,188 | 322 |
You are given a string S consisting of letters `b`, `d`, `p` and `q`. Determine whether S is a _mirror string_. Here, a mirror string is a string S such that the following sequence of operations on S results in the same string S: 1. Reverse the order of the characters in S. 2. Replace each occurrence of `b` by `d`, `d` by `b`, `p` by `q`, and `q` by `p`, simultaneously.
|
s = input().rstrip()
n = len(s)
if n % 2 == 1:
print("No")
exit()
for a, b in zip(s[n//2], s[::-1]):
if a == "p" and b == "q":
continue
elif a == "q" and b == "p":
continue
elif a == "b" and b == "d":
continue
elif a == "d" and b == "b":
continue
else:
print("No")
exit()
print("Yes")
|
s194664851
|
Accepted
| 27 | 3,188 | 323 |
s = input().rstrip()
n = len(s)
if n % 2 == 1:
print("No")
exit()
for a, b in zip(s[:n//2], s[::-1]):
if a == "p" and b == "q":
continue
elif a == "q" and b == "p":
continue
elif a == "b" and b == "d":
continue
elif a == "d" and b == "b":
continue
else:
print("No")
exit()
print("Yes")
|
s130001869
|
p03565
|
u780698286
| 2,000 | 262,144 |
Wrong Answer
| 29 | 9,084 | 325 |
E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One more thing he found is a sheet of paper with the following facts written on it: * Condition 1: The string S contains a string T as a contiguous substring. * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1. Print the string S. If such a string does not exist, print `UNRESTORABLE`.
|
s = input()
t = input()
l = []
for i in range(len(s)-len(t)+1):
for j in range(len(t)):
if s[i+j] != t[j] and s[i+j] != "?":
break
else:
print(s[:i]+t+s[i+j+1:])
l.append(s[:i]+t+s[i+j+1:])
if len(l) == 0:
print("UNRESTORABLE")
exit()
l.sort()
print(l[0].replace("?", "a"))
|
s077762302
|
Accepted
| 24 | 8,912 | 298 |
s = input()
t = input()
l = []
for i in range(len(s)-len(t)+1):
for j in range(i, i+len(t)):
if s[j] != "?" and s[j] != t[j-i]:
break
else:
l.append(s[:i]+t+s[i+len(t):])
if len(l) == 0:
print("UNRESTORABLE")
exit()
l.sort()
print(l[0].replace("?", "a"))
|
s962522938
|
p03456
|
u126232616
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 127 |
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.
|
from math import sqrt
a,b = map(int,input().split())
c = a*10+b
if int(sqrt(c))**2 == c:
print("Yes")
else:
print("No")
|
s213437354
|
Accepted
| 18 | 3,060 | 199 |
from math import sqrt
a,b = map(int,input().split())
if b < 10:
c = 10*a+b
elif b < 100:
c = 100*a + b
else:
c = 1000*a + b
if int(sqrt(c))**2 == c:
print("Yes")
else:
print("No")
|
s932790072
|
p03455
|
u610232423
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 72 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
import math
a, b = input().split()
float.is_integer(math.sqrt(int(a+b)))
|
s152992559
|
Accepted
| 17 | 2,940 | 81 |
a,b = map(int, input().split())
print("Odd") if a * b % 2 == 1 else print("Even")
|
s638296943
|
p03854
|
u014047173
| 2,000 | 262,144 |
Wrong Answer
| 18 | 4,852 | 649 |
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 checks(s) :
ret = 'NO'
if len(s) < 5 :
return 'NO'
elif( s[0] == 'd' ) :
#dream
if s[:5] == 'dream' :
if len(s) != 5 :
ret = checks(s[5:])
else :
return 'YES'
#dreamer
if ( len(s) > 6 ) and ( ret != 'YES' ) and s[:7] == 'dreamer' :
if len(s) != 7 :
ret = checks(s[7:])
else :
return 'YES'
elif( s[0] == 'e' ) :
if s[:5] == 'erase' :
if len(s) != 5 :
ret = checks(s[5:])
else :
return 'YES'
r
if ( len(s) > 5 ) and ( ret != 'YES' ) and s[:6] == 'eraser' :
if len(s) != 6 :
ret = checks(s[7:])
else :
return 'YES'
return ret
S = input()
print(checks(S))
|
s433812934
|
Accepted
| 37 | 3,188 | 651 |
s = input()
tmp_index = 0
while(len(s) - tmp_index > 4) :
if( s[tmp_index] == 'd' ) :
if s[tmp_index:tmp_index+7] == 'dreamer' :
if ( s[tmp_index + 5:tmp_index + 10] == 'erase' ):
tmp_index += 5
else :
tmp_index += 7
elif s[tmp_index:tmp_index+5] == 'dream' :
tmp_index += 5
else :
tmp_index = len(s) - 1
elif( s[tmp_index] == 'e' ) :
if s[tmp_index:tmp_index + 6] == 'eraser' :
tmp_index += 6
elif s[tmp_index:tmp_index+5] == 'erase' :
tmp_index += 5
else :
tmp_index = len(s) - 1
else :
tmp_index = len(s) - 1
if len(s) == tmp_index :
print('YES')
elif len(s) - tmp_index < 5 :
print('NO')
|
s594793228
|
p03597
|
u667949809
| 2,000 | 262,144 |
Wrong Answer
| 16 | 2,940 | 49 |
We have an N \times N square grid. We will paint each square in the grid either black or white. If we paint exactly A squares white, how many squares will be painted black?
|
n = int(input())
a = int(input())
print = (n*n-a)
|
s774250210
|
Accepted
| 17 | 2,940 | 48 |
n = int(input())
a = int(input())
print(n**2-a)
|
s621536211
|
p03997
|
u814171899
| 2,000 | 262,144 |
Wrong Answer
| 24 | 3,064 | 442 |
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.
|
sa = input()
sb = input()
sc = input()
cs = sa
cp = ""
np = "a"
while(True):
cp = np
if cs=='' :
break
np = cs[0]
# print(cp)
cs = cs.replace(np, '', 1)
# print(cs)
# print("")
if cp=="a" :
sa = cs
elif cp=="b" :
sb = cs
elif cp=="c" :
sc = cs
if np=="a" :
cs = sa
elif np=="b" :
cs = sb
elif np=="c" :
cs = sc
print(cp.upper())
|
s111511779
|
Accepted
| 24 | 3,064 | 73 |
a = int(input())
b = int(input())
h = int(input())
print(int((a+b)*h/2))
|
s305059089
|
p02410
|
u510829608
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,528 | 286 |
Write a program which reads a $ n \times m$ matrix $A$ and a $m \times 1$ vector $b$, and prints their product $Ab$. A column vector with m elements is represented by the following equation. \\[ b = \left( \begin{array}{c} b_1 \\\ b_2 \\\ : \\\ b_m \\\ \end{array} \right) \\] A $n \times m$ matrix with $m$ column vectors, each of which consists of $n$ elements, is represented by the following equation. \\[ A = \left( \begin{array}{cccc} a_{11} & a_{12} & ... & a_{1m} \\\ a_{21} & a_{22} & ... & a_{2m} \\\ : & : & : & : \\\ a_{n1} & a_{n2} & ... & a_{nm} \\\ \end{array} \right) \\] $i$-th element of a $m \times 1$ column vector $b$ is represented by $b_i$ ($i = 1, 2, ..., m$), and the element in $i$-th row and $j$-th column of a matrix $A$ is represented by $a_{ij}$ ($i = 1, 2, ..., n,$ $j = 1, 2, ..., m$). The product of a $n \times m$ matrix $A$ and a $m \times 1$ column vector $b$ is a $n \times 1$ column vector $c$, and $c_i$ is obtained by the following formula: \\[ c_i = \sum_{j=1}^m a_{ij}b_j = a_{i1}b_1 + a_{i2}b_2 + ... + a_{im}b_m \\]
|
a = []; b = []; c = []
n, m = map(int, input().split())
for i in range(n):
row = map(int, input().split())
a.append(list(row))
for j in range(m):
col = int(input())
b.append(col)
for k in range(n):
temp = 0
for l in range(m):
temp += a[k][l] * b[l]
c.append(temp)
print(c)
|
s143387328
|
Accepted
| 30 | 8,128 | 190 |
n, m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
b = [int(input()) for j in range(m)]
for a_row in a:
print(sum(a_row[k] * b[k] for k in range(m)))
|
s490905849
|
p03711
|
u314050667
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 169 |
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.
|
x,y = map(int, input().split())
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
if x in A == y in A:
print("Yes")
elif x in B == y in B:
print("Yes")
else:
print("No")
|
s313253471
|
Accepted
| 17 | 3,064 | 179 |
x,y = map(int, input().split())
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
if (x in A) and (y in A):
print("Yes")
elif (x in B) and (y in B):
print("Yes")
else:
print("No")
|
s163459212
|
p03457
|
u203382704
| 2,000 | 262,144 |
Wrong Answer
| 2,105 | 27,380 | 698 |
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())
loc = [list(map(int, input().split())) for i in range(N)]
t = 0
x = 0
y = 0
def check(X,Y):
k=0
global x,y,t
for i in range(len(loc)):
d = (loc[i][0] - t) - (abs(loc[i][1] - X) + abs(loc[i][2] - Y))
if d %2 ==0 and d >= 0:
t = loc[i][0]
x = loc[i][1]
y = loc[i][2]
loc.remove(loc[i])
k =1
break
if k ==0:
t = -1
while(len(loc) !=0 and t!= -1):
check(x,y)
if t == -1:
print('NO')
elif len(loc) ==0:
print('YES')
else:
print('error')
#print(loc)
|
s411543980
|
Accepted
| 465 | 27,380 | 589 |
N = int(input())
loc = [list(map(int, input().split())) for i in range(N)]
t = 0
x = 0
y = 0
i = 0
def check(X,Y):
k=0
global x,y,t,i
d = (loc[i][0] - t) - (abs(loc[i][1] - X) + abs(loc[i][2] - Y))
if d %2 ==0 and d >= 0:
t = loc[i][0]
x = loc[i][1]
y = loc[i][2]
#loc.remove(loc[i])
k =1
i += 1
if k ==0:
t = -1
while(i < N and t!= -1):
check(x,y)
if t == -1:
print('No')
else:
print('Yes')
#print(loc)
|
s894573711
|
p03679
|
u363992934
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 123 |
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.
|
a, b, c = map(int, input().split())
if(b<c):
print("delicious")
elif((a+b)<c):
print("safe")
else:
print("dangerous")
|
s124098219
|
Accepted
| 17 | 2,940 | 125 |
a, b, c = map(int, input().split())
if(b>=c):
print("delicious")
elif((a+b)>=c):
print("safe")
else:
print("dangerous")
|
s055732739
|
p03563
|
u667024514
| 2,000 | 262,144 |
Wrong Answer
| 76 | 6,004 | 119 |
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.
|
N = int(input())
K = int(input())
A = N-K
B = K-1
C = N*K
i =1
p=0
while p<B:
i=i*2
p=p+1
print(i)
print(i+C-K*K+K)
|
s919882042
|
Accepted
| 17 | 2,940 | 50 |
a = int(input())
b = int(input())
print(b + b - a)
|
s534266011
|
p02608
|
u095403885
| 2,000 | 1,048,576 |
Wrong Answer
| 24 | 9,000 | 370 |
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
from itertools import product
n = int(input())
def calc(i):
xs = [a for a in range(1,int(i**0.5))]
ys = [a for a in range(1,int(i**0.5))]
zs = [a for a in range(1,int(i**0.5))]
#print(xs,ys,zs)
cnt = 0
for x,y,z in list(product(xs,ys,zs)):
if x**2+y**2+z**2+x*y+y*z+z*x == i:
cnt += 1
#print(x,y,z)
return cnt
|
s428017306
|
Accepted
| 510 | 9,156 | 259 |
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
for j in range(1,105):
for k in range(1,105):
v = i*i+j*j+k*k+i*j+j*k+k*i;
if v<10050:
ans[v]+=1
for i in range(n):
print(ans[i+1])
|
s179291547
|
p03578
|
u135847648
| 2,000 | 262,144 |
Wrong Answer
| 255 | 69,340 | 400 |
Rng is preparing a problem set for a qualification round of CODEFESTIVAL. He has N candidates of problems. The difficulty of the i-th candidate is D_i. There must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems. Determine whether Rng can complete the problem set without creating new candidates of problems.
|
import collections
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
grA = dict(collections.Counter(d))
grB = dict(collections.Counter(t))
for numB,cntB in grB.items():
#print(numB,grA[numB])
try:
if grA[numB] < cntB:
print("No")
exit()
except KeyError:
print("No")
exit()
print("Yes")
|
s876322638
|
Accepted
| 259 | 69,340 | 400 |
import collections
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
grA = dict(collections.Counter(d))
grB = dict(collections.Counter(t))
for numB,cntB in grB.items():
#print(numB,grA[numB])
try:
if grA[numB] < cntB:
print("NO")
exit()
except KeyError:
print("NO")
exit()
print("YES")
|
s749926798
|
p03574
|
u136843617
| 2,000 | 262,144 |
Wrong Answer
| 31 | 3,824 | 540 |
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.
|
import pprint
h,w = map(int,input().split())
s = [["!"]*(w+2)] + [list("!" + input() + "!") for _ in range(h)] + [["!"]*(w+2)]
next = [[-1,-1],[-1,0],[-1,1],[0,-1],[0,1],[1,-1],[1,0],[1,1]]
for i in range(1,h+1):
for j in range(1,w+1):
if s[i][j] == "#":
continue
count = 0
for d1,d2 in next:
count += (s[i + d1][j+d2] == "#")
s[i][j] = str(count)
ans = []
for k in s:
k = [x for x in k if not x =="!"]
if k:
ans.append(k)
for adf in ans:
print(" ".join(adf))
|
s679954705
|
Accepted
| 31 | 3,696 | 539 |
import pprint
h,w = map(int,input().split())
s = [["!"]*(w+2)] + [list("!" + input() + "!") for _ in range(h)] + [["!"]*(w+2)]
next = [[-1,-1],[-1,0],[-1,1],[0,-1],[0,1],[1,-1],[1,0],[1,1]]
for i in range(1,h+1):
for j in range(1,w+1):
if s[i][j] == "#":
continue
count = 0
for d1,d2 in next:
count += (s[i + d1][j+d2] == "#")
s[i][j] = str(count)
ans = []
for k in s:
k = [x for x in k if not x =="!"]
if k:
ans.append(k)
for adf in ans:
print("".join(adf))
|
s244515314
|
p03377
|
u862757671
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 83 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a, b, x = map(int, input().split())
print('Yes' if a + b >= x and a <= x else 'No')
|
s971446278
|
Accepted
| 17 | 2,940 | 83 |
a, b, x = map(int, input().split())
print('YES' if a + b >= x and a <= x else 'NO')
|
s898465582
|
p02646
|
u005569385
| 2,000 | 1,048,576 |
Wrong Answer
| 25 | 9,120 | 138 |
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 (b-a)+t*v <= t*w:
print("YES")
else:
print("NO")
|
s331601063
|
Accepted
| 24 | 9,204 | 141 |
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())
if abs(b-a)+t*w <= t*v:
print("YES")
else:
print("NO")
|
s205831318
|
p03943
|
u403986473
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 102 |
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.
|
can = list(map(int,input().split()))
if sum(can)/2 == max(can):
print('YES')
else:
print('NO')
|
s376545547
|
Accepted
| 17 | 2,940 | 122 |
can = list(map(int,input().split()))
can_sort = sorted(can)
print('Yes' if can_sort[0]+can_sort[1]==can_sort[2] else 'No')
|
s053258087
|
p03693
|
u203962828
| 2,000 | 262,144 |
Wrong Answer
| 27 | 9,068 | 111 |
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
|
r, g, b, = map(int, input().split())
if (r * 100 + g *10 + b) % 4 == 0:
print('Yes')
else:
print('No')
|
s175207887
|
Accepted
| 24 | 9,068 | 112 |
r, g, b, = map(int, input().split())
if (r * 100 + g * 10 + b) % 4 == 0:
print('YES')
else:
print('NO')
|
s608603726
|
p03457
|
u167681750
| 2,000 | 262,144 |
Wrong Answer
| 402 | 28,068 | 327 |
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())
txy = [[int(0)] * 3]
txy += ([list(map(int, input().split())) for i in range(n)])
for i in range(n):
t_diff = txy[i+1][0] - txy[i][0]
xy_diff = (txy[i+1][1] + txy[i+1][2]) - (txy[i][1] + txy[i][2])
if t_diff % 2 != xy_diff % 2 or xy_diff > t_diff:
print("NO")
exit()
print("YES")
|
s386757761
|
Accepted
| 327 | 3,060 | 169 |
n = int(input())
for i in range(n):
t, x, y = map(int, input().split())
if (t + x + y) % 2 == 1 or (x + y) > t:
print("No")
exit()
print("Yes")
|
s627298327
|
p03795
|
u060793972
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 42 |
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())
print(n*800-(n//15)*-200)
|
s052122982
|
Accepted
| 17 | 2,940 | 43 |
n = int(input())
print(n*800+(n//15)*-200)
|
s467447088
|
p02795
|
u942033906
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 78 |
We have a grid with H rows and W columns, where all the squares are initially white. You will perform some number of painting operations on the grid. In one operation, you can do one of the following two actions: * Choose one row, then paint all the squares in that row black. * Choose one column, then paint all the squares in that column black. At least how many operations do you need in order to have N or more black squares in the grid? It is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations.
|
H = int(input())
W = int(input())
N = int(input())
print((N+1) // max(H,W))
|
s859521135
|
Accepted
| 17 | 2,940 | 83 |
H = int(input())
W = int(input())
N = int(input())
print((N-1) // max(H,W) + 1)
|
s635435228
|
p03854
|
u526459074
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,316 | 402 |
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()
wordList = ['dream', 'dreamer', 'erase', 'eraser']
ansFlg = False
def ansFunc(s1, ansFlg):
for w in wordList:
if s1.startswith(w):
s1 = s1.replace(w, "")
print(s1)
if s1 == '':
ansFlg =True
print("YES")
exit()
else:
ansFunc(s1, ansFlg)
ansFunc(s, ansFlg)
print("NO")
|
s418168351
|
Accepted
| 19 | 3,188 | 137 |
s=input().replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","")
if s:
print("NO")
else:
print("YES")
|
s604526698
|
p02602
|
u398511319
| 2,000 | 1,048,576 |
Wrong Answer
| 151 | 31,752 | 166 |
M-kun is a student in Aoki High School, where a year is divided into N terms. There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows: * For the first through (K-1)-th terms: not given. * For each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term. M-kun scored A_i in the exam at the end of the i-th term. For each i such that K+1 \leq i \leq N, determine whether his grade for the i-th term is **strictly** greater than the grade for the (i-1)-th term.
|
N, K= map(int, input().split())
A = list(map(int, input().split()))
for i in range(0,N-K):
if A[i]<A[i+K]:
print('yes')
else:
print('No')
|
s226256238
|
Accepted
| 147 | 31,440 | 167 |
N, K= map(int, input().split())
A = list(map(int, input().split()))
for i in range(0,N-K):
if A[i]<A[i+K]:
print('Yes')
else:
print('No')
|
s168416951
|
p02399
|
u836133197
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,608 | 97 |
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
|
a, b = map(int, input().split())
c, d = divmod(a, b)
e = a / b
print("{} {} {}".format(c, d, e))
|
s733979992
|
Accepted
| 20 | 5,600 | 72 |
a, b = map(int, input().split())
print("%d %d %.5f" % (a//b, a%b, a/b))
|
s801116009
|
p03730
|
u326245870
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 247 |
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`.
|
# -*- coding: utf-8 -*-
a, b, c = map(int, input().split())
result = False
for i in range(1, b+1):
sum_a = a * i
if sum_a % b == c:
result = True
break
if result:
print("Yes")
else:
print("No")
|
s367018623
|
Accepted
| 18 | 2,940 | 247 |
# -*- coding: utf-8 -*-
a, b, c = map(int, input().split())
result = False
for i in range(1, b+1):
sum_a = a * i
if sum_a % b == c:
result = True
break
if result:
print("YES")
else:
print("NO")
|
s651349875
|
p03132
|
u104282757
| 2,000 | 1,048,576 |
Wrong Answer
| 2,104 | 10,972 | 5,044 |
Snuke stands on a number line. He has L ears, and he will walk along the line continuously under the following conditions: * He never visits a point with coordinate less than 0, or a point with coordinate greater than L. * He starts walking at a point with integer coordinate, and also finishes walking at a point with integer coordinate. * He only changes direction at a point with integer coordinate. Each time when Snuke passes a point with coordinate i-0.5, where i is an integer, he put a stone in his i-th ear. After Snuke finishes walking, Ringo will repeat the following operations in some order so that, for each i, Snuke's i-th ear contains A_i stones: * Put a stone in one of Snuke's ears. * Remove a stone from one of Snuke's ears. Find the minimum number of operations required when Ringo can freely decide how Snuke walks.
|
# D
L = int(input())
A_list = [0]*L
for i in range(L):
A_list[i] = int(input())
left_min = 0
left = 0
left_min_i_odd = -1
for i in range(L):
if A_list[i] == 0:
left -= 1
else:
if A_list[i] % 2 == 1:
left += A_list[i]
else:
left += A_list[i] - 1
if left < left_min:
left_min = left
left_min_i_odd = i
if left_min_i_odd == -1:
left_min_odd = 0
else:
left_min_odd = sum(A_list[:(left_min_i_odd+1)])
left_min = 0
left = 0
left_min_i_even = -1
for i in range(L):
if A_list[i] == 0:
left -= 2
else:
if A_list[i] % 2 == 0:
left += A_list[i]
else:
left += A_list[i] - 1
if left < left_min:
left_min = left
left_min_i_even = i
if left_min_i_even == -1:
left_min_even = 0
else:
left_min_even = sum(A_list[:(left_min_i_even+1)])
right_min = 0
right = 0
right_min_i_odd = L
for i in range(L-1, -1, -1):
if A_list[i] == 0:
right -= 1
else:
if A_list[i] % 2 == 1:
right += A_list[i]
else:
right += A_list[i] - 1
if right < right_min:
right_min = right
right_min_i_odd = i
if right_min_i_odd == L:
right_min_odd = 0
else:
right_min_odd = sum(A_list[right_min_i_odd:])
right_min = 0
right = 0
right_min_i_even = L
for i in range(L-1, -1, -1):
if A_list[i] == 0:
right -= 2
else:
if A_list[i] % 2 == 0:
right += A_list[i]
else:
right += A_list[i] - 1
if right < right_min:
right_min = right
right_min_i_even = i
if right_min_i_even == L:
right_min_even = 0
else:
right_min_even = sum(A_list[right_min_i_even:])
0
偶奇0
偶0
奇0
0
res_list_8 = []
for p in range(4):
if p == 0:
left_min = left_min_even
left_i = left_min_i_even
right_min = right_min_even
right_i = right_min_i_even
elif p == 1:
left_min = left_min_even
left_i = left_min_i_even
right_min = right_min_odd
right_i = right_min_i_odd
elif p == 2:
left_min = left_min_odd
left_i = left_min_i_odd
right_min = right_min_odd
right_i = right_min_i_odd
else:
left_min = left_min_odd
left_i = left_min_i_odd
right_min = right_min_even
right_i = right_min_i_even
res1 = left_min + right_min
left_min = 0
for i in range(left_i +1, right_i):
if A_list[i] == 0:
res1 += 2
else:
res1 += A_list[i] % 2
left = 0
right = 0
left_min = 0
right_min = 0
for i in range(left_i +1, right_i):
if A_list[i] == 0:
left -= 1
elif A_list[i] % 2 == 0:
left += 1
else:
left -= 1
if left < left_min:
left_min = left
if i == right_i - 1:
right_min = 1
if right_min != 1:
for i in range(right_i-1, left_i, -1):
if A_list[i] == 0:
right -= 1
elif A_list[i] % 2 == 0:
right += 1
else:
right -= 1
if right < right_min:
right_min = right
else:
right_min = 0
res1 += (left_min+right_min)
res_list_8.append(res1)
0
for p in range(4):
if p == 0:
left_min = left_min_even
left_i = left_min_i_even
right_min = right_min_even
right_i = right_min_i_even
elif p == 1:
left_min = left_min_even
left_i = left_min_i_even
right_min = right_min_odd
right_i = right_min_i_odd
elif p == 2:
left_min = left_min_odd
left_i = left_min_i_odd
right_min = right_min_odd
right_i = right_min_i_odd
else:
left_min = left_min_odd
left_i = left_min_i_odd
right_min = right_min_even
right_i = right_min_i_even
res1 = left_min + right_min
left_min = 0
for i in range(left_i +1, right_i):
res1 += (A_list[i]+1) % 2
left = 0
right = 0
left_min = 0
right_min = 0
for i in range(left_i +1, right_i):
if A_list[i] == 0:
left += 1
elif A_list[i] % 2 == 0:
left -= 1
else:
left += 1
if left < left_min:
left_min = left
if i == right_i - 1:
right_min = 1
if right_min != 1:
for i in range(right_i-1, left_i, -1):
if A_list[i] == 0:
right += 1
elif A_list[i] % 2 == 0:
right -= 1
else:
right += 1
if right < right_min:
right_min = right
else:
right_min = 0
res1 += (left_min+right_min)
res_list_8.append(res1)
print(min(res_list_8[4:]))
|
s793543072
|
Accepted
| 818 | 10,868 | 475 |
# D
L = int(input())
A_list = [0]*L
for i in range(L):
A_list[i] = int(input())
DP = [0]*5
for i in range(L):
r0 = A_list[i]
r1 = (A_list[i] + 1) % 2
if A_list[i] == 0:
r2 = 2
else:
r2 = A_list[i] % 2
DP[4] = min(DP[0], DP[1], DP[2], DP[3], DP[4]) + r0
DP[3] = min(DP[0], DP[1], DP[2], DP[3]) + r2
DP[2] = min(DP[0], DP[1], DP[2]) + r1
DP[1] = min(DP[0], DP[1]) + r2
DP[0] = DP[0] + r0
print(min(DP))
|
s418321505
|
p03712
|
u691018832
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 158 |
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())
hw = '#'*(w+2)
a = []
for i in range(h):
a.append(input())
print(hw)
for i in range(h):
print('#'+a[0]+'#')
print(hw)
|
s280593211
|
Accepted
| 17 | 3,060 | 159 |
h, w = map(int, input().split())
hw = '#'*(w+2)
a = []
for i in range(h):
a.append(input())
print(hw)
for i in range(h):
print('#'+a[i]+'#')
print(hw)
|
s158232103
|
p03624
|
u066455063
| 2,000 | 262,144 |
Wrong Answer
| 39 | 4,280 | 128 |
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead.
|
s = input()
result_s = sorted(s)
atoz = 'abcdefghjklmnopqrstuvwxyz'
if atoz in s:
print("None")
else:
print(result_s[0])
|
s002633042
|
Accepted
| 30 | 3,188 | 159 |
S = input()
s = "abcdefghijklnmopqrstuvwxyz"
s = list(s)
for i in S:
if i in s:
s.remove(i)
if s == []:
print("None")
else:
print(s[0])
|
s283425521
|
p03228
|
u222841610
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,060 | 206 |
In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi: * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person. Find the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.
|
def abk(x,y):
if x%2==1:
x = x-1
y = y + x/2
x = x/2
return (x,y)
a,b,k = map(int, input().split())
for _ in range(k):
if _%2==0:
a,b = abk(a,b)
else:
b,a = abk(b,a)
print(a,b)
|
s367911809
|
Accepted
| 17 | 3,064 | 228 |
def abk(x,y):
if x%2==1:
x = x-1
y = y + x/2
x = x/2
return (x,y)
a,b,k = map(int, input().split())
for _ in range(k):
if _%2==0:
a,b = abk(a,b)
else:
b,a = abk(b,a)
a = int(a)
b = int(b)
print(a,b)
|
s649774600
|
p02406
|
u957680575
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,480 | 86 |
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto. Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements. void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; }
|
a = int(input())
x=0
y=[]
while x<=a:
y.append(str(x))
x+=3
print(" ".join(y))
|
s825916104
|
Accepted
| 20 | 7,916 | 125 |
a = int(input())
x=0
y=[]
while x<a:
x+=1
if "3" in str(x) or x%3==0:
y.append(str(x))
print(" "+" ".join(y))
|
s792224560
|
p03160
|
u414615201
| 2,000 | 1,048,576 |
Wrong Answer
| 128 | 20,620 | 289 |
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() )
h = [int(x) for x in input().split()]
dp = [0]*( len(h) + 1 )
dp[1] = h[0]
dp[2] = h[1]
for ii in range( 3, len(dp) ):
from_2 = abs(h[ii-1] - h[ii-3])
from_1 = abs(h[ii-1] - h[ii-2])
dp[ii] = min( dp[ii-2] + from_2, dp[ii-1] + from_1 )
print(dp[-1])
|
s702619564
|
Accepted
| 126 | 20,380 | 292 |
N = int( input() )
h = [int(x) for x in input().split()]
dp = [0]*( len(h) )
dp[0] = 0
dp[1] = abs( h[0] - h[1] )
for ii in range( 2, len(dp) ):
from_1 = abs(h[ii] - h[ii-1])
from_2 = abs(h[ii] - h[ii-2])
dp[ii] = min( dp[ii-1] + from_1, dp[ii-2] + from_2 )
print(dp[-1])
|
s595887225
|
p03380
|
u947823593
| 2,000 | 262,144 |
Wrong Answer
| 92 | 14,052 | 348 |
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.
|
def comb(x, y):
return math.factorial(x) / (math.factorial(x - y) * math.factorial(y))
def solve(N, AS):
x = max(AS)
y = min(map(lambda z: [abs(z - x / 2), z] , AS), key=lambda x: x[0])[1]
return (x, y)
if __name__ == '__main__':
n = int(input())
AS = list(map(lambda x: int(x), input().split()))
print(solve(n, AS))
|
s686087756
|
Accepted
| 97 | 14,420 | 408 |
def comb(x, y):
return math.factorial(x) / (math.factorial(x - y) * math.factorial(y))
def solve(N, AS):
x = max(AS)
AS = list(AS)
AS.remove(x)
y = min(map(lambda z: [abs(z - x / 2), z] , AS), key=lambda x: x[0])[1]
return (x, y)
if __name__ == '__main__':
n = int(input())
AS = list(map(lambda x: int(x), input().split()))
tmp = solve(n, AS)
print(tmp[0], tmp[1])
|
s506275481
|
p03555
|
u636162168
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 118 |
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()
c1_re=c1[::-1]
c2_re=c2[::-1]
if c2_re==c1 and c1_re==c2:
print("Yes")
else:
print("No")
|
s818803977
|
Accepted
| 18 | 2,940 | 118 |
c1=input()
c2=input()
c1_re=c1[::-1]
c2_re=c2[::-1]
if c2_re==c1 and c1_re==c2:
print("YES")
else:
print("NO")
|
s132985877
|
p03555
|
u788856752
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 141 |
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.
|
l1 = list(input())
l2 = list(input())
L1 = reversed(l1)
L2 = reversed(l2)
if l1 == L2 and l2 == L1:
print("No")
else:
print("Yes")
|
s459992013
|
Accepted
| 17 | 3,064 | 133 |
l1 = list(input())
l2 = list(input())
L1 = l1[::-1]
L2 = l2[::-1]
if l1 == L2 and l2 == L1:
print("YES")
else:
print("NO")
|
s539930749
|
p03494
|
u952396514
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 189 |
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
|
n = int(input())
nums = map(int, input().split())
count = 0
while not next((True for num in nums if num % 2 == 1), True):
nums = map(lambda x: x // 2, nums)
count += 1
print(count)
|
s311020844
|
Accepted
| 19 | 3,060 | 213 |
n = int(input())
nums = list(map(int, input().split()))
count = 0
while not next((True for num in nums if num % 2 == 1 or num < 1), False):
nums = list(map(lambda x: x // 2, nums))
count += 1
print(count)
|
s488637215
|
p03593
|
u366959492
| 2,000 | 262,144 |
Wrong Answer
| 27 | 3,444 | 404 |
We have an H-by-W matrix. Let a_{ij} be the element at the i-th row from the top and j-th column from the left. In this matrix, each a_{ij} is a lowercase English letter. Snuke is creating another H-by-W matrix, A', by freely rearranging the elements in A. Here, he wants to satisfy the following condition: * Every row and column in A' can be read as a palindrome. Determine whether he can create a matrix satisfying the condition.
|
h,w=map(int,input().split())
if h==1 and w==1:
print("No")
exit()
from collections import Counter
a=[]
for _ in range(h):
a+=list(input())
c=Counter(a)
four=1 if h>1 and w>1 else 0
four+=(w-2)//2
four+=(h-2)//2
two=0
two+=(w-2)%2
two+=(h-2)%2
for k,v in c.items():
four-=v//4
c[k]-=v//4
two-=c[k]//2
c[k]-=c[k]//2
if four==0 and two==0:
print("Yes")
else:
print("No")
|
s983089439
|
Accepted
| 21 | 3,444 | 821 |
h,w=map(int,input().split())
from collections import Counter
l=[]
for _ in range(h):
l+=list(input())
c=Counter(l)
if h==1 and w==1:
print("Yes")
elif h==1:
two=w//2
for k,v in c.items():
c[k]-=2*(v//2)
two-=v//2
if two==0:
print("Yes")
else:
print("No")
elif w==1:
two=h//2
for k,v in c.items():
c[k]-=2*(v//2)
two-=v//2
if two==0:
print("Yes")
else:
print("No")
else:
four=((w//2)*(h//2))
two=0
if w%2==1 and h%2==1:
two=(h+w-2)//2
elif w%2==1:
two=h//2
elif h%2==1:
two=w//2
for k,v in c.items():
four-=v//4
c[k]-=4*(v//4)
two-=c[k]//2
c[k]-=2*(c[k]//2)
if four==0 and two==0:
print("Yes")
else:
print("No")
|
s189286708
|
p02612
|
u598283679
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 9,136 | 30 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n = int(input())
print(n%1000)
|
s110899024
|
Accepted
| 28 | 9,144 | 52 |
n = int(input())
res = 1000-(n%1000)
print(res%1000)
|
s021362759
|
p00001
|
u814278309
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,596 | 122 |
There is a data which provides heights (in meter) of mountains. The data is only for ten mountains. Write a program which prints heights of the top three mountains in descending order.
|
hs=[list(map(int, input().split())) for _ in range(10)]
h=sorted(hs,reverse=True)[:3]
print(h[0])
print(h[1])
print(h[2])
|
s862949001
|
Accepted
| 20 | 5,604 | 93 |
x = [int(input()) for i in range(10)]
x.sort(reverse=True)
for i in range(3):
print(x[i])
|
s176757587
|
p03478
|
u183803097
| 2,000 | 262,144 |
Wrong Answer
| 49 | 9,380 | 314 |
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).
|
from sys import stdin
n, a, b = [int(x) for x in stdin.readline().rstrip().split()]
sum = 0
for x in range(1,n+1):
l = x // 10000
m = (x % 10000) // 1000
n = (x % 1000) // 100
o = (x % 100) // 10
p = x % 10
if l+m+n+o+p >= a and l+m+n+o+p <= b:
sum += x
print(l,m,n,o,p,sum)
print(sum)
|
s487400619
|
Accepted
| 34 | 9,192 | 290 |
from sys import stdin
n, a, b = [int(x) for x in stdin.readline().rstrip().split()]
sum = 0
for x in range(1,n+1):
l = x // 10000
m = (x % 10000) // 1000
n = (x % 1000) // 100
o = (x % 100) // 10
p = x % 10
if l+m+n+o+p >= a and l+m+n+o+p <= b:
sum += x
print(sum)
|
s521917792
|
p02612
|
u561294476
| 2,000 | 1,048,576 |
Wrong Answer
| 27 | 9,136 | 34 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
N = int(input())
print(N % 1000)
|
s223051581
|
Accepted
| 28 | 9,144 | 48 |
N = int(input())
print((1000-(N % 1000))%1000)
|
s524830265
|
p02606
|
u168583210
| 2,000 | 1,048,576 |
Wrong Answer
| 24 | 9,020 | 99 |
How many multiples of d are there among the integers between L and R (inclusive)?
|
import math
L,R,d = map(int, input().strip().split())
x=math.ceil(L/d)
y=math.floor(R/d)
print(y-x)
|
s101530447
|
Accepted
| 28 | 9,088 | 102 |
import math
L,R,d = map(int, input().strip().split())
x=math.ceil(L/d)
y=math.floor(R/d)
print(y-x+1)
|
s227162366
|
p03944
|
u788137651
| 2,000 | 262,144 |
Wrong Answer
| 23 | 3,444 | 1,697 |
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i). Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows: * If a_i = 1, he painted the region satisfying x < x_i within the rectangle. * If a_i = 2, he painted the region satisfying x > x_i within the rectangle. * If a_i = 3, he painted the region satisfying y < y_i within the rectangle. * If a_i = 4, he painted the region satisfying y > y_i within the rectangle. Find the area of the white region within the rectangle after he finished painting.
|
#
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A):
for a in A: print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
W,H,N = MI()
bottom = 0
top = H
left = 0
right = W
print(right)
for i in range(N):
a,b,c = MI()
if c==1:
left = max(left,a)
if c==2:
right = min(right,a)
if c==3:
bottom = max(bottom, b)
if c==4:
top = min(top, b)
print((right-left)*(top-bottom))
if __name__ == '__main__':
main()
|
s132645213
|
Accepted
| 23 | 3,444 | 1,751 |
#
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A):
for a in A: print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
W,H,N = MI()
bottom = 0
top = H
left = 0
right = W
for i in range(N):
a,b,c = MI()
if c==1:
left = max(left,a)
if c==2:
right = min(right,a)
if c==3:
bottom = max(bottom, b)
if c==4:
top = min(top, b)
if left <= right and bottom <= top:
print((right-left)*(top-bottom))
else:
print(0)
if __name__ == '__main__':
main()
|
s801882441
|
p03543
|
u295811595
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 118 |
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
|
N=input()
if N[0]==N[1] and N[1]==N[2]:
print("yes")
elif N[1]==N[2] and N[2]==N[3]:
print("yes")
else:
print("no")
|
s493623731
|
Accepted
| 17 | 2,940 | 118 |
N=input()
if N[0]==N[1] and N[1]==N[2]:
print("Yes")
elif N[1]==N[2] and N[2]==N[3]:
print("Yes")
else:
print("No")
|
s856644528
|
p03555
|
u474423089
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 83 |
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
|
c_1=input()
c_2=input()
if c_1 == c_2[::-1]:
print('Yes')
else:
print('No')
|
s425795686
|
Accepted
| 17 | 2,940 | 83 |
c_1=input()
c_2=input()
if c_1 == c_2[::-1]:
print('YES')
else:
print('NO')
|
s875856335
|
p03149
|
u492030100
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,064 | 749 |
You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974".
|
S = input ( )
dusted = False
cont = False
line = 'keyence'
find = S.find ( 'keyence' )
rfind = S.rfind ( 'keyence' )
#print ( 'find {} rfind {}'.format ( find, rfind ) )
if find == 0 or rfind == len ( S ) - 7:
print ( 'YES' )
exit ( 0 )
elif find != -1:
print ( 'NO' )
exit ( 0 )
fs = True
line = ''
keyence = [ c for c in "keyence" ]
for i in range(len ( S )):
#print ( 'i {} ri {}'.format ( S[i], S[len(S)-1-i] ) )
try:
keyence.remove ( S[len(S)-1-i] )
if not keyence:
print ( 'YES' )
exit ( 0 )
keyence.remove ( S[i] )
except ValueError:
print ( 'NO' )
exit ( 0 )
if not keyence:
print ( 'YES' )
exit ( 0 )
|
s085578123
|
Accepted
| 17 | 2,940 | 107 |
line=input().split()
print('YES' if '1' in line and '9' in line and '7' in line and '4' in line else 'NO')
|
s005836474
|
p03434
|
u816070625
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 136 |
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.sort()
for i in range(N//2):
s+=A[2*i]-A[2*i+1]
if N%2==1:
s+=A[N-1]
print(s)
|
s841085954
|
Accepted
| 17 | 3,060 | 149 |
N=int(input())
A=list(map(int,input().split()))
s=0
A.sort()
A.reverse()
for i in range(N//2):
s+=A[2*i]-A[2*i+1]
if N%2==1:
s+=A[N-1]
print(s)
|
s088228957
|
p03719
|
u791664126
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 57 |
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<=b::2])
|
s882857423
|
Accepted
| 17 | 2,940 | 60 |
a,b,c=map(int,input().split());print('YNeos'[a>c or b<c::2])
|
s401435394
|
p02645
|
u206352909
| 2,000 | 1,048,576 |
Wrong Answer
| 27 | 8,772 | 22 |
When you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters. You have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him.
|
a=input()
print(a[3:])
|
s511772142
|
Accepted
| 28 | 9,076 | 22 |
a=input()
print(a[:3])
|
s914085935
|
p03400
|
u994988729
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 131 |
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces. Find the number of chocolate pieces prepared at the beginning of the camp.
|
n=int(input())
d,x=map(int,input().split())
for _ in range(n):
a=int(input())
day=1
while day<d:
x+=1
day+=a
print(x)
|
s346548621
|
Accepted
| 18 | 2,940 | 132 |
n=int(input())
d,x=map(int,input().split())
for _ in range(n):
a=int(input())
day=1
while day<=d:
x+=1
day+=a
print(x)
|
s602974122
|
p03997
|
u479953984
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 76 |
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a = int(input())
b = int(input())
h = int(input())
print((a + b) * h / 2)
|
s874199289
|
Accepted
| 17 | 2,940 | 76 |
a = int(input())
b = int(input())
h = int(input())
print((a + b) * h // 2)
|
s901131965
|
p02399
|
u227438830
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,608 | 63 |
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
|
a, b = map(int, input().split())
print(a // b , a % b , a / b )
|
s148994999
|
Accepted
| 20 | 5,604 | 89 |
a, b = map(int,input().split())
d,r,f = a//b,a%b,a/b
print('{} {} {:.5f}'.format(d,r,f))
|
s251958255
|
p03339
|
u071416928
| 2,000 | 1,048,576 |
Wrong Answer
| 2,104 | 5,964 | 128 |
There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.
|
n = int(input())
s = input()
cnt = [0]*n
for i in range(n):
cnt[i] = s[0:i].count("w") + s[i+1:n].count("e")
print(min(cnt))
|
s013776481
|
Accepted
| 242 | 29,472 | 295 |
n = int(input())
s = input()
cnt = [0]*n
cnt_e = [0]*n
cnt_w = [0]*n
e = 0
w = 0
for i in range(n):
if s[i] == "E":
e += 1
else :
w += 1
cnt_e[i] = e
cnt_w[i] = w
cnt[0] = e - cnt_e[0]
for i in range(1,n):
cnt[i] = cnt_w[i-1] + e - cnt_e[i]
print(min(cnt))
|
s198838985
|
p03215
|
u844789719
| 2,525 | 1,048,576 |
Wrong Answer
| 2,656 | 30,772 | 434 |
One day, Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He is interested in properties of the sequence a. For a nonempty contiguous subsequence a_l, ..., a_r (1 \leq l \leq r \leq N) of the sequence a, its _beauty_ is defined as a_l + ... + a_r. Niwango-kun wants to know the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. (Subsequences may share elements.) Find the maximum possible value for him.
|
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
B = []
for i in range(N):
B += [A[i]]
for j in range(i+1,N):
B += [B[-1] + A[j]]
ans = 0
for i in range(40, -1, -1):
B_new = []
for b in B:
if b & 1 << i:
B_new += [b]
if len(B_new) >= K:
ans += 1 << i
B = [_ % 1 << i for _ in B_new]
else:
B = [_ % 1 << i for _ in B]
print(ans)
|
s620562923
|
Accepted
| 163 | 39,796 | 406 |
import numpy as np
N, K = [int(_) for _ in input().split()]
A = np.array([0] + [int(_) for _ in input().split()])
C = np.cumsum(A)
X = np.zeros(N * (N + 1) // 2, dtype=int)
il = 0
for l in range(N):
X[il:il + N - l] = C[l + 1:N + 1] - C[l]
il += N - l
ans = 0
for i in range(40, -1, -1):
Y = (X // (2**i) & 1)
I = Y == 1
if I.sum() >= K:
X = X[I]
ans += 2**i
print(ans)
|
s634745221
|
p03547
|
u454524105
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 72 |
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?
|
a, b = (x for x in input().split())
print("a") if a <= b else print("b")
|
s540295907
|
Accepted
| 18 | 3,060 | 97 |
a, b = (x for x in input().split())
if a < b: print("<")
elif a == b: print("=")
else: print(">")
|
s376274072
|
p04029
|
u502028059
| 2,000 | 262,144 |
Wrong Answer
| 20 | 2,940 | 70 |
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
|
n = int(input())
ans = 0
for i in range(1, n+1):
ans += 1
print(ans)
|
s833082898
|
Accepted
| 17 | 2,940 | 70 |
n = int(input())
ans = 0
for i in range(1, n+1):
ans += i
print(ans)
|
s004816532
|
p03377
|
u044026875
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 88 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a,b,x=map(int,input().split())
if a+b>=x and a<x:
print("Yes")
else:
print("No")
|
s861920076
|
Accepted
| 17 | 2,940 | 89 |
a,b,x=map(int,input().split())
if a+b>=x and a<=x:
print("YES")
else:
print("NO")
|
s651908484
|
p02612
|
u735996463
| 2,000 | 1,048,576 |
Wrong Answer
| 32 | 9,136 | 36 |
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())
k = n%1000
print(k)
|
s614382306
|
Accepted
| 29 | 9,176 | 74 |
n = int(input())
k = n%1000
if(k==0):
print(0)
else:
print(1000-k)
|
s326259721
|
p03657
|
u467831546
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 89 |
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.
|
A, B = map(int,input().split())
print("Possibile" if (A + B) % 3 == 0 else "Impossible")
|
s160343977
|
Accepted
| 17 | 2,940 | 116 |
A, B = map(int,input().split())
print("Possible" if (A + B) % 3 == 0 or A % 3 == 0 or B % 3 == 0 else "Impossible")
|
s872778493
|
p02389
|
u436634575
| 1,000 | 131,072 |
Wrong Answer
| 30 | 6,720 | 45 |
Write a program which calculates the area and perimeter of a given rectangle.
|
a, b = map(int, input().split())
print(a * b)
|
s084844718
|
Accepted
| 30 | 6,720 | 58 |
a, b = map(int, input().split())
print(a * b, 2 * (a + b))
|
s638594325
|
p03997
|
u636290142
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 83 |
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a = int(input())
b = int(input())
h = int(input())
print((a + b) * float(h) / 2)
|
s659308234
|
Accepted
| 17 | 2,940 | 80 |
a = int(input())
b = int(input())
h = int(input())
print(int((a + b) * h / 2))
|
s020063614
|
p03545
|
u573754721
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 352 |
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
|
n=input()
c=len(n)-1
for i in range(2**c):
L=['-']*c
for j in range(c):
if ((i>>j)&1):
L[c-1-j]="+"
L+=['']
f=""
for a,b in zip(n,L):
f+=a+b
if eval(f)==7:
print(f + '7')
break
|
s327266106
|
Accepted
| 17 | 3,064 | 353 |
n=input()
c=len(n)-1
for i in range(2**c):
L=['-']*c
for j in range(c):
if ((i>>j)&1):
L[c-1-j]="+"
L+=['']
f=""
for a,b in zip(n,L):
f+=a+b
if eval(f)==7:
print(f + '=7')
break
|
s778593687
|
p03227
|
u515124567
| 2,000 | 1,048,576 |
Wrong Answer
| 21 | 2,940 | 87 |
You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.
|
S = input().split()
if len(S) == 2:
print(S)
elif len(S) == 3:
print(S[::-1])
|
s495490330
|
Accepted
| 17 | 2,940 | 79 |
S = input()
if len(S) == 2:
print(S)
elif len(S) == 3:
print(S[::-1])
|
s045656860
|
p02697
|
u961674365
| 2,000 | 1,048,576 |
Wrong Answer
| 74 | 9,296 | 90 |
You are going to hold a competition of one-to-one game called AtCoder Janken. _(Janken is the Japanese name for Rock-paper-scissors.)_ N players will participate in this competition, and they are given distinct integers from 1 through N. The arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive). You cannot assign the same integer to multiple playing fields. The competition consists of N rounds, each of which proceeds as follows: * For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there. * Then, each player adds 1 to its integer. If it becomes N+1, change it to 1. You want to ensure that no player fights the same opponent more than once during the N rounds. Print an assignment of integers to the playing fields satisfying this condition. It can be proved that such an assignment always exists under the constraints given.
|
n,m = map(int,input().split())
l=1
r=2
for i in range(m):
print(l,r)
l+=1
r+=2
|
s435100065
|
Accepted
| 113 | 9,224 | 431 |
n,m = map(int,input().split())
l=1
if n%2==1:
r=n
for i in range(m):
d=min(abs(l-r),n-abs(l-r))
print(l,r)
l+=1
r-=1
else:
if n%4==0:
r=n-1
else:
r=n
rev=False
for i in range(m):
d=min(abs(l-r),n-abs(l-r))
if d == n//2:
rev=True
l+=1
print(l,r)
else:
print(l,r)
l+=1
r-=1
|
s579324264
|
p03729
|
u760831084
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 100 |
You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `YES`. Otherwise, print `NO`.
|
a, b, c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
print('Yes')
else:
print('No')
|
s472438812
|
Accepted
| 17 | 2,940 | 100 |
a, b, c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
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.