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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s527892710 | p03433 | u601082779 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 56 | E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins. | a=int(input());b=int(input());print("Yneos"[a%500<b::2]) | s414519637 | Accepted | 17 | 2,940 | 56 | a=int(input());b=int(input());print("YNeos"[a%500>b::2]) |
s980977572 | p03494 | u884959062 | 2,000 | 262,144 | Wrong Answer | 20 | 2,940 | 307 | 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. | e = [[int(i) for i in input().split()] for i in range(2)]
max_count = 0
for i in range(e[0][0]):
tmp = e[1][i]
count = 0
while True:
tmp, m = divmod(tmp, 2)
if m == 1:
break
count += 1
if count < max_count:
max_count = count
print(max_count)
| s216774715 | Accepted | 19 | 3,060 | 312 | e = [[int(i) for i in input().split()] for i in range(2)]
max_count = 999999
for i in range(e[0][0]):
tmp = e[1][i]
count = 0
while True:
tmp, m = divmod(tmp, 2)
if m == 1:
break
count += 1
if count < max_count:
max_count = count
print(max_count)
|
s269136561 | p04044 | u577504524 | 2,000 | 262,144 | Wrong Answer | 25 | 9,108 | 164 | 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 sm... | #B
n,l = map(int,input().split())
word_list=[]
for i in range(n):
word = str(input())
word_list.append(word)
x = sorted(word_list)
print(''.join(word_list)) | s812948162 | Accepted | 27 | 9,172 | 156 | #B
n,l = map(int,input().split())
word_list=[]
for i in range(n):
word = str(input())
word_list.append(word)
x = sorted(word_list)
print(''.join(x)) |
s506298878 | p02255 | u843404779 | 1,000 | 131,072 | Wrong Answer | 20 | 7,680 | 457 | Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key ... | def print_list(ele_list):
print(" ".join(map(str, ele_list)))
def insertion_sort(ele_list):
len_ele_list = len(ele_list)
for i in range(1, len_ele_list):
key = ele_list[i]
j = i - 1
while j >= 0 and ele_list[j] > key:
ele_list[j+1] = ele_list[j]
j -= 1
... | s280184181 | Accepted | 20 | 7,672 | 482 | def print_list(ele_list):
print(" ".join(map(str, ele_list)))
def insertion_sort(ele_list):
len_ele_list = len(ele_list)
print_list(ele_list)
for i in range(1, len_ele_list):
key = ele_list[i]
j = i - 1
while j >= 0 and ele_list[j] > key:
ele_list[j+1] = ele_list[j]
... |
s054842854 | p03680 | u936985471 | 2,000 | 262,144 | Wrong Answer | 195 | 8,948 | 163 | Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It ... | n=int(input())
a=[None]*n
for i in range(len(a)):
a[i]=int(input())-1
cur=0
ok=False
for i in range(n+1):
cur=a[cur]
if cur==1:
break
print((-1,i)[ok]) | s268573231 | Accepted | 219 | 7,668 | 240 | n=int(input())
a=[-1]*n
for i in range(n):
a[i]=int(input())-1
reached=[False]*n
tar=0
cnt=0
suc=False
while reached[tar]==False:
reached[tar]=True
cnt+=1
tar=a[tar]
if tar==1:
suc=True
break
print((-1,cnt)[suc])
|
s149297287 | p03160 | u043236471 | 2,000 | 1,048,576 | Wrong Answer | 156 | 13,976 | 309 | 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... | N = int(input())
h = [int(x) for x in input().split()]
def chmin(a, b):
return a if a <= b else b
dp = [float('inf')] * N
dp[0] = 0
for i in range(1, N):
dp[i] = chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
if i > 1:
dp[i] = chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]))
print(dp[1]) | s178854027 | Accepted | 160 | 14,052 | 310 | N = int(input())
h = [int(x) for x in input().split()]
def chmin(a, b):
return a if a <= b else b
dp = [float('inf')] * N
dp[0] = 0
for i in range(1, N):
dp[i] = chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
if i > 1:
dp[i] = chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]))
print(dp[-1]) |
s533837426 | p03455 | u026406748 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 121 | AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. | a = input().split()
b = [int(i) for i in a]
c = b[0] * b[1]
if c%2 == 0:
print("偶数")
else:
print("奇数") | s984083086 | Accepted | 17 | 3,064 | 116 | a = input().split()
b = [int(i) for i in a]
c = b[0] * b[1]
if c%2 == 0:
print("Even")
else:
print("Odd") |
s064156669 | p02865 | u538276565 | 2,000 | 1,048,576 | Wrong Answer | 21 | 3,316 | 82 | How many ways are there to choose two distinct positive integers totaling N, disregarding the order? | def solve():
print(int(input()) // 2)
if __name__ == "__main__":
solve() | s226582364 | Accepted | 17 | 2,940 | 121 | def solve():
i = int(input())
print(i // 2 -1 if i % 2 == 0 else i // 2)
if __name__ == "__main__":
solve() |
s124622292 | p03352 | u020091453 | 2,000 | 1,048,576 | Wrong Answer | 19 | 3,188 | 271 | You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2. | import math
from bisect import bisect_right
X = int(input())
s = list([1])
for i in range(2,math.ceil(1000**0.5)):
for j in range(0,9):
if i**j > 1000:
break
else:
s.append(i**j)
s.sort()
print(s[bisect_right(s,X) -1])
| s470123917 | Accepted | 18 | 3,188 | 268 | import math
from bisect import bisect_right
X = int(input())
s = list([1])
for i in range(2,math.ceil(1000**0.5)):
for j in range(2,9):
if i**j > 1000:
break
else:
s.append(i**j)
s.sort()
print(s[bisect_right(s,X) -1]) |
s276986789 | p03067 | u239528020 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 138 | There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise. | a, b, c = map(int, input().split())
if a >= b:
tmp = a
b = a
a = tmp
if a<=c and c<=b:
print("yes")
else:
print("no") | s481828602 | Accepted | 17 | 2,940 | 148 |
a, b, c = map(int, input().split())
if a >= b:
tmp = b
b = a
a = tmp
if a<=c and c<=b:
print("Yes")
else:
print("No") |
s080263303 | p02383 | u299798926 | 1,000 | 131,072 | Wrong Answer | 20 | 7,812 | 1,016 | Write a program to simulate rolling a dice, which can be constructed by the following net. As shown in the figures, each face is identified by a different label from 1 to 6. Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, ... | x=[int(i)for i in input().split()]
y=[[int(0)for i in range(4)]for i in range(3)]
y[0][1]=x[0]
y[1][1]=x[1]
y[1][2]=x[2]
y[1][0]=x[3]
y[1][3]=x[4]
y[2][1]=x[5]
m=[i for i in input()]
z=y.copy()
for i in range(len(m)):
if m[i]=='N':
y[0][1],z[1][1]=z[1][1],y[0][1]
y[1][1],z[2][1]=z[2][1],y[1][1]
... | s212919276 | Accepted | 10 | 7,944 | 788 | x=[int(i)for i in input().split()]
y=[[int(0)for i in range(4)]for i in range(3)]
y[0][1]=x[0]
y[1][1]=x[1]
y[1][2]=x[2]
y[1][0]=x[3]
y[1][3]=x[4]
y[2][1]=x[5]
m=[i for i in input()]
for i in range(len(m)):
if m[i]=='N':
y[0][1],y[1][1]=y[1][1],y[0][1]
y[1][1],y[2][1]=y[2][1],y[1][1]
y[2][1]... |
s903259883 | p02865 | u269778596 | 2,000 | 1,048,576 | Wrong Answer | 2,104 | 3,932 | 191 | How many ways are there to choose two distinct positive integers totaling N, disregarding the order? | n = int(input())
count = 0
seen = []
for i in range(1,n+1):
if i!=(n-i):
if i and n-i not in seen:
seen.append(i)
seen.append(n-i)
count += 1
print(count)
| s072836244 | Accepted | 17 | 2,940 | 32 | n = int(input())
print((n-1)//2) |
s990840260 | p02284 | u912143677 | 2,000 | 131,072 | Wrong Answer | 20 | 5,608 | 1,529 | Write a program which performs the following operations to a binary search tree $T$ by adding the find operation to A: Binary Search Tree I. * insert $k$: Insert a node containing $k$ as key into $T$. * find $k$: Report whether $T$ has a node containing $k$. * print: Print the keys of the binary search tree by... |
class Tree():
def __init__(self):
self.root = None
def insert(self, key):
z = Node(key)
y = None
x = self.root
while x:
y = x
if z.key < x.key:
x = x.left
else:
x = x.right
z.parent = y
i... | s063320387 | Accepted | 6,900 | 116,656 | 1,619 |
class Tree():
def __init__(self):
self.root = None
def insert(self, key):
z = Node(key)
y = None
x = self.root
while x:
y = x
if z.key < x.key:
x = x.left
else:
x = x.right
z.parent = y
i... |
s953673935 | p02257 | u196653484 | 1,000 | 131,072 | Wrong Answer | 20 | 5,672 | 700 | A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. Write a program which reads a list of _N_ integers and prints the number of prime numbers in the list. |
import math
def check(B,i):
sum=0
for j in range(len(B)):
if B[j]%10 in [1,2,4,5,6,8]:
del B[j]
check(B,i)
if B[j]%i==0:
sum+=1
del B[j]
return sum
def Prime_Numbers(A):
mx=max(A)
sum=0
if 2 in A:
sum+=1
if 3 in A:
... | s057474588 | Accepted | 1,150 | 6,008 | 497 |
import math
def Prime_Numbers_Check(x):
i=2
flag=True
while i <= math.sqrt(x):
if x%i==0:
flag=False
break
i+=1
return flag
def Prime_Numbers_Count(A):
sum=0
for i in A:
if Prime_Numbers_Check(i):
sum+=1
return sum
if __name__ ... |
s852935007 | p03574 | u824734140 | 2,000 | 262,144 | Wrong Answer | 34 | 9,176 | 521 | You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square con... | h, w = map(int, input().split())
s = [list(input()) for _ in range(0, h)]
dx = [1, 0, -1, 0, 1, -1, -1, -1]
dy = [0, 1, 0, -1, 1, 1, -1, -1]
for i in range(0, h):
for j in range(0, w):
if s[i][j] != '.':
continue
cnt = 0
for k in range(0, 8):
ni = i + dy[k]
... | s449846540 | Accepted | 38 | 9,136 | 529 | h, w = map(int, input().split())
s = [list(input()) for _ in range(0, h)]
dx = [1, 1, 1, 0, 0, -1, -1, -1]
dy = [1, 0, -1, 1, -1, 1, 0, -1]
for i in range(0, h):
for j in range(0, w):
if s[i][j] != '.':
continue
cnt = 0
for k in range(0, 8):
ni = i + dy[k]
... |
s293369405 | p03493 | u300651214 | 2,000 | 262,144 | Wrong Answer | 25 | 8,856 | 32 | Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble. | s = list(input())
s.count("1")
| s259842484 | Accepted | 27 | 9,080 | 32 | a = input()
print(a.count('1'))
|
s484834080 | p03759 | u160659351 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 104 | Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful. | #58
a, b, c = map(int, input().rstrip().split())
if b-a == c-a:
print("YES")
else:
print("NO") | s161513461 | Accepted | 17 | 2,940 | 104 | #58
a, b, c = map(int, input().rstrip().split())
if b-a == c-b:
print("YES")
else:
print("NO") |
s975871076 | p02388 | u335511832 | 1,000 | 131,072 | Wrong Answer | 30 | 6,724 | 17 | Write a program which calculates the cube of a given integer x. | x = 3
print(x**3) | s224024076 | Accepted | 30 | 6,724 | 28 | x = int(input())
print(x**3) |
s148622904 | p03543 | u778700306 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 130 | We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**? |
a = list(input())
if a[0] == a[1] and a[1] == a[2] or a[1] == a[2] and a[2] == a[3]:
print("YES")
else:
print("NO")
| s133782016 | Accepted | 18 | 2,940 | 130 |
a = list(input())
if a[0] == a[1] and a[1] == a[2] or a[1] == a[2] and a[2] == a[3]:
print("Yes")
else:
print("No")
|
s913153871 | p03303 | u674185143 | 2,000 | 1,048,576 | Wrong Answer | 18 | 2,940 | 86 | You are given a string S consisting of lowercase English letters. We will write down this string, starting a new line after every w letters. Print the string obtained by concatenating the letters at the beginnings of these lines from top to bottom. | s=input()
w=int(input())
ans=s[0]
for i in range(1,len(s)//w):
ans+=s[i*w]
print(ans) | s692651247 | Accepted | 17 | 2,940 | 39 | s=input()
w=int(input())
print(s[0::w]) |
s582124330 | p04031 | u901307908 | 2,000 | 262,144 | Wrong Answer | 23 | 3,064 | 163 | 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 (... | n = int(input())
a = input()
a = list(map(int, a.split()))
#print(a)
x_min = round(sum(a) / 3 )
cost = sum([(x_min - i) * (x_min - i) for i in a])
print(cost) | s377213309 | Accepted | 24 | 3,188 | 163 | n = int(input())
a = input()
a = list(map(int, a.split()))
#print(a)
x_min = round(sum(a) / n )
cost = sum([(x_min - i) * (x_min - i) for i in a])
print(cost) |
s236310590 | p03436 | u742897895 | 2,000 | 262,144 | Wrong Answer | 32 | 3,700 | 819 | We have an H \times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j). Snuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player re... | from collections import deque
h, w = map(int, input().split())
s = [list(input()) for j in range(h)]
dx = [-1, 1, 0, 0]
dy = [ 0, 0,-1, 1]
q = deque([(0, 0, 0)])
used = {(0, 0)}
res = None
while q:
i, j, cost = q.popleft()
if i == w - 1 and j == h - 1:
res = cost
break
for k in range(4):
... | s812892276 | Accepted | 33 | 3,700 | 785 | from collections import deque
h, w = map(int, input().split())
s = [list(input()) for j in range(h)]
dx = [-1, 1, 0, 0]
dy = [ 0, 0,-1, 1]
q = deque([(0, 0, 0)])
used = {(0, 0)}
res = None
while q:
i, j, cost = q.popleft()
if i == w - 1 and j == h - 1:
res = cost
break
for k in range(4):
... |
s848276033 | p03438 | u692632484 | 2,000 | 262,144 | Wrong Answer | 29 | 4,600 | 345 | You are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N. Determine if we can repeat the following operation zero or more times so that the sequences a and b become equal. Operation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two ac... | N=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
total_do=sum(a)-sum(b)
must_do_a=0
must_do_b=0
for i in range(N):
dist=a[i]-b[i]
if dist<0:
dist=-dist
must_do_a+=int(dist/2)
if dist%2!=0:
must_do_b+=1
elif dist>0:
must_do_b+=dist
if must_do_a>=must_do_b:
print("Y... | s861995510 | Accepted | 28 | 4,600 | 370 | N=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
can = sum(b)-sum(a)
actA,actB = 0,0
for i in range(N):
diff = b[i]-a[i]
if diff==0:continue
if diff>0:
actA+=(diff+1)//2
actB+=diff%2
else:
actB+=(-diff)
leftA = can-actA
leftB = can-actB
prin... |
s695990924 | p03251 | u175204984 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,064 | 606 | Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes incli... | l = input().split()
N = int(l[0])
M = int(l[1])
X = int(l[2])
Y = int(l[3])
if X < -100:
X = -100
elif X > 100:
X = 100
if Y < -100:
Y = -100
elif Y > 100:
Y = 100
lx = input().split()
ly = input().split()
lx = [int(z) for z in lx]
ly = [int(z) for z in ly]
lx = sorted(lx)
ly = sorted(ly)
fla... | s444526876 | Accepted | 17 | 3,064 | 554 | l = input().split()
N = int(l[0])
M = int(l[1])
X = int(l[2])
Y = int(l[3])
"""
if X < -100:
X = -100
elif X > 100:
X = 100
if Y < -100:
Y = -100
elif Y > 100:
Y = 100
"""
lx = input().split()
ly = input().split()
lx = [int(z) for z in lx]
ly = [int(z) for z in ly]
lx = sorted(lx)
ly = sorted(l... |
s550172635 | p03543 | u274045692 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 125 | We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**? | N = input()
if (N[0] == N[1] and N[1] == N[2]) or (N[1] == N[2] and N[2] == N[3]):
print("true")
else:
print("false") | s927355379 | Accepted | 18 | 2,940 | 121 | N = input()
if (N[0] == N[1] and N[1] == N[2]) or (N[1] == N[2] and N[2] == N[3]):
print("Yes")
else:
print("No") |
s834322207 | p03337 | u883792993 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 54 | You are given two integers A and B. Find the largest value among A+B, A-B and A \times B. | A,B=list(map(int, input().split()))
max(A+B, A-B, A*B) | s485367244 | Accepted | 17 | 2,940 | 61 | A,B=list(map(int, input().split()))
print(max(A+B, A-B, A*B)) |
s542836844 | p03379 | u057993957 | 2,000 | 262,144 | Wrong Answer | 287 | 25,620 | 155 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..... | n = int(input())
x = list(map(int, input().split()))
sort_x = sorted(x)
l = sort_x[n//2 - 1]
r = sort_x[n//2]
for xi in x:
print(l if xi <= l else r)
| s683743771 | Accepted | 282 | 25,224 | 155 | n = int(input())
x = list(map(int, input().split()))
sort_x = sorted(x)
l = sort_x[n//2 - 1]
r = sort_x[n//2]
for xi in x:
print(r if xi <= l else l)
|
s125406347 | p03878 | u945181840 | 2,000 | 262,144 | Wrong Answer | 236 | 34,096 | 224 | There are N computers and N sockets in a one-dimensional world. The coordinate of the i-th computer is a_i, and the coordinate of the i-th socket is b_i. It is guaranteed that these 2N coordinates are pairwise distinct. Snuke wants to connect each computer to a socket using a cable. Each socket can be connected to onl... | import sys
import numpy as np
read = sys.stdin.read
N, *ab = map(int, read().split())
mod = 10 ** 9 + 7
a = np.array(ab[:N], np.int64)
b = np.array(ab[N:], np.int64)
a.sort()
b.sort()
idx = np.searchsorted(b, a)
print(0)
| s304073541 | Accepted | 278 | 27,484 | 566 | import sys
from operator import itemgetter
read = sys.stdin.read
N, *ab = map(int, read().split())
mod = 10 ** 9 + 7
ab = list(zip(ab, [0] * N + [1] * N))
ab.sort(key=itemgetter(0))
remain_pc = 0
remain_power = 0
answer = 1
for x, p in ab:
if p == 0:
if remain_power == 0:
remain_pc += 1
... |
s212244612 | p02414 | u012062731 | 1,000 | 131,072 | Wrong Answer | 20 | 7,616 | 539 | Write a program which reads a $n \times m$ matrix $A$ and a $m \times l$ matrix $B$, and prints their product, a $n \times l$ matrix $C$. An element of matrix $C$ is obtained by the following formula: \\[ c_{ij} = \sum_{k=1}^m a_{ik}b_{kj} \\] where $a_{ij}$, $b_{ij}$ and $c_{ij}$ are elements of $A$, $B$ and $C$ res... | n, m, l = map(int, input().split()) # n = 3, c = 2, l = 3
a_matrix = [list(map(int, input().split())) for row in range(n)] # [[1, 2], [0, 3], [4, 5]]
b_matrix = [list(map(int, input().split())) for row in range(m)] # [[1, 2, 1], [0, 3, 2]]
result_matrix = [[0 for x in range(l)] for y in range(n)] # [[0, 0, 0], [0, 0,... | s176105612 | Accepted | 510 | 8,896 | 518 | n, m, l = map(int, input().split()) # n = 3, c = 2, l = 3
a_matrix = [list(map(int, input().split())) for row in range(n)] # [[1, 2], [0, 3], [4, 5]]
b_matrix = [list(map(int, input().split())) for row in range(m)] # [[1, 2, 1], [0, 3, 2]]
result_matrix = [[0 for x in range(l)] for y in range(n)] # [[0, 0, 0], [0, 0,... |
s152367606 | p04043 | u629540524 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 86 | 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 ... | a = input().split()
print('Yes' if a.count('5') == 2 and a.count('7') == 1 else 'No') | s540025696 | Accepted | 17 | 2,940 | 78 | a = input()
print('YES' if a.count('5') == 2 and a.count('7') == 1 else 'NO') |
s641948024 | p02866 | u571969099 | 2,000 | 1,048,576 | Wrong Answer | 115 | 14,396 | 281 | Given is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition: * For every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i. | n = int(input())
d = [int(i) for i in input().split()]
a = [0] * n
for i in d:
a[i] += 1
if d[0] != 0:
print(0)
else:
j = 1
for i in range(n - 1):
if a[i] == 0:
break
j *= a[i] ** a[i + 1]
j %= 998244353
print(a)
print(j) | s153777833 | Accepted | 126 | 14,396 | 275 | n = int(input())
d = [int(i) for i in input().split()]
a = [0] * n
k = 0
for i in d:
a[i] += 1
k=max(k,i)
if d[0] != 0:
print(0)
elif a[0] != 1:
print(0)
else:
j = 1
for i in range(k):
j *= a[i] ** a[i + 1]
j %= 998244353
print(j)
|
s062215171 | p03433 | u190079347 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 85 | E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins. | n = int(input())
a = int(input())
if n % 500 <= a:
print("YES")
else:
print("NO") | s997369149 | Accepted | 17 | 2,940 | 85 | n = int(input())
a = int(input())
if n % 500 <= a:
print("Yes")
else:
print("No") |
s395633984 | p03377 | u294385082 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 87 | There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals. | A,B,X = map(int,input().split())
if A <= X <= A+B :
print("Yes")
else :
print("No") | s985859041 | Accepted | 17 | 2,940 | 87 | A,B,X = map(int,input().split())
if A <= X <= A+B :
print("YES")
else :
print("NO") |
s194382911 | p03338 | u265281278 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,060 | 128 | You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when ... | N = int(input())
S = input()
ans = 0
for i in range(1,N):
x = set(S[:i]) and set(S[i:])
ans = max(ans,len(x))
print(ans) | s527369613 | Accepted | 17 | 2,940 | 126 | N = int(input())
S = input()
ans = 0
for i in range(1,N):
x = set(S[:i]) & set(S[i:])
ans = max(ans,len(x))
print(ans) |
s159462724 | p04029 | u451017206 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 37 | There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total? | N = int(input())
print(N * (N + 1)/2) | s188441235 | Accepted | 18 | 2,940 | 38 | N = int(input())
print(N * (N + 1)//2) |
s459283168 | p02260 | u456917014 | 1,000 | 131,072 | Wrong Answer | 20 | 5,592 | 207 | Write a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: SelectionSort(A) 1 for i = 0 to A.length-1 2 mini = i 3 for j = i to A.length-1 4 if A[j] < A[mini] 5 mini = j 6 swap A[... | n=int(input())
l=list(map(int,input().split()))
count=0
for i in range(n):
m=i
for j in range(i,n):
if l[j]<l[m]:
m=j
l[i],l[m]=l[m],l[i]
count+=1
print(*l)
print(count)
| s508557251 | Accepted | 20 | 5,608 | 230 | n=int(input())
l=list(map(int,input().split()))
count=0
for i in range(n):
m=i
for j in range(i,n):
if l[j]<l[m]:
m=j
l[i],l[m]=l[m],l[i]
if l[i]!=l[m]:
count+=1
print(*l)
print(count)
|
s015970135 | p02259 | u865220118 | 1,000 | 131,072 | Wrong Answer | 20 | 5,592 | 684 | Write a program of the Bubble Sort algorithm which sorts a sequence _A_ in ascending order. The algorithm should be based on the following pseudocode: BubbleSort(A) 1 for i = 0 to A.length-1 2 for j = A.length-1 downto i+1 3 if A[j] < A[j-1] 4 swap A[j] and A[j-1] Note that, in... |
A = []
LENGTH =int(input())
A = input().split()
N = 0
M = LENGTH - 1
CHANGE = 0
while N <= LENGTH -1 :
M = LENGTH - 1
print ('N=',N)
# for j = A.length-1 downto i+1
while M >= N + 1:
print ('-M=',M)
# if A[j] < A[j-1]
if A[M] < A[M-1] :
tmp = A[M-1]
... | s553320550 | Accepted | 20 | 5,600 | 695 |
A = []
LENGTH =int(input())
A = input().split()
N = 0
M = LENGTH - 1
CHANGE = 0
while N <= LENGTH -1 :
M = LENGTH - 1
# print ('N=',N)
# for j = A.length-1 downto i+1
while M >= N + 1:
# print ('-M=',M)
# if A[j] < A[j-1]
if int(A[M]) < int(A[M-1]) :
tmp = A[... |
s317598015 | p03796 | u703890795 | 2,000 | 262,144 | Wrong Answer | 51 | 2,940 | 82 | Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7. | N = int(input())
s = 1
for i in range(1, N+1):
s *= i
s %= (7 + 1E+9)
print(s) | s215632958 | Accepted | 50 | 2,940 | 87 | N = int(input())
s = 1
for i in range(1, N+1):
s *= i
s %= (7 + 1E+9)
print(int(s)) |
s544975059 | p03673 | u385309449 | 2,000 | 262,144 | Wrong Answer | 2,104 | 25,156 | 107 | You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b. The i-th operation is as follows: 1. Append a_i to the end of b. 2. Reverse the order of the elements in b. Find the sequence b obtained after these n operations. | n = int(input())
a = list(map(int,input().split()))
b = []
for i in a:
b.append(i)
b = b[::-1]
print(b) | s203713851 | Accepted | 68 | 27,204 | 180 | n = int(input())
a = list(map(str,input().split()))
b = a[::-1]
b = b[::2]
if n%2 == 0:
c = a[::2]
else:
c = a[1::2]
d = b+c
if n >= 2:
print(' '.join(d))
else:
print(a[0]) |
s968350468 | p02613 | u674190122 | 2,000 | 1,048,576 | Wrong Answer | 152 | 16,296 | 252 | 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`,... | result = []
for _ in range(int(input())):
result.append(input())
print("AC X {}".format(result.count("AC")))
print("WA X {}".format(result.count("WA")))
print("TLE X {}".format(result.count("TLE")))
print("RE X {}".format(result.count("RE")))
| s614507616 | Accepted | 147 | 16,196 | 245 | result = []
for _ in range(int(input())):
result.append(input())
print("AC x {}".format(result.count("AC")))
print("WA x {}".format(result.count("WA")))
print("TLE x {}".format(result.count("TLE")))
print("RE x {}".format(result.count("RE")))
|
s750473663 | p03729 | u840570107 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 185 | You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `Y... | lis = input().split()
lis_a = lis[0][len(lis[0])-1]
lis_b = lis[1][len(lis[1])-1]
lis_c = lis[2][len(lis[2])-1]
if lis_a == lis_b and lis_b == lis_c:
print("YES")
else:
print("NO") | s305700403 | Accepted | 17 | 3,060 | 195 | lis = input().split()
lis_a = lis[0][len(lis[0])-1]
lis_bt = lis[1][0]
lis_bf = lis[1][len(lis[1])-1]
lis_c = lis[2][0]
if lis_a == lis_bt and lis_bf == lis_c:
print("YES")
else:
print("NO") |
s326874377 | p03813 | u863442865 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 79 | 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. | x = int(input())
s = x // 11
a = x % 11
print(s*2+2) if a > 6 else print(s*2+1) | s664918802 | Accepted | 17 | 2,940 | 53 | print('ABC') if int(input()) < 1200 else print('ARC') |
s609316362 | p03054 | u052499405 | 2,000 | 1,048,576 | Wrong Answer | 393 | 3,784 | 664 | We have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left. On this grid, there is a piece, which is initially placed at square (s_r,s_c). Takahashi and Aoki will play a game, where each player has a st... | h, w, n = [int(item) for item in input().split()]
sr, sc = [int(item) for item in input().split()]
s = input().rstrip()
t = input().rstrip()
# l, r, u, d
move_limit = [-(w-sr+1), -sr, -(h-sc+1), -sc]
max_move = [0] * 4
move = [0] * 4
direction = "LRUD"
reverse = "RLDU"
for i in range(n):
move[direction.index(s[i])... | s626117054 | Accepted | 247 | 3,888 | 857 | h, w, n = [int(item) for item in input().split()]
sr, sc = [int(item) for item in input().split()]
sr -= 1
sc -= 1
s = input().rstrip()
t = input().rstrip()
x = sc
# Check left
for i in range(n):
if s[i] == "L":
x -= 1
if x < 0:
print("NO")
exit()
if t[i] == "R" and x+1 < w-1:
... |
s064914879 | p02399 | u731710433 | 1,000 | 131,072 | Wrong Answer | 30 | 7,480 | 72 | Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number) | a, b = map(float, input().split())
print(int(a // b), int(a % b), a / b) | s456933563 | Accepted | 20 | 7,728 | 94 | a, b = [int(x) for x in input().split()]
print("{0} {1} {2:.5f}".format(a // b, a % b, a / b)) |
s672416299 | p02408 | u635647915 | 1,000 | 131,072 | Wrong Answer | 30 | 7,780 | 457 | Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers). The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond. | #coding:utf-8
def ch2int(a):
s=["S","H","C","D"]
for i,b in enumerate(s):
if a==b:
return i
def int2ch(i):
s=["S","H","C","D"]
return s[i]
n=int(input())
card=[[0 for i in range(0,4)]for j in range(0,13)]
for i in range(n):
c,x=list(map(str,input().split()))
card[int(x)-... | s912385780 | Accepted | 20 | 7,712 | 457 | #coding:utf-8
def ch2int(a):
s=["S","H","C","D"]
for i,b in enumerate(s):
if a==b:
return i
def int2ch(i):
s=["S","H","C","D"]
return s[i]
n=int(input())
card=[[0 for i in range(0,13)]for j in range(0,4)]
for i in range(n):
c,x=list(map(str,input().split()))
card[ch2int(... |
s542307176 | p03578 | u966601619 | 2,000 | 262,144 | Wrong Answer | 2,105 | 35,420 | 312 | Rng is preparing a problem set for a qualification round of CODEFESTIVAL. He has N candidates of problems. The difficulty of the i-th candidate is D_i. There must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems.... | q=input()
x=[int(i) for i in input().split()]
cnt=input()
j=0
y=[int(i) for i in input().split()]
for k in range(len(y)) :
for i in range(len(x)) :
if x[i] == y[k] :
del x[i]
break
if i+1 == len(x) :
print('NO')
j=1
break
if j==0 :
print('YES') | s103935280 | Accepted | 305 | 41,816 | 443 |
q=input()
x=[int(i) for i in input().split()]
cnt=input()
y=[int(i) for i in input().split()]
if max(x) >= max(y):
MAX=max(x)
else:
MAX=max(y)
dic = {}
for k in x :
if k in dic.keys() :
dic[k] += 1
else :
dic[k] = 1
for i in y :
if i in dic.keys() :
dic[i] -= 1
... |
s770316780 | p03470 | u401077816 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 80 | An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you h... | N = int(input())
A = list(map(int, input().split()))
print(len(set(sorted(A)))) | s741839572 | Accepted | 17 | 2,940 | 76 | N = int(input())
l = sorted([input() for _ in range(N)])
print(len(set(l))) |
s018667884 | p03089 | u731368968 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,064 | 420 | Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N oper... | N=int(input())
b = list(map(int, input().split()))
ans=[]
for i in range(N):
print(b)
#j:index of delete + 1(ans base)
j = 1
if j < len(b):
while b[j] == j + 1:
j += 1
if j == len(b):break
if b[j - 1] == j:
del b[j-1]
ans.append(j)
else:
... | s040202527 | Accepted | 17 | 3,064 | 422 | N=int(input())
b = list(map(int, input().split()))
ans=[]
#delete N times
for i in range(N):
#j:index of delete + 1(ans base)
j = False
for k in range(len(b)-1,-1,-1):
if b[k] == k + 1:
j = True
del b[k]
ans.append(k+1)
break
if not j:
pr... |
s822957986 | p03549 | u463655976 | 2,000 | 262,144 | Wrong Answer | 19 | 3,188 | 78 | Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of th... | N, M = map(int, input().split())
print((1900 * M + 100 * (N-M)) / pow(1/2, M)) | s240115259 | Accepted | 18 | 2,940 | 96 | N, M = map(int, input().split())
print("{:.0f}".format((1900 * M + 100 * (N-M)) / pow(1/2, M)))
|
s345213768 | p03836 | u752513456 | 2,000 | 262,144 | Wrong Answer | 23 | 3,064 | 292 | Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement ... | sx, sy, tx, ty = map(int, input().split())
s = ''
s += 'R' * (tx - sx) + 'U' * (ty - sy)
s += 'L' + 'D' * (ty - sy - 1) + 'L' * (tx - sx - 1) + 'D'
s += 'D' + 'R' * (tx - sx + 1) + 'U' * (ty - sy + 1) + 'L'
s+= 'U' + 'L' * 2 + 'D' * (ty - sy - 1) + 'L' * (tx - sx - 1) + 'D' + 'R'
print(s)
| s223291104 | Accepted | 22 | 3,064 | 256 | sx, sy, tx, ty = map(int, input().split())
s = ''
s += 'U' * (ty - sy) + 'R' * (tx - sx)
s += 'D' * (ty - sy) + 'L' * (tx - sx)
s += 'L' + 'U' * (ty - sy + 1) + 'R' * (tx - sx + 1) + 'D'
s += 'R' + 'D' * (ty - sy + 1) + 'L' * (tx -sx + 1) + 'U'
print(s)
|
s943553690 | p03192 | u858523893 | 2,000 | 1,048,576 | Wrong Answer | 18 | 2,940 | 18 | You are given an integer N that has exactly four digits in base ten. How many times does `2` occur in the base-ten representation of N? | input().count("2") | s831356119 | Accepted | 20 | 2,940 | 25 | print(input().count("2")) |
s873401721 | p03149 | u065793287 | 2,000 | 1,048,576 | Wrong Answer | 18 | 2,940 | 87 | You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974". | a = list(map(int,input().split()))
a.sort()
print( 'YES' if a == [1,9,7,4] else 'NO' )
| s063261084 | Accepted | 18 | 2,940 | 87 | a = list(map(int,input().split()))
a.sort()
print( 'YES' if a == [1,4,7,9] else 'NO' )
|
s355021238 | p02742 | u902380746 | 2,000 | 1,048,576 | Wrong Answer | 18 | 3,060 | 217 | We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the to... | import sys
import math
import bisect
def main():
n, m = map(int, input().split())
a = (m + 1) // 2
b = m // 2
ans = a * (n + 1) // 2 + b * n // 2
print(ans)
if __name__ == "__main__":
main()
| s677655376 | Accepted | 17 | 3,060 | 278 | import sys
import math
import bisect
def main():
n, m = map(int, input().split())
if n == 1 or m == 1:
print(1)
else:
ans = ((m + 1) // 2) * ((n + 1) // 2)
ans += (m // 2) * (n // 2)
print(ans)
if __name__ == "__main__":
main()
|
s419224621 | p03471 | u281303342 | 2,000 | 262,144 | Wrong Answer | 685 | 3,060 | 178 | The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situat... | N,Y = map(int,input().split())
for i in range(N+1):
for j in range(N-i+1):
if i*10000 + j*5000 + (N-(i+j))*1000 == Y:
print(i,j,N-(i+j))
break | s269323620 | Accepted | 712 | 3,060 | 537 | # python 3.4.3
import sys
input = sys.stdin.readline
# -------------------------------------------------------------
# library
# -------------------------------------------------------------
# -------------------------------------------------------------
# main
# ----------------------------------------------------... |
s143581906 | p02602 | u377834804 | 2,000 | 1,048,576 | Wrong Answer | 1,705 | 25,184 | 222 | M-kun is a student in Aoki High School, where a year is divided into N terms. There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows: * For the first through (K-1)-th terms: not given. * For each of the K-th through N-th terms: the m... | N, K = map(int, input().split())
A = []
for i, a in enumerate(input().split()):
if i < K:
A.append(a)
continue
else:
A.append(a)
x = A.pop(0)
if x < a:
print('Yes')
else:
print('No') | s835318911 | Accepted | 1,654 | 31,544 | 238 | N, K = map(int, input().split())
A = []
for i, a in enumerate(list(map(int, input().split()))):
if i < K:
A.append(a)
continue
else:
A.append(a)
x = A.pop(0)
if x < a:
print('Yes')
else:
print('No') |
s897746303 | p02853 | u368796742 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,064 | 412 | We held two competitions: Coding Contest and Robot Maneuver. In each competition, the contestants taking the 3-rd, 2-nd, and 1-st places receive 100000, 200000, and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competitions receives an additional 400000 yen.... | x,y = map(int, input().split())
if x > 3 and y > 3:
print("0")
elif x == 1:
if y == 1:
print("100000")
elif y == 2:
print("50000")
elif y == 3:
print("40000")
elif x == 2:
if y == 1:
print("500000")
elif y == 2:
print("40000")
elif y == 3:
print("30000")
elif x == 3:
if y == 1:
... | s487102081 | Accepted | 17 | 3,064 | 250 | x,y = map(int,input().split())
def point(a):
if a == 1:
return 300000
elif a == 2:
return 200000
elif a == 3:
return 100000
else:
return 0
c = point(x)
b = point(y)
if x == 1 and y == 1:
print(1000000)
else:
print(c+b) |
s232051202 | p03573 | u117193815 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 68 | 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. | a,b,c=map(int, input().split())
if a==b:
print(c)
else:
print(a) | s550372279 | Accepted | 17 | 3,064 | 91 | a,b,c=map(int, input().split())
if a==b:
print(c)
elif a==c:
print(b)
else:
print(a)
|
s156151691 | p02669 | u923270446 | 2,000 | 1,048,576 | Wrong Answer | 23 | 9,136 | 458 | You start with the number 0 and you want to reach the number N. You can change the number, paying a certain amount of coins, with the following operations: * Multiply the number by 2, paying A coins. * Multiply the number by 3, paying B coins. * Multiply the number by 5, paying C coins. * Increase or decrease... | t = int(input())
for i in range(t):
n, a, b, c, d = map(int, input().split())
ans = 0
for i in range(60):
if n == 1:
ans += d
n = 0
break
if n % 5 == 0:
ans += c
n //= 5
elif n % 3 == 0:
ans += b
n //... | s133993692 | Accepted | 286 | 11,004 | 509 | def dfs(n):
if n == 1:
return d
if n == 0:
return 0
if n in dic:
return dic[n]
ans = min(n * d, dfs(n // 2) + a + (n % 2) * d, dfs((n + 1) // 2) + a + ((-1 * n) % 2) * d, dfs(n // 3) + b + (n % 3) * d, dfs((n + 2) // 3) + b + ((-1 * n) % 3) * d, dfs(n // 5) + c + (n % 5) * d, dfs... |
s024264750 | p03712 | u530383736 | 2,000 | 262,144 | Wrong Answer | 24 | 3,952 | 305 | 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. | # -*- coding: utf-8 -*-
H,W = list(map(int, input().rstrip().split()))
a_list = [list(input().strip()) for _ in range(H)]
#-----
b_list=[ ["#" for c in range(W+2)] for r in range(H+2) ]
for i in range(H):
for j in range(W):
b_list[i+1][j+1] = a_list[i][j]
for li in b_list:
print(*li)
| s414538360 | Accepted | 25 | 4,596 | 312 | # -*- coding: utf-8 -*-
H,W = list(map(int, input().rstrip().split()))
a_list = [list(input().strip()) for _ in range(H)]
#-----
b_list=[ ["#" for c in range(W+2)] for r in range(H+2) ]
for i in range(H):
for j in range(W):
b_list[i+1][j+1] = a_list[i][j]
for li in b_list:
print(*li,sep="")
|
s194254079 | p04029 | u777394984 | 2,000 | 262,144 | Wrong Answer | 21 | 3,316 | 31 | There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total? | n=int(input())
print((1+n)*n/2) | s223641914 | Accepted | 23 | 3,316 | 37 | n=int(input())
print(int((1+n)*n/2))
|
s503464086 | p03657 | u457957084 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 122 | 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 ca... | a, b = map(int,input().split())
if (a % 3 != 0) and ( b % 3 != 0):
print("Impossible")
else:
print("Possible")
| s537994892 | Accepted | 17 | 2,940 | 141 | a, b = map(int,input().split())
if (a % 3 == 0) or( b % 3 == 0) or ((a + b) % 3 ==0):
print("Possible")
else:
print("Impossible")
|
s176564177 | p03501 | u344888046 | 2,000 | 262,144 | Wrong Answer | 26 | 9,100 | 53 | You are parking at a parking lot. You can choose from the following two fee plans: * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours. * Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours. | N, A, B = map(int, input().split())
print(N * A + B) | s944688488 | Accepted | 28 | 9,092 | 80 | N, A, B = map(int, input().split())
ans = N * A if N * A < B else B
print(ans) |
s380315834 | p02615 | u608755339 | 2,000 | 1,048,576 | Wrong Answer | 238 | 31,432 | 170 | 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... | N = int(input())
A = sorted([int(i) for i in input().split()], reverse=True)
S = A[0]
step = 2
print(S)
for i in range(1,N-1):
S += (A[(i+1)//2])
print(S)
print(S) | s707535539 | Accepted | 150 | 31,500 | 150 | N = int(input())
A = sorted([int(i) for i in input().split()], reverse=True)
S = A[0]
step = 2
for i in range(1,N-1):
S += (A[(i+1)//2])
print(S) |
s586676636 | p02850 | u602740328 | 2,000 | 1,048,576 | Wrong Answer | 2,105 | 29,184 | 581 | Given is a tree G with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i. Consider painting the edges in G with some number of colors. We want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different. Among the colo... | from functools import reduce
from operator import mul
N = int(input())
ab = [tuple(map(int, input().split())) for _ in range(N-1)]
print(N, ab)
E_n = {k: 0 for k in ab}
for i in range(1,N+1):
items = {k:v for k,v in E_n.items() if i in k}
c = 0
for k in items.keys():
if items[k] != 0: continue
w... | s227730394 | Accepted | 605 | 49,600 | 417 | N = int(input())
edge = {}
tree = [[] for i in range(N)]
colors = [1]*(N-1)
c_p = [[] for i in range(N)]
for i in range(N-1):
a,b = map(int,input().split())
a,b = a-1,b-1
tree[a].append(b)
edge[(a,b)] = i
for i in range(N):
c = 1
for v_c in tree[i]:
while c in c_p[i]: c+=1
colors[ed... |
s027836696 | p02608 | u243748614 | 2,000 | 1,048,576 | Wrong Answer | 2,206 | 9,204 | 497 | Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N). | from math import trunc, sqrt
def p(x,y,z):
return x**2+y**2+z**2+x*y+y*z+z*x
def perm(x,y,z):
if x==y and y==z and z==x:
return 1
if x!=y and y!=z and z!=x:
return 6
return 3
def f(n):
mn=trunc(sqrt(n // 3))+1
k=0
for x in range(1,mn+1):
for y in range(x,mn+1):
... | s032108665 | Accepted | 235 | 9,252 | 245 | N=int(input())
a=[0]*N
x=1
while x*x<=N:
y=1
while x*x+y*y+x*y<=N:
z=1
while z*z+x*x+y*y+x*y+z*y+z*x<=N:
a[z*z+x*x+y*y+x*y+z*y+z*x-1]+=1
z+=1
y+=1
x+=1
for n in a:
print(n)
|
s498309868 | p03854 | u472534477 | 2,000 | 262,144 | Wrong Answer | 18 | 3,188 | 370 | You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. | S= input()
i=0
while True:
flag = False
if S[i:i+7] == "dreamer":
i += 7
flag = True
if S[i:i+6] == "eraser":
i += 6
flag = True
if S[i:i+5] == "erase" or S[i:i+5] == "dream":
i += 5
flag = True
if not flag:
break
if i == len(S):
p... | s642435279 | Accepted | 18 | 3,188 | 128 | s=input().replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","")
print("YES" if len(s)==0 else "NO") |
s261435705 | p03944 | u589969467 | 2,000 | 262,144 | Wrong Answer | 29 | 9,076 | 454 | 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) po... | w,h,n = map(int,input().split())
#print(x_list)
#print(y_list)
min_x = 0
max_x = w
min_y = 0
max_y = h
for i in range(n):
x,y,a = map(int,input().split())
if a==1:
min_x = x
elif a==2:
max_x = x
elif a==3:
min_y = y
else:
max_y = y
if min_x > max_x or min_y > max_y:... | s836923603 | Accepted | 29 | 9,100 | 498 | w,h,n = map(int,input().split())
#print(x_list)
#print(y_list)
min_x = 0
max_x = w
min_y = 0
max_y = h
for i in range(n):
x,y,a = map(int,input().split())
if a==1:
min_x = max(min_x,x)
elif a==2:
max_x = min(max_x,x)
elif a==3:
min_y = max(min_y,y)
else:
max_y = min... |
s862226060 | p03360 | u936985471 | 2,000 | 262,144 | Wrong Answer | 19 | 2,940 | 80 | 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... | l=list(map(int,input().split()))
k=int(input())
print(sum(l)+max(l)**k-max(l))
| s048957645 | Accepted | 17 | 2,940 | 73 | A=list(map(int,input().split()))
print(sum(A)+max(A)*(2**int(input())-1)) |
s814248298 | p03573 | u126747509 | 2,000 | 262,144 | Wrong Answer | 22 | 3,316 | 229 | 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. | from collections import defaultdict
def main():
d = defaultdict(lambda: 0)
for i in input().split():
d[int(i)] += 1
d = {v:k for k, v in d.items()}
print(d[2])
if __name__ == "__main__":
main() | s970267132 | Accepted | 21 | 3,316 | 229 | from collections import defaultdict
def main():
d = defaultdict(lambda: 0)
for i in input().split():
d[int(i)] += 1
d = {v:k for k, v in d.items()}
print(d[1])
if __name__ == "__main__":
main() |
s729025168 | p03993 | u502175663 | 2,000 | 262,144 | Wrong Answer | 2,103 | 16,308 | 255 | There are N rabbits, numbered 1 through N. The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i. For a pair of rabbits i and j (i<j), we call the pair (i,j) a _friendly pair_ if the following condition is met. * Rabbit i likes rabbit j and rabbit j likes rabbit i. Calculat... | n = int(input())
line = input().split(' ')
total_list =[]
for i in range(0,n):
total = i + int(line[i])
total_list.append(total)
print(total_list)
answer = 0
for i in range(n *2 -1):
if total_list.count(i) == 2:
answer += 1
print(answer) | s725586290 | Accepted | 113 | 10,740 | 158 | n = int(input())
a = input().split(' ')
t = 0
for o in range(n):
i = o + 1
b = int(a[o]) - i
if i == int(a[o + b]):
t += 1
print(int(t / 2)) |
s753410179 | p02233 | u216229195 | 1,000 | 131,072 | Wrong Answer | 20 | 7,604 | 152 | Write a program which prints $n$-th fibonacci number for a given integer $n$. The $n$-th fibonacci number is defined by the following recursive formula: \begin{equation*} fib(n)= \left \\{ \begin{array}{ll} 1 & (n = 0) \\\ 1 & (n = 1) \\\ fib(n - 1) + fib(n - 2) & \\\ \end{array} \right. \end{equation*} | def fib(n):
if n < 0:
print("error")
exit()
if n < 2:
result = 1
result = fib(n-1) + fib(n-2)
return result
n = int(input())
fib(n) | s052848630 | Accepted | 20 | 5,604 | 218 | def fibr(n):
if arr[n] != 0:
return arr[n]
if n < 2:
arr[n] = 1
else:
arr[n] = fibr(n-1) + fibr(n-2)
return arr[n]
n = int(input())
arr = [0 for i in range(n+1)]
print(fibr(n))
|
s800568439 | p02748 | u490489966 | 2,000 | 1,048,576 | Wrong Answer | 464 | 18,612 | 297 | You are visiting a large electronics store to buy a refrigerator and a microwave. The store sells A kinds of refrigerators and B kinds of microwaves. The i-th refrigerator ( 1 \le i \le A ) is sold at a_i yen (the currency of Japan), and the j-th microwave ( 1 \le j \le B ) is sold at b_j yen. You have M discount tic... | #B
a,b,m=map(int,input().split())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
amin=min(al)
bmin=min(bl)
minp=amin+bmin
print(amin,bmin)
for i in range(m):
num=list(map(int,input().split()))
price=al[num[0]-1]+bl[num[1]-1]-num[2]
minp=min(price,minp)
print(minp) | s446408584 | Accepted | 458 | 18,612 | 280 | #B
a,b,m=map(int,input().split())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
amin=min(al)
bmin=min(bl)
minp=amin+bmin
for i in range(m):
num=list(map(int,input().split()))
price=al[num[0]-1]+bl[num[1]-1]-num[2]
minp=min(price,minp)
print(minp) |
s297675886 | p03448 | u698348858 | 2,000 | 262,144 | Wrong Answer | 30 | 3,064 | 268 | 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 co... | #coding:utf-8
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for i in range(a):
for j in range(b):
for k in range(c):
p = a * 500 + b * 100 + c * 50
if p == x:
cnt += 1
elif p > x:
break
print(cnt) | s213251245 | Accepted | 48 | 3,064 | 280 | #coding:utf-8
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for i in range(a + 1):
for j in range(b + 1):
for k in range(c + 1):
p = i * 500 + j * 100 + k * 50
if p > x:
break
if p == x:
cnt += 1
print(cnt) |
s126579976 | p02401 | u104931506 | 1,000 | 131,072 | Time Limit Exceeded | 40,000 | 7,864 | 179 | Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part. | a, op, b = input().split()
while True:
if op == '+' : print(a + b)
elif op == '-' : print(a - b)
elif op == '/' : print(a / b)
elif op == '*' : print(a * b)
else : break | s214950619 | Accepted | 40 | 7,656 | 203 | while True:
a, op, b = input().split()
a = int(a)
b = int(b)
if op == '+': print(a + b)
elif op == '-': print(a - b)
elif op == '/': print(a // b)
elif op == '*': print(a * b)
else: break |
s295979512 | p03455 | u323532272 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 82 | AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. | a, b = map(int, input().split())
if a*b == 0:
print('Even')
else:
print('Odd') | s764873628 | Accepted | 17 | 2,940 | 85 | a, b = map(int, input().split())
if a*b%2 == 0:
print('Even')
else:
print('Odd')
|
s788949008 | p03130 | u989623817 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,064 | 392 | There are four towns, numbered 1,2,3 and 4. Also, there are three roads. The i-th road connects different towns a_i and b_i bidirectionally. No two roads connect the same pair of towns. Other than these roads, there is no way to travel between these towns, but any town can be reached from any other town using these roa... | a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())
cnt = {1: 0, 2: 0, 3: 0, 4: 0}
for i in range(4):
if not i+1 in [a1, a2, a3, b1, b2, b3]:
print('NO')
exit()
lis = [a1, a2, a3, b1, b2, b3]
c = 0
for l in range(4):
cnt = lis.count(l+1)
... | s987488845 | Accepted | 17 | 3,064 | 401 | a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())
cnt = {1: 0, 2: 0, 3: 0, 4: 0}
for i in range(4):
if not i+1 in [a1, a2, a3, b1, b2, b3]:
print('NO')
exit()
lis = [a1, a2, a3, b1, b2, b3]
c = 0
for l in range(4):
cnt = lis.count(l+1)
... |
s164764282 | p02742 | u571395477 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 208 | We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the to... | import math
def main():
H, W = [int(_) for _ in input().split()]
if H % 2 == 0 or W % 2 == 0:
m = (H * W) /2
else:
m = (H * W) /2
m = int(math.ceil(m))
print(m)
main() | s983001390 | Accepted | 18 | 3,060 | 294 | import sys
import math
def main():
H, W = [int(_) for _ in input().split()]
if H == 1 or W == 1:
m = 1
print(int(m))
sys.exit()
elif H % 2 == 1 and W % 2 == 1:
m = (H * W) // 2 + 1
else:
m = (H * W) // 2
print(int(m))
main() |
s803407351 | p03379 | u962127640 | 2,000 | 262,144 | Wrong Answer | 2,109 | 34,196 | 233 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..... | import numpy as np
N= int(input())
a = list(map(int, input().split(' ')))
a = np.array(a)
ret = []
for i in range(N):
ind = np.ones(N, dtype=bool)
ind[i] = False
tmp = a[ind]
ret.append(int(np.median(tmp)))
print(ret) | s525779032 | Accepted | 413 | 34,156 | 214 | import numpy as np
N= int(input())
a = list(map(int, input().split(' ')))
sort_a = sorted(a)
small = sort_a[N//2-1]
big = sort_a[N//2]
for aa in a:
if aa < big:
print(big)
else:
print(small) |
s284051930 | p03359 | u777846995 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 118 | In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For ... | x, y = map(int, input().split())
cnt = 0
for i in range(1, 13):
if x == i and y == i:
cnt += 1
print(cnt) | s639572936 | Accepted | 17 | 2,940 | 74 | x, y = map(int, input().split())
if x <= y:
print(x)
else:
print(x-1) |
s798753036 | p03502 | u061545295 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 89 | An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number. | N = input()
f = [int(i) for i in N]
if N%f == 0:
print("Yes")
else:
print('No')
| s915782919 | Accepted | 17 | 2,940 | 110 | N = input()
num = [int(i) for i in N]
f = sum(num)
if int(N)%f == 0:
print("Yes")
else:
print('No')
|
s534572122 | p04029 | u701318346 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 40 | There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total? | N = int(input())
print((1 + N) * N / 2) | s162981110 | Accepted | 17 | 2,940 | 45 | N = int(input())
print(int((1 + N) * N / 2)) |
s066801736 | p03644 | u527190736 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 188 | 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... | n = int(input())
x = 1
cnt = 0
list = []
for i in range(n):
i = x
while i % 2 == 0:
i /= 2
cnt += 1
x += 1
list.append(cnt)
cnt = 0
print(max(list))
| s099147105 | Accepted | 17 | 2,940 | 196 | n = int(input())
x = 1
cnt = 0
list = []
for i in range(n):
i = x
while i % 2 == 0:
i = i//2
cnt += 1
x += 1
list.append(cnt)
cnt = 0
print(2 ** max(list))
|
s620950634 | p03371 | u859897687 | 2,000 | 262,144 | Wrong Answer | 47 | 3,060 | 185 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the curr... | a,b,c,x,y=map(int,input().split())
if a+b>=c+c:
print(a*x+b*y)
else:
ans=10000000000
for i in range(0,(max(x,y)+1)//2):
k=c*2*i+a*(x-i)+b*(y-i)
ans=min(ans,k)
print(ans) | s511777933 | Accepted | 121 | 3,060 | 150 | a,b,c,x,y=map(int,input().split())
ans=10000000000
for i in range(0,(max(x,y)+1)):
k=c*2*i+a*max(0,(x-i))+max(0,b*(y-i))
ans=min(ans,k)
print(ans) |
s987175021 | p03193 | u518987899 | 2,000 | 1,048,576 | Wrong Answer | 18 | 3,188 | 160 | There are N rectangular plate materials made of special metal called AtCoder Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically and B_i horizontally). Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are exactly H \times W. He is trying to obtain such a plate by cho... | import sys
lines = [list(map(int, line.strip().split(' '))) for line in sys.stdin]
print(sum([1 for h,w in lines[1:] if h <= lines[0][1] and w <= lines[0][2]])) | s210542012 | Accepted | 18 | 3,188 | 160 | import sys
lines = [list(map(int, line.strip().split(' '))) for line in sys.stdin]
print(sum([1 for h,w in lines[1:] if lines[0][1] <= h and lines[0][2] <= w])) |
s984572968 | p00067 | u847467233 | 1,000 | 131,072 | Wrong Answer | 30 | 5,620 | 1,085 | 地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。 ■■■■□□□□■■■■ ■■■□□□□□■■■■ ■■□□□□□□■■■■ ■□□□□□□□■■■■ □□□■□□□■□□□□ □□□□□□■■■□□□ □□□□□■■■■■□□ ■□□□■■■■■■■□ ■■□□□■■■■■□□ ■■■□□□■■■□□□ ■... | # AOJ 0067 The Number of Island
# Python3 2018.6.16 bal4u
# UNION-FIND library
MAX = 12*12
id, size = [0]*MAX, [0]*MAX
def init(n):
for i in range(n): id[i], size[i] = i, 1
def root(i):
while i != id[i]:
id[i] = id[id[i]]
i = id[i]
return i
def connected(p, q):
return root(p) == root(q)
def unite(p, q)... | s824486759 | Accepted | 30 | 5,608 | 1,045 | # AOJ 0067 The Number of Island
# Python3 2018.6.16 bal4u
# UNION-FIND library
MAX = 12*12
id, size = [0]*MAX, [0]*MAX
def init(n):
for i in range(n): id[i], size[i] = i, 1
def root(i):
while i != id[i]:
id[i] = id[id[i]]
i = id[i]
return i
def connected(p, q):
return root(p) == root(q)
def unite(p, q)... |
s436730464 | p03610 | u626468554 | 2,000 | 262,144 | Wrong Answer | 76 | 5,292 | 76 | You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1. | s = list(input())
for i in range(1,len(s),2):
print(s[i],end="")
print() | s277091605 | Accepted | 68 | 5,292 | 76 | s = list(input())
for i in range(0,len(s),2):
print(s[i],end="")
print() |
s433879903 | p04045 | u488884575 | 2,000 | 262,144 | Wrong Answer | 35 | 3,064 | 528 | 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 ... |
import itertools
N, K = input().split()
P = input().split()
a= sorted(set([str(i) for i in range(10)])-set(P))
b1 = itertools.product(a, repeat=len(N))
b2 = itertools.product(a, repeat=len(N)+1)
ans=str()
cnt=0
for i in b1:
#print(type(i))
ans = "".join(i)
if N <= ans:
print(ans)
cnt=1
break
if ... | s421744213 | Accepted | 19 | 3,064 | 548 |
import itertools
N, K = input().split()
P = input().split()
a= sorted(set([str(i) for i in range(10)])-set(P))
b1 = itertools.product(a, repeat=len(N))
b2 = itertools.product(a, repeat=len(N)+1)
ans=str()
cnt=0
for i in b1:
#print(type(i))
ans = "".join(i)
if N <= ans:
print(ans)
cnt=1
break
if ... |
s942125315 | p03433 | u421499233 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 125 | E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins. | N = int(input())
A = int(input())
if N <= A:
print("Yes")
elif N - 500 <= A:
print ("Yes")
else:
print("No")
| s490810038 | Accepted | 17 | 2,940 | 93 | N = int(input())
A = int(input())
r = N%500
if A >= r:
print("Yes")
else:
print("No") |
s904587578 | p03067 | u559346857 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 71 | There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise. | a,b,c=map(int,input().split())
print("YES" if a<c<b or b<c<a else "NO") | s981580960 | Accepted | 18 | 2,940 | 71 | a,b,c=map(int,input().split())
print("Yes" if a<c<b or b<c<a else "No") |
s861338851 | p03680 | u716660050 | 2,000 | 262,144 | Wrong Answer | 162 | 12,988 | 178 | Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It ... | N=int(input())
a=[int(input())for i in range(N)]
p=1
ok=False
ans=0
for i in range(N):
ans+=1
if p==2:
ok=True
break
p=a[p-1]
print(ans if ok else -1) | s946087932 | Accepted | 160 | 13,048 | 178 | N=int(input())
a=[int(input())for i in range(N)]
p=1
ok=False
ans=0
for i in range(N):
if p==2:
ok=True
break
p=a[p-1]
ans+=1
print(ans if ok else -1) |
s590092663 | p03573 | u798260206 | 2,000 | 262,144 | Wrong Answer | 25 | 9,020 | 66 | 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. | a = list(map(int,input().split()))
print(sum(a)-sum(list(set(a)))) | s459807971 | Accepted | 33 | 9,128 | 144 | a = list(map(int,input().split()))
if a[0]!=a[1]and a[0]!=a[2]:
print(a[0])
elif a[1]!=a[0]and a[1]!=a[2]:
print(a[1])
else:
print(a[2]) |
s074099561 | p03493 | u348868667 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 90 | Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble. | S = input()
count = 0
for i in range(3):
if S[i] == 1:
count += 1
print(count) | s059615988 | Accepted | 17 | 2,940 | 92 | S = input()
count = 0
for i in range(3):
if S[i] == "1":
count += 1
print(count) |
s191578545 | p04012 | u281303342 | 2,000 | 262,144 | Wrong Answer | 21 | 3,316 | 173 | 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. | from collections import Counter
W = input()
Ans = "YES"
C = Counter(W).items()
for c in C:
_x,cnt = c
if cnt%2 != 0:
Ans = "NO"
break
print(Ans)
| s858613553 | Accepted | 20 | 3,316 | 526 | # python 3.4.3
import sys
input = sys.stdin.readline
# import numpy as np
from collections import Counter
# -------------------------------------------------------------
# function
# -------------------------------------------------------------
# -------------------------------------------------------------
# main
#... |
s562527423 | p02406 | u682153677 | 1,000 | 131,072 | Wrong Answer | 20 | 5,592 | 167 | In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement ... | # -*- coding: utf-8 -*-
n = int(input())
i = 1
while True:
if i % 3 == 0 | i % 10 == 3:
print(' {0}'.format(i))
i += 1
if i > n:
break
| s345331143 | Accepted | 70 | 6,532 | 411 | # -*- coding: utf-8 -*-
from functools import reduce
n = int(input())
i = 1
while True:
a = [int(x) for x in list(str(i))]
if 3 in a:
print(" {0}".format(int(reduce(lambda x, y: x + y, [str(x) for x in a]))), end='')
elif sum(a) % 3 == 0:
print(" {0}".format(int(reduce(lambda x, y: x + y... |
s535452182 | p02398 | u941509088 | 1,000 | 131,072 | Wrong Answer | 20 | 7,608 | 113 | Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b. | a, b, c = map(int, input().split())
numbers_list = [i for i in range(a,b+1) if i%c==0]
print(len(numbers_list)) | s787558495 | Accepted | 60 | 7,720 | 117 | a, b, c = map(int, input().split())
numbers_list = [i for i in range(a,b+1) if c % i == 0]
print(len(numbers_list)) |
s242061075 | p03719 | u646792990 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 102 | You are given three integers A, B and C. Determine whether C is not less than A and not greater than B. | a, b, c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
print('YES')
else:
print('NO')
| s971263887 | Accepted | 17 | 2,940 | 98 | a, b, c = map(int, input().split())
if a <= c and c <= b:
print('Yes')
else:
print('No')
|
s949098648 | p02390 | u120055135 | 1,000 | 131,072 | Wrong Answer | 20 | 5,580 | 106 | Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively. | S = int(input())
h = int(S/360)
m = int((S - h*360)/60)
s = int(S - h*360 -m*60)
print(h, ':', m, ':', s)
| s900517760 | Accepted | 20 | 5,588 | 118 | S = int(input())
h = int(S/3600)
m = int((S - h*3600)/60)
s = int(S - h*3600 - m*60)
print(h, ':', m, ':', s, sep='')
|
s905234598 | p03493 | u100652283 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 128 | Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble. | s = input()
print(s)
count = 0
if s[0] == '1':
count+=1
if s[1] == '1':
count+=1
if s[2] == '1':
count+=1
print(count) | s455106065 | Accepted | 17 | 2,940 | 119 | s = input()
count = 0
if s[0] == '1':
count+=1
if s[1] == '1':
count+=1
if s[2] == '1':
count+=1
print(count) |
s707111910 | p03556 | u441201379 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 72 | Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer. | from math import sqrt, floor
n = int(input())
print((floor(sqrt(n)))^2) | s387732979 | Accepted | 17 | 2,940 | 79 | from math import sqrt, floor
n = int(input())
rt = floor(sqrt(n))
print(rt**2) |
s095975976 | p02865 | u163320134 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 25 | How many ways are there to choose two distinct positive integers totaling N, disregarding the order? | n=int(input())
print(n-1) | s301581079 | Accepted | 17 | 2,940 | 61 | n=int(input())
if n%2==0:
print(n//2-1)
else:
print(n//2) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.