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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s532643549
|
p02646
|
u217836256
| 2,000 | 1,048,576 |
Wrong Answer
| 22 | 9,188 | 216 |
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
|
A,V = [int(x) for x in input().split()]
B,W = [int(x) for x in input().split()]
T = int(input())
D = abs(A-B)
S = V-W
if S==0 and D == 0:
print('Yes')
elif S>0 and D/S <= T:
print('Yes')
else:
print('No')
|
s826352211
|
Accepted
| 24 | 9,208 | 283 |
AV = [int(x) for x in input().split()]
BW = [int(x) for x in input().split()]
A = AV[0]
V = AV[1]
B = BW[0]
W = BW[1]
T = int(input())
T = float(T)
D = abs(A-B)
S = V-W
if S>0:
T1 = float(D/S)
if T1<=T:
print('YES')
else:
print('NO')
else:
print('NO')
|
s684945558
|
p03567
|
u598016178
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 35 |
Snuke built an online judge to hold a programming contest. When a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring. (The judge can return any two-character substring of S.) Determine whether the judge can return the string `AC` as the verdict to a program.
|
print(["NO","YES"]["AC"in input()])
|
s538401509
|
Accepted
| 17 | 2,940 | 35 |
print(["No","Yes"]["AC"in input()])
|
s661259632
|
p03456
|
u633548583
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,188 | 149 |
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
|
a,b=map(str,input().split())
n=int(a+b)
for i in range(1,1000):
if i**2==n:
print('Yes')
break
else:
print('No')
|
s450852279
|
Accepted
| 19 | 3,060 | 91 |
c=int(input().replace(" ",""))
if int(c**0.5)**2==c:
print('Yes')
else:
print('No')
|
s224919334
|
p02694
|
u865418111
| 2,000 | 1,048,576 |
Wrong Answer
| 24 | 9,292 | 179 |
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
import math
X = int(input())
x = math.log(X/100, 1.01)
count = 0
temp = 100
while True:
temp = temp * 1.01 // 1
count += 1
if (temp > X):
break
print(count)
|
s331105016
|
Accepted
| 25 | 9,228 | 138 |
X = int(input())
count = 0
temp = 100
while True:
temp = temp * 1.01 // 1
count += 1
if temp >= X:
break
print(count)
|
s936133335
|
p03943
|
u114954806
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 98 |
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
lst = sorted(list(map(int,input().split())))
print("YES" if ((lst[0]+lst[1]) == lst[2]) else "NO")
|
s947128630
|
Accepted
| 17 | 2,940 | 98 |
lst = sorted(list(map(int,input().split())))
print("Yes" if ((lst[0]+lst[1]) == lst[2]) else "No")
|
s405877916
|
p03360
|
u265118937
| 2,000 | 262,144 |
Wrong Answer
| 25 | 9,104 | 128 |
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after K operations?
|
a,b,c=map(int,input().split())
k=int(input())
l=[]
l.append((k+1)*a +b+c)
l.append((k+1)*b +a+c)
l.append((k+1)*c +a+b)
print(l)
|
s368336200
|
Accepted
| 25 | 9,016 | 78 |
a,b,c=map(int,input().split())
k=int(input())
print(a+b+c+max(a,b,c)*(2**k-1))
|
s373072836
|
p03795
|
u642528832
| 2,000 | 262,144 |
Wrong Answer
| 27 | 9,164 | 119 |
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())
y_count = 0
x = 800*n
for i in range(n):
if i%15==0:
y_count+=1
print(x-y_count*200)
|
s544994317
|
Accepted
| 24 | 9,188 | 123 |
n = int(input())
y_count = 0
x = 800*n
for i in range(1,n+1):
if i%15==0:
y_count+=1
print(x-y_count*200)
|
s836996787
|
p02241
|
u567380442
| 1,000 | 131,072 |
Wrong Answer
| 40 | 6,744 | 792 |
For a given weighted graph $G = (V, E)$, find the minimum spanning tree (MST) of $G$ and print total weight of edges belong to the MST.
|
def memoize(f):
cache = {}
def helper(x):
if x not in cache:
cache[x] = f(x)
return cache[x]
return helper
def split_apex(a):
if len(a) == 2:
yield (a[0],), (a[1],)
else:
for i in range(0, len(a)):
yield (a[i],), a[:i] + a[i + 1:]
@memoize
def wait(a):
global g
if len(a) == 1:
return 0
return min(calc_wait(apex, apices) for apex, apices in split_apex(a))
def calc_wait(apex, apices):
global g
w = [g[apex[0]][i] for i in apices if g[apex[0]][i] != -1]
return wait(apex) + wait(apices) + (min(w) if len(w) else 200000)
n = int(input())
g = [None] + [[None] + list(map(int, input().split())) for _ in range(n)]
a = tuple(i + 1 for i in range(n))
wait(a)
|
s638123336
|
Accepted
| 50 | 7,168 | 1,028 |
class Forest:
def __init__(self, g, id):
self.forest = set([id])
self.graph = g
self.next_wait = self.graph[id]
self.wait = 0
def add_tree(self, id):
self.wait += self.next_wait[id]
self.forest.update([id])
self.marge_next_wait(id)
def next_tree(self):
min_id = min_wait = None
for id, wait in self.next_wait.items():
if id not in self.forest:
if min_wait == None or min_wait > wait:
min_wait = wait
min_id = id
return min_id
def marge_next_wait(self, merge_id):
for id, wait in self.graph[merge_id].items():
if id not in self.next_wait or self.next_wait[id] > wait:
self.next_wait[id] = wait
n = int(input())
g = [{e:i for e, i in enumerate(map(int, input().split())) if i != -1} for _ in range(n)]
forest = Forest(g,0)
for i in range(n - 1):
id = forest.next_tree()
forest.add_tree(id)
print(forest.wait)
|
s339076515
|
p02845
|
u674343825
| 2,000 | 1,048,576 |
Wrong Answer
| 107 | 20,588 | 506 |
N people are standing in a queue, numbered 1, 2, 3, ..., N from front to back. Each person wears a hat, which is red, blue, or green. The person numbered i says: * "In front of me, exactly A_i people are wearing hats with the same color as mine." Assuming that all these statements are correct, find the number of possible combinations of colors of the N people's hats. Since the count can be enormous, compute it modulo 1000000007.
|
n = int(input())
a = list(map(int,input().split()))
c = [0,0,0]
count = 1
for i in range(n):
match = (a[i]==c[0])+(a[i]==c[1])+(a[i]==c[2])
if match==0:
count = 0
break
elif match==1 or a[i]==0:
c[c.index(a[i])] += 1
else:
c[c.index(a[i])] += 1
count = (count*match)%(1e+9+7)
if count != 0:
match = (c[0]==c[1])+(c[1]==c[2])+(c[2]==c[0])
for i in range(2,match+1):
count = (count*i)%(1e+9+7)
print(int(count))
|
s183151271
|
Accepted
| 108 | 20,784 | 615 |
n = int(input())
a = list(map(int,input().split()))
c = [0,0,0]
count = 1
for i in range(n):
match = (a[i]==c[0])+(a[i]==c[1])+(a[i]==c[2])
if match==0:
count = 0
break
elif match==1 or a[i]==0:
c[c.index(a[i])] += 1
else:
c[c.index(a[i])] += 1
count = (count*match)%(1e+9+7)
if count != 0:
c = sorted(c,reverse=True)
while 0 in c:
c.pop()
memory = set()
kinds = 0
for x in c:
if not x in memory:
kinds += 1
for i in range(3,3-kinds,-1):
count = (count*i)%(1e+9+7)
print(int(count))
|
s399413589
|
p00082
|
u136916346
| 1,000 | 131,072 |
Wrong Answer
| 30 | 5,608 | 232 |
遊園地にあるメリーゴーランドはご存じでしょう。大きな円盤の上に馬や馬車などの乗り物が固定されていて、円盤が回転すると同時に乗り物が上下に揺れる、定番の遊具です。ある遊園地のメリーゴーランドは、4人乗りの馬車が2台、2人乗りの車2台、1人乗りの馬が4台、計8台の乗り物が図1のような順序で備えられています。そして、遊園地においでのお客様は、図1に示す乗り場0〜7のどこかで待つようになっています。 この遊園地のメリーゴーランドは、かならず乗り物が乗り場にぴったりと合う位置に停止します。そして、0〜7のそれぞれで待っているお客さまは、目の前にとまった乗り物に乗ることになっています。急いで他の乗り場へ移動してそこから乗るということはできません。効率よく、お客さまにたのしんでいただくためには、メリーゴーランドの停止する位置をうまく調整して、乗れないお客さまをできるだけ少なくするようにしなければなりません。 乗り場0〜7で待っているお客さまの人数を読み込んで、どの位置にどの乗り物が来るように止めれば乗れないお客さまが最も少なくなるかを出力するプログラムを作成してください。
|
import sys
t=[1,4,1,4,1,2,1,2]
for i in sys.stdin:
l=map(int,i[:-1].split())
q=[sum([j if j<i else i for (i,j) in zip(t[i:]+t[:i],l)]) for i in range(8)]
idx=q.index(max(q))
print(" ".join(map(str,t[idx:]+t[:idx])))
|
s782649585
|
Accepted
| 30 | 5,624 | 383 |
import sys
t=[1,4,1,4,1,2,1,2]
for i in sys.stdin:
l=list(map(int,i[:-1].split()))
q={}
for i in range(8):
e=int("".join(map(str,t[i:]+t[:i])))
s=sum([j if j<i else i for (i,j) in zip(t[i:]+t[:i],l)])
if s not in q:
q[s]=[e]
else:
q[s].extend([e])
print(" ".join([i for i in str(sorted(q[max(q.keys())])[0])]))
|
s067404566
|
p04012
|
u476562059
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 206 |
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.
|
a = input()
ans = "Yes"
char_list = list(a)
doubli = list(set(char_list))
#print(doubli)
for x in doubli:
#print(char_list.count(x))
if(char_list.count(x) == 1):
ans = "No"
break
|
s304231749
|
Accepted
| 17 | 2,940 | 219 |
a = input()
ans = "Yes"
char_list = list(a)
doubli = list(set(char_list))
#print(doubli)
for x in doubli:
#print(char_list.count(x))
if(char_list.count(x) % 2 == 1):
ans = "No"
break
print(ans)
|
s107370995
|
p04031
|
u858523893
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 181 |
Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2). Find the minimum total cost to achieve his objective.
|
N = int(input())
a = [int(x) for x in input().split()]
mean = sum(a) // len(a) if sum(a) % len(a) == 0 else sum(a) // len(a) + 1
df = 0
for i in a :
df += (i - mean) ** 2
df
|
s269776330
|
Accepted
| 24 | 2,940 | 241 |
N = int(input())
a = [int(x) for x in input().split()]
min_df = 10**100
for i in range(min(a), max(a) + 1) :
sum_over = 0
for j in a :
sum_over += (i - j) ** 2
min_df = min(min_df, sum_over)
print(min_df)
|
s682796758
|
p02743
|
u077291787
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 169 |
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?
|
# C - Sqrt Inequality
def main():
A, B, C = map(int, input().split())
print("Yes" if A ** 2 + B ** 2 < C ** 2 else "No")
if __name__ == "__main__":
main()
|
s840416385
|
Accepted
| 34 | 5,076 | 220 |
# C - Sqrt Inequality
from decimal import Decimal
def main():
A, B, C = map(Decimal, input().split())
print("Yes" if A + B + Decimal("2") * (A * B).sqrt() < C else "No")
if __name__ == "__main__":
main()
|
s486566565
|
p02258
|
u822971508
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,588 | 313 |
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen. Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .
|
if __name__ == "__main__":
n = int(input())
r0 = int(input())
r1 = int(input())
minv = r0 if r0 <= r1 else r1
maxv = r1 - r0
for i in range(2, n):
r = int(input())
if maxv >= (r-minv):
maxv = r-minv
if r <= minv:
minv = r
print(maxv)
|
s152023860
|
Accepted
| 620 | 5,612 | 277 |
if __name__ == "__main__":
n = int(input())
r0 = int(input())
r1 = int(input())
minv = r0 if r0 <= r1 else r1
maxv = r1 - r0
for i in range(2, n):
r = int(input())
maxv = max(maxv, (r-minv))
minv = min(minv, r)
print(maxv)
|
s348358349
|
p03129
|
u239342230
| 2,000 | 1,048,576 |
Wrong Answer
| 19 | 2,940 | 76 |
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
|
a,b=map(int,input().split())
if a/b >= 2:
print('YES')
else:
print('NO')
|
s609520792
|
Accepted
| 18 | 2,940 | 81 |
a,b=map(int,input().split())
if (a+1)/b >= 2:
print('YES')
else:
print('NO')
|
s565397170
|
p03387
|
u228223940
| 2,000 | 262,144 |
Wrong Answer
| 22 | 3,444 | 429 |
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.
|
import copy
a,b,c = map(int,input().split())
max_v = max(a,b,c)
if max_v == b:
tmp = a
a = b
b = tmp
elif max_v == c:
tmp = a
a = c
c = tmp
tmp_b = (a-b) // 2
tmp_c = (a-c) // 2
if a - (b + 2 * tmp_b) + a - (c + 2 * tmp_c) == 2:
ans = tmp_b + tmp_c + 1
elif a - (b + 2 * tmp_b) + a - (c + 2 * tmp_c) == 0:
ans = tmp_b + tmp_c
else:
ans = tmp_b + tmp_c + 2
print(tmp_b,tmp_c)
print(ans)
|
s320000911
|
Accepted
| 25 | 3,444 | 409 |
import copy
a,b,c = map(int,input().split())
max_v = max(a,b,c)
if max_v == b:
tmp = a
a = b
b = tmp
elif max_v == c:
tmp = a
a = c
c = tmp
tmp_b = (a-b) // 2
tmp_c = (a-c) // 2
if a - (b + 2 * tmp_b) + a - (c + 2 * tmp_c) == 2:
ans = tmp_b + tmp_c + 1
elif a - (b + 2 * tmp_b) + a - (c + 2 * tmp_c) == 0:
ans = tmp_b + tmp_c
else:
ans = tmp_b + tmp_c + 2
print(ans)
|
s044029160
|
p02557
|
u520276780
| 2,000 | 1,048,576 |
Wrong Answer
| 277 | 56,000 | 538 |
Given are two sequences A and B, both of length N. A and B are each sorted in the ascending order. Check if it is possible to reorder the terms of B so that for each i (1 \leq i \leq N) A_i \neq B_i holds, and if it is possible, output any of the reorderings that achieve it.
|
n=int(input())
*a,=map(int, input().split())
*b,=map(int, input().split())
from collections import Counter
ac=Counter(a)
bc=Counter(b)
for ai in ac:
if ai in bc:
if ac[ai]+bc[ai]>n:
print('No')
exit()
bb=[0]*n
l=0;r=n-1
x=0
for i in range(n):
if b[i]!=a[r]:
bb[r]=b[i]
r-=1
else:
if b[i]!=a[l]:
bb[l]=b[i]
l+=1
else:
tmp=bb[x]
bb[x]=b[i]
x+=1
bb[l]=tmp
print("Yes")
print(*bb)
|
s499780913
|
Accepted
| 465 | 55,952 | 487 |
n=int(input())
*a,=map(int, input().split())
*b,=map(int, input().split())
shift=0
from bisect import bisect_right,bisect_left
from collections import Counter
sb=Counter(b)
sa=Counter(a)
for bi in sb:
if bi in sa:
if sa[bi]+sb[bi]>n:
print("No")
exit()
for bi in sb:
lb=bisect_left(b,bi)
ra=bisect_right(a,bi)
if a[ra-1]==b[lb]:
shift=max(shift,ra-lb)
ans=[b[(i-shift)%n] for i in range(n)]##
print("Yes")
print(*ans)
|
s851467810
|
p03564
|
u020604402
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 134 |
Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value: * Operation A: The displayed value is doubled. * Operation B: The displayed value increases by K. Square1001 needs to perform these operations N times in total. Find the minimum possible value displayed in the board after N operations.
|
N = int(input())
K = int(input())
ans = 0
for _ in range(N):
if ans + K > ans * 2:
ans *= 2
else:
ans += K
print(ans)
|
s229769792
|
Accepted
| 18 | 2,940 | 135 |
N = int(input())
K = int(input())
ans = 1
for _ in range(N):
if ans + K > ans * 2:
ans *= 2
else:
ans += K
print(ans)
|
s567222951
|
p03679
|
u750651325
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 144 |
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())
eat = A+B
if A >= B:
print("delicious")
elif eat >= X+1:
print("dangerous")
else:
print("safe")
|
s030406893
|
Accepted
| 17 | 2,940 | 144 |
X, A, B = map(int, input().split())
eat = B-A
if A >= B:
print("delicious")
elif eat >= X+1:
print("dangerous")
else:
print("safe")
|
s723063750
|
p02678
|
u833071789
| 2,000 | 1,048,576 |
Wrong Answer
| 1,678 | 66,644 | 2,381 |
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.
|
import glob
import math
REL_PATH = 'ABC\\168\\D'
TOP_PATH = 'C:\\AtCoder'
class Common:
problem = []
index = 0
def __init__(self, rel_path):
self.rel_path = rel_path
def initialize(self, path):
file = open(path)
self.problem = file.readlines()
self.index = 0
return
def input_data(self):
try:
IS_TEST
self.index += 1
return self.problem[self.index-1]
except NameError:
return input()
def resolve(self):
pass
def exec_resolve(self):
try:
IS_TEST
for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
print("Test: " + path)
self.initialize(path)
self.resolve()
print("\n\n")
except NameError:
self.resolve()
class Solver(Common):
alph = []
def rec(self, result, now, max, N):
if now == N:
res = ""
for i in result:
res += self.alph[i]
print(res)
return
if now == 0:
result[0] = 0
self.rec(result, now+1, 0, N)
return
for i in range(0, max+2):
if i == N:
return
result[now] = i
if i > max:
self.rec(result, now+1, i, N)
else:
self.rec(result, now+1, max, N)
def resolve(self):
count = 0
N, M = map(int, self.input_data().split())
node = [list(map(int, self.input_data().split())) for i in range(M)]
sp = [[0, 200000] for i in range(N+1)] # signpost
path = [[] for i in range(N+1)]
for n in node:
path[n[0]].append(n[1])
path[n[1]].append(n[0])
next = [1]
sp[1][1] = 0
while len(next) != 0:
now = next.pop(0)
for n in path[now]:
if sp[n][1] > sp[now][1]+1:
sp[n][0] = now
sp[n][1] = sp[now][1]+1
next.append(n)
print('yes')
for i in range(2,N+1):
print(str(sp[i][0]))
solver = Solver(REL_PATH)
solver.exec_resolve()
|
s471759111
|
Accepted
| 1,761 | 66,432 | 2,381 |
import glob
import math
REL_PATH = 'ABC\\168\\D'
TOP_PATH = 'C:\\AtCoder'
class Common:
problem = []
index = 0
def __init__(self, rel_path):
self.rel_path = rel_path
def initialize(self, path):
file = open(path)
self.problem = file.readlines()
self.index = 0
return
def input_data(self):
try:
IS_TEST
self.index += 1
return self.problem[self.index-1]
except NameError:
return input()
def resolve(self):
pass
def exec_resolve(self):
try:
IS_TEST
for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
print("Test: " + path)
self.initialize(path)
self.resolve()
print("\n\n")
except NameError:
self.resolve()
class Solver(Common):
alph = []
def rec(self, result, now, max, N):
if now == N:
res = ""
for i in result:
res += self.alph[i]
print(res)
return
if now == 0:
result[0] = 0
self.rec(result, now+1, 0, N)
return
for i in range(0, max+2):
if i == N:
return
result[now] = i
if i > max:
self.rec(result, now+1, i, N)
else:
self.rec(result, now+1, max, N)
def resolve(self):
count = 0
N, M = map(int, self.input_data().split())
node = [list(map(int, self.input_data().split())) for i in range(M)]
sp = [[0, 200000] for i in range(N+1)] # signpost
path = [[] for i in range(N+1)]
for n in node:
path[n[0]].append(n[1])
path[n[1]].append(n[0])
next = [1]
sp[1][1] = 0
while len(next) != 0:
now = next.pop(0)
for n in path[now]:
if sp[n][1] > sp[now][1]+1:
sp[n][0] = now
sp[n][1] = sp[now][1]+1
next.append(n)
print('Yes')
for i in range(2,N+1):
print(str(sp[i][0]))
solver = Solver(REL_PATH)
solver.exec_resolve()
|
s863208897
|
p03779
|
u415905784
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 110 |
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.
|
import math
X = int(input())
x = int(math.sqrt(2 * X))
if x ** 2 - x >= 2 * X:
print(x)
else:
print(x + 1)
|
s170485701
|
Accepted
| 18 | 2,940 | 63 |
import math
X = int(input())
print(int(0.5 + math.sqrt(2 * X)))
|
s239665212
|
p02397
|
u498511622
| 1,000 | 131,072 |
Wrong Answer
| 50 | 7,532 | 118 |
Write a program which reads two integers x and y, and prints them in ascending order.
|
while True:
a,b=map(int,input().split())
if a==0 and b==0:
break
if a<b:
print(b,a)
else:
print(a,b)
|
s625225935
|
Accepted
| 60 | 7,668 | 121 |
while True:
a,b=map(int,input().split())
if a==0 and b==0:
break
if a <= b:
print(a,b)
else:
print(b,a)
|
s969537994
|
p02388
|
u429841998
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,576 | 56 |
Write a program which calculates the cube of a given integer x.
|
x = input()
y = int(x) ** 3
print('Xの3乗は'+str(y))
|
s626759018
|
Accepted
| 20 | 5,576 | 37 |
x = input()
y = int(x) ** 3
print(y)
|
s793960982
|
p03944
|
u732870425
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 328 |
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i). Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows: * If a_i = 1, he painted the region satisfying x < x_i within the rectangle. * If a_i = 2, he painted the region satisfying x > x_i within the rectangle. * If a_i = 3, he painted the region satisfying y < y_i within the rectangle. * If a_i = 4, he painted the region satisfying y > y_i within the rectangle. Find the area of the white region within the rectangle after he finished painting.
|
W, H, N = map(int, input().split())
xya = [list(map(int, input().split())) for _ in range(N)]
x1 = W
x2 = 0
y3 = H
y4 = 0
for x,y,a in xya:
if a == 1:
x1 = min(x1, x)
elif a == 2:
x2 = max(x2, x)
elif a == 3:
y3 = min(y3, y)
elif a == 4:
y4 = max(y4, y)
print((x1-x2) * (y3-y4))
|
s596177381
|
Accepted
| 18 | 3,064 | 564 |
W, H, N = map(int, input().split())
xya = [list(map(int, input().split())) for _ in range(N)]
x1 = 0
x2 = W
y3 = 0
y4 = H
for x,y,a in xya:
if a == 1:
x1 = max(x1, x)
elif a == 2:
x2 = min(x2, x)
elif a == 3:
y3 = max(y3, y)
elif a == 4:
y4 = min(y4, y)
else:
if x2 <= x1 or y4 <= y3:
print(0)
else:
print((x2-x1) * (y4-y3))
|
s803550403
|
p00084
|
u553058997
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,408 | 112 |
インターネットの検索エンジン、例えば、Google などでは、世界中のウェブページを自動で収捨して分類し、巨大なデータベースを作成します。また、ユーザが入力した検索キーワードを解析して、データベース検索のための問い合わせ文を作成します。 いずれの場合も、効率的な検索を実現するために複雑な処理を行っていますが、とりあえずの基本は全て文章からの単語の切り出しです。 ということで、文章からの単語の切り出しに挑戦してください。今回は以下の通り、単語区切りが明確な英語の文章を対象とします。 * 対象となる文章 : 改行を含まない 1024 文字以下の英語の文章 * 区切り文字 : いずれも半角で空白、ピリオド、カンマのみ * 切り出す単語 : 3 から 6 文字の単語(2文字以下や7文字以上の単語は無視)
|
print(' '.join([w for w in input().replace(',', '').replace('.', '').split(', ') if len(w) > 2 and len(w) < 7]))
|
s900528826
|
Accepted
| 20 | 7,484 | 111 |
print(' '.join([w for w in input().replace(',', '').replace('.', '').split(' ') if len(w) > 2 and len(w) < 7]))
|
s540623457
|
p03129
|
u777028980
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 77 |
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
|
A,B=map(int,input().split())
if(A>2*B-1):
print("YES")
else:
print("NO")
|
s427292563
|
Accepted
| 17 | 2,940 | 78 |
A,B=map(int,input().split())
if(A>=2*B-1):
print("YES")
else:
print("NO")
|
s156748933
|
p02601
|
u846463155
| 2,000 | 1,048,576 |
Wrong Answer
| 28 | 9,088 | 188 |
M-kun has the following three cards: * A red card with the integer A. * A green card with the integer B. * A blue card with the integer C. He is a genius magician who can do the following operation at most K times: * Choose one of the three cards and multiply the written integer by 2. His magic is successful if both of the following conditions are satisfied after the operations: * The integer on the green card is **strictly** greater than the integer on the red card. * The integer on the blue card is **strictly** greater than the integer on the green card. Determine whether the magic can be successful.
|
a, b, c = map(int, input().split())
k = int(input())
cnt = 0
while a>=b:
b *= 2
cnt += 1
while b>=c:
c *= 2
cnt += 1
if(cnt <= k):
print("YES")
else:
print("NO")
|
s521541966
|
Accepted
| 32 | 9,092 | 188 |
a, b, c = map(int, input().split())
k = int(input())
cnt = 0
while a>=b:
b *= 2
cnt += 1
while b>=c:
c *= 2
cnt += 1
if(cnt <= k):
print("Yes")
else:
print("No")
|
s786726975
|
p03860
|
u363558926
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 27 |
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
|
print("A" +input()[8] +"B")
|
s756900217
|
Accepted
| 17 | 2,940 | 27 |
print("A" +input()[8] +"C")
|
s038189644
|
p02612
|
u137038354
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 9,140 | 36 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
N = int(input())
p = N%1000
print(p)
|
s806293851
|
Accepted
| 30 | 9,152 | 89 |
N = int(input())
p = N%1000
if p%1000 == 0:
ans = 0
else:
ans = 1000-p
print(ans)
|
s420957645
|
p03555
|
u209918867
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 62 |
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
|
s1=input()
s2=input()
print('YES' if s1[::-1] is s2 else 'NO')
|
s640015574
|
Accepted
| 18 | 2,940 | 64 |
s1=input()
s2=input()
print('YES' if s1[::-1] == s2 else 'NO')
|
s339647438
|
p02388
|
u580508010
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,356 | 38 |
Write a program which calculates the cube of a given integer x.
|
def jack(x):
y = x**3
return y
|
s482490679
|
Accepted
| 20 | 7,520 | 33 |
a= int(input())
b= a**3
print (b)
|
s545281983
|
p03814
|
u172780602
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,516 | 111 |
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()
m=s.find("A")
n=s.find("Z",m)
print(m)
print(n)
if m<n:
ans=(n-m)+1
print(ans)
else:
pass
|
s390532338
|
Accepted
| 17 | 3,512 | 92 |
s=input()
m=s.find("A")
n=s.rfind("Z")
if m<n:
ans=(n-m)+1
print(ans)
else:
pass
|
s451973448
|
p03360
|
u591295155
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 83 |
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after K operations?
|
A, B, C = map(int, input().split())
K = int(input())
print(max(A, B, C)**(2*K)+B+C)
|
s799393386
|
Accepted
| 17 | 2,940 | 98 |
A, B, C = map(int, input().split())
K = int(input())
print(max(A, B, C)*(2**K)+A+B+C-max(A, B, C))
|
s980487369
|
p03573
|
u740767776
| 2,000 | 262,144 |
Wrong Answer
| 19 | 2,940 | 130 |
You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
|
s = list(input().split())
if s[0] == s[1]:
print(int(s[2]))
elif s[1] == s[2]:
print(int(s[0]))
else:
print(int(s[0]))
|
s685298889
|
Accepted
| 17 | 3,060 | 124 |
s = list(input().split())
if s[0] == s[1]:
print(int(s[2]))
elif s[1] == s[2]:
print(int(s[0]))
else:
print(int(s[1]))
|
s617415465
|
p03813
|
u548624367
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 44 |
Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise. You are given Smeke's current rating, x. Print `ABC` if Smeke will participate in ABC, and print `ARC` otherwise.
|
print("ABC" if 1200<int(input()) else "ARC")
|
s515001037
|
Accepted
| 18 | 2,940 | 44 |
print("ABC" if 1200>int(input()) else "ARC")
|
s115365806
|
p03779
|
u976162616
| 2,000 | 262,144 |
Wrong Answer
| 21 | 3,060 | 274 |
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.
|
def obj(t):
return t**2 + t
import math
X = int(input())
s = 0
e = 2e9
m = math.floor((s + e) / 2.0)
while(True):
if (obj(m) < (2 * X)):
s = m
else:
e = m
if ((e - s) <= 1):
print(m)
break
m = math.floor((s + e) / 2.0)
|
s493113958
|
Accepted
| 21 | 3,316 | 274 |
def obj(t):
return t**2 + t
import math
X = int(input())
s = 0
e = 2e9
m = math.floor((s + e) / 2.0)
while(True):
if (obj(m) < (2 * X)):
s = m
else:
e = m
if ((e - s) <= 1):
print(e)
break
m = math.floor((s + e) / 2.0)
|
s555992933
|
p03971
|
u701318346
| 2,000 | 262,144 |
Wrong Answer
| 108 | 4,712 | 381 |
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these. Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests. * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B. * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students. A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these. Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass.
|
N, A, B = map(int, input().split())
S = list(input())
a, b = 0, 0
for s in S:
if s == 'a':
if (a + b) <= (A + B):
print('Yes')
a += 1
else:
print('No')
elif s == 'b':
if (a + b) <= (A + B) and b <= B:
print('Yes')
b += 1
else:
print('No')
else:
print('No')
|
s204434669
|
Accepted
| 111 | 4,712 | 379 |
N, A, B = map(int, input().split())
S = list(input())
a, b = 0, 0
for s in S:
if s == 'a':
if (a + b) < (A + B):
print('Yes')
a += 1
else:
print('No')
elif s == 'b':
if (a + b) < (A + B) and b < B:
print('Yes')
b += 1
else:
print('No')
else:
print('No')
|
s376077662
|
p03485
|
u803096981
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 107 |
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 = (int(x) for x in input().split())
x = (a+b) / 2
if (a+b) % 2 == 0:
print(x)
else:
print(x + 0.5)
|
s652851045
|
Accepted
| 17 | 2,940 | 117 |
a, b = (int(x) for x in input().split())
x = (a+b) / 2
if (a+b) % 2 == 0:
print(int(x))
else:
print(int(x + 0.5))
|
s233202833
|
p02694
|
u880400515
| 2,000 | 1,048,576 |
Wrong Answer
| 25 | 9,156 | 87 |
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
X = int(input())
bal = 100
i = 0
while (bal < X):
bal = bal + bal * 0.01
print(i)
|
s668292752
|
Accepted
| 21 | 9,152 | 123 |
import math
X = int(input())
bal = 100
i = 0
while (bal < X):
bal = bal + math.floor(bal * 0.01)
i += 1
print(i)
|
s597651447
|
p03999
|
u941753895
| 2,000 | 262,144 |
Wrong Answer
| 27 | 3,064 | 337 |
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.
|
s=input()
if s=='125':
exit()
n=len(s)-1
if n==0:
print(s)
else:
l=[]
a=len(bin(1<<n))-3
for i in range(1<<n):
l.append(str(bin(i))[2:].zfill(a))
su=0
for i in l:
ind=0
st=s[ind]
for j in i:
if j=='0':
pass
else:
st+='+'
ind+=1
st+=s[ind]
su+=eval(st)
print(su)
|
s097231610
|
Accepted
| 52 | 5,532 | 705 |
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()
# 10 -> n
def ten2n(a,n):
x=a//n
y=a%n
if x:
return ten2n(x,n)+str(y)
return str(y)
def main():
n=S()
l=list(n)
l2=[]
for i in range(pow(2,len(n)-1)):
l2.append(list(ten2n(i,2).zfill(len(n)-1)))
sm=0
for x in l2:
s=''
for i in range(len(x)):
if x[i]=='0':
s+=l[i]
else:
s+=l[i]+'+'
if len(l)>1:
s+=l[-1]
sm+=eval(s)
return sm
print(main())
|
s673972310
|
p04044
|
u223133214
| 2,000 | 262,144 |
Wrong Answer
| 33 | 3,572 | 619 |
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
|
N,L=map(int,input().split())
s_list=[]
for i in range(N):
s_list.append(input())
def moji(m,a):
return list(m)[a]
ans = ''
for i in range(L):
if len(ans) == L*N:
break
hantei = True
max = '}'
while hantei == True:
for j in range(N):
if max > moji(s_list[j],i):
max = moji(s_list[j],i)
maxj = j
if max != '}':
ans += s_list[maxj]
print(ans)
s_list[maxj] = '}'*L
max = '}'
else:
hantei = False
print(ans)
|
s331134170
|
Accepted
| 18 | 3,060 | 104 |
N,L=map(int,input().split())
s = []
for i in range(N):
s.append(input())
s.sort()
print(''.join(s))
|
s611847951
|
p04045
|
u296518383
| 2,000 | 262,144 |
Wrong Answer
| 21 | 3,316 | 265 |
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money. Find the amount of money that she will hand to the cashier.
|
N,K=map(int,input().split())
D=list(map(int,input().split()))
C=[]
for i in range(0,10):
if i not in D:
C.append(i)
#print(C)
for i in range(N,10**10):
cnt=0
for j in list(map(int,list(str(i)))):
cnt+=1
if len(str(i))==cnt:
print(i)
exit()
|
s964529910
|
Accepted
| 154 | 3,060 | 231 |
N, K = map(int, input().split())
D = list(map(int, input().split()))
for i in range(N, 10 * N + 1):
A = list(map(int, str(i)))
flag = 1
for a in A:
if a in D:
flag = 0
break
if flag:
print(i)
exit()
|
s073540981
|
p03645
|
u893209854
| 2,000 | 262,144 |
Wrong Answer
| 2,106 | 36,172 | 341 |
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuke is on Island 1 now, and wants to go to Island N. However, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services. Help him.
|
import sys
N, M = map(int, input().split())
routes = []
for i in range(M):
a, b = map(int, input().split())
routes.append([a, b])
m = []
for r in routes:
if r[0] == 1:
m.append(r[1])
print(m)
for r in routes:
if r[0] in m:
if r[1] == N:
print('Possible')
sys.exit()
print('Impossible')
|
s429333417
|
Accepted
| 606 | 18,936 | 280 |
import sys
N, M = map(int, input().split())
m = set()
m2 = set()
for i in range(M):
a, b = map(int, input().split())
if a == 1:
m.add(b)
if b == N:
m2.add(a)
for me in m:
if me in m2:
print('POSSIBLE')
sys.exit()
print('IMPOSSIBLE')
|
s721857156
|
p03380
|
u897328029
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 14,440 | 475 |
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.
|
#!/usr/bin/env python3
import math
n = int(input().split()[0])
a_list = list(map(int, input().split()))
def C(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
a_list = sorted(a_list)
max_comb = -float("inf")
for i, ai in enumerate(a_list):
for j, aj in enumerate(a_list[:i]):
comb = C(ai, aj)
if max_comb < comb:
max_comb = comb
comb_set = (ai, aj)
ans = "{} {}".format(ai, aj)
print(ans)
|
s452461346
|
Accepted
| 242 | 23,100 | 860 |
#!/usr/bin/env python3
import math
import bisect
import numpy as np
n = int(input().split()[0])
a_list = list(map(int, input().split()))
def C(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
a_list = sorted(a_list)
max_comb = -float("inf")
a_list = sorted(a_list, reverse=True)
ai = a_list[0]
w_list = a_list[1:]
w_list = sorted(w_list)
if ai % 2 == 0:
idx = np.abs(np.asarray(w_list) - ai // 2).argmin()
aj = w_list[idx]
else:
t_1 = (ai - 1) // 2
idx_1 = np.abs(np.asarray(w_list) - t_1).argmin()
aj_1 = w_list[idx_1]
t_2 = (ai + 1) // 2
idx_2 = np.abs(np.asarray(w_list) - t_2).argmin()
aj_2 = w_list[idx_2]
if abs(t_1 - aj_1) < abs(t_2 - aj_2):
aj = aj_1
else:
aj = aj_2
ans = "{} {}".format(ai, aj)
print(ans)
|
s645813486
|
p02972
|
u744920373
| 2,000 | 1,048,576 |
Wrong Answer
| 904 | 10,516 | 867 |
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 sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#from collections import defaultdict #d = defaultdict(int) d[key] += value
N = ii()
A = li()
A_f = A[:N//2]
A_l = A[N//2:]
table = [0] * (N//2)
for i in reversed(range(N//2)):
ind = i+1
while(ind < N):
table[i] += A[ind-1]
ind += i+1
table[i] %= 2
table += A_l
ans = ''
print(sum(table))
for i in range(N):
if table[i]%2 == 1:
ans += str(i+1) + ' '
print(ans)
|
s637940693
|
Accepted
| 1,035 | 8,600 | 831 |
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#from collections import defaultdict #d = defaultdict(int) d[key] += value
N = ii()
A = li()
for i in reversed(range(N)):
ind = 2*(i+1)
while(ind-1 < N):
A[i] ^= A[ind-1]
ind += i+1
print(sum(A))
ans = ''
for i in range(N):
if A[i] == 1:
ans += str(i+1) + ' '
if ans != '':
print(ans[:-1])
|
s491670189
|
p03457
|
u915763824
| 2,000 | 262,144 |
Wrong Answer
| 26 | 9,116 | 219 |
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
|
N = int(input())
now_t, now_x, now_y = (0, 0, 0)
for _ in range(N):
t, x, y = list(map(int, input().split()))
if (abs(now_x - x) + abs(now_y - y) - now_t) % 2:
print("No")
break
else:
print("Yes")
|
s884623614
|
Accepted
| 243 | 9,116 | 326 |
N = int(input())
now_t, now_x, now_y = 0, 0, 0
for _ in range(N):
t, x, y = list(map(int, input().split()))
distance = abs(now_x - x) + abs(now_y - y)
has_time = t - now_t
if (distance - has_time) > 0 or (distance - has_time) % 2:
print("No")
break
now_t, now_x, now_y = t, x, y
else:
print("Yes")
|
s280514663
|
p03456
|
u019584841
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 109 |
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
|
a,b=input().split()
n=int(a+b)
for i in range(100):
if n==i**i:
print("Yes")
exit()
print("No")
|
s369887333
|
Accepted
| 18 | 2,940 | 132 |
a,b=input().split()
n=int(a+b)
for i in range(1000):
if n==i**2:
print("Yes")
break
if n<i**2:
print("No")
break
|
s653289220
|
p03635
|
u863370423
| 2,000 | 262,144 |
Wrong Answer
| 26 | 9,036 | 57 |
In _K-city_ , there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?
|
def blocks(n,m):
n=int(n)
m=int(m)
print(n*m)
|
s693572886
|
Accepted
| 27 | 9,096 | 57 |
a, b = map(int, input().split(" "))
print((a-1) * (b-1))
|
s828648464
|
p03588
|
u150491838
| 2,000 | 262,144 |
Wrong Answer
| 370 | 22,624 | 218 |
A group of people played a game. All players had distinct scores, which are positive integers. Takahashi knows N facts on the players' scores. The i-th fact is as follows: the A_i-th highest score among the players is B_i. Find the maximum possible number of players in the game.
|
N = int(input())
people = {}
for i in range(N):
ai, bi = map(int, input().split())
people[ai] = bi
max_key = max([(k,v) for k,v in people.items()])[0]
min_value = people[max_key]
count = N + min_value
print(count)
|
s405304990
|
Accepted
| 362 | 22,624 | 305 |
N = int(input())
people = {}
for i in range(N):
ai, bi = map(int, input().split())
people[ai] = bi
max_key = max([(k,v) for k,v in people.items()])[0]
min_key = max([(k,v) for k,v in people.items()])[0]
range_key = max_key - min_key + 1
count = people[max_key] + min_key -1 + range_key
print(count)
|
s902629438
|
p03695
|
u075303794
| 2,000 | 262,144 |
Wrong Answer
| 26 | 9,120 | 408 |
In AtCoder, a person who has participated in a contest receives a _color_ , which corresponds to the person's rating as follows: * Rating 1-399 : gray * Rating 400-799 : brown * Rating 800-1199 : green * Rating 1200-1599 : cyan * Rating 1600-1999 : blue * Rating 2000-2399 : yellow * Rating 2400-2799 : orange * Rating 2800-3199 : red Other than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not. Currently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i. Find the minimum and maximum possible numbers of different colors of the users.
|
N=int(input())
A=list(map(int,input().split()))
color=set()
over_3200=0
for i in range(N):
if A[i]<=399:
color.add(1)
elif A[i]<=799:
color.add(2)
elif A[i]<=1199:
color.add(3)
elif A[i]<=1599:
color.add(4)
elif A[i]<=2399:
color.add(5)
elif A[i]<=2799:
color.add(5)
elif A[i]<=3199:
color.add(6)
else:
over_3200+=1
print(len(color),len(color)+over_3200)
|
s582895647
|
Accepted
| 27 | 9,092 | 488 |
N=int(input())
A=list(map(int,input().split()))
color=set()
over_3200=0
for i in range(N):
if A[i]<=399:
color.add(1)
elif A[i]<=799:
color.add(2)
elif A[i]<=1199:
color.add(3)
elif A[i]<=1599:
color.add(4)
elif A[i]<=1999:
color.add(5)
elif A[i]<=2399:
color.add(6)
elif A[i]<=2799:
color.add(7)
elif A[i]<=3199:
color.add(8)
else:
over_3200+=1
if len(color)==0:
print(1,over_3200)
else:
print(len(color),len(color)+over_3200)
|
s878295966
|
p03472
|
u797740860
| 2,000 | 262,144 |
Wrong Answer
| 583 | 36,140 | 410 |
You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, …, Katana N, and can perform the following two kinds of attacks in any order: * Wield one of the katana you have. When you wield Katana i (1 ≤ i ≤ N), the monster receives a_i points of damage. The same katana can be wielded any number of times. * Throw one of the katana you have. When you throw Katana i (1 ≤ i ≤ N) at the monster, it receives b_i points of damage, and you lose the katana. That is, you can no longer wield or throw that katana. The monster will vanish when the total damage it has received is H points or more. At least how many attacks do you need in order to vanish it in total?
|
import math
n, h = [int(i) for i in input().split(" ")]
t = []
for i in range(0, n):
a, b = [int(i) for i in input().split(" ")]
t.append((a, "a"))
t.append((b, "b"))
t = sorted(t, key=lambda k: k[0], reverse=True)
print(t)
c = 0
i = 0
while h > 0:
if t[i][1] == "b":
h -= t[i][0]
c += 1
i += 1
else:
c += math.ceil(h / t[i][0])
h = 0
print(c)
|
s187964970
|
Accepted
| 504 | 28,292 | 400 |
import math
n, h = [int(i) for i in input().split(" ")]
t = []
for i in range(0, n):
a, b = [int(i) for i in input().split(" ")]
t.append((a, "a"))
t.append((b, "b"))
t = sorted(t, key=lambda k: k[0], reverse=True)
c = 0
i = 0
while h > 0:
if t[i][1] == "b":
h -= t[i][0]
c += 1
i += 1
else:
c += math.ceil(h / t[i][0])
h = 0
print(c)
|
s887046646
|
p03997
|
u243699903
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 61 |
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a=int(input())
b=int(input())
h=int(input())
print((a+b)*h/2)
|
s377275609
|
Accepted
| 17 | 2,940 | 66 |
a=int(input())
b=int(input())
h=int(input())
print(int((a+b)*h/2))
|
s452124515
|
p00014
|
u847467233
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,600 | 136 |
Write a program which computes the area of a shape represented by the following three lines: $y = x^2$ $y = 0$ $x = 600$ It is clear that the area is $72000000$, if you use an integral you learn in high school. On the other hand, we can obtain an approximative area of the shape by adding up areas of many rectangles in the shape as shown in the following figure: $f(x) = x^2$ The approximative area $s$ where the width of the rectangles is $d$ is: area of rectangle where its width is $d$ and height is $f(d)$ $+$ area of rectangle where its width is $d$ and height is $f(2d)$ $+$ area of rectangle where its width is $d$ and height is $f(3d)$ $+$ ... area of rectangle where its width is $d$ and height is $f(600 - d)$ The more we decrease $d$, the higer-precision value which is close to $72000000$ we could obtain. Your program should read the integer $d$ which is a divisor of $600$, and print the area $s$.
|
# AOJ 0014 Integral
# Python3 2018.6.10 bal4u
import sys
for d in sys.stdin:
print(sum(x**2 for x in range(int(d), 600, int(d))))
|
s694763452
|
Accepted
| 20 | 5,604 | 145 |
# AOJ 0014 Integral
# Python3 2018.6.10 bal4u
import sys
for d in sys.stdin:
a = int(d)
print(sum(a * x**2 for x in range(a, 600, a)))
|
s309697144
|
p02393
|
u677096240
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,576 | 48 |
Write a program which reads three integers, and prints them in ascending order.
|
print(sorted(list(map(int, input().split()))))
|
s776413416
|
Accepted
| 20 | 5,588 | 80 |
s = list(map(str, sorted(list(map(int, input().split())))))
print(' '.join(s))
|
s035467945
|
p03997
|
u264265458
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 60 |
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()) for i in range(3)]
print((a[0]+a[1])*a[2]/2)
|
s407954982
|
Accepted
| 18 | 2,940 | 65 |
a=[int(input()) for i in range(3)]
print(int((a[0]+a[1])*a[2]/2))
|
s979329033
|
p03829
|
u950708010
| 2,000 | 262,144 |
Wrong Answer
| 176 | 14,228 | 226 |
There are N towns on a line running east-west. The towns are numbered 1 through N, in order from west to east. Each point on the line has a one- dimensional coordinate, and a point that is farther east has a greater coordinate value. The coordinate of town i is X_i. You are now at town 1, and you want to visit all the other towns. You have two ways to travel: * Walk on the line. Your _fatigue level_ increases by A each time you travel a distance of 1, regardless of direction. * Teleport to any location of your choice. Your fatigue level increases by B, regardless of the distance covered. Find the minimum possible total increase of your fatigue level when you visit all the towns in these two ways.
|
n,a,b = (int(i) for i in input().split())
x = list(int(i) for i in input().split())
ans = 0
for i in range(n-1):
dist = x[i+1]-x[i]
move = dist*a
print(move)
if move <= b:
ans += move
else:
ans += b
print(ans)
|
s426106560
|
Accepted
| 93 | 14,224 | 220 |
n,a,b = (int(i) for i in input().split())
x = list(int(i) for i in input().split())
ans = 0
for i in range(n-1):
dist = x[i+1]-x[i]
move = dist*a
if move <= b:
ans += move
else:
ans += b
print(ans)
|
s343995064
|
p03751
|
u535125086
| 1,000 | 262,144 |
Wrong Answer
| 47 | 4,980 | 444 |
Mr.X, who the handle name is T, looked at the list which written N handle names, S_1, S_2, ..., S_N. But he couldn't see some parts of the list. Invisible part is denoted `?`. Please calculate all possible index of the handle name of Mr.X when you sort N+1 handle names (S_1, S_2, ..., S_N and T) in lexicographical order. Note: If there are pair of people with same handle name, either one may come first.
|
n = int(input())
s_list = list()
for i in range(n):
s_list.append(input())
t = input()
s_list_a = [s.replace("?","a") for s in s_list]
s_list_a.append(t)
s_list_a.sort()
index_a = [i+1 for i,x in enumerate(s_list_a) if x == t]
s_list_z = [s.replace("?","z") for s in s_list]
s_list_z.append(t)
s_list_z.sort()
index_z = [i+1 for i,x in enumerate(s_list_z) if x == t]
indexes = [i for i in range(index_z[0],index_a[-1]+1)]
print(indexes)
|
s597162044
|
Accepted
| 44 | 5,108 | 476 |
n = int(input())
s_list = list()
for i in range(n):
s_list.append(input())
t = input()
s_list_a = [s.replace("?","a") for s in s_list]
s_list_a.append(t)
s_list_a.sort()
index_a = [i+1 for i,x in enumerate(s_list_a) if x == t]
s_list_z = [s.replace("?","z") for s in s_list]
s_list_z.append(t)
s_list_z.sort()
index_z = [i+1 for i,x in enumerate(s_list_z) if x == t]
indexes = [str(i) for i in range(index_z[0],index_a[-1]+1)]
answer = ' '.join(indexes)
print(answer)
|
s598025834
|
p03448
|
u625963200
| 2,000 | 262,144 |
Wrong Answer
| 50 | 3,060 | 211 |
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
A=int(input())
B=int(input())
C=int(input())
X=int(input())
total,out=0,0
for a in range(A+1):
for b in range(B+1):
for c in range(C+1):
if a*500+b*100+c*50 == 0:
out+=1
print(out)
|
s353895211
|
Accepted
| 51 | 3,060 | 203 |
A=int(input())
B=int(input())
C=int(input())
X=int(input())
out=0
for a in range(A+1):
for b in range(B+1):
for c in range(C+1):
if a*500+b*100+c*50 == X:
out+=1
print(out)
|
s394974139
|
p03400
|
u591503175
| 2,000 | 262,144 |
Time Limit Exceeded
| 2,206 | 9,104 | 360 |
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces. Find the number of chocolate pieces prepared at the beginning of the camp.
|
def resolve():
'''
code here
'''
N = int(input())
D, X = [int(item) for item in input().split()]
As = [int(input()) for _ in range(N)]
cnt = 0
for i in range(N):
day = 0
j = 0
while day <= D:
day = j * As[i] + 1
cnt +=1
print(cnt)
if __name__ == "__main__":
resolve()
|
s543268933
|
Accepted
| 30 | 9,060 | 341 |
def resolve():
'''
code here
'''
N = int(input())
D, X = [int(item) for item in input().split()]
As = [int(input()) for _ in range(N)]
cnt = 0
for i in range(N):
day = 1
while day <= D:
day +=As[i]
cnt +=1
print(cnt+X)
if __name__ == "__main__":
resolve()
|
s041196970
|
p03160
|
u530804336
| 2,000 | 1,048,576 |
Wrong Answer
| 114 | 13,980 | 228 |
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
|
N = int(input())
arr = list(map(int, input().split()))
dp = [0 for _ in range(N)]
for i in range(1, N):
if i == 1:
dp[i] = abs(arr[i] - arr[i-1])
else:
dp[i] = min(abs(arr[i]-arr[i-1]), abs(arr[i]-arr[i-1]))
print(dp[-1])
|
s706275464
|
Accepted
| 134 | 13,980 | 244 |
N = int(input())
arr = list(map(int, input().split()))
dp = [0 for _ in range(N)]
for i in range(1, N):
if i == 1:
dp[i] = abs(arr[i] - arr[i-1])
else:
dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]))
print(dp[-1])
|
s426295490
|
p03401
|
u903596281
| 2,000 | 262,144 |
Wrong Answer
| 225 | 14,048 | 218 |
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled.
|
N=int(input())
A=[int(x) for x in input().split()]
A=[0]+A
X=sum(abs(A[i]-A[i-1]) for i in range(1,N+1))
for i in range(1,N):
print(X-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]))
print(X-abs(A[N]-A[N-1]))
|
s638006986
|
Accepted
| 224 | 14,048 | 194 |
N=int(input())
A=[0]+[int(x) for x in input().split()]+[0]
X=sum(abs(A[i]-A[i-1]) for i in range(1,N+2))
for i in range(1,N+1):
print(X-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]))
|
s377411259
|
p03353
|
u516272298
| 2,000 | 1,048,576 |
Wrong Answer
| 36 | 5,044 | 144 |
You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. Also, we say that substrings are different when they are different as strings. Let X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \neq y_{j}.
|
s = str(input())
k = int(input())
l = []
for i in range(len(s)):
for j in range(k+1):
l.append(s[i:i+j])
print(sorted(set(l))[k-1])
|
s009585938
|
Accepted
| 37 | 5,068 | 146 |
s = str(input())
k = int(input())
l = []
for i in range(len(s)):
for j in range(1,k+1):
l.append(s[i:i+j])
print(sorted(set(l))[k-1])
|
s597572840
|
p03377
|
u408620326
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 74 |
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 = [int(x) for x in input().split()]
print('YNeos'[A<=X<=A+B-1::2])
|
s988199660
|
Accepted
| 17 | 2,940 | 79 |
A, B, X = [int(x) for x in input().split()]
print('YNEOS'[1-(A<=X<=A+B-1)::2])
|
s398586870
|
p02261
|
u354053070
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,756 | 757 |
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 BubbleSort(C, N):
for i in range(N):
for j in range(N - 1, i, -1):
if int(C[j][1]) < int(C[j - 1][1]):
C[j], C[j - 1] = C[j - 1], C[j]
return C
def SelectionSort(C, N):
for i in range(N):
minj = i
for j in range(i, N):
if int(C[j][1]) < int(C[minj][1]):
minj = j
C[i], C[minj] = C[minj], C[i]
return C
def isStable(B, S, N):
for i in range(N):
if B[i] != S[i]:
return False
return True
N = int(input())
C = input().split()
B = BubbleSort(C, N)
S = SelectionSort(C, N)
mes = "Stable" if isStable(B, S, N) else "Not stable"
print(" ".join(list(map(str, B))))
print("Stable")
print(" ".join(list(map(str, S))))
print(mes)
|
s011537926
|
Accepted
| 60 | 7,844 | 734 |
def BubbleSort(C, N):
for i in range(N):
for j in range(N - 1, i, -1):
if int(C[j][1]) < int(C[j - 1][1]):
C[j], C[j - 1] = C[j - 1], C[j]
return C
def SelectionSort(C, N):
for i in range(N):
minj = i
for j in range(i, N):
if int(C[j][1]) < int(C[minj][1]):
minj = j
C[i], C[minj] = C[minj], C[i]
return C
def isStable(B, S, N):
for i in range(N):
if B[i] != S[i]:
return False
return True
N = int(input())
B = input().split()
S = B[:]
B = BubbleSort(B, N)
S = SelectionSort(S, N)
mes = "Stable" if isStable(B, S, N) else "Not stable"
print(" ".join(B))
print("Stable")
print(" ".join(S))
print(mes)
|
s769711816
|
p03229
|
u987164499
| 2,000 | 1,048,576 |
Wrong Answer
| 153 | 9,044 | 361 |
You are given N integers; the i-th of them is A_i. Find the maximum possible sum of the absolute differences between the adjacent elements after arranging these integers in a row in any order you like.
|
from sys import stdin
n = int(stdin.readline().rstrip())
li = [int(stdin.readline().rstrip()) for _ in range(n)]
li.sort()
lis = li[:n//2]
lin = li[n//2:][::-1]
liv = []
if n%2 == 1:
liv.append(lin[0])
lin = lin[1:]
for i,j in zip(li,lin):
liv.append(i)
liv.append(j)
point = 0
for i in range(n-1):
point += abs(liv[i+1]-liv[i])
print(point)
|
s763556383
|
Accepted
| 112 | 8,148 | 513 |
from sys import stdin
n = int(stdin.readline().rstrip())
li = [int(stdin.readline().rstrip()) for _ in range(n)]
li.sort()
if n%2 == 1:
mid = li[n//2]
mae = li[:n//2]
ushiro = li[n//2+1:]
sono1 = -mid - mae[-1]
sono1 += sum(ushiro)*2-sum(mae[:-1])*2
sono2 = mid + ushiro[0]
sono2 += sum(ushiro[1:])*2-sum(mae)*2
print(max(sono1,sono2))
else:
mae = li[:n//2]
ushiro = li[n//2:]
sono3 = -mae[-1] + ushiro[0]
sono3 += sum(ushiro[1:])*2-sum(mae[:-1])*2
print(sono3)
|
s208754002
|
p02410
|
u546968095
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,600 | 346 |
Write a program which reads a $ n \times m$ matrix $A$ and a $m \times 1$ vector $b$, and prints their product $Ab$. A column vector with m elements is represented by the following equation. \\[ b = \left( \begin{array}{c} b_1 \\\ b_2 \\\ : \\\ b_m \\\ \end{array} \right) \\] A $n \times m$ matrix with $m$ column vectors, each of which consists of $n$ elements, is represented by the following equation. \\[ A = \left( \begin{array}{cccc} a_{11} & a_{12} & ... & a_{1m} \\\ a_{21} & a_{22} & ... & a_{2m} \\\ : & : & : & : \\\ a_{n1} & a_{n2} & ... & a_{nm} \\\ \end{array} \right) \\] $i$-th element of a $m \times 1$ column vector $b$ is represented by $b_i$ ($i = 1, 2, ..., m$), and the element in $i$-th row and $j$-th column of a matrix $A$ is represented by $a_{ij}$ ($i = 1, 2, ..., n,$ $j = 1, 2, ..., m$). The product of a $n \times m$ matrix $A$ and a $m \times 1$ column vector $b$ is a $n \times 1$ column vector $c$, and $c_i$ is obtained by the following formula: \\[ c_i = \sum_{j=1}^m a_{ij}b_j = a_{i1}b_1 + a_{i2}b_2 + ... + a_{im}b_m \\]
|
n,m = [int(i) for i in input().split()]
print(n,m)
A = [[0 for i in range(m)] for j in range(n)]
#B = [[0 for i in range(1)] for j in range(m)]
B = [0 for i in range(m)]
C = [[0 for i in range(1)] for j in range(n)]
print(A)
print(B)
print(C)
A = [[i for i in input().split()] for j in range(n)]
B = [input() for i in range(m)]
print(A)
print(B)
|
s986033220
|
Accepted
| 20 | 6,012 | 228 |
n,m = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for j in range(n)]
B = [int(input()) for i in range(m)]
for i in range(n):
c = 0
for j in range(m):
c += A[i][j]*B[j]
print(c)
|
s864956541
|
p02409
|
u625806423
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,620 | 456 |
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left. Assume that initially no person lives in the building.
|
room = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for i in range(n):
b,f,r,v = map(int,input().split())
room[b-1][f-1][r-1] += v
sep = "#"*20
for i in range(4):
for j in range(3):
print(" {0} {1} {2} {3} {4} {5} {6} {7} {8} {9}".format(room[i][j][0],room[i][j][1],room[i][j][2],room[i][j][3],room[i][j][4],room[i][j][5],room[i][j][6],room[i][j][7],room[i][j][8],room[i][j][9]))
if j != 3:
print(sep)
|
s769506095
|
Accepted
| 20 | 5,620 | 455 |
room = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for i in range(n):
b,f,r,v = map(int,input().split())
room[b-1][f-1][r-1] += v
sep = "#"*20
for i in range(4):
for j in range(3):
print(" {0} {1} {2} {3} {4} {5} {6} {7} {8} {9}".format(room[i][j][0],room[i][j][1],room[i][j][2],room[i][j][3],room[i][j][4],room[i][j][5],room[i][j][6],room[i][j][7],room[i][j][8],room[i][j][9]))
if i < 3:
print(sep)
|
s169197334
|
p03548
|
u598229387
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 71 |
We have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters. We would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two people, and between the end of the seat and a person. At most how many people can sit on the seat?
|
x,y,z = map(int, input().split())
x = x-2*z
ans = x // (y+z)
print(ans)
|
s480592809
|
Accepted
| 20 | 3,060 | 69 |
x,y,z = map(int, input().split())
x = x-z
ans = x // (y+z)
print(ans)
|
s480562460
|
p03814
|
u853900545
| 2,000 | 262,144 |
Wrong Answer
| 40 | 3,816 | 143 |
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 = 0
z = -1
while 1:
if s[a] == 'A':
break
a+=1
while 1:
if s[z] =='Z':
break
z-=1
print(s[a:z+1])
|
s984055761
|
Accepted
| 40 | 3,516 | 147 |
s = input()
a = 0
z = -1
while 1:
if s[a] == 'A':
break
a+=1
while 1:
if s[z] =='Z':
break
z-=1
print(len(s)-a+z+1)
|
s852569488
|
p03814
|
u934119021
| 2,000 | 262,144 |
Wrong Answer
| 69 | 3,516 | 231 |
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()
start = 0
for i in range(len(s)):
if s[i] == 'A' and start == 0:
start = i
print(start)
stop = 0
for i in range(len(s), start, -1):
if s[i -1] == 'Z' and stop == 0:
stop = i
print(stop)
print(stop - start)
|
s565920582
|
Accepted
| 36 | 3,516 | 200 |
s = input()
start = 0
stop = 0
for i in range(len(s)):
if s[i] == 'A':
start = i
break
for i in range(len(s) -1, start, -1):
if s[i] == 'Z':
stop = i
break
print(stop - start + 1)
|
s656859277
|
p03545
|
u721425712
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 634 |
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
|
a, b, c, d = map(int, input())
l = [a+b+c+d, a+b+c-d, a+b-c+d, a+b-c-d, a-b+c+d, a-b+c-d, a-b-c+d, a-b-c-d]
if l.index(7) == 0:
print(a, '+', b, '+', c, '+', d, '= 7')
elif l.index(7) == 1:
print(a, '+', b, '+', c, '-', d, '= 7')
elif l.index(7) == 2:
print(a, '+', b, '-', c, '+', d, '= 7')
elif l.index(7) == 3:
print(a, '+', b, '-', c, '-', d, '= 7')
elif l.index(7) == 4:
print(a, '-', b, '+', c, '+', d, '= 7')
elif l.index(7) == 5:
print(a, '-', b, '+', c, '-', d, '= 7')
elif l.index(7) == 6:
print(a, '-', b, '-', c, '+', d, '= 7')
elif l.index(7) == 7:
print(a, '-', b, '-', c, '-', d, '= 7')
|
s734572202
|
Accepted
| 17 | 3,064 | 348 |
# C
# 2020/04/21 16:18-16:27
l = list(map(str, input()))
n = len(l)
for i in range(2**(n-1)):
op = ['+']*(n-1)
for j in range(n):
if i >> j & 1:
op[j] = '-'
if eval(l[0] + op[0] + l[1] + op[1] + l[2] + op[2] + l[3]) == 7:
print(l[0] + op[0] + l[1] + op[1] + l[2] + op[2] + l[3], '=7', sep='')
break
|
s473503595
|
p02613
|
u321950203
| 2,000 | 1,048,576 |
Wrong Answer
| 147 | 9,212 | 277 |
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
string = input()
if string == 'AC':
ac += 1
elif string == 'WA':
wa += 1
elif string == 'TLE':
tle += 1
else:
re += 1
print('AC X',ac)
print('WA X',ac)
print('TLE X',ac)
print('RE X',ac)
|
s144765240
|
Accepted
| 144 | 9,108 | 278 |
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
string = input()
if string == 'AC':
ac += 1
elif string == 'WA':
wa += 1
elif string == 'TLE':
tle += 1
else:
re += 1
print('AC x',ac)
print('WA x',wa)
print('TLE x',tle)
print('RE x',re)
|
s126516806
|
p03813
|
u123745130
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 39 |
Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise. You are given Smeke's current rating, x. Print `ABC` if Smeke will participate in ABC, and print `ARC` otherwise.
|
print(["ARC","ABC"][1200<int(input())])
|
s061226820
|
Accepted
| 17 | 2,940 | 39 |
print(["ARC","ABC"][1200>int(input())])
|
s596851773
|
p03997
|
u059262067
| 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())
c = int(input())
print((a+b)*c/2)
|
s593594414
|
Accepted
| 17 | 2,940 | 76 |
a = int(input())
b = int(input())
c = int(input())
print(int((a+b)*c/2))
|
s691195423
|
p03457
|
u898058223
| 2,000 | 262,144 |
Wrong Answer
| 491 | 17,320 | 437 |
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
|
N=int(input())
S=[(0,0,0)]
for i in range(N):
t,x,y=map(int,input().split())
S.append((t,x,y))
flag=0
for i in range(N):
if abs(S[i+1][1]-S[i][1])+abs(S[i+1][2]-S[i][2])>S[i+1][0]-S[i][0]:
flag=1
break
elif (S[i+1][0]-S[i][0])%2==1 and (abs(S[i+1][1]-S[i][1])+abs(S[i+1][2]-S[i][2]))%2==0:
flag=1
break
elif (S[i+1][0]-S[i][0])%2==0 and (abs(S[i+1][1]-S[i][1])+abs(S[i+1][2]-S[i][2]))%2==1:
flag=1
break
|
s401555364
|
Accepted
| 481 | 17,332 | 485 |
N=int(input())
S=[(0,0,0)]
for i in range(N):
t,x,y=map(int,input().split())
S.append((t,x,y))
flag=0
for i in range(N):
if abs(S[i+1][1]-S[i][1])+abs(S[i+1][2]-S[i][2])>S[i+1][0]-S[i][0]:
flag=1
break
elif (S[i+1][0]-S[i][0])%2==1 and (abs(S[i+1][1]-S[i][1])+abs(S[i+1][2]-S[i][2]))%2==0:
flag=1
break
elif (S[i+1][0]-S[i][0])%2==0 and (abs(S[i+1][1]-S[i][1])+abs(S[i+1][2]-S[i][2]))%2==1:
flag=1
break
if flag==1:
print("No")
else:
print("Yes")
|
s355490109
|
p02409
|
u042885182
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,712 | 1,563 |
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left. Assume that initially no person lives in the building.
|
# coding: utf-8
# Here your code !
# coding: utf-8
# Here your code !
def func():
try:
line = input()
except:
return inputError()
(buildings,floors,rooms,maxnumber)=(4,3,10,9)
tenants=[ [ [0 for i in range(rooms)] for j in range(floors)] for k in range(buildings)]
while(True):
try:
line=input().rstrip()
info=line.split(" ")
(building, floor, room, number)=( int(info[0])-1, int(info[1])-1, int(info[2])-1, int(info[3]) )
except EOFError:
break
except:
return inputError()
if( (building >= 0) and (building < buildings) ):
if( (floor >= 0) and (floor < floors) ):
if( (room >= 0) and (room < rooms) ):
if( (tenants[building][floor][room]+number > 0) and (tenants[building][floor][room]+number < maxnumber+1) ):
tenants[building][floor][room] += number
else:
return inputError()
else:
return inputError()
else:
return inputError()
else:
return inputError()
result=""
for i in range(buildings):
for j in range(floors):
for k in range(rooms):
result += " {0}".format(tenants[i][j][k])
result += "\n"
result+="#"*rooms*2+"\n"
print(result.rstrip())
def inputError():
print("input error")
return -1
func()
|
s488266468
|
Accepted
| 20 | 7,800 | 1,597 |
# coding: utf-8
# Here your code !
# coding: utf-8
# Here your code !
def func():
try:
line = input()
except:
return inputError()
(buildings,floors,rooms,maxnumber)=(4,3,10,9)
tenants=[ [ [0 for i in range(rooms)] for j in range(floors)] for k in range(buildings)]
while(True):
try:
line=input().rstrip()
info=line.split(" ")
(building, floor, room, number)=( int(info[0])-1, int(info[1])-1, int(info[2])-1, int(info[3]) )
except EOFError:
break
except:
return inputError()
if( (building >= 0) and (building < buildings) ):
if( (floor >= 0) and (floor < floors) ):
if( (room >= 0) and (room < rooms) ):
if( (tenants[building][floor][room]+number >= 0) and (tenants[building][floor][room]+number < maxnumber+1) ):
tenants[building][floor][room] += number
else:
return inputError()
else:
return inputError()
else:
return inputError()
else:
return inputError()
result=""
for i in range(buildings):
for j in range(floors):
for k in range(rooms):
result += " {0}".format(tenants[i][j][k])
result += "\n"
if(i+1 < buildings):
result+="#"*rooms*2+"\n"
print(result.rstrip())
def inputError():
print("input error")
return -1
func()
|
s052059156
|
p03623
|
u077019541
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 62 |
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())
print(min(abs(x-a),abs(x-b)))
|
s064968592
|
Accepted
| 17 | 2,940 | 90 |
x,a,b = map(int,input().split())
if abs(x-a)<abs(x-b):
print("A")
else:
print("B")
|
s773218222
|
p02264
|
u404682284
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,600 | 548 |
_n_ _q_ _name 1 time1_ _name 2 time2_ ... _name n timen_ In the first line the number of processes _n_ and the quantum _q_ are given separated by a single space. In the following _n_ lines, names and times for the _n_ processes are given. _name i_ and _time i_ are separated by a single space.
|
n, q = [int(i) for i in input().split()]
que = []
ans_count = 0
time = 0
for i in range(n):
que.append([i for i in input().split()])
while(ans_count!=n):
pop_process = que.pop(0)
pop_process[1] = int(pop_process[1])
if pop_process[1] < q:
time += pop_process[1]
print('{0} {1}'.format(pop_process[0], time))
ans_count += 1
else:
time += q
pop_process[1] -= q
que.append(pop_process)
|
s739245202
|
Accepted
| 850 | 13,788 | 549 |
n, q = [int(i) for i in input().split()]
que = []
ans_count = 0
time = 0
for i in range(n):
que.append([i for i in input().split()])
while(ans_count!=n):
pop_process = que.pop(0)
pop_process[1] = int(pop_process[1])
if pop_process[1] <= q:
time += pop_process[1]
print('{0} {1}'.format(pop_process[0], time))
ans_count += 1
else:
time += q
pop_process[1] -= q
que.append(pop_process)
|
s331066351
|
p03494
|
u943386568
| 2,000 | 262,144 |
Wrong Answer
| 28 | 9,000 | 141 |
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())
A = list(map(int, input().split()))
c=0
for i in range(N):
if A[i]%2 == 1:
break
else:
c+=1
print(c)
|
s957285162
|
Accepted
| 27 | 9,180 | 274 |
N = int(input())
A = list(map(int, input().split()))
c=0
odd_exist = True
for j in range(200):
for i in range(N):
if A[i]%2 == 0:
A[i] = int(A[i]/2)
else:
odd_exist = False
break
if odd_exist:
c+=1
print(c)
|
s087558177
|
p02612
|
u921617614
| 2,000 | 1,048,576 |
Wrong Answer
| 33 | 9,136 | 32 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n=int(input())
a=n%1000
print(a)
|
s269507244
|
Accepted
| 27 | 9,092 | 57 |
n=int(input())
ans = (n+999)//1000 * 1000 - n
print(ans)
|
s329441409
|
p03339
|
u698479721
| 2,000 | 1,048,576 |
Wrong Answer
| 255 | 22,800 | 204 |
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()
s1 = S[1:]
b = []
b.append(s1.count('E'))
j = 1
while j < N:
b.append(0)
b[j] = b[j-1]
if S[j] == 'E':
b[j] += -1
if S[j-1] == 'W':
b[j] += 1
j += 1
print(b)
|
s336981652
|
Accepted
| 238 | 15,820 | 209 |
N = int(input())
S = input()
s1 = S[1:]
b = []
b.append(s1.count('E'))
j = 1
while j < N:
b.append(0)
b[j] = b[j-1]
if S[j] == 'E':
b[j] += -1
if S[j-1] == 'W':
b[j] += 1
j += 1
print(min(b))
|
s330235694
|
p02389
|
u867908153
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,548 | 97 |
Write a program which calculates the area and perimeter of a given rectangle.
|
nums = input().split(' ')
h1 = int(nums[0])
h2 = int(nums[1])
print( h1*h2 ),
print( 2*(h1+h2) )
|
s766873713
|
Accepted
| 30 | 7,620 | 88 |
nums = input().split(' ')
h1 = int(nums[0])
h2 = int(nums[1])
print( h1*h2, 2*(h1+h2) )
|
s884540045
|
p03386
|
u269969976
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,316 | 189 |
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
|
# -*- coding: utf-8 -*-
(a, b, k) = [int(i) for i in input().rstrip().split(" ")]
for i in [i for i in range(a, min(a+k, b+1))] or [i for i in range(max(b-k + 1, a), b + 1)]:
print(i)
|
s111554607
|
Accepted
| 17 | 3,060 | 224 |
# coding: utf-8
(a,b,k) = map(int, input().rstrip().split(" "))
ans = []
for i in range(a, min(b+1,a+k)):
ans.append(i)
for i in range(max(a, b-k+1), b+1):
ans.append(i)
for i in sorted(set(ans)):
print(i)
|
s922930438
|
p03814
|
u790012205
| 2,000 | 262,144 |
Wrong Answer
| 44 | 9,256 | 181 |
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()
l = len(s)
for i in range(l):
if s[i] == 'A':
a = i
break
for i in range(l - 1, -1, -1):
if s[i] == 'Z':
z = i
break
print(z - a)
|
s321797405
|
Accepted
| 40 | 9,272 | 185 |
s = input()
l = len(s)
for i in range(l):
if s[i] == 'A':
a = i
break
for i in range(l - 1, -1, -1):
if s[i] == 'Z':
z = i
break
print(z - a + 1)
|
s973702190
|
p02416
|
u996758922
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,536 | 154 |
Write a program which reads an integer and prints sum of its digits.
|
number = input()
number2 = []
for i in range(len(number)):
number2.append(number[i])
number2 = map(int, number2)
answer = sum(number2)
print(answer)
|
s719694385
|
Accepted
| 30 | 7,648 | 264 |
while True:
number = input()
if number == "0":
break
else:
number2 = []
for i in range(len(number)):
number2.append(number[i])
number2 = map(int, number2)
answer = sum(number2)
print(answer)
|
s460635458
|
p03599
|
u871841829
| 3,000 | 262,144 |
Wrong Answer
| 728 | 3,188 | 932 |
Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations. * Operation 1: Pour 100A grams of water into the beaker. * Operation 2: Pour 100B grams of water into the beaker. * Operation 3: Put C grams of sugar into the beaker. * Operation 4: Put D grams of sugar into the beaker. In our experimental environment, E grams of sugar can dissolve into 100 grams of water. Snuke will make sugar water with the highest possible density. The beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker. Find the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it. If there is more than one candidate, any of them will be accepted. We remind you that the sugar water that contains a grams of water and b grams of sugar is \frac{100b}{a + b} percent. Also, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.
|
A, B, C, D, E, F = map(int, input().split())
A *= 100
B *= 100
max_solvent = 0
max_solute = 0
max_strength = 0.0
for na in range(0, 31):
for nb in range(0, 31):
for nc in range(0, 31):
for nd in range(0, 31):
if not (any([na, nb]) and any([nc, nd])):
continue
if na * A + nb * B + nc * C + nd * D > F:
# print("exceeded")
continue
if (na * A + nb * B)/100 * E < nc * C + nd * D:
# print("exceeded2")
continue
strength = float(nc * C + nd * D) / (na * A + na * B + nc * C + nd * D)
# print(strength)
if max_strength < strength:
max_strength = strength
max_solvent = na * A + nb * B
max_solute = nc * C + nd * D
print(max_solvent, " ", max_solute)
|
s307352524
|
Accepted
| 337 | 3,064 | 1,169 |
A, B, C, D, E, F = map(int, input().split())
# A *= 100
# B *= 100
max_solvent = 0
max_solute = 0
max_strength = 0.0
for na in range(0, 31):
for nb in range(0, 31):
for nc in range(0, 101):
for nd in range(0, 101):
solute = nc * C + nd * D
solvent = 100 * na * A + 100 * nb * B
# if not (any([na, nb]) and any([nc, nd])):
# continue
if solvent == 0:
break
if solute + solvent > F:
# print("exceeded")
break
else:
# if (solvent/100) * E < solute:
if solvent/100 * E >= solute:
# print("exceeded2")
# break
strength = 100 * solute / (solute + solvent)
# print(strength, solvent+solute, solute)
if max_strength <= strength:
max_strength = strength
max_solute = solute
max_solvent = solute + solvent
print(max_solvent, max_solute)
|
s731589179
|
p03644
|
u256734681
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 130 |
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
|
N = int(input())
target = 1
for i in range(1, N+1):
print('i=', i)
if 2 ** i <= N:
target = 2 ** i
print(target)
|
s226698600
|
Accepted
| 17 | 2,940 | 111 |
N = int(input())
target = 1
for i in range(1, N+1):
if 2 ** i <= N:
target = 2 ** i
print(target)
|
s379351995
|
p03712
|
u713914478
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 203 |
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
|
H,W = map(int,input().split())
A = [input().split() for i in range(H)]
X = "#"*W
#print(H,W,A)
for i in range(H):
A[i][0] = "#" + A[i][0] +"#"
print(X)
for i in range(H):
print(A[i][0])
print(X)
|
s790261121
|
Accepted
| 17 | 3,060 | 207 |
H,W = map(int,input().split())
A = [input().split() for i in range(H)]
X = "#"*(W+2)
#print(H,W,A)
for i in range(H):
A[i][0] = "#" + A[i][0] +"#"
print(X)
for i in range(H):
print(A[i][0])
print(X)
|
s694655436
|
p04043
|
u930705402
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 78 |
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=''.join(sorted(map(str,input().split())))
print('Yes' if a=='557' else 'No')
|
s271606878
|
Accepted
| 17 | 2,940 | 78 |
a=''.join(sorted(map(str,input().split())))
print('YES' if a=='557' else 'NO')
|
s078139521
|
p03795
|
u411544692
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 54 |
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 = 800*N
y = 200+(N//15)
print(x-y)
|
s131044268
|
Accepted
| 17 | 2,940 | 54 |
N = int(input())
x = 800*N
y = 200*(N//15)
print(x-y)
|
s164541782
|
p02600
|
u084411645
| 2,000 | 1,048,576 |
Wrong Answer
| 28 | 9,116 | 28 |
M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a _kyu_ (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have?
|
print(9 - int(input())//200)
|
s751018272
|
Accepted
| 32 | 9,120 | 30 |
print(10 - int(input())//200)
|
s846739326
|
p03997
|
u370429695
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 73 |
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) / 2 * h)
|
s056944113
|
Accepted
| 17 | 2,940 | 78 |
a = int(input())
b = int(input())
h = int(input())
print(int((a + b) / 2 * h))
|
s837204759
|
p03478
|
u107798522
| 2,000 | 262,144 |
Wrong Answer
| 45 | 3,628 | 263 |
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())
sumn = 0
sumans = 0
for n in range(1,N+1):
Ns = str(n)
sumn = 0
for i in range(len(Ns)):
sumn = sumn + int(Ns[i])
if A <= sumn and sumn <= B:
sumans = sumans + n
print(sumn)
print(sumans)
|
s538993921
|
Accepted
| 39 | 3,060 | 265 |
#B - Some Sums
#30min
N, A, B = map(int, input().split())
sumn = 0
sumans = 0
for n in range(1,N+1):
Ns = str(n)
sumn = 0
for i in range(len(Ns)):
sumn = sumn + int(Ns[i])
if A <= sumn and sumn <= B:
sumans = sumans + n
print(sumans)
|
s696790961
|
p03377
|
u497952650
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 93 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
A,B,X = map(int,input().split())
if X <= A+B and A<=X:
print("Yes")
else:
print("No")
|
s871581751
|
Accepted
| 18 | 2,940 | 93 |
A,B,X = map(int,input().split())
if X <= A+B and A<=X:
print("YES")
else:
print("NO")
|
s081786934
|
p03657
|
u825343780
| 2,000 | 262,144 |
Wrong Answer
| 27 | 9,160 | 110 |
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.
|
a, b = map(int, input().split())
print("possible" if a % 3 == 0 or b % 3 == 0 or a+b%3 == 0 else "Impossible")
|
s643389506
|
Accepted
| 24 | 9,112 | 112 |
a, b = map(int, input().split())
print("Possible" if a % 3 == 0 or b % 3 == 0 or (a+b)%3 == 0 else "Impossible")
|
s375474407
|
p03377
|
u467307100
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 94 |
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, c =map(int, input().split())
if a + b > c and a < c:
print("Yes")
else:
print("No")
|
s063360418
|
Accepted
| 19 | 2,940 | 96 |
a, b, c =map(int, input().split())
if a + b >= c and a <= c:
print("YES")
else:
print("NO")
|
s879674649
|
p03997
|
u652057333
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 74 |
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a = int(input())
b = int(input())
h = int(input())
print((a + b) * h / 2)
|
s849717186
|
Accepted
| 20 | 2,940 | 79 |
a = int(input())
b = int(input())
h = int(input())
print(int((a + b) * h / 2))
|
s292265382
|
p02615
|
u488884575
| 2,000 | 1,048,576 |
Wrong Answer
| 173 | 31,432 | 212 |
Quickly after finishing the tutorial of the online game _ATChat_ , you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the **friendliness** of Player i is A_i. The N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere. When each player, except the first one to arrive, arrives at the place, the player gets **comfort** equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0. What is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?
|
n = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
print(A)
conf = min(A[::2])
ans = 0
for i in range(n):
if i==0:
continue
elif i==1:
ans+=A[i-1]
else:
ans+=conf
print(ans)
|
s739086439
|
Accepted
| 119 | 31,428 | 353 |
n = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
if n%2==0:
print(sum(A[:n//2]) *2 -A[0])
else:
print(sum(A[:n//2]) *2 -A[0] +A[n//2])
|
s107777124
|
p03963
|
u494927057
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 63 |
There are N balls placed in a row. AtCoDeer the deer is painting each of these in one of the K colors of his paint cans. For aesthetic reasons, any two adjacent balls must be painted in different colors. Find the number of the possible ways to paint the balls.
|
N, K = map(int, input().split())
print(K * (K - 1) ^ (N - 1))
|
s152338935
|
Accepted
| 17 | 2,940 | 65 |
N, K = map(int, input().split())
print(K * pow((K - 1), N - 1))
|
s486795091
|
p03160
|
u840310460
| 2,000 | 1,048,576 |
Wrong Answer
| 141 | 13,928 | 175 |
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
|
N = int(input())
H = [int(i) for i in input().split()]
dp = [0]*N
for i in range(2, N):
dp[i] = min(dp[i-2] + abs(H[i]-H[i-2]), dp[i-1] + abs(H[i]-H[i-1]))
print(dp[-1])
|
s318642802
|
Accepted
| 129 | 13,928 | 206 |
N = int(input())
H = [int(i) for i in input().split()]
dp = [0] * N
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
dp[i] = min(dp[i-2] + abs(H[i] - H[i-2]), dp[i-1] + abs(H[i] - H[i-1]))
print(dp[-1])
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.