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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s119503882
|
p03494
|
u582614471
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,060 | 219 |
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())
l = [int(i) for i in input().split()]
ans = 0
b = True
while b:
for i in range(n):
if l[i]%2==0:
l[i]/=2
else:
b=False
break
ans+=1
print(ans)
|
s269338985
|
Accepted
| 19 | 3,060 | 231 |
n = int(input())
l = [int(i) for i in input().split()]
ans = 0
b = True
while b:
for i in range(n):
if l[i]%2==0:
l[i]/=2
else:
b=False
break
if b:
ans+=1
print(ans)
|
s413737668
|
p03693
|
u566428756
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 82 |
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())
rgb=r*100+g*10+b
print('Yes' if rgb%4==0 else 'No')
|
s677049979
|
Accepted
| 17 | 2,940 | 82 |
r,g,b=map(int,input().split())
rgb=r*100+g*10+b
print('YES' if rgb%4==0 else 'NO')
|
s927633774
|
p02261
|
u741801763
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,600 | 684 |
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).
|
def bubble_sort(seq):
for i in range(len(seq)):
flag = 0
for j in range(len(seq)-1,i,-1):
if seq[j-1][1] > seq[j][1]:
seq[j-1],seq[j] = seq[j],seq[j-1]
flag = 1
if flag == 0: break
return seq
def selection_sort(seq):
for i in range(len(seq)):
mini = i
for j in range(i+1,len(seq)):
if seq[mini][1] > seq[j][1]:mini = j
seq[i],seq[mini] = seq[mini],seq[i]
return seq
n = int(input())
*seq,= input().split()
seq2 = seq[:]
bl = bubble_sort(seq)
print(bl)
print("Stable")
sl = selection_sort(seq2)
print(sl)
if bl == sl:print("Stable")
else:print("Not stable")
|
s635277793
|
Accepted
| 20 | 5,616 | 684 |
def bubble_sort(seq):
for i in range(len(seq)):
flag = 0
for j in range(len(seq)-1,i,-1):
if seq[j-1][1] > seq[j][1]:
seq[j-1],seq[j] = seq[j],seq[j-1]
flag = 1
if flag == 0: break
return seq
def selection_sort(seq):
for i in range(len(seq)):
mini = i
for j in range(i,len(seq)):
if seq[mini][1] > seq[j][1]:mini = j
seq[i],seq[mini] = seq[mini],seq[i]
return seq
n = int(input())
*seq,= input().split()
seq2 = seq[:]
bl = bubble_sort(seq)
print(*bl)
print("Stable")
sl = selection_sort(seq2)
print(*sl)
if bl == sl:print("Stable")
else:print("Not stable")
|
s422818746
|
p03778
|
u842388336
| 2,000 | 262,144 |
Wrong Answer
| 19 | 2,940 | 65 |
AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
|
w,a,b=map(int,input().split())
print(max(0,min(b-(a+w),a-(b+w))))
|
s184801375
|
Accepted
| 17 | 3,060 | 144 |
w,a,b=map(int,input().split())
if ((a<=b)and(b<=(a+w)))or((a<=(b+w))and((b+w)<=(a+w))):
print(0)
else:
print(min(abs(b-(a+w)),abs(a-(b+w))))
|
s437441316
|
p02972
|
u332906195
| 2,000 | 1,048,576 |
Wrong Answer
| 2,104 | 27,488 | 471 |
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
|
import math
N = int(input())
A = list(map(int, input().split()))
B = [str(N - i) for i in range(math.ceil(N / 2)) if A[N - i - 1] == 1]
C = [0] * math.floor(N / 2) + A[math.floor(N / 2):]
for i in range(math.floor(N / 2), 0, -1):
count = 0
for j in range(i, N + 1, i):
print(j, C[j - 1])
count += C[j - 1]
if not count % 2 == A[i - 1]:
B.append(str(i))
C[i - 1] = 1
print(len(B))
if not len(B) == 0:
print(" ".join(B))
|
s217564395
|
Accepted
| 555 | 17,972 | 444 |
import math
N = int(input())
A = list(map(int, input().split()))
B = [str(N - i) for i in range(math.ceil(N / 2)) if A[N - i - 1] == 1]
C = [0] * math.floor(N / 2) + A[math.floor(N / 2):]
for i in range(math.floor(N / 2), 0, -1):
count = 0
for j in range(i, N + 1, i):
count += C[j - 1]
if not count % 2 == A[i - 1]:
B.append(str(i))
C[i - 1] = 1
print(len(B))
if not len(B) == 0:
print(" ".join(B))
|
s594994497
|
p02846
|
u686230543
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,064 | 546 |
Takahashi and Aoki are training for long-distance races in an infinitely long straight course running from west to east. They start simultaneously at the same point and moves as follows **towards the east** : * Takahashi runs A_1 meters per minute for the first T_1 minutes, then runs at A_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever. * Aoki runs B_1 meters per minute for the first T_1 minutes, then runs at B_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever. How many times will Takahashi and Aoki meet each other, that is, come to the same point? We do not count the start of the run. If they meet infinitely many times, report that fact.
|
def meet(faster, slower):
if slower[0] - faster[0] < 0:
print(0)
else:
print((slower[0] - faster[0]) // (faster[1] - slower[1]) + 1)
t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())
at1 = a1 * t1
at2 = a2 * t2
bt1 = b1 * b1
bt2 = b2 * b2
if at1 + at2 < bt1 + bt2:
faster = [bt1, bt1 + bt2]
slower = [at1, at1 + at2]
meet(faster, slower)
elif at1 + at2 > bt1 + bt2:
faster = [at1, at1 + at2]
slower = [bt1, bt1 + bt2]
meet(faster, slower)
else:
print('infinity')
|
s716272025
|
Accepted
| 17 | 3,064 | 650 |
def meet(faster, slower):
if slower[0] - faster[0] < 0:
print(0)
else:
count = (slower[0] - faster[0]) // (sum(faster) - sum(slower))
if (slower[0] - faster[0]) % (sum(faster) - sum(slower)) == 0:
print(count * 2)
else:
print(count * 2 + 1)
t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())
at1 = a1 * t1
at2 = a2 * t2
bt1 = b1 * t1
bt2 = b2 * t2
if at1 + at2 < bt1 + bt2:
faster = [bt1, bt2]
slower = [at1, at2]
meet(faster, slower)
elif at1 + at2 > bt1 + bt2:
faster = [at1, at2]
slower = [bt1, bt2]
meet(faster, slower)
else:
print('infinity')
|
s121830470
|
p02659
|
u720065198
| 2,000 | 1,048,576 |
Wrong Answer
| 23 | 9,172 | 97 |
Compute A \times B, truncate its fractional part, and print the result as an integer.
|
import math
a, b = map(str, input().split())
a = int(a)
b = float(b)
b = math.floor(b)
print(a*b)
|
s947914441
|
Accepted
| 29 | 9,164 | 85 |
a,b = map(str, input().split())
a = int(a)
b = int(b.replace(".",""))
print(a*b//100)
|
s753106198
|
p03007
|
u798818115
| 2,000 | 1,048,576 |
Wrong Answer
| 69 | 14,264 | 287 |
There are N integers, A_1, A_2, ..., A_N, written on a blackboard. We will repeat the following operation N-1 times so that we have only one integer on the blackboard. * Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y. Find the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.
|
N=int(input())
A=list(map(int,input().split()))
flag=True
if A[0]==0:
flag=False
else:
for item in A:
temp=A[0]*item
if temp<=0:
flag=False
A=list(map(lambda x:abs(x),A))
if flag:
print(sum(A)-2*min(A))
else:
print(sum(A))
|
s944604918
|
Accepted
| 293 | 27,228 | 662 |
N=int(input())
A=list(map(int,input().split()))
B=list(map(lambda x:abs(x),A))
A.sort()
for i in range(N):
if A[i]>0:
break
hu=A[:i]
sei=A[i:]
l=[]
if sei and hu:
ans=sei.pop(-1)
for item in sei:
l.append([hu[0],item])
hu[0]-=item
for item in hu:
l.append([ans,item])
ans-=item
elif sei:
ans=sei.pop(-1)
for i in range(len(sei)-1):
l.append([sei[0],sei[i+1]])
sei[0]-=sei[i+1]
l.append([ans,sei[0]])
ans-=sei[0]
elif hu:
for i in range(len(hu)-1):
l.append([hu[-1],hu[-i-2]])
hu[-1]-=hu[-i-2]
ans=hu[-1]
print(ans)
for item in l:
print(*item)
|
s096515169
|
p03680
|
u642012866
| 2,000 | 262,144 |
Wrong Answer
| 207 | 7,852 | 190 |
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i. When Button i is not lighten up, nothing will happen by pressing it. Initially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up. Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.
|
N = int(input())
a = [int(input()) for _ in range(N)]
b = [True]*N
i = 0
cnt = 1
while b[i]:
if a[i] == 2:
break
b[i] = False
i = a[i]-1
cnt += 1
else:
print(-1)
|
s429431307
|
Accepted
| 201 | 7,852 | 222 |
N = int(input())
a = [int(input())-1 for _ in range(N)]
b = [True]*N
b[0] = False
i = a[0]
cnt = 1
while b[i]:
if i == 1:
print(cnt)
break
b[i] = False
i = a[i]
cnt += 1
else:
print(-1)
|
s531312945
|
p03149
|
u907468986
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,064 | 912 |
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".
|
# -*- coding: utf-8 -*-
import sys
class YearNumberJudger:
def __init__(self):
self.input_num_list = []
def input(self, num):
self.input_num_list.append(num)
def result(self):
if len(self.input_num_list) != 4:
return 'NO'
input_map = {}
for num in self.input_num_list:
input_map[num] = True
if '1' not in input_map:
return 'NO'
if '9' not in input_map:
return 'NO'
if '7' not in input_map:
return 'NO'
if '4' not in input_map:
return 'NO'
return 'YES'
if __name__ == "__main__":
year_number_judger = YearNumberJudger()
is_first_paramter = True
for arg in sys.argv:
if is_first_paramter:
is_first_paramter = False
continue
year_number_judger.input(arg)
print(year_number_judger.result())
|
s851489944
|
Accepted
| 18 | 3,064 | 787 |
# -*- coding: utf-8 -*-
import sys
class YearNumberJudger:
def __init__(self):
self.input_num_list = []
def input(self, num):
self.input_num_list.append(num)
def result(self):
if len(self.input_num_list) != 4:
return 'NO'
input_map = {}
for num in self.input_num_list:
input_map[num] = True
if 1 not in input_map:
return 'NO'
if 9 not in input_map:
return 'NO'
if 7 not in input_map:
return 'NO'
if 4 not in input_map:
return 'NO'
return 'YES'
year_number_judger = YearNumberJudger()
num_list = list(map(int,input().split()))
for num in num_list:
year_number_judger.input(num)
print(year_number_judger.result())
|
s927252666
|
p03081
|
u792078574
| 2,000 | 1,048,576 |
Wrong Answer
| 1,890 | 53,996 | 393 |
There are N squares numbered 1 to N from left to right. Each square has a character written on it, and Square i has a letter s_i. Besides, there is initially one golem on each square. Snuke cast Q spells to move the golems. The i-th spell consisted of two characters t_i and d_i, where d_i is `L` or `R`. When Snuke cast this spell, for each square with the character t_i, all golems on that square moved to the square adjacent to the left if d_i is `L`, and moved to the square adjacent to the right if d_i is `R`. However, when a golem tried to move left from Square 1 or move right from Square N, it disappeared. Find the number of golems remaining after Snuke cast the Q spells.
|
N, Q = map(int, input().split())
S = ' ' + input() + ' '
ps = [0, N+1]
unvisited = [0] + [1] * N + [0]
dirs = { 'L': 1, 'R': -1 }
QS = [input().split() for _ in range(Q)]
for t, d in QS[::-1]:
for i, p in enumerate(ps):
np = p + dirs[d]
print(t, d, p, np)
if 0 <= np <= N+1 and S[np] == t:
print(p, '->', np)
unvisited[np] = 0
ps[i] = np
print(sum(unvisited))
|
s354285398
|
Accepted
| 612 | 40,892 | 527 |
N, Q = map(int, input().split())
S = ' ' + input() + ' '
ps = [0, N+1]
dirs = { 'L': 1, 'R': -1 }
QS = [input().split() for _ in range(Q)][::-1]
p = 0
for t, d in QS:
di = dirs[d]
np = p + di
if 0 <= np <= N+1 and di == 1 and S[np] == t:
p += 1
if 0 <= np <= N+1 and di == -1 and S[p] == t:
p -= 1
p1 = p
p = N+1
for t, d in QS:
di = dirs[d]
np = p + di
if 0 <= np <= N+1 and di == -1 and S[np] == t:
p -= 1
if 0 <= np <= N+1 and di == 1 and S[p] == t:
p += 1
p2 = p
print(max(0, p2 - p1 - 1))
|
s108053010
|
p03478
|
u760961723
| 2,000 | 262,144 |
Wrong Answer
| 42 | 9,164 | 161 |
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
|
N, A, B = map(int,input().split())
ans = 0
for n in range(N):
sums = sum(list(map(int,list(str(n)))))
if A <= sums and sums <= B:
ans += sums
print(ans)
|
s626679960
|
Accepted
| 43 | 9,104 | 161 |
N, A, B = map(int,input().split())
ans = 0
for n in range(N+1):
sums = sum(list(map(int,list(str(n)))))
if A <= sums and sums <= B:
ans += n
print(ans)
|
s470926403
|
p03796
|
u185806788
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 4,380 | 66 |
Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
|
a=int(input())
import math
x=math.factorial(a)
print(x//(10**9+7))
|
s949558322
|
Accepted
| 231 | 3,980 | 65 |
a=int(input())
import math
x=math.factorial(a)
print(x%(10**9+7))
|
s348716826
|
p03351
|
u086056891
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 98 |
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
|
a, b, c, d = map(int, input().split())
if abs(c - a) <= d:
print('Yes')
else:
print('No')
|
s938956532
|
Accepted
| 17 | 2,940 | 139 |
a, b, c, d = map(int, input().split())
if abs(c - a) <= d or (abs(b - a) <= d and abs(c - b) <= d):
print('Yes')
else:
print('No')
|
s529987496
|
p03795
|
u923712635
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 51 |
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())
x = N*800
y = int(N/15)
print(x-y)
|
s744435624
|
Accepted
| 18 | 2,940 | 55 |
N = int(input())
x = N*800
y = int(N/15)*200
print(x-y)
|
s834056199
|
p03814
|
u087279476
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,500 | 94 |
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.
|
s = input()
a, z, ans = (0, 0, 0)
a = s.find("A")
z = s.rfind("Z")
ans = z - a + 3
print(ans)
|
s521435842
|
Accepted
| 18 | 3,516 | 95 |
s = input()
a, z, ans = (0, 0, 0)
a = s.find("A")
z = s.rfind("Z")
ans = z - a + 1
print(ans)
|
s636879968
|
p03455
|
u420324813
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 160 |
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())
check_number = a * b
if check_number % 2 == 0 :
print("Even")
else:
print("Odd")
|
s644239733
|
Accepted
| 18 | 2,940 | 128 |
a,b = (int(x) for x in input().split())
check_number = a * b
if check_number % 2 == 0 :
print("Even")
else:
print("Odd")
|
s370879549
|
p02412
|
u313021086
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,596 | 351 |
Write a program which identifies the number of combinations of three integers which satisfy the following conditions: * You should select three distinct integers from 1 to n. * A total sum of the three integers is x. For example, there are two combinations for n = 5 and x = 9. * 1 + 3 + 5 = 9 * 2 + 3 + 4 = 9
|
n, x = map(int, input().split())
while n != 0 or x != 0:
cnt = 0
i = 1
while i <= x - 2:
j = i + 1
if i >= n:
break
while j <= x - 1:
k = j + 1
if i + j >= n:
break
while k <= x:
if i + j + k > n:
break
if i + j + k == n:
cnt += 1
k += 1
j += 1
i += 1
print(cnt)
n, x = map(int, input().split())
|
s491261002
|
Accepted
| 470 | 5,596 | 351 |
n, x = map(int, input().split())
while n != 0 or x != 0:
cnt = 0
i = 1
while i <= n - 2:
j = i + 1
if i >= x:
break
while j <= n - 1:
k = j + 1
if i + j >= x:
break
while k <= n:
if i + j + k > x:
break
if i + j + k == x:
cnt += 1
k += 1
j += 1
i += 1
print(cnt)
n, x = map(int, input().split())
|
s713306552
|
p03251
|
u778700306
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 159 |
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
|
n,m,x,y=map(int,input().split())
xs=map(int,input().split())
ys=map(int,input().split())
xx = max(xs)
yy = min(ys)
if xx < yy:
print("No ")
print("War")
|
s343830189
|
Accepted
| 17 | 3,064 | 239 |
n,m,x,y=map(int,input().split())
xs=map(int,input().split())
ys=map(int,input().split())
xx = max(xs)
yy = min(ys)
ok = False
for z in range(x + 1, y + 1):
if xx < z <= yy:
ok = True
print("No War" if ok else "War")
|
s669681290
|
p03494
|
u018679195
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 227 |
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.
|
from sys import exit
print(0.5%45)
n=int(input())
l=[int(n) for n in input().split()]
sum=0
for i in l:
if i%2!=0:
print(0)
exit(0)
sum+=i
c=0
while(sum%2==0 and sum>=2):
c+=1
sum=sum//2
print(c)
|
s795689308
|
Accepted
| 19 | 3,060 | 240 |
input()
numbers = list(map(lambda x: int(x), input().split(" ")))
min = -1
for number in numbers:
count = 0
while number%2 == 0:
count += 1
number /= 2
if count < min or min == -1:
min = count
print(min)
|
s196340540
|
p04043
|
u688925304
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 252 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
l = list(map(int, input().split()))
s = sum(l)
if(s == 17):
if(l[0]==5 or l[0]==7):
if(l[0]+ l[1] == 10 or l[0] +l[1] == 12):
print("Yes")
else:
print("No")
else:
print("No")
else:
print("No")
|
s291799349
|
Accepted
| 17 | 3,060 | 252 |
l = list(map(int, input().split()))
s = sum(l)
if(s == 17):
if(l[0]==5 or l[0]==7):
if(l[0]+ l[1] == 10 or l[0] +l[1] == 12):
print("YES")
else:
print("NO")
else:
print("NO")
else:
print("NO")
|
s016566478
|
p03455
|
u045953894
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 151 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a,b = input().split()
for i in range(1000):
if i*i == int(a+b):
print('Yes')
c = 0
break
else:
c = 1
if c == 1:
print('No')
|
s736147391
|
Accepted
| 17 | 2,940 | 87 |
a,b = map(int,input().split())
if (a*b) % 2 == 0:
print('Even')
else:
print('Odd')
|
s314349659
|
p02613
|
u642528832
| 2,000 | 1,048,576 |
Wrong Answer
| 139 | 16,200 | 227 |
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())
Sn = [input()for i in range(n)]
C0 = Sn.count('AC')
C1 = Sn.count('WA')
C2 = Sn.count('TLE')
C3 = Sn.count('RE')
print('AC × '+str(C0))
print('WA × '+str(C1))
print('TLE × '+str(C2))
print('RE × '+str(C3))
|
s735994837
|
Accepted
| 138 | 16,184 | 228 |
n = int(input())
Sn = [input()for i in range(1,n+1)]
C0 = Sn.count('AC')
C1 = Sn.count('WA')
C2 = Sn.count('TLE')
C3 = Sn.count('RE')
print('AC x '+str(C0))
print('WA x '+str(C1))
print('TLE x '+str(C2))
print('RE x '+str(C3))
|
s564508800
|
p03486
|
u405256066
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 176 |
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
|
from sys import stdin
s = "".join(sorted(list(stdin.readline().rstrip())))
t = "".join(sorted(list(stdin.readline().rstrip())))
if s < t:
print("Yes")
else:
print("No")
|
s744913666
|
Accepted
| 17 | 2,940 | 188 |
from sys import stdin
s = "".join(sorted(list(stdin.readline().rstrip())))
t = "".join(reversed((sorted(list(stdin.readline().rstrip())))))
if s < t:
print("Yes")
else:
print("No")
|
s005746090
|
p03504
|
u257974487
| 2,000 | 262,144 |
Wrong Answer
| 2,105 | 33,092 | 550 |
Joisino is planning to record N TV programs with recorders. The TV can receive C channels numbered 1 through C. The i-th program that she wants to record will be broadcast from time s_i to time t_i (including time s_i but not t_i) on Channel c_i. Here, there will never be more than one program that are broadcast on the same channel at the same time. When the recorder is recording a channel from time S to time T (including time S but not T), it cannot record other channels from time S-0.5 to time T (including time S-0.5 but not T). Find the minimum number of recorders required to record the channels so that all the N programs are completely recorded.
|
M, N = map(int,input().split())
tvlist = [list(map(int,input().split())) for i in range(M)]
print(tvlist)
p = 1
for i in range(M-1):
for j in range(M-2):
if tvlist[i][2] != tvlist[j+1][2]:
if tvlist[i][0] >= tvlist[j+1][0]:
if tvlist[j+1][1] >= tvlist[i][0]:
p += 1
break
elif tvlist[j+1][0] >= tvlist[i][0]:
if tvlist[i][1] >= tvlist[j+1][0]:
p += 1
break
i = j + 1
j += 2
print(p)
|
s200378651
|
Accepted
| 1,413 | 27,508 | 432 |
L = 100005
n,c = map(int, input().split())
arr = [[0]*L for j in range(c)]
for _ in range(n):
s,t,col = map(lambda x:int(x)-1, input().split())
arr[col][s] += 1
arr[col][t] -= 1
imos = [0]*L
for i in range(c):
for p in range(L):
if arr[i][p] == 1: imos[p] += 1
if arr[i][p] == -1: imos[p+1] -= 1
ans = 0
for i in range(1,L):
imos[i] += imos[i-1]
ans = max(ans, imos[i])
print(ans)
|
s884712529
|
p02678
|
u591295155
| 2,000 | 1,048,576 |
Wrong Answer
| 293 | 56,692 | 641 |
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
|
from collections import deque
def main():
N, M, *AB = map(int, open(0).read().split())
graph = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(AB)] * 2):
graph[a].append(b)
graph[b].append(a)
# bfs
queue = deque([1])
sign = [0] * (N + 1)
sign[1] = 1
while queue:
u = queue.popleft()
for v in graph[u]:
if not sign[v]:
sign[v] = u
queue.append(v)
print(sign)
if all(sign[2:]):
print("Yes")
print("\n".join(map(str, sign[2:])))
else:
print("No")
if __name__ == "__main__":
main()
|
s100424598
|
Accepted
| 297 | 56,696 | 625 |
from collections import deque
def main():
N, M, *AB = map(int, open(0).read().split())
graph = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(AB)] * 2):
graph[a].append(b)
graph[b].append(a)
# bfs
queue = deque([1])
sign = [0] * (N + 1)
sign[1] = 1
while queue:
u = queue.popleft()
for v in graph[u]:
if not sign[v]:
sign[v] = u
queue.append(v)
if all(sign[2:]):
print("Yes")
print("\n".join(map(str, sign[2:])))
else:
print("No")
if __name__ == "__main__":
main()
|
s314323950
|
p03495
|
u466331465
| 2,000 | 262,144 |
Wrong Answer
| 2,109 | 34,004 | 348 |
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them.
|
import numpy as np
a = list(map(int,input().split()))
N = a[0]
K = a[1]
b = list(map(int,input().split()))
li = list(set(b))
c = np.array(b)
d = np.array([])
h = len(li) -K
Num = 0
if K>len(li):
print(0)
for i in li :
ind = c[np.where( c== i)]
d = np.append(d,ind.shape)
d = np.sort(d)
print(d)
for i in range(h):
Num = d[i]
print(int(Num))
|
s770832242
|
Accepted
| 363 | 48,160 | 381 |
import numpy as np
from collections import Counter
import collections
a = list(map(int,input().split()))
N = a[0]
K = a[1]
d = np.array([])
b = list(map(int,input().split()))
li = list(set(b))
c = np.array(b)
l = Counter(b)
h = len(li) -K
Num = 0
if K >= len(li):
print(0)
exit()
d = np.append(d,list(l.values()))
d = np.sort(d)
for i in range(h):
Num += d[i]
print(int(Num))
|
s029232245
|
p03920
|
u729133443
| 2,000 | 262,144 |
Wrong Answer
| 24 | 2,940 | 82 |
The problem set at _CODE FESTIVAL 20XX Finals_ consists of N problems. The score allocated to the i-th (1≦i≦N) problem is i points. Takahashi, a contestant, is trying to score exactly N points. For that, he is deciding which problems to solve. As problems with higher scores are harder, he wants to minimize the highest score of a problem among the ones solved by him. Determine the set of problems that should be solved.
|
n=int(input())
s=0
for i in range(1,n+1):
s+=i
if s>=n:
print(i)
break
|
s369548425
|
Accepted
| 21 | 3,572 | 131 |
n=int(input())
s=0
for i in range(1,n+1):
s+=i
t=s-n
if t>=0:
print(*[j for j in range(1,i+1)if j!=t],sep='\n')
break
|
s490778349
|
p04043
|
u989851123
| 2,000 | 262,144 |
Wrong Answer
| 28 | 8,856 | 112 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
a,b,c = map(str, input().split())
ok = ["575", "557", "755"]
if (a+b+c in ok):
print("OK")
else:
print("NG")
|
s678504198
|
Accepted
| 27 | 8,916 | 113 |
a,b,c = map(str, input().split())
ok = ["575", "557", "755"]
if (a+b+c in ok):
print("YES")
else:
print("NO")
|
s908647377
|
p03162
|
u375542418
| 2,000 | 1,048,576 |
Wrong Answer
| 1,223 | 39,940 | 384 |
Taro's summer vacation starts tomorrow, and he has decided to make plans for it now. The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day: * A: Swim in the sea. Gain a_i points of happiness. * B: Catch bugs in the mountains. Gain b_i points of happiness. * C: Do homework at home. Gain c_i points of happiness. As Taro gets bored easily, he cannot do the same activities for two or more consecutive days. Find the maximum possible total points of happiness that Taro gains.
|
import numpy as np
N = int(input())
h_list = []
for i in range(N):
h_list.append([i for i in map(int,input().split())])
print(h_list)
dp = np.zeros((N,3))
dp[0] = h_list[0]
for i in range(1,N):
dp[i,0] = max(dp[i-1,1], dp[i-1,2]) + h_list[i][0]
dp[i,1] = max(dp[i-1,0], dp[i-1,2]) + h_list[i][1]
dp[i,2] = max(dp[i-1,0], dp[i-1,1]) + h_list[i][2]
print(max(dp[-1]))
|
s516906543
|
Accepted
| 1,221 | 35,552 | 390 |
import numpy as np
N = int(input())
h_list = []
for i in range(N):
h_list.append([i for i in map(int,input().split())])
#print(h_list)
dp = np.zeros((N,3))
dp[0] = h_list[0]
for i in range(1,N):
dp[i,0] = max(dp[i-1,1], dp[i-1,2]) + h_list[i][0]
dp[i,1] = max(dp[i-1,0], dp[i-1,2]) + h_list[i][1]
dp[i,2] = max(dp[i-1,0], dp[i-1,1]) + h_list[i][2]
print(int(max(dp[-1])))
|
s299644355
|
p03005
|
u887207211
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 98 |
Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?
|
N, K = map(int,input().split())
if(N > K):
print(K-2)
elif(N < K):
print(K-1)
else:
print(0)
|
s314981254
|
Accepted
| 21 | 3,064 | 133 |
N, K = map(int,input().split())
if(K == 1 or N == 1):
print(0)
elif(N > K):
print(N-K)
elif(N < K):
print(K-1)
else:
print(0)
|
s515438678
|
p03738
|
u363407238
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 61 |
You are given two positive integers A and B. Compare the magnitudes of these numbers.
|
123456789012345678901234567890
234567890123456789012345678901
|
s182334892
|
Accepted
| 17 | 2,940 | 127 |
a = int(input())
b = int(input())
if a > b:
print('GREATER')
elif a < b:
print('LESS')
elif a == b:
print('EQUAL')
|
s383397817
|
p02265
|
u195186080
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,636 | 429 |
Your task is to implement a double linked list. Write a program which performs the following operations: * insert x: insert an element with key x into the front of the list. * delete x: delete the first element which has the key of x from the list. If there is not such element, you need not do anything. * deleteFirst: delete the first element from the list. * deleteLast: delete the last element from the list.
|
def delete(l, num):
for i, x in enumerate(l):
if x == num:
return l[0:i] + l[i+1:]
return l
n = int(input())
l = []
for i in range(n):
com = input().split()
if com[0] == 'insert':
l = [int(com[1])] + l
elif com[0] == 'delete':
l = delete(l, int(com[1]))
elif com[0] == 'deleteFirst':
l = l[1:]
elif com[0] == 'deleteLast':
l = l[:-1]
print(*l)
|
s151195941
|
Accepted
| 4,580 | 48,120 | 387 |
import collections
q = collections.deque()
n = int(input())
for i in range(n):
com = input().split()
if com[0] == 'insert':
q.appendleft(int(com[1]))
elif com[0] == 'delete':
try:
q.remove(int(com[1]))
except:
pass
elif com[0] == 'deleteFirst':
q.popleft()
elif com[0] == 'deleteLast':
q.pop()
print(*q)
|
s332031028
|
p02390
|
u302561071
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,608 | 88 |
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
|
s = int(input())
h=s/60
s=s/60
m=s/60
s=s%60
print(str(h) + ":" + str(m) + ":" + str(s))
|
s023569953
|
Accepted
| 30 | 7,632 | 94 |
s = int(input())
h=s//3600
m=s%3600
s=m%60
m=m//60
print(str(h) + ":" + str(m) + ":" + str(s))
|
s970587135
|
p02265
|
u317901693
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,952 | 554 |
Your task is to implement a double linked list. Write a program which performs the following operations: * insert x: insert an element with key x into the front of the list. * delete x: delete the first element which has the key of x from the list. If there is not such element, you need not do anything. * deleteFirst: delete the first element from the list. * deleteLast: delete the last element from the list.
|
from collections import deque
def insert(x, dll):
dll.appendleft(x)
def delete(x, dll):
dll.remove(x)
def deleteFirst(dll):
dll.popleft()
def deleteLast(dll):
dll.pop()
n = int(input())
command1 = {"insert": insert, "delete": delete}
command2 = {"deleteFirst": deleteFirst, "deleteLast": deleteLast}
dll = deque()
for i in range(n):
input_line = [str(s) for s in input().split()]
if(input_line[0] in command1):
command1[input_line[0]](int(input_line[1]), dll)
else:
command2[input_line[0]](dll)
print(dll)
|
s501196156
|
Accepted
| 3,870 | 72,016 | 427 |
from collections import deque
n = int(input())
dll = deque()
for i in range(n):
input_line = input().split()
if input_line[0] == "insert":
dll.appendleft(input_line[1])
elif input_line[0] == "delete":
try:
dll.remove(input_line[1])
except:
pass
elif input_line[0] == "deleteFirst":
dll.popleft()
else:
dll.pop()
print(*dll)
|
s035843853
|
p00050
|
u136916346
| 1,000 | 131,072 |
Wrong Answer
| 40 | 6,472 | 54 |
福島県は果物の産地としても有名で、その中でも特に桃とりんごは全国でも指折りの生産量を誇っています。ところで、ある販売用の英文パンフレットの印刷原稿を作ったところ、手違いでりんごに関する記述と桃に関する記述を逆に書いてしまいました。 あなたは、apple と peach を修正する仕事を任されましたが、なにぶん面倒です。1行の英文を入力して、そのなかの apple という文字列を全て peach に、peach という文字列を全てapple に交換した英文を出力するプログラムを作成してください。
|
import re
s=input()
print(re.sub("peach","apple",s))
|
s227457943
|
Accepted
| 40 | 6,472 | 115 |
import re
s=input()
s=re.sub("peach","!!!!!",s)
s=re.sub("apple","peach",s)
s=re.sub("!!!!!","apple",s)
print(s)
|
s035233986
|
p03693
|
u972475732
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 100 |
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 (100*r+10*g+b) & 4 == 0:
print('Yes')
else:
print('No')
|
s774225214
|
Accepted
| 17 | 2,940 | 100 |
r,g,b = map(int, input().split())
if (100*r+10*g+b) % 4 == 0:
print("YES")
else:
print("NO")
|
s832913671
|
p00003
|
u897625141
| 1,000 | 131,072 |
Wrong Answer
| 40 | 7,896 | 204 |
Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so.
|
n = int(input())
array = [[int(i) for i in input().split()] for i in range(n)]
for i in range(n):
if array[i][0]**2+array[i][1]**2 == array[i][2]**2:
print("Yes")
else:
print("No")
|
s634499833
|
Accepted
| 40 | 7,836 | 362 |
n = int(input())
array = [[int(i) for i in input().split()] for i in range(n)]
for i in range(n):
if array[i][0]**2+array[i][1]**2 == array[i][2]**2:
print("YES")
elif array[i][0]**2+array[i][2]**2 == array[i][1]**2:
print("YES")
elif array[i][1]**2+array[i][2]**2 == array[i][0]**2:
print("YES")
else:
print("NO")
|
s039740008
|
p03502
|
u319690708
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 163 |
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number.
|
N = str(input())
N_int = int(N)
Nl = list(N)
Ni = []
for i in Nl:
i = int(i)
Ni.append(i)
A = sum(Ni)
if N_int%A == 0:
print("YES")
else:
print("NO")
|
s530458966
|
Accepted
| 17 | 2,940 | 163 |
N = str(input())
N_int = int(N)
Nl = list(N)
Ni = []
for i in Nl:
i = int(i)
Ni.append(i)
A = sum(Ni)
if N_int%A == 0:
print("Yes")
else:
print("No")
|
s102357326
|
p02418
|
u299798926
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,528 | 574 |
Write a program which finds a pattern $p$ in a ring shaped text $s$.
|
s=[ord(i) for i in input()]
n=[ord(i) for i in input()]
flag=0
flack=0
for i in range(len(s)):
flack=0
if n[0]==s[i]:
flack=1
for j in range(1,len(n)):
if i+j>=len(s):
if n[j]==s[i+j-len(s)]:
flack=flack+1
else:
break
else:
if n[j]==s[i+j]:
flack=flack+1
else:
break
if flack==len(n):
flag=1
break
if flag:
print('yes')
else:
print('no')
|
s080146432
|
Accepted
| 30 | 7,588 | 574 |
s=[ord(i) for i in input()]
n=[ord(i) for i in input()]
flag=0
flack=0
for i in range(len(s)):
flack=0
if n[0]==s[i]:
flack=1
for j in range(1,len(n)):
if i+j>=len(s):
if n[j]==s[i+j-len(s)]:
flack=flack+1
else:
break
else:
if n[j]==s[i+j]:
flack=flack+1
else:
break
if flack==len(n):
flag=1
break
if flag:
print('Yes')
else:
print('No')
|
s770503633
|
p02742
|
u096294926
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 109 |
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
|
a,b = list(map(int,input().split()))
c = a*b
if c%2==0:
print(a*b/2)
else:
d = (a*b+1)/2
print(d)
|
s890147613
|
Accepted
| 34 | 5,076 | 182 |
from decimal import Decimal
a,b = list(map(int,input().split()))
if a == 1 or b ==1:
d =1
elif a*b%2==0 and a >1 and b >1:
d = a*b/2
else:
d = (a*b+1)/2
print(Decimal(d))
|
s877151895
|
p02645
|
u281829807
| 2,000 | 1,048,576 |
Wrong Answer
| 21 | 9,420 | 186 |
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.
|
import random
S = input()
a=len(S)
b=[random.randrange(a-2)]
b.append(random.randint(b[0]+1,a-2))
b.append(random.randint(b[1]+1,a-1))
c=[S[b[i]] for i in range(3)]
print(c[0]+c[1]+c[2])
|
s505003984
|
Accepted
| 24 | 9,488 | 84 |
import random
S = input()
a=len(S)
b=random.randrange(a-2)
print(S[b]+S[b+1]+S[b+2])
|
s866533109
|
p03339
|
u589578850
| 2,000 | 1,048,576 |
Wrong Answer
| 295 | 17,644 | 265 |
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()
e = [0]
w = [0]
cnt_e = 0
cnt_w = 0
for i in range(n):
if s[i] == "E" :
cnt_e += 1
else:
cnt_w += 1
e.append(cnt_e)
w.append(cnt_w)
ans = n +1
for j in range(n):
t = w[i] + e[n] - e[ i +1 ]
ans = min(ans,t)
print(ans)
|
s994774763
|
Accepted
| 303 | 17,644 | 272 |
n = int(input())
s = input()
e = [0]
w = [0]
cnt_e = 0
cnt_w = 0
for i in range(n):
if s[i] == "E" :
cnt_e += 1
else:
cnt_w += 1
e.append(cnt_e)
w.append(cnt_w)
ans = 10000000000
for j in range(n):
t = w[j] + e[n] - e[ j +1 ]
ans = min(ans,t)
print(ans)
|
s419614767
|
p03351
|
u688925304
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 157 |
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
|
A,B,C,D = map(int, input().split())
if(C-B <= D):
if(B-A <= D):
print("YES")
else:
print("NO")
elif(C-A <= D):
print("YES")
else:
print("NO")
|
s753006844
|
Accepted
| 17 | 3,060 | 172 |
A,B,C,D = map(int, input().split())
if(abs(C-B) <= D):
if(abs(B-A) <= D):
print("Yes")
else:
print("No")
elif(abs(C-A) <= D):
print("Yes")
else:
print("No")
|
s826022900
|
p03503
|
u130263865
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 241 |
Joisino is planning to open a shop in a shopping street. Each of the five weekdays is divided into two periods, the morning and the evening. For each of those ten periods, a shop must be either open during the whole period, or closed during the whole period. Naturally, a shop must be open during at least one of those periods. There are already N stores in the street, numbered 1 through N. You are given information of the business hours of those shops, F_{i,j,k}. If F_{i,j,k}=1, Shop i is open during Period k on Day j (this notation is explained below); if F_{i,j,k}=0, Shop i is closed during that period. Here, the days of the week are denoted as follows. Monday: Day 1, Tuesday: Day 2, Wednesday: Day 3, Thursday: Day 4, Friday: Day 5. Also, the morning is denoted as Period 1, and the afternoon is denoted as Period 2. Let c_i be the number of periods during which both Shop i and Joisino's shop are open. Then, the profit of Joisino's shop will be P_{1,c_1}+P_{2,c_2}+...+P_{N,c_N}. Find the maximum possible profit of Joisino's shop when she decides whether her shop is open during each period, making sure that it is open during at least one period.
|
N = int(input())
F = []
P = []
for i in range(N):
F.append(input().split().count("1"))
for i in range(N):
P.append(list(map(int, input().split()[0:F[i]+1])))
result = 0;
for i in P:
print(i)
result += max(i)
print(result)
|
s888571277
|
Accepted
| 280 | 3,064 | 418 |
N = int(input())
F = []
P = []
for i in range(N):
F.append(list(map(int, input().split())))
for i in range(N):
P.append(list(map(int, input().split())))
res = -1e20
for i in range(2**10):
bs = format(i, "#012b")[2:]
if bs == "0000000000": continue
cnt = 0
for j in range(N):
tmp = 0
for k in range(10):
if F[j][k] == 1 and bs[k] == '1':
tmp+=1
cnt += P[j][tmp]
res = max(cnt, res)
print(res)
|
s581233081
|
p01102
|
u217703215
| 8,000 | 262,144 |
Wrong Answer
| 30 | 5,576 | 434 |
The programming contest named _Concours de Programmation Comtemporaine Interuniversitaire_ (CPCI) has a judging system similar to that of ICPC; contestants have to submit correct outputs for two different inputs to be accepted as a correct solution. Each of the submissions should include the program that generated the output. A pair of submissions is judged to be a correct solution when, in addition to the correctness of the outputs, they include an identical program. Many contestants, however, do not stop including a different version of their programs in their second submissions, after modifying a single string literal in their programs representing the input file name, attempting to process different input. The organizers of CPCI are exploring the possibility of showing a special error message for such _close_ submissions, indicating contestants what's wrong with such submissions. Your task is to detect such close submissions.
|
while True:
s1=input().split('"')
if s1==["."]: break
s2=input().split('"')
if len(s1)!=len(s2):
print("DIFFERENT")
continue
else:
cnt=0
for i in range(len(s1)):
if s1[i]!=s2[i]:
cnt+=1
else: pass
if cnt==0:
print("IDENTICAL")
elif cnt==1:
print("CLOSE")
else:
print("DEFFERENT")
|
s029593510
|
Accepted
| 20 | 5,592 | 727 |
ans=[]
while 1:
s1=input().split('"')
if s1==["."]: break
s2=input().split('"')
if len(s1)!=len(s2):
ans.append("DIFFERENT")
continue
else:
cnt=0
flag=0
for i in range(len(s1)):
if s1[i]!=s2[i]:
if i%2==0:
ans.append("DIFFERENT")
flag=1
break
else:
cnt+=1
else: pass
if flag==1:
continue
else: pass
if cnt==0:
ans.append("IDENTICAL")
elif cnt==1:
ans.append("CLOSE")
else:
ans.append("DIFFERENT")
for i in range(len(ans)):
print(ans[i])
|
s579132259
|
p03228
|
u999989620
| 2,000 | 1,048,576 |
Wrong Answer
| 26 | 9,176 | 280 |
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.
|
a, b, k = map(int, input().split(' '))
for i in range(0, k):
if i % 2 == 0:
if a % 2 != 0:
a -= 1
b += a // 2
a -= a/2
else:
if b % 2 != 0:
b -= 1
a += b // 2
b -= b/2
print(f'{max(0,a)} {max(0,b)}')
|
s191761036
|
Accepted
| 29 | 9,140 | 282 |
a, b, k = map(int, input().split(' '))
for i in range(0, k):
if i % 2 == 0:
if a % 2 != 0:
a -= 1
b += a // 2
a -= a//2
else:
if b % 2 != 0:
b -= 1
a += b // 2
b -= b//2
print(f'{max(0,a)} {max(0,b)}')
|
s146900978
|
p04029
|
u227082700
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 32 |
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())
print(n*(n-1)//2)
|
s902196783
|
Accepted
| 17 | 2,940 | 33 |
n=int(input())
print(n*(n+1)//2)
|
s554746200
|
p03197
|
u600402037
| 2,000 | 1,048,576 |
Wrong Answer
| 98 | 7,844 | 308 |
There is an apple tree that bears apples of N colors. The N colors of these apples are numbered 1 to N, and there are a_i apples of Color i. You and Lunlun the dachshund alternately perform the following operation (starting from you): * Choose one or more apples from the tree and eat them. Here, the apples chosen at the same time must all have different colors. The one who eats the last apple from the tree will be declared winner. If both you and Lunlun play optimally, which will win?
|
import sys
stdin = sys.stdin
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip() # ignore trailing spaces
N = ri()
A = [ri() for _ in range(N)]
cnt = [1 for x in A if x % 2 == 0]
bool = sum(cnt) % 2 == 0
print('first' if bool else 'second')
|
s175661879
|
Accepted
| 94 | 7,840 | 320 |
import sys
stdin = sys.stdin
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip() # ignore trailing spaces
N = ri()
A = [ri() for _ in range(N)]
even_cnt = sum([1 for x in A if x % 2 == 0])
odd_cnt = N - even_cnt
print('first' if odd_cnt else 'second')
|
s982199737
|
p03457
|
u848654125
| 2,000 | 262,144 |
Wrong Answer
| 2,109 | 18,564 | 484 |
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.
|
import scipy as sp
from scipy.spatial.distance import cityblock
def delta(n):
l = len([0])
delta = n - sp.vstack((sp.zeros(l), n[1:]))
return delta
answer = "Yes"
N = int(input())
points = sp.array([0,0,0])
for i in range(N):
points = sp.vstack((points, [int(i) for i in input().split()]))
points = sp.array(list(points))
for t, x, y in points:
mdist = cityblock(x, y)
if mdist - t%2 != 0 and t < mdist:
answer = "No"
break
print(answer)
|
s647388650
|
Accepted
| 353 | 21,108 | 237 |
answer = "Yes"
N = int(input())
points = [[int(i) for i in input().split()] for i in range(N)]
for t, x, y in points:
mdist = abs(x) + abs(y)
if (mdist - t)%2 != 0 or t < mdist:
answer = "No"
break
print(answer)
|
s157091390
|
p03636
|
u441246928
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 91 |
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
|
s = input()
t = 0
for i in range(1,len(s)-2):
t += 1
print(s[0] + str(t) + s[len(s)-1])
|
s285606721
|
Accepted
| 17 | 2,940 | 56 |
s = list(input())
print(s[0] + str(len(s) - 2 ) + s[-1])
|
s372281598
|
p02390
|
u257897291
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,552 | 79 |
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
|
t = int(input())
s = t%60
m = t//60
h = m/60
print("{0}:{1}:{2}".format(h,m,s))
|
s892508502
|
Accepted
| 30 | 7,652 | 57 |
h = int(input())
print(h//3600,(h%3600)//60,h%60,sep=":")
|
s427620676
|
p03418
|
u257974487
| 2,000 | 262,144 |
Wrong Answer
| 104 | 3,064 | 267 |
Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had.
|
N, K = map(int,input().split())
ans = 0
a = K + 1
print(ans)
if K != 0:
for i in range(K, N):
s = N % a
t = N - s
p = t // a * (a - K)
q = max(0, s - (K - 1))
ans += (p + q)
a += 1
else:
ans = N ** 2
print(ans)
|
s454091530
|
Accepted
| 107 | 3,064 | 256 |
N, K = map(int,input().split())
ans = 0
a = K + 1
if K != 0:
for i in range(K, N):
s = N % a
t = N - s
p = t // a * (a - K)
q = max(0, s - (K - 1))
ans += (p + q)
a += 1
else:
ans = N ** 2
print(ans)
|
s523985721
|
p03853
|
u506587641
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 137 |
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
|
h,w = map(int,input().split())
c = [list(map(str,input().split())) for _ in range(h)]
for i in range(h):
print(c[i])
print(c[i])
|
s377320969
|
Accepted
| 17 | 3,060 | 155 |
h,w = map(int,input().split())
c = [list(map(str,input().split())) for _ in range(h)]
for i in range(h):
print(''.join(c[i]))
print(''.join(c[i]))
|
s877341294
|
p03836
|
u705007443
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 220 |
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
|
sx,sy,tx,ty=map(int,input().split())
dx,dy=tx-sx,ty-sy
route=["","","",""]
route[0]='U'*dx+'R'*dy
route[1]='D'*dx+'L'*dy
route[2]='L'+'U'*(dx+1)+'R'*(dy+1)+'D'
route[3]='R'+'U'*(dx+1)+'L'*(dy+1)+'U'
print("".join(route))
|
s652059943
|
Accepted
| 17 | 3,064 | 220 |
sx,sy,tx,ty=map(int,input().split())
dx,dy=tx-sx,ty-sy
route=["","","",""]
route[0]='U'*dy+'R'*dx
route[1]='D'*dy+'L'*dx
route[2]='L'+'U'*(dy+1)+'R'*(dx+1)+'D'
route[3]='R'+'D'*(dy+1)+'L'*(dx+1)+'U'
print("".join(route))
|
s457375322
|
p02273
|
u798803522
| 2,000 | 131,072 |
Wrong Answer
| 30 | 7,848 | 1,576 |
Write a program which reads an integer _n_ and draws a Koch curve based on recursive calles of depth _n_. The Koch curve is well known as a kind of You should start (0, 0), (100, 0) as the first segment.
|
import math
def Koch(initialx,endx,initialy,endy,repeat):
if repeat > num:
return 0
else:
onex,secondx = (endx-initialx) / 3 + min(initialx,endx),(endx-initialx) * 2 / 3 + min(initialx,endx)
if initialy <= endy:
oney,secondy = abs(endy-initialy) / 3 +initialy,abs(endy-initialy) * 2 / 3 + initialy
else:
oney,secondy = initialy - abs(endy-initialy) / 3 ,initialy - abs(endy-initialy) * 2 / 3
if initialy == endy:
thirdy = math.sqrt(3) / 2 * (secondx-onex) + oney
thirdx = (onex + secondx) / 2
else:
if initialy > endy:
if initialx > endx:
thirdx = initialx
thirdy = secondy
else:
thirdx = endx
thirdy = oney
else:
if initialx > endx:
thirdx = endx
thirdy = oney
else:
thirdx = initialx
thirdy = secondy
if [round(initialx,8),round(initialy,8)] not in ans:
ans.append([round(initialx,8),round(initialy,8)])
#print(initialx,endx,onex,oney,secondx,secondy,thirdx,thirdy)
Koch(initialx,onex,initialy,oney,repeat+1)
Koch(onex,thirdx,oney,thirdy,repeat+1)
Koch(thirdx,secondx,thirdy,secondy,repeat+1)
Koch(secondx,endx,secondy,endy,repeat+1)
global num
num = int(input())
ans = []
Koch(0,100,0,0,0)
for n in range(len(ans)):
print(*ans[n])
print("100.00000000 0.0")
|
s994128979
|
Accepted
| 720 | 8,392 | 1,735 |
import math
def Koch(initialx,endx,initialy,endy,repeat):
if repeat > num:
return 0
else:
if initialx >= endx:
onex,secondx = abs(endx-initialx) * 2 / 3 + endx,abs(endx-initialx) / 3 + endx
else:
onex,secondx = abs(endx-initialx) / 3 + initialx,abs(endx-initialx) * 2 / 3 + initialx
if initialy <= endy:
oney,secondy = abs(endy-initialy) / 3 +initialy,abs(endy-initialy) * 2 / 3 + initialy
else:
oney,secondy = initialy - abs(endy-initialy) / 3 ,initialy - abs(endy-initialy) * 2 / 3
if initialy == endy:
thirdy = math.sqrt(3) / 2 * (secondx-onex) + oney
thirdx = (onex + secondx) / 2
else:
if initialy > endy:
if initialx > endx:
thirdx = initialx
thirdy = secondy
else:
thirdx = endx
thirdy = oney
else:
if initialx > endx:
thirdx = endx
thirdy = oney
else:
thirdx = initialx
thirdy = secondy
if [round(initialx,8),round(initialy,8)] not in ans:
ans.append([round(initialx,8),round(initialy,8)])
#print(initialx,endx,onex,oney,secondx,secondy,thirdx,thirdy)
Koch(initialx,onex,initialy,oney,repeat+1)
Koch(onex,thirdx,oney,thirdy,repeat+1)
Koch(thirdx,secondx,thirdy,secondy,repeat+1)
Koch(secondx,endx,secondy,endy,repeat+1)
global num
num = int(input())
ans = []
Koch(0,100,0,0,0)
for n in range(len(ans)):
print("%.8f %.8f" % (ans[n][0],ans[n][1]))
print("100.00000000 0.00000000")
|
s165552380
|
p03079
|
u561859676
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 90 |
You are given three integers A, B and C. Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
|
i = input().split()
if i[0]==i[1] and i[1]==i[2]:
print("YES")
else:
print("No")
|
s199755236
|
Accepted
| 18 | 2,940 | 89 |
i = input().split()
if i[0]==i[1] and i[1]==i[2]:
print("Yes")
else:
print("No")
|
s482409308
|
p03863
|
u334712262
| 2,000 | 262,144 |
Wrong Answer
| 59 | 6,856 | 1,657 |
There is a string s of length 3 or greater. No two neighboring characters in s are equal. Takahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi going first: * Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s. The player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.
|
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from pprint import pprint
from collections import Counter, defaultdict, deque
import queue
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
sys.setrecursionlimit(10000)
def read_int():
return int(input())
def read_int_n():
return list(map(int, input().split()))
def read_float():
return float(input())
def read_float_n():
return list(map(float, input().split()))
def read_str():
return input().strip()
def read_str_n():
return list(map(str, input().split()))
def error_print(*args):
print(*args, file=sys.stderr)
def mt(f):
import time
def wrap(*args, **kwargs):
s = time.time()
ret = f(*args, **kwargs)
e = time.time()
error_print(e - s, 'sec')
return ret
return wrap
def Prim(g):
V = list(g.keys())
for v in g.values():
V.extend(list(v.keys()))
V = list(set(V))
used = set([])
q = []
heapq.heappush(q, (0, V[0]))
ret = 0
while q:
c, v = heapq.heappop(q)
if v in used:
continue
used.add(v)
ret += c
for u in g[v]:
heapq.heappush(q, (g[v][u], u))
return ret
@mt
def slv(S):
even = len(S) % 2 == 0
hte = S[0] == S[1]
if even != hte:
return 'Second'
return 'First'
def main():
S = read_str()
print(slv(S))
if __name__ == '__main__':
main()
|
s257911104
|
Accepted
| 54 | 6,344 | 1,657 |
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from pprint import pprint
from collections import Counter, defaultdict, deque
import queue
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
sys.setrecursionlimit(10000)
def read_int():
return int(input())
def read_int_n():
return list(map(int, input().split()))
def read_float():
return float(input())
def read_float_n():
return list(map(float, input().split()))
def read_str():
return input().strip()
def read_str_n():
return list(map(str, input().split()))
def error_print(*args):
print(*args, file=sys.stderr)
def mt(f):
import time
def wrap(*args, **kwargs):
s = time.time()
ret = f(*args, **kwargs)
e = time.time()
error_print(e - s, 'sec')
return ret
return wrap
def Prim(g):
V = list(g.keys())
for v in g.values():
V.extend(list(v.keys()))
V = list(set(V))
used = set([])
q = []
heapq.heappush(q, (0, V[0]))
ret = 0
while q:
c, v = heapq.heappop(q)
if v in used:
continue
used.add(v)
ret += c
for u in g[v]:
heapq.heappush(q, (g[v][u], u))
return ret
@mt
def slv(S):
even = len(S) % 2 == 0
hte = S[0] == S[-1]
if even != hte:
return 'Second'
return 'First'
def main():
S = read_str()
print(slv(S))
if __name__ == '__main__':
main()
|
s257075854
|
p03407
|
u102242691
| 2,000 | 262,144 |
Wrong Answer
| 19 | 2,940 | 87 |
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
|
a,b,c = map(int,input().split())
if a+b <= c:
print("Yes")
else:
print("No")
|
s680287723
|
Accepted
| 17 | 2,940 | 87 |
a,b,c = map(int,input().split())
if a+b >= c:
print("Yes")
else:
print("No")
|
s215150639
|
p03999
|
u704001626
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 396 |
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion. All strings that can be obtained in this way can be evaluated as formulas. Evaluate all possible formulas, and print the sum of the results.
|
# -*- coding: utf-8 -*-
s = input()
len_s = len(s)
ret = 0
def calc_cumsum(idx,right_str):
if idx == len(right_str):
return int(right_str)
_ifplus = int(right_str[0:idx])* (2**(len(right_str[idx:len_s]) -1 )) + calc_cumsum(1,right_str[idx:len_s])
_ifnotplus = calc_cumsum(idx+1,right_str)
print(_ifplus+_ifnotplus)
return (_ifplus+_ifnotplus)
print(calc_cumsum(1,s))
|
s701963432
|
Accepted
| 18 | 3,060 | 366 |
# -*- coding: utf-8 -*-
s = input()
len_s = len(s)
ret = 0
def calc_cumsum(idx,right_str):
if idx == len(right_str):
return int(right_str)
_ifplus = int(right_str[0:idx])* (2**(len(right_str[idx:len_s]) -1 )) + calc_cumsum(1,right_str[idx:len_s])
_ifnotplus = calc_cumsum(idx+1,right_str)
return (_ifplus+_ifnotplus)
print(calc_cumsum(1,s))
|
s605651461
|
p02271
|
u510829608
| 5,000 | 131,072 |
Wrong Answer
| 30 | 7,696 | 677 |
Write a program which reads a sequence _A_ of _n_ elements and an integer _M_ , and outputs "yes" if you can make _M_ by adding elements in _A_ , otherwise "no". You can use an element only once. You are given the sequence _A_ and _q_ questions where each question contains _M i_.
|
import itertools as it
def check(p, li):
li_ad = [i for i in li if i < p]
flag = False
for j in range(len(li_ad)):
li_perm = list(it.permutations(li_ad, j+1))
for k in range(len(li_perm)):
if sum(li_perm[k]) == p:
flag = True
break
if flag:
break
return flag
n = int(input())
A = sorted(list(map(int, input().split())))
q = int(input())
m = list(map(int, input().split()))
min_range = A[0] + A[1]
max_range = sum(A)
for i in range(q):
if m[i] < min_range or m[i] > max_range:
print('no')
else:
print('yes' if check(m[i], A) else 'no' )
|
s831938749
|
Accepted
| 420 | 7,764 | 265 |
from itertools import combinations
n = int(input())
A = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
l = set(sum(t) for i in range(n) for t in combinations(A, i+1))
for j in m:
print('yes' if j in l else 'no')
|
s829509426
|
p03997
|
u485566817
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 71 |
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)
|
s048780334
|
Accepted
| 17 | 2,940 | 76 |
a = int(input())
b = int(input())
h = int(input())
print(int((a+b) * h / 2))
|
s319450748
|
p03471
|
u653005308
| 2,000 | 262,144 |
Wrong Answer
| 29 | 3,064 | 398 |
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
|
n,y=map(int,input().split())
z=int(str(y)[::])
if n*10000<y:
print("-1 -1 -1")
exit()
for i in range((y//10000)+1):
y-=i*10000
w=int(str(y)[::])
if (n-i)*5000<y:
continue
for j in range((y//5000)+1):
y-=j*5000
if 1000*(n-i-j)==y:
print(str(i)+' '+str(j)+' '+str(n-i-j))
exit()
y=w
y=z
print("-1 -1 -1")
|
s774113521
|
Accepted
| 33 | 3,064 | 379 |
n,y=map(int,input().split())
if n*10000<y:
print("-1 -1 -1")
exit()
for i in range((y//10000),-1,-1):
y-=i*10000
if (n-i)*5000<y:
continue
for j in range((y//5000),-1,-1):
y-=j*5000
if 1000*(n-i-j)==y:
print(str(i)+' '+str(j)+' '+str(n-i-j))
exit()
y+=j*5000
y+=i*10000
print("-1 -1 -1")
|
s968234406
|
p03623
|
u144980750
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 79 |
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
|
a,b,c=map(int,input().split())
if (b-a)>=(c-a):
print("B")
else:
print("A")
|
s852572491
|
Accepted
| 17 | 2,940 | 85 |
a,b,c=map(int,input().split())
if abs(b-a)>=abs(c-a):
print("B")
else:
print("A")
|
s036175282
|
p02255
|
u804019169
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,660 | 498 |
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
|
import sys
def print_arr(arr):
for v in arr:
print(v, end=' ')
print('')
def insertion_sort(arr):
for i in range(1, len(arr)):
print_arr(arr)
v = arr[i]
j = i-1
while j >= 0 and arr[j] > v:
arr[j+1] = arr[j]
j -= 1
arr[j+1] = v
input0 = sys.stdin.readline()
input_sample = sys.stdin.readline()
# input_sample = "5 2 4 6 1 3"
input = input_sample.split(" ")
input = [int(i) for i in input]
insertion_sort(input)
|
s276575813
|
Accepted
| 20 | 7,756 | 552 |
import sys
def print_arr(arr):
ln = ''
for v in arr:
ln += str(v) + ' '
ln = ln.strip()
print(ln)
def insertion_sort(arr):
for i in range(1, len(arr)):
print_arr(arr)
v = arr[i]
j = i-1
while j >= 0 and arr[j] > v:
arr[j+1] = arr[j]
j -= 1
arr[j+1] = v
print_arr(arr)
input0 = sys.stdin.readline()
input_sample = sys.stdin.readline()
# input_sample = "5 2 4 6 1 3"
input = input_sample.split(" ")
input = [int(i) for i in input]
insertion_sort(input)
|
s715847716
|
p03679
|
u813098295
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 121 |
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.
|
x, a, b = map(int, input().split())
if a-b <= 0: print("delicious")
elif a-b <= x: print("safe")
else: print("dangerous")
|
s772286119
|
Accepted
| 17 | 2,940 | 122 |
x, a, b = map(int, input().split())
if b-a <= 0: print("delicious")
elif b-a <= x: print("safe")
else: print("dangerous")
|
s188567705
|
p03407
|
u752552310
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 84 |
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
|
a, b, c = map(int, input().split())
if a + b > c:
print("No")
else:
print("Yes")
|
s317983784
|
Accepted
| 17 | 3,064 | 84 |
a, b, c = map(int, input().split())
if a + b < c:
print("No")
else:
print("Yes")
|
s526895436
|
p02742
|
u011277545
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 72 |
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
|
A,B=map(int, input().split())
print(A,B)
C=A*B//2
D=A*B%2
E=C+D
print(E)
|
s199428626
|
Accepted
| 17 | 2,940 | 92 |
A,B=map(int, input().split())
C=A*B//2
D=A*B%2
if A==1 or B==1:
E=1
else:
E=C+D
print(E)
|
s907869754
|
p02390
|
u024715419
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,480 | 84 |
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
|
s = int(input())
h = s/3600
m = (s-3600*h)/60
s = s-3600*h-60*m
print(h,m,s,sep=":")
|
s366428297
|
Accepted
| 20 | 7,640 | 70 |
s=int(input())
h=s//3600
m=s%3600//60
s=s%3600%60
print(h,m,s,sep=":")
|
s746315668
|
p03598
|
u213431796
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 151 |
There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N. In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he placed the i-th type-A robot at coordinates (0, i), and the i-th type-B robot at coordinates (K, i). Thus, now we have one type-A robot and one type-B robot on each of the N lines y = 1, y = 2, ..., y = N. When activated, each type of robot will operate as follows. * When a type-A robot is activated at coordinates (0, a), it will move to the position of the ball on the line y = a, collect the ball, move back to its original position (0, a) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. * When a type-B robot is activated at coordinates (K, b), it will move to the position of the ball on the line y = b, collect the ball, move back to its original position (K, b) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. Snuke will activate some of the 2N robots to collect all of the balls. Find the minimum possible total distance covered by robots.
|
N = int(input())
K = int(input())
x = list(map(int,input().split(" ")))
sum = 0
for i in range(0, N):
sum += min(0 - x[i], K - x[i]) * 2
print(sum)
|
s637389295
|
Accepted
| 17 | 2,940 | 149 |
N = int(input())
K = int(input())
x = list(map(int,input().split(" ")))
sum = 0
for i in range(N):
sum += abs(min(x[i], K - x[i]) * 2)
print(sum)
|
s040558655
|
p03130
|
u349444371
| 2,000 | 1,048,576 |
Wrong Answer
| 21 | 3,316 | 235 |
There are four towns, numbered 1,2,3 and 4. Also, there are three roads. The i-th road connects different towns a_i and b_i bidirectionally. No two roads connect the same pair of towns. Other than these roads, there is no way to travel between these towns, but any town can be reached from any other town using these roads. Determine if we can visit all the towns by traversing each of the roads exactly once.
|
from collections import deque
S = [list(map(int, input().split())) for _ in range(3)]
S.sort()
l=[0,0,0,0]
for i in range(3):
for j in range(2):
l[S[i][j]-1]+=1
print(l)
if max(l)==3:
print("NO")
else:
print("YES")
|
s747125714
|
Accepted
| 20 | 3,316 | 228 |
from collections import deque
S = [list(map(int, input().split())) for _ in range(3)]
l=[0,0,0,0]
for i in range(3):
for j in range(2):
l[S[i][j]-1]+=1
#print(l)
if max(l)==3:
print("NO")
else:
print("YES")
|
s833273571
|
p03493
|
u648759666
| 2,000 | 262,144 |
Wrong Answer
| 24 | 8,888 | 24 |
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
|
s = input()
s.count('1')
|
s010470512
|
Accepted
| 27 | 9,020 | 31 |
s = input()
print(s.count('1'))
|
s014901173
|
p03170
|
u375616706
| 2,000 | 1,048,576 |
Wrong Answer
| 2,104 | 106,912 | 408 |
There is a set A = \\{ a_1, a_2, \ldots, a_N \\} consisting of N positive integers. Taro and Jiro will play the following game against each other. Initially, we have a pile consisting of K stones. The two players perform the following operation alternately, starting from Taro: * Choose an element x in A, and remove exactly x stones from the pile. A player loses when he becomes unable to play. Assuming that both players play optimally, determine the winner.
|
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N, K = map(int, input().split())
S = list(map(int, input().split()))
dp = [0]*(K+1)
for i in range(K+1):
if dp[i] == 0:
for s in S:
if i+s > K:
continue
else:
dp[i+s] = 1
print(dp)
if dp[K]:
print("First")
else:
print("Second")
|
s769466398
|
Accepted
| 126 | 3,828 | 394 |
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N, K = map(int, input().split())
S = list(map(int, input().split()))
dp = [0]*(K+1)
for i in range(K+1):
if dp[i] == 0:
for s in S:
if i+s > K:
continue
else:
dp[i+s] = 1
if dp[K]:
print("First")
else:
print("Second")
|
s322260573
|
p03471
|
u167681750
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 3,064 | 400 |
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
|
n, y = map(int, input().split())
y = y/1000
counter = []
for rep1 in range(n + 1):
for rep2 in range(n + 1):
for rep3 in range(n + 1):
if rep1 + rep2 + rep3 == n and rep1 * 10 + rep2 * 5 + rep3 == y:
print(rep1 * 10 + rep2 * 5 + rep3)
counter = ([rep1, rep2, rep3])
break
print(counter) if counter != [] else print("-1 -1 -1")
|
s922493535
|
Accepted
| 932 | 3,064 | 323 |
n, y = map(int, input().split())
y = y/1000
answer= []
for ten in range(n + 1):
for five in range(n + 1 - ten):
one = n - ten - five
if ten * 10 + five * 5 + one == y:
answer = [ten, five, one]
break
print(answer[0], answer[1], answer[2]) if answer != [] else print("-1 -1 -1")
|
s241738977
|
p03854
|
u462434199
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 495 |
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 DFS(S):
word_list = ["dreamer", "dream", "eraser", "erase"]
stack = ["dream", "dreamer", "erase", "eraser"]
while stack:
word = stack.pop()
if word == S[0]:
return "YES"
for i in word_list:
next_word = word + i
check = S[0][:len(word + i)]
if next_word != check:
continue
if next_word == check:
stack.append(next_word)
print(stack)
return "NO"
|
s723063587
|
Accepted
| 1,653 | 166,464 | 541 |
def DFS(S):
word_list = ["dreamer", "dream", "eraser", "erase"]
stack = ["dream", "dreamer", "erase", "eraser"]
while stack:
word = stack.pop()
if word == S[0]:
return "YES"
for i in word_list:
next_word = word + i
check = S[0][:len(word + i)]
if next_word != check:
continue
if next_word == check:
stack.append(next_word)
return "NO"
if __name__ == "__main__":
S = [input()]
print(DFS(S))
|
s660302434
|
p04012
|
u976225138
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 97 |
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
|
w = input()
if all([w.count(s) % 2 == 0 for s in set(w)]):
print("YES")
else:
print("No")
|
s557892345
|
Accepted
| 17 | 2,940 | 96 |
w = input()
if not any([w.count(s) % 2 for s in set(w)]):
print("Yes")
else:
print("No")
|
s222211162
|
p03759
|
u429029348
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 87 |
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
|
a,b,c=map(int,input().split())
if a-b==b-c:
ans="Yes"
else:
ans="No"
print(ans)
|
s364944456
|
Accepted
| 17 | 2,940 | 87 |
a,b,c=map(int,input().split())
if a-b==b-c:
ans="YES"
else:
ans="NO"
print(ans)
|
s221215160
|
p03377
|
u884691894
| 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 + B >= X >= A:
print("Yes")
else:
print("No")
|
s907576987
|
Accepted
| 17 | 2,940 | 98 |
A,B,X = map(int, input().split())
if A + B >= X and A <= X:
print("YES")
else:
print("NO")
|
s319858416
|
p03351
|
u814986259
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 2,940 | 146 |
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
|
a,b,c,d = map(int ,input().split())
if abs(a - c) <= d:
print("YES")
elif abs(a- b) <= d and abs(b - c) <= d:
print("YES")
else:
print("NO")
|
s182375756
|
Accepted
| 17 | 2,940 | 119 |
a,b,c,d=map(int,input().split())
if abs(c-a) <= d or (abs(c-b)<=d and abs(b-a)<=d):
print("Yes")
else:
print("No")
|
s514647967
|
p03657
|
u111365362
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 132 |
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.
|
#16:31
a,b = map(int,input().split())
if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0:
print('POSSIBLE')
else:
print('IMPOSSIBLE')
|
s525720667
|
Accepted
| 17 | 2,940 | 132 |
#16:31
a,b = map(int,input().split())
if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0:
print('Possible')
else:
print('Impossible')
|
s388518517
|
p03485
|
u761989513
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 99 |
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())
n = a + b
if n % 2 == 0:
print(n / 2)
else:
print((n / 2) + 1)
|
s003676869
|
Accepted
| 17 | 2,940 | 102 |
a, b = map(int, input().split())
n = a + b
if n % 2 == 0:
print(n // 2)
else:
print((n // 2) + 1)
|
s953267120
|
p03861
|
u267300160
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 109 |
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
|
a,b,x = map(int,input().split())
count = int(b//x - a//x)
if(count == 0):
print(0)
else:
print(count)
|
s115230725
|
Accepted
| 17 | 2,940 | 55 |
a,b,x = map(int,input().split())
print(b//x - (a-1)//x)
|
s345806321
|
p03623
|
u843318346
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 78 |
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
|
x,a,b = map(int,input().split())
aa = abs(x-a)
bb = abs(x-b)
print(min(aa,bb))
|
s904843731
|
Accepted
| 17 | 2,940 | 102 |
x,a,b = map(int,input().split())
aa = abs(x-a)
bb = abs(x-b)
if aa<bb:
print('A')
else:
print('B')
|
s339359450
|
p03574
|
u600608564
| 2,000 | 262,144 |
Wrong Answer
| 28 | 3,188 | 573 |
You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process.
|
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
print(s)
dx = [-1, 0, 1]
dy = [-1, 0, 1]
for i in range(h):
for j in range(w):
if s[i][j] == '#':
for d_x in dx:
for d_y in dy:
if 0 <= i + d_x < h and 0 <= j + d_y < w:
if s[i + d_x][j + d_y] != '#':
if s[i + d_x][j + d_y] == '.':
s[i + d_x][j + d_y] = 1
else:
s[i + d_x][j + d_y] += 1
print(s)
|
s762759688
|
Accepted
| 30 | 3,444 | 674 |
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
dx = [-1, 0, 1]
dy = [-1, 0, 1]
for i in range(h):
for j in range(w):
if s[i][j] == '#':
for d_x in dx:
for d_y in dy:
if 0 <= i + d_x < h and 0 <= j + d_y < w and s[i + d_x][j + d_y] != '#':
if s[i + d_x][j + d_y] == '.':
s[i + d_x][j + d_y] = 1
else:
s[i + d_x][j + d_y] += 1
for i in range(h):
for j in range(w):
if s[i][j] == '.':
s[i][j] = 0
print(s[i][j], end='')
print()
|
s052692576
|
p03997
|
u085334230
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 75 |
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)
|
s572514910
|
Accepted
| 18 | 2,940 | 80 |
a = int(input())
b = int(input())
h = int(input())
print(int((a + b) * h / 2))
|
s696972955
|
p04043
|
u745812846
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 101 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
a=list(map(int, input().split()))
a.sort()
if a == [5, 5, 7]:
print('Yes')
else:
print('No')
|
s955783207
|
Accepted
| 17 | 2,940 | 101 |
a=list(map(int, input().split()))
a.sort()
if a == [5, 5, 7]:
print('YES')
else:
print('NO')
|
s358785583
|
p03796
|
u440129511
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 3,464 | 71 |
Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
|
n=int(input())
k=1
for i in range(1,n):
k*=i
print( k%((10**9)+7) )
|
s527901236
|
Accepted
| 35 | 2,940 | 74 |
n=int(input())
k=1
for i in range(1,n+1):
k=(k*i)%((10**9)+7)
print(k)
|
s925054907
|
p03434
|
u785066634
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 323 |
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
|
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
print(a)
Alice=[]
Bob=[]
for i in range(n):
if i%2==0:
Alice.append(a[i])
else:
Bob.append(a[i])
#print('Alice',Alice)
#print('Bob',Bob)
print((sum(Alice))-(sum(Bob)))
|
s408689937
|
Accepted
| 17 | 3,060 | 324 |
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
#print(a)
Alice=[]
Bob=[]
for i in range(n):
if i%2==0:
Alice.append(a[i])
else:
Bob.append(a[i])
#print('Alice',Alice)
#print('Bob',Bob)
print((sum(Alice))-(sum(Bob)))
|
s395518319
|
p03162
|
u768256617
| 2,000 | 1,048,576 |
Wrong Answer
| 1,102 | 57,456 | 317 |
Taro's summer vacation starts tomorrow, and he has decided to make plans for it now. The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day: * A: Swim in the sea. Gain a_i points of happiness. * B: Catch bugs in the mountains. Gain b_i points of happiness. * C: Do homework at home. Gain c_i points of happiness. As Taro gets bored easily, he cannot do the same activities for two or more consecutive days. Find the maximum possible total points of happiness that Taro gains.
|
n=int(input())
a=[]
for i in range(n):
a_=list(map(int,input().split()))
a.append(a_)
dp=[[0]*3 for i in range(n)]
dp[0]=a[0]
for i in range(1,n):
for k in range(3):
for j in range(3):
if k!=j:
dp[i][k]=max(dp[i][k], dp[i-1][j] + a[i-1][k])
print(dp)
print(max(dp[n-1]))
|
s553245038
|
Accepted
| 664 | 47,324 | 403 |
n=int(input())
abc=[[0,0,0]]
for i in range(n):
labc=list(map(int,input().split()))
abc.append(labc)
dp=[[0]*3 for i in range(n+1)]
for i in range(n):
for j in range(3):
if j==0:
dp[i+1][j]=max(dp[i][1],dp[i][2])+abc[i+1][j]
elif j==1:
dp[i+1][j]=max(dp[i][0],dp[i][2])+abc[i+1][j]
else:
dp[i+1][j]=max(dp[i][1],dp[i][0])+abc[i+1][j]
print(max(dp[n]))
#print(dp)
|
s446923616
|
p04014
|
u268793453
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 140 |
For integers b (b \geq 2) and n (n \geq 1), let the function f(b,n) be defined as follows: * f(b,n) = n, when n < b * f(b,n) = f(b,\,{\rm floor}(n / b)) + (n \ {\rm mod} \ b), when n \geq b Here, {\rm floor}(n / b) denotes the largest integer not exceeding n / b, and n \ {\rm mod} \ b denotes the remainder of n divided by b. Less formally, f(b,n) is equal to the sum of the digits of n written in base b. For example, the following hold: * f(10,\,87654)=8+7+6+5+4=30 * f(100,\,87654)=8+76+54=138 You are given integers n and s. Determine if there exists an integer b (b \geq 2) such that f(b,n)=s. If the answer is positive, also find the smallest such b.
|
n = int(input())
s = int(input())
ans = -1
if n == s:
ans = 1
if n == 1:
ans = n
elif s <= -(-n//2):
ans = n-(s-1)
print(ans)
|
s989335004
|
Accepted
| 354 | 3,064 | 466 |
import math
n = int(input())
s = int(input())
ans = []
def f(b, n):
if n < b:
return n
else:
return f(b, n//b) + n % b
if n == s:
ans.append(n+1)
elif n < s:
ans.append(-1)
else:
rootn = int(math.sqrt(n))
for b in range(2, rootn+2):
if s == f(b, n):
ans.append(b)
break
for p in range(1, rootn):
b = (n-s)//p + 1
if s == p + n%b:
ans.append(b)
if not ans:
ans.append(-1)
print(min(ans))
|
s266549036
|
p02612
|
u455809703
| 2,000 | 1,048,576 |
Wrong Answer
| 27 | 9,140 | 31 |
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)
|
s637695752
|
Accepted
| 31 | 9,176 | 79 |
N = int(input())
if N % 1000 == 0:
print(0)
else:
print(1000 - N%1000)
|
s159858802
|
p04043
|
u735008991
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 98 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
a, b, c = input().split()
print("YES" if sorted([len(a), len(b), len(c)]) == [5, 5, 7] else "NO")
|
s759579745
|
Accepted
| 17 | 2,940 | 86 |
a = input().split()
print("YES" if a.count("5") == 2 and a.count("7") == 1 else "NO")
|
s656555890
|
p03644
|
u756030237
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 48 |
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
|
a = int(input())
print(len(str(bin(int(a))))-3)
|
s773005873
|
Accepted
| 18 | 2,940 | 78 |
a = int(input())
len_a = len(str(bin(int(a))))-3
print(int("1" + "0"*len_a,2))
|
s498440198
|
p03729
|
u498575211
| 2,000 | 262,144 |
Wrong Answer
| 29 | 9,080 | 89 |
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")
|
s710171905
|
Accepted
| 25 | 9,092 | 89 |
a,b,c=input().split()
if a[-1]==b[0] and b[-1]==c[0]:
print('YES')
else:
print('NO')
|
s330727829
|
p03644
|
u767664985
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 1 |
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
|
7
|
s516828262
|
Accepted
| 19 | 3,064 | 130 |
N = int(input())
ans_list = [2**i for i in range(8)]
ai = 0
while (ans_list[ai] <= N):
ai += 1
print(ans_list[max(0, ai-1)])
|
s374347961
|
p03565
|
u230717961
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 523 |
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`.
|
def solve(s, t):
length = len(t)
ans = ""
i = 0
flg = False
while i < len(s):
tmp = s[i:i+length]
print(tmp, t)
count = len([i for i, j in zip(tmp, t) if i == j or i == "?"])
if length == count:
ans += t
i += length
flg = True
else:
ans += "a" if s[i] == "?" else s[i]
i += 1
return ans if flg else "UNRESTORABLE"
if __name__ == "__main__":
s = input()
t = input()
print(solve(s, t))
|
s303043894
|
Accepted
| 20 | 3,064 | 466 |
def solve(s, t):
length = len(t)
ans = []
i = 0
flg = False
while i < len(s):
tmp = s[i:i+length]
count = len([i for i, j in zip(tmp, t) if i == j or i == "?"])
if length == count:
a = s[:i] + t + s[i+length:]
ans.append(a.replace("?", "a"))
i += 1
return min(ans) if len(ans) > 0 else "UNRESTORABLE"
if __name__ == "__main__":
s = input()
t = input()
print(solve(s, t))
|
s084605025
|
p03591
|
u331464808
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 62 |
Ringo is giving a present to Snuke. Ringo has found out that Snuke loves _yakiniku_ (a Japanese term meaning grilled meat. _yaki_ : grilled, _niku_ : meat). He supposes that Snuke likes grilled things starting with `YAKI` in Japanese, and does not like other things. You are given a string S representing the Japanese name of Ringo's present to Snuke. Determine whether S starts with `YAKI`.
|
s=input()
if s[:3]=="YAKI":
print("Yes")
else:
print("No")
|
s126891487
|
Accepted
| 20 | 3,060 | 62 |
s=input()
if s[:4]=="YAKI":
print("Yes")
else:
print("No")
|
s923882832
|
p02402
|
u627002197
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,592 | 117 |
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.
|
input_data = [int(i) for i in input().split()]
print(max(input_data),min(input_data),sum(input_data)/len(input_data))
|
s087629266
|
Accepted
| 20 | 8,696 | 96 |
num = int(input())
data = [int(i) for i in input().split()]
print(min(data),max(data),sum(data))
|
s461924267
|
p03636
|
u421499233
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 37 |
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
|
print(input().replace("2017","2018"))
|
s223640037
|
Accepted
| 18 | 2,940 | 59 |
s = input()
n = len(s)-2
print(s[0] + str(n) + s[len(s)-1])
|
s332711785
|
p03455
|
u422272120
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 226 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
i = list(map(int, input().split()))
a=i[0]
b=i[1]
if a % 2 == 0 or b % 2 == 0:
print ("even")
exit (0)
print ("odd")
|
s133387225
|
Accepted
| 17 | 2,940 | 173 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
i = list(map(int, input().split()))
a=i[0]
b=i[1]
if a % 2 == 0 or b % 2 == 0:
print ("Even")
exit (0)
print ("Odd")
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.