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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s627599645 | p03471 | u646130340 | 2,000 | 262,144 | Wrong Answer | 749 | 3,060 | 158 | 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 a in range(N+1):
for b in range(N - a + 1):
c = N - a - b
if Y == 10000*a + 5000*b + 1000*c:
print(a,b,c) | s003249184 | Accepted | 838 | 3,060 | 247 | N, Y = map(int, input().split())
ans_a = -1
ans_b = -1
ans_c = -1
for a in range(N+1):
for b in range(N - a + 1):
c = N - a - b
if Y == 10000*a + 5000*b + 1000*c:
ans_a = a
ans_b = b
ans_c = c
print(ans_a, ans_b, ans_c) |
s498450927 | p03435 | u036104576 | 2,000 | 262,144 | Wrong Answer | 30 | 9,484 | 735 | We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) ... | import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# map(int, input().split()... | s211135870 | Accepted | 29 | 9,164 | 735 | import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# map(int, input().split()... |
s300422261 | p02601 | u450288159 | 2,000 | 1,048,576 | Wrong Answer | 33 | 9,188 | 472 | 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 successfu... | def main():
a, b, c = map(int, input().split())
k = int(input())
cnt = 0
while(1):
# print(a)
# print(b)
# print(c)
# print('------------------')
if cnt-1 == k:
print('No')
return
cnt += 1
if a < b and b < c:
pri... | s016600368 | Accepted | 24 | 9,180 | 472 | def main():
a, b, c = map(int, input().split())
k = int(input())
cnt = 0
while(1):
# print(a)
# print(b)
# print(c)
# print('------------------')
if cnt-1 == k:
print('No')
return
cnt += 1
if a < b and b < c:
pri... |
s271837643 | p03729 | u446711904 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 69 | 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... | a,b,c=input().split();print('NYoe s'[a[-1]==b[0] and b[-1]==c[0]::2]) | s643730973 | Accepted | 17 | 2,940 | 69 | a,b,c=input().split();print('NYOE S'[a[-1]==b[0] and b[-1]==c[0]::2]) |
s356394530 | p03486 | u692453235 | 2,000 | 262,144 | Wrong Answer | 30 | 9,276 | 353 | You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order. | from collections import defaultdict
s = input()
t = input()
AL = "abcdefghijklmnopqrstuvwxyz"
S = defaultdict(int)
T = defaultdict(int)
for al in s:
S[al] += 1
for al in t:
T[al] += 1
ans_s = ""
for al in AL:
ans_s += al*S[al]
ans_t = ""
for al in reversed(list(al)):
ans_t += al*T[al]
if ans_s < ans_t:
... | s344258613 | Accepted | 28 | 8,936 | 142 | s = input()
t = input()
S = "".join(sorted(list(s)))
T = "".join(sorted(list(t), reverse=True))
if S < T:
print("Yes")
else:
print("No") |
s122598050 | p03919 | u943004959 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 355 | There is a grid with H rows and W columns. The square at the i-th row and j-th column contains a string S_{i,j} of length 5. The rows are labeled with the numbers from 1 through H, and the columns are labeled with the uppercase English letters from `A` through the W-th letter of the alphabet. Exactly one of the sq... | def solve():
H, W = [int(x) for x in input().split(" ")]
snake = []
for _ in range(H):
snake.append(list(map(str, input().split(" "))))
for i in range(H):
for j in range(W):
if snake[i][j] == "snuke":
print(i + 1, chr(65 + j))
print("".join([c... | s917433391 | Accepted | 17 | 3,060 | 313 | def solve():
H, W = [int(x) for x in input().split(" ")]
snake = []
for _ in range(H):
snake.append(list(map(str, input().split(" "))))
for i in range(H):
for j in range(W):
if snake[i][j] == "snuke":
print("".join([chr(65 + j), str(i + 1)]))
solve() |
s664068615 | p03623 | u234929275 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 385 | 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... | x,a,b = input().split()
x = int(x)
a = int(a)
b = int(b)
print("x = ", x)
print("a = ", a)
print("b = ", b)
if x < a:
distance_xa = a - x
else:
distance_xa = x - a
print("distance_xa = ", distance_xa)
if x < b:
distance_xb = b - x
else:
distance_xb = x - b
print("distance_xb = ", distance_xb)
if d... | s644849904 | Accepted | 17 | 3,060 | 178 | x, a, b = input().split()
x = int(x)
a = int(a)
b = int(b)
if x > a:
xa = x-a
else:
xa = a-x
if x > b:
xb = x-b
else:
xb = b-x
if xa > xb:
print("B")
else:
print("A") |
s062929678 | p03478 | u244836567 | 2,000 | 262,144 | Wrong Answer | 32 | 9,156 | 125 | 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). | a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
d=0
for i in range(a):
if b<=(i//10+(i-(i//10)*10))<=c:
d=d+1
print(d) | s453203643 | Accepted | 32 | 8,972 | 202 | a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
d=0
for i in range(1,a+1):
if b<=(i//10000+(i//1000-(i//10000)*10))+(i//100-(i//1000)*10)+(i//10-(i//100)*10)+(i//1-(i//10)*10)<=c:
d=d+i
print(d)
|
s180498672 | p02388 | u797431839 | 1,000 | 131,072 | Wrong Answer | 20 | 5,576 | 65 | Write a program which calculates the cube of a given integer x. | x = int(input("数字を入力してください:"))
print(x**3)
| s480793642 | Accepted | 20 | 5,576 | 29 | x = int(input())
print(x**3)
|
s519869636 | p02619 | u942051624 | 2,000 | 1,048,576 | Wrong Answer | 60 | 9,376 | 1,059 | Let's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to che... | D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for i in range(D)]
lastday=[0 for j in range(26)]
points=[0 for i in range(D)]
t=[0 for i in range(D)]
total=[0 for i in range(D)]
lastday=[lastday[i]+1 for i in range(26)]
bestpoint=0
for i in range(26):
temp=[con for con in lastday... | s685502865 | Accepted | 33 | 9,248 | 566 | D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for i in range(D)]
test=[int(input()) for i in range(D)]
lastday=[0 for j in range(26)]
points=[0 for i in range(D)]
lastday=[lastday[i]+1 for i in range(26)]
lastday[test[0]-1]=0
minus=sum([x*y for (x,y) in zip(c,lastday)])
points[0]=... |
s888220198 | p03997 | u939552576 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 61 | You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid. | a,b,h = int(input()),int(input()),int(input())
print(a*b*h/2) | s176170848 | Accepted | 17 | 2,940 | 64 | a,b,h = int(input()),int(input()),int(input())
print((a+b)*h//2) |
s522021929 | p02795 | u025241948 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 69 | We have a grid with H rows and W columns, where all the squares are initially white. You will perform some number of painting operations on the grid. In one operation, you can do one of the following two actions: * Choose one row, then paint all the squares in that row black. * Choose one column, then paint all t... | H=int(input())
W=int(input())
N=int(input())
a=max(H,W)
print(N//a) | s545491619 | Accepted | 17 | 2,940 | 92 | import math
H=int(input())
W=int(input())
N=int(input())
a=max(H,W)
print(math.ceil(N/a)) |
s907058285 | p03476 | u994988729 | 2,000 | 262,144 | Time Limit Exceeded | 2,104 | 7,064 | 520 | We say that a odd number N is _similar to 2017_ when both N and (N+1)/2 are prime. You are given Q queries. In the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i. | def sieve(n):
tmp=[i for i in range(n, 1, -1)]
s=[]
while len(tmp)>0:
p=tmp.pop()
s.append(p)
for i in range(len(tmp), 0, -1):
if tmp[-i]%p==0:
del tmp[-i]
return s
naturals=sieve(100000)
q=int(input())
for _ in range(q):
left, right=map(int,inpu... | s264971715 | Accepted | 357 | 15,172 | 720 | from itertools import chain, accumulate
def prime_set(N):
if N < 4:
return ({}, {}, {2}, {2, 3})[N]
Nsq = int(N ** 0.5 + 0.5) + 1
primes = {2, 3} | set(chain(range(5, N + 1, 6), range(7, N + 1, 6)))
for i in range(5, Nsq, 2):
if i in primes:
primes -= set(range(i * i, ... |
s913908151 | p02936 | u599114793 | 2,000 | 1,048,576 | Wrong Answer | 2,246 | 2,083,572 | 710 | Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0. Now, the following Q operations will be performed: * Operati... | from collections import deque
n,q = map(int,input().split())
nei_mat = []
nei_list = [[0]]
score_list = [0] * (n+1)
for i in range(n+1):
nei_mat.append([0]*(n+1))
for i in range(n-1):
a,b = map(int,input().split())
nei_mat[a][b] = 1
for i in range(1,n+1):
work_q = deque([])
work_q.append(i)
visi... | s104736215 | Accepted | 1,761 | 63,876 | 509 | n, q = map(int, input().split())
nei_list = [[] for i in range(n+1)]
for i in range(n - 1):
a, b = map(int, input().split())
nei_list[a].append(b)
nei_list[b].append(a)
score = [0] * (n+1)
for i in range(q):
p, x = map(int, input().split())
score[p] += x
work_stack = [1]
visited = set()
while work_s... |
s993039699 | p03549 | u412563426 | 2,000 | 262,144 | Wrong Answer | 21 | 3,188 | 176 | 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 = list(map(int, input().split()))
T = 100*(n-m) + 1900 * m
# print(T)
gamma = 0.5**m
sum = 0
for i in range(1000):
sum += T * (i+1) * 1/4 * (3/4) **i
print(round(sum)) | s978022541 | Accepted | 18 | 2,940 | 173 | n, m = list(map(int, input().split()))
T = 100*(n-m) + 1900 * m
gamma = 0.5**m
sum = 0
for i in range(1000):
sum += T * (i+1) * gamma * (1 - gamma) **i
print(round(sum)) |
s626925890 | p02606 | u844895214 | 2,000 | 1,048,576 | Wrong Answer | 118 | 26,988 | 434 | How many multiples of d are there among the integers between L and R (inclusive)? | import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().spl... | s517164956 | Accepted | 130 | 27,144 | 496 | import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().spl... |
s138222629 | p03455 | u557284649 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 79 | 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(" "))
r = a * b % 2
print(r if "Odd" else "Even") | s406204915 | Accepted | 17 | 2,940 | 95 | a, b = map(int, input().split(" "))
r = a * b % 2
if r == 0:
print("Even")
else:
print("Odd") |
s080575034 | p02410 | u806005289 | 1,000 | 131,072 | Wrong Answer | 20 | 5,592 | 458 | 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 ve... | l=input().split()
n=int(l[0])
m=int(l[1])
i=0
A=[]
while i<n:
a=input().split()
for p in a:
A.append(int(p))
i+=1
I=0
B=[]
while I<m:
b=int(input())
B.append(b)
I+=1
#Ci=ai1b1+ai2b2+...+aimbm
#C[i]=a[m*(i)+1]*b[1]+a[m*(i)+2]*b[2]+...a[m*(i)+m]*b[m]
q=0
C=[]
while q<n:
Q=0
cq... | s404116957 | Accepted | 30 | 5,948 | 473 | l=input().split()
n=int(l[0])
m=int(l[1])
i=0
A=[]
while i<n:
a=input().split()
for p in a:
A.append(int(p))
i+=1
I=0
B=[]
while I<m:
b=int(input())
B.append(b)
I+=1
#Ci=ai1b1+ai2b2+...+aimbm
#C[i]=a[m*(i)+1]*b[1]+a[m*(i)+2]*b[2]+...a[m*(i)+m]*b[m]
q=0
C=[]
while q<n:
Q=0
cq... |
s834706757 | p03385 | u100572972 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 64 | You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`. | N = str(input())
print(('a' in N) and ('b' in N) and ('c' in N)) | s789693097 | Accepted | 17 | 2,940 | 90 | N = str(input())
print('Yes') if ('a' in N) and ('b' in N) and ('c' in N) else print('No') |
s604624571 | p03377 | u163791883 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 75 | There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals. | A, B, X = map(int,input().split())
print('Yes' if A < X < A + B else 'No') | s156689049 | Accepted | 17 | 2,940 | 77 | A, B, X = map(int,input().split())
print('YES' if A <= X <= A + B else 'NO') |
s761222068 | p03971 | u701874561 | 2,000 | 262,144 | Wrong Answer | 76 | 9,280 | 367 | 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 t... | n,a,b=map(int,input().split())
s=input().strip()
njp=0
nop=0
for i in range(len(s)):
if s[i]=='a':
if njp<(a+b):
njp+=1
print('Yes')
else:
print('No')
elif s[i]=='b':
if njp<(a+b):
if nop<=b:
nop+=1
njp+=1
print('yes')
else:
print('No')
e... | s027808437 | Accepted | 73 | 9,240 | 366 | n,a,b=map(int,input().split())
s=input().strip()
njp=0
nop=0
for i in range(len(s)):
if s[i]=='a':
if njp<(a+b):
njp+=1
print('Yes')
else:
print('No')
elif s[i]=='b':
if njp<(a+b):
if nop<b:
nop+=1
njp+=1
print('Yes')
else:
print('No')
el... |
s535765151 | p03644 | u859897687 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 75 | Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can... | n=int(input())
for i in range(6,0,-1):
if 2**i<=n:
print(i)
break | s159585608 | Accepted | 18 | 2,940 | 79 | n=int(input())
for i in range(6,-1,-1):
if 2**i<=n:
print(2**i)
break |
s237352347 | p03644 | u670180528 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 46 | 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());print(2**(len(bin(n+(n>1)))-3)) | s442240055 | Accepted | 17 | 2,940 | 52 | n=int(input());print(2**(len(bin(n+(n>1>n&~-n)))-3)) |
s401970296 | p03565 | u101851939 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 361 | E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One mo... | s_dash = input()
t = input()
answer = 'UNRESTORABLE'
if s_dash < t:
pass
else:
for i in range(len(s_dash)-len(t)+1):
for j, k in zip(s_dash[i:i+len(t)], t):
if j != '?' and j != k:
break
else:
answer = s_dash[:i] + t + s_dash[i+len(t):]
answer ... | s466686608 | Accepted | 17 | 3,064 | 371 |
s_dash = input()
t = input()
answer = 'UNRESTORABLE'
if len(s_dash) < len(t):
pass
else:
for i in range(len(s_dash)-len(t)+1):
for j, k in zip(s_dash[i:i+len(t)], t):
if j != '?' and j != k:
break
else:
answer = s_dash[:i] + t + s_dash[i+len(t):]
... |
s200083563 | p03699 | u593590006 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 83 | You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When... | n=int(input())
l=[int(input()) for i in range(n)]
s=sum(l)
print(s if s%10 else -0) | s532271311 | Accepted | 17 | 3,060 | 175 | n=int(input())
l=[int(input()) for i in range(n)]
s=sum(l)
if s%10:
print(s)
exit()
mini=[i for i in l if i%10]
if not mini:
print(0)
exit()
print(s-min(mini)) |
s739767462 | p03044 | u279266699 | 2,000 | 1,048,576 | Wrong Answer | 844 | 83,908 | 604 | We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied: * For any two vertices... | import sys
sys.setrecursionlimit(1000000)
n = int(input())
t = [[] for _ in range(n)]
color = [None for _ in range(n)]
visited = [False for _ in range(n)]
def dfs(n_num):
visited[n_num] = True
for i in t[n_num]:
if visited[i[0]]:
continue
if i[1] % 2 == 0:
color[i[0]] ... | s868131041 | Accepted | 757 | 80,176 | 594 | import sys
sys.setrecursionlimit(1000000)
n = int(input())
t = [[] for _ in range(n)]
color = [None for _ in range(n)]
visited = [False for _ in range(n)]
def dfs(n_num):
visited[n_num] = True
for i in t[n_num]:
if visited[i[0]]:
continue
if i[1] % 2 == 0:
color[i[0]] ... |
s047772646 | p03605 | u914330401 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 124 | It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N? | def main():
n = input()
for s in n:
if s == '9':
print("YES")
return
print("NO")
return
main() | s983519154 | Accepted | 17 | 2,940 | 124 | def main():
n = input()
for s in n:
if s == '9':
print("Yes")
return
print("No")
return
main() |
s970206077 | p03857 | u205166254 | 2,000 | 262,144 | Wrong Answer | 1,391 | 31,168 | 1,119 | There are N cities. There are also K roads and L railways, extending between the cities. The i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities. No two roads connect the same pair of cities. Similarly, no two railways connect the s... |
def f(m, r):
connmap = [[] for _ in range(m + 1)]
for _ in range(r):
a, b = map(int, input().split())
connmap[a].append(b)
connmap[b].append(a)
group = [0] * (m + 1)
num = 0
for i in range(1, m + 1):
if group[i] > 0:
continue
if len(connmap[i]) ==... | s477434553 | Accepted | 1,490 | 50,760 | 1,065 |
def f(m, r):
connmap = [[] for _ in range(m + 1)]
for _ in range(r):
a, b = map(int, input().split())
connmap[a].append(b)
connmap[b].append(a)
group = [0] * (m + 1)
num = 0
for i in range(1, m + 1):
if group[i] > 0:
continue
num += 1
grou... |
s719815445 | p03449 | u626468554 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 306 | We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You ... | n = int(input())
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
ttl = 0
li1 = []
for i in range(n):
ttl += a1[i]
li1.append(ttl)
ttl = 0
li2 = []
for i in range(1,n+1):
ttl += a2[i*(-1)]
li2.append(ttl)
ans = 0
for i in range(n):
ans = max(ans,li1[i]+li2[i]) | s636271327 | Accepted | 17 | 3,064 | 353 | n = int(input())
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
ttl = 0
li1 = []
for i in range(n):
ttl += a1[i]
li1.append(ttl)
ttl = 0
li2 = []
for i in range(1,n+1):
ttl += a2[i*(-1)]
li2.append(ttl)
ans = 0
for i in range(n):
#print(li1[i]+li2[i])
ans = max(ans,li... |
s144140141 | p03485 | u833089798 | 2,000 | 262,144 | Wrong Answer | 27 | 9,048 | 71 | 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. | # -*- coding:utf-8 -*-
a, b = map(int, input().split())
print((a+b)/2)
| s509829301 | Accepted | 28 | 9,056 | 100 | # -*- coding:utf-8 -*-
from math import ceil
a, b = map(int, input().split())
print(ceil((a+b)/2))
|
s952037598 | p03777 | u686036872 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 109 | Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or Dishonest_. In this game, an honest player always tells the truth, and an dishonest player always tell lies. You are given two characters a and b as the input. Each of them is either `H` or `D`, and carries the following information: If a=`H`, AtCo... | a, b=input().split()
if a=='H' and b=='H':
print('H')
if a=='D' and b=='D':
print('H')
else:
print('D') | s889060369 | Accepted | 17 | 2,940 | 137 | a, b = map(str, input().split())
if a == "H" and b == "H":
print("H")
elif a == "D" and b == "D":
print("H")
else:
print("D") |
s425829710 | p02741 | u695199406 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,060 | 154 | Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 | list_1 = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
s = list_1[k-1:k+1]
print(s) | s448849210 | Accepted | 18 | 3,060 | 144 | list_1 = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(list_1[k-1]) |
s254939078 | p03377 | u424044793 | 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") | s053426300 | Accepted | 20 | 3,060 | 87 | a,b,x = map(int,input().split())
if a<=x<=(a+b):
print("YES")
else:
print("NO") |
s187187372 | p02262 | u264972437 | 6,000 | 131,072 | Wrong Answer | 30 | 7,776 | 537 | Shell Sort is a generalization of [Insertion Sort](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A) to arrange a list of $n$ elements $A$. 1 insertionSort(A, n, g) 2 for i = g to n-1 3 v = A[i] 4 j = i - g 5 while j >= 0 && A[j] > v 6 A[j+... | def insertionSort(A,n,g,cnt):
for i in range(g,n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
cnt += 1
A[j+g] = v
return A,cnt
def shellSort(A,n):
cnt = 0
m = n//2 + 1
G = [2*i + 1*(i==0) for i in range(m)[::-1]]
for g in G:
A,cnt = insertionSort(A,n,g,cnt)
return A... | s237960210 | Accepted | 20,960 | 55,232 | 647 | def insertionSort(A,n,g,cnt):
for i in range(g,n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
cnt += 1
A[j+g] = v
return A,cnt
def shellSort(A,n):
cnt = 0
G = [1]
while G[-1]*3+1 <= n:
G.append(G[-1]*3 + 1)
G = G[::-1]
m = len(G)
for g in G:
A,cnt = insertionSort... |
s714682643 | p04011 | u729119068 | 2,000 | 262,144 | Wrong Answer | 29 | 9,184 | 71 | There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee. | a,b,c,d=[int(input()) for i in range(4)]
print(c*min(a,b)+d*max(b-a,0)) | s480103769 | Accepted | 29 | 9,032 | 71 | a,b,c,d=[int(input()) for i in range(4)]
print(c*min(a,b)+d*max(a-b,0)) |
s170644289 | p03565 | u015593272 | 2,000 | 262,144 | Wrong Answer | 27 | 9,108 | 1,001 | E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One mo... | def main():
S_part = list(input())
T_hint = list(input())
N = len(S_part)
ans = []
for i in range(N):
index_init = i
if (index_init + len(T_hint) <= N):
s = S_part[index_init:index_init + len(T_hint)]
if ('?' in s):
FLA... | s465185388 | Accepted | 26 | 9,108 | 689 | S_hatena = input()
T_hint = input()
N = len(S_hatena)
ans_list = []
for i in range(N):
index_init = i
index_end = i + len(T_hint) - 1
s = S_hatena[index_init:index_end + 1]
FLAG = True
if (index_end < N):
for j in range(len(T_hint)):
if (s[j] != T_hint[j] and s[j] != ... |
s587400597 | p03658 | u870297120 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 109 | Snuke has N sticks. The length of the i-th stick is l_i. Snuke is making a snake toy by joining K of the sticks together. The length of the toy is represented by the sum of the individual sticks that compose it. Find the maximum possible length of the toy. | n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
a.reverse()
print(sum(a[0:k-1])) | s629064684 | Accepted | 17 | 2,940 | 107 | n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
a.reverse()
print(sum(a[0:k])) |
s033350715 | p03351 | u245487028 | 2,000 | 1,048,576 | Wrong Answer | 20 | 3,316 | 152 | Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either ... | a, b, c, d = map(int, input().split())
if abs(a-c) < d:
print("Yes")
elif (abs(a-b) < d) and (abs(b-c) < d):
print("Yes")
else:
print("No")
| s208159527 | Accepted | 18 | 2,940 | 155 | a, b, c, d = map(int, input().split())
if abs(a-c) <= d:
print("Yes")
elif (abs(a-b) <= d) and (abs(b-c) <= d):
print("Yes")
else:
print("No")
|
s297278266 | p03574 | u999799597 | 2,000 | 262,144 | Wrong Answer | 26 | 3,572 | 1,291 | 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())
mass = []
for i in range(h):
x = input()
mass.append([])
for j in range(w):
mass[i].append(x[j])
init = []
for i in range(h):
# x = input()
init.append([])
for j in range(w):
init[i].append(0)
for i in range(h):
for j in range(w):
if... | s368182954 | Accepted | 25 | 3,188 | 1,347 | h, w = map(int, input().split())
mass = []
for i in range(h):
x = input()
mass.append([])
for j in range(w):
mass[i].append(x[j])
init = []
for i in range(h):
# x = input()
init.append([])
for j in range(w):
init[i].append(0)
for i in range(h):
for j in range(w):
if... |
s311506158 | p03385 | u684084063 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 165 | You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`. | # -*- coding: utf-8 -*-
S = map(int,input().split())
if S=="abc" or S=="acb" or S=="bac" or S=="bca" or S=="cab" or S=="cba":
print("Yes")
else:
print("No")
| s585352468 | Accepted | 17 | 2,940 | 148 | # -*- coding: utf-8 -*-
S =input()
if S=="abc" or S=="acb" or S=="bac" or S=="bca" or S=="cab" or S=="cba":
print("Yes")
else:
print("No")
|
s346202946 | p02364 | u442472098 | 1,000 | 131,072 | Wrong Answer | 30 | 6,724 | 572 | Find the sum of weights of edges of the Minimum Spanning Tree for a given weighted undirected graph G = (V, E). | #!/usr/bin/env python3
V, E = map(int, input().split())
D = 0
vertices = []
for i in range(V):
vertices.append(i)
edges = []
for i in range(E):
s, t, d = map(int, input().split())
edges.append((s, t, d))
edges.sort(key=lambda x: x[2])
while edges:
if V == 0:
break
s, t, d = ed... | s712670690 | Accepted | 2,310 | 31,848 | 772 | #!/usr/bin/env python3
from collections import defaultdict
V, E = map(int, input().split())
D = 0
tree = []
vertices = defaultdict(set)
for i in range(V):
tree.append(i)
vertices[i].add(i)
edges = []
for i in range(E):
s, t, d = map(int, input().split())
edges.append((s, t, d))
edges.sort... |
s778517317 | p03447 | u265118937 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 125 | You went shopping to buy cakes and donuts with X yen (the currency of Japan). First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop. How much do you have left after shopping? | x = int(input())
a = int(input())
b = int(input())
cnt = 0
yen = x -a
while yen > 0:
yen -= b
cnt += 1
print(yen -cnt*b) | s613863823 | Accepted | 17 | 2,940 | 134 | x = int(input())
a = int(input())
b = int(input())
yen = x -a
while True:
yen -= b
if yen < 0:
yen += b
break
print(yen)
|
s833015161 | p03836 | u011062360 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 170 | 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, gx, gy = map(int, input().split())
print("U"*(gy-sy)+"R"*(gx-sx)+"D"*(gy-sy)+"L"*(gx-sx)+"L"+"U"*(gy-sy+1)+"R"*(gx-sx+1)+"D"+"R"+"D"*(gy-sy+1)+"L"*(gx-sx+1)+"D") | s538170406 | Accepted | 18 | 3,060 | 170 | sx, sy, gx, gy = map(int, input().split())
print("U"*(gy-sy)+"R"*(gx-sx)+"D"*(gy-sy)+"L"*(gx-sx)+"L"+"U"*(gy-sy+1)+"R"*(gx-sx+1)+"D"+"R"+"D"*(gy-sy+1)+"L"*(gx-sx+1)+"U") |
s246378829 | p03712 | u527993431 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 205 | 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())
L=[]
for i in range (H):
T=input()
L.append(T)
A="#"*(H+2)
for i in range (H+2):
if i==0 or i==H+1:
print(A)
else:
print("#",end="")
print(L[i-1],end="")
print("#") | s026932497 | Accepted | 17 | 3,060 | 205 | H,W=map(int,input().split())
L=[]
for i in range (H):
T=input()
L.append(T)
A="#"*(W+2)
for i in range (H+2):
if i==0 or i==H+1:
print(A)
else:
print("#",end="")
print(L[i-1],end="")
print("#") |
s588537799 | p00002 | u947762778 | 1,000 | 131,072 | Wrong Answer | 30 | 7,628 | 88 | Write a program which computes the digit number of sum of two integers a and b. | inputNums = list(map(int, input().split()))
print(len(str(inputNums[0] + inputNums[1]))) | s814189510 | Accepted | 60 | 7,652 | 151 | while True:
try:
inputNums = list(map(int, input().split()))
print(len(str(inputNums[0] + inputNums[1])))
except:
break |
s147121409 | p00016 | u548155360 | 1,000 | 131,072 | Wrong Answer | 30 | 5,728 | 304 | When a boy was cleaning up after his grand father passing, he found an old paper: In addition, other side of the paper says that "go ahead a number of steps equivalent to the first integer, and turn clockwise by degrees equivalent to the second integer". His grand mother says that Sanbonmatsu was standing at t... | # coding=utf-8
import math
x = 0
y = 0
direction = math.pi/2
while True:
d, a = map(int, input().split(','))
if d == 0 and a == 0:
break
x += d * math.cos(direction)
y += d * math.sin(direction)
direction -= a*math.pi/180
print('{0:.0f}'.format(x))
print('{0:.0f}'.format(y)) | s841221101 | Accepted | 30 | 5,732 | 332 | # coding=utf-8
import math
x = 0
y = 0
direction = math.pi/2
while True:
d, a = map(int, input().split(','))
if d == 0 and a == 0:
break
x += d * math.cos(direction)
y += d * math.sin(direction)
direction -= a*math.pi/180
print('{0:.0f}'.format(math.modf(x)[1]))
print('{0:.0f}'.format(math.... |
s179956714 | p03993 | u542190960 | 2,000 | 262,144 | Wrong Answer | 2,104 | 13,880 | 271 | 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())
a_list = list(map(int, input().split()))
cnt = 0
index_list = list(range(0,n,1))
print(index_list)
for i in (index_list):
if a_list[a_list[i]-1] == i+1:
cnt += 1
index_list.remove(a_list[i]-1)
index_list.remove(i)
print(cnt) | s243331323 | Accepted | 69 | 14,324 | 255 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(input())
a = list(map(int, input().split()))
cnt = 0
for i in range(n):
if a[a[i]-1] == i + 1:
cnt += 1
print(cnt//2) |
s936453600 | p03494 | u370429695 | 2,000 | 262,144 | Wrong Answer | 19 | 3,060 | 258 | 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())
li = list(map(int,input().split()))
split_cnt = 0
p = 0
while p == 0:
for i in range(len(li)):
if li[i] % 2 == 1:
p = 1
break
else:
li[i] = li[i] / 2
split_cnt += 1
print(split_cnt) | s394244841 | Accepted | 20 | 3,060 | 262 | n = int(input())
li = list(map(int,input().split()))
split_cnt = 0
p = 0
while p == 0:
for i in range(len(li)):
if li[i] % 2 == 1:
p = 1
break
else:
li[i] = li[i] / 2
split_cnt += 1
print(split_cnt - 1) |
s858587563 | p03351 | u516272298 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 112 | Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either ... | a,b,c,d = map(int,input().split())
if b-a <= d and c-b <= d and c-a <= d:
print("Yes")
else:
print("No") | s053161325 | Accepted | 17 | 2,940 | 126 | a,b,c,d = map(int,input().split())
if abs(b-a) <= d and abs(c-b) <= d or abs(c-a) <= d:
print("Yes")
else:
print("No") |
s420072289 | p03469 | u347397127 | 2,000 | 262,144 | Wrong Answer | 25 | 8,908 | 34 | On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date col... | S = input()
print(S[:2]+"8"+S[4:]) | s298728941 | Accepted | 29 | 8,948 | 35 | S = input()
print(S[:3]+"8"+S[4:])
|
s218741126 | p03380 | u426764965 | 2,000 | 262,144 | Wrong Answer | 2,104 | 14,348 | 487 | 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. | n = int(input())
a = sorted(map(int, input().split()))
print(a)
from operator import mul
from functools import reduce
def comb(n, r):
r = min(r, n-r)
numer = reduce(mul, range(n, n-r, -1), 1)
denom = reduce(mul, range(1, r+1), 1)
return numer // denom
from bisect import bisect_left
n = a[-1]
p = bisect_left(... | s004321577 | Accepted | 108 | 14,060 | 157 | n = int(input())
A = sorted(map(int, input().split()))
ans_n = A[-1]
ans_r = -1
for a in A:
if ans_r < min(a, ans_n - a):
ans_r = a
print(ans_n, ans_r) |
s606820788 | p02694 | u080685822 | 2,000 | 1,048,576 | Time Limit Exceeded | 2,206 | 16,908 | 95 | 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 abo... | x = int(input())
for n in 10 ** 10 ** 10:
if x <= (101 ** n) / (100 ** (n - 1)):
print(n) | s399873321 | Accepted | 21 | 9,060 | 99 | x = int(input())
n = 0
mon = 100
while mon < x:
mon *= 1.01
mon = int(mon)
n += 1
print(n) |
s098972020 | p02397 | u406002631 | 1,000 | 131,072 | Wrong Answer | 50 | 5,616 | 126 | Write a program which reads two integers x and y, and prints them in ascending order. | while True:
l = input().split()
b = int(l[0])
c = int(l[1])
if b == 0 and c == 0:
break
print(b,c) | s203013074 | Accepted | 60 | 5,608 | 175 | while True:
l = input().split()
b = int(l[0])
c = int(l[1])
if b == 0 and c == 0:
break
if b < c:
print(b, c)
else:
print(c, b) |
s214007011 | p03474 | u859897687 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 65 | The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom. | a,b=map(int,input().split())
s=input()
print(s[:a+1]+"-"+s[a+1:]) | s467438291 | Accepted | 18 | 2,940 | 106 | a,b=map(int,input().split())
s=input()
if s.count("-")<2 and s[a]=="-":
print("Yes")
else:
print("No") |
s812748008 | p02694 | u688587139 | 2,000 | 1,048,576 | Wrong Answer | 23 | 9,156 | 108 | 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 abo... | import math
a = 100
n = 0
X = int(input())
while a <= X:
n += 1
a = math.floor(a * 1.01)
print(n) | s253498758 | Accepted | 21 | 9,160 | 108 | import math
a = 100
n = 0
X = int(input())
while a < X:
n += 1
a = math.floor(a * 1.01)
print(n)
|
s176879858 | p03645 | u013408661 | 2,000 | 262,144 | Wrong Answer | 354 | 48,640 | 261 | 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 Snuk... | import sys
n,m=map(int,input().split())
l=[[int(i) for i in l.split()] for l in sys.stdin]
possible=[]
possible2=[]
for i in l:
if i[0]==1:
possible.append(i[1])
for i in l:
if i[1]==n:
possible2.append(i[0])
print(len(set(possible)&set(possible2))) | s898193123 | Accepted | 348 | 48,552 | 308 | import sys
n,m=map(int,input().split())
l=[[int(i) for i in l.split()] for l in sys.stdin]
possible=[]
possible2=[]
for i in l:
if i[0]==1:
possible.append(i[1])
for i in l:
if i[1]==n:
possible2.append(i[0])
if len(set(possible)&set(possible2))>0:
print('POSSIBLE')
else:
print('IMPOSSIBLE') |
s269760557 | p03305 | u202826462 | 2,000 | 1,048,576 | Wrong Answer | 2,111 | 116,332 | 1,884 | Kenkoooo is planning a trip in Republic of Snuke. In this country, there are n cities and m trains running. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Any city can be reached from any city by changing trains. Two currencies are used in the country: yen and snuuk.... | import heapq
def dijkstra(s):
d = [float("inf")] * (n+1)
used = [True] * (n+1)
d[s] = 0
used[s] = False
edgelist = []
for e in graph_a[s]:
heapq.heappush(edgelist,e)
while len(edgelist):
minedge = heapq.heappop(edgelist)
if not used[minedge[1]]:
... | s905807736 | Accepted | 1,606 | 90,184 | 1,211 | import heapq
INF = 10**18
def dijkstra(s, edge, n):
d = [INF] * n
used = [True] * n #True: not used
d[s] = 0
used[s] = False
edgelist = []
for e in edge[s]:
heapq.heappush(edgelist,e)
while len(edgelist):
minedge = heapq.heappop(edgelist)
if not used[minedge[1]]:
... |
s879678034 | p02645 | u011277545 | 2,000 | 1,048,576 | Wrong Answer | 21 | 9,024 | 22 | When you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters. You have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him. | S=input()
print(S[:2]) | s578890014 | Accepted | 26 | 9,084 | 22 | S=input()
print(S[:3]) |
s748427237 | p04030 | u405256066 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 229 | Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this stri... | from sys import stdin
s = (stdin.readline().rstrip())
ans = ""
for i in s:
if i == "0":
ans = ans + "0"
elif i == "1":
ans = "1" + ans
elif i == "B" and len(ans) != 0:
ans = ans[:-1]
print(ans) | s680804389 | Accepted | 17 | 3,060 | 229 | from sys import stdin
s = (stdin.readline().rstrip())
ans = ""
for i in s:
if i == "0":
ans = ans + "0"
elif i == "1":
ans = ans + "1"
elif i == "B" and len(ans) != 0:
ans = ans[:-1]
print(ans) |
s372114743 | p02399 | u921038488 | 1,000 | 131,072 | Wrong Answer | 20 | 5,612 | 139 | 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) | def getCal(a,b):
return a+b, a%b, float(a/b)
a, b = map(int, input().split())
d, r, f = getCal(a,b)
print("{} {} {}".format(d, r, f)) | s856695974 | Accepted | 20 | 5,596 | 66 | a, b = map(int, input().split())
print(a//b, a%b, '%.5f' % (a/b)) |
s091061855 | p03162 | u280978334 | 2,000 | 1,048,576 | Wrong Answer | 1,163 | 35,540 | 374 | Taro's summer vacation starts tomorrow, and he has decided to make plans for it now. The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day: * A: Swim in the sea. Gain a_i points of happiness. * B: Catch bugs in the mountains. Gain... | n = int(input())
import numpy as np
abc = np.array([[int(x) for x in input().split()] for y in range(n)],dtype=int)
dp = np.zeros((n,3),dtype=int)
dp[0] = abc[0]
for p in range(1,n):
dp[p][0] = max(dp[p-1][1],dp[p-1][2]) + abc[p][0]
dp[p][1] = max(dp[p-1][0],dp[p-1][2]) + abc[p][1]
dp[p][2] = max(dp[p-1][0]... | s141814636 | Accepted | 1,093 | 35,552 | 364 | n = int(input())
import numpy as np
abc = np.array([[int(x) for x in input().split()] for y in range(n)],dtype=int)
dp = np.zeros((n,3),dtype=int)
dp[0] = abc[0]
for p in range(1,n):
dp[p][0] = max(dp[p-1][1],dp[p-1][2]) + abc[p][0]
dp[p][1] = max(dp[p-1][0],dp[p-1][2]) + abc[p][1]
dp[p][2] = max(dp[p-1][0]... |
s593464690 | p02612 | u383416302 | 2,000 | 1,048,576 | Wrong Answer | 30 | 9,080 | 106 | 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. | def main():
n = int(input())
print(n - (n // 1000) * 1000)
if __name__ == "__main__":
main() | s397577206 | Accepted | 25 | 9,148 | 91 | def main():
n = int(input())
print(-n%1000)
if __name__ == "__main__":
main() |
s623625321 | p02607 | u260068288 | 2,000 | 1,048,576 | Wrong Answer | 30 | 9,060 | 146 | We have N squares assigned the numbers 1,2,3,\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i. How many squares i satisfy both of the following conditions? * The assigned number, i, is odd. * The written integer is odd. | n= int(input())
l=list(map(int,input().split()))
count = 0
for i in range(0,n,2):
print(l[i]&1)
if l[i]&1:
count += 1
print(count) | s499094955 | Accepted | 26 | 9,100 | 128 | n= int(input())
l=list(map(int,input().split()))
count = 0
for i in range(0,n,2):
if l[i]&1:
count += 1
print(count) |
s037772231 | p03386 | u863044225 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 173 | 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. | a,b,k=map(int,input().split())
x=[]
for i in range(a,min(b+1,a+k)):
x.append(i)
for i in range(max(a,b-k+1),b+1):
x.append(i)
ans=list(set(x))
for i in ans:
print(i) | s639950576 | Accepted | 17 | 3,060 | 184 | a,b,k=map(int,input().split())
x=[]
for i in range(a,min(b+1,a+k)):
x.append(i)
for i in range(max(a,b-k+1),b+1):
x.append(i)
ans=list(set(x))
ans.sort()
for i in ans:
print(i) |
s982926836 | p03711 | u272377260 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 275 | Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group. | x, y = map(int, input().split())
group_1 = (1,2,5,7,8,10,12)
group_2 = (4,7,9,11)
group_3 = (2,)
if x in group_1 and y in group_1:
print('Yes')
elif x in group_2 and y in group_2:
print('Yes')
elif x in group_3 and y in group_3:
print('Yes')
else:
print('No') | s226805531 | Accepted | 18 | 3,060 | 275 | x, y = map(int, input().split())
group_1 = (1,3,5,7,8,10,12)
group_2 = (4,6,9,11)
group_3 = (2,)
if x in group_1 and y in group_1:
print('Yes')
elif x in group_2 and y in group_2:
print('Yes')
elif x in group_3 and y in group_3:
print('Yes')
else:
print('No') |
s021994547 | p03351 | u287431190 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 104 | Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either ... | a,b,c,d = map(int, input().split())
if (b-a)<=d:
if (c-b)<=d:
print('No')
exit()
print('Yes') | s300762906 | Accepted | 17 | 2,940 | 152 | a,b,c,d = map(int, input().split())
if abs(c-a)<=d:
print('Yes')
exit()
if abs(b-a)<=d:
if abs(c-b)<=d:
print('Yes')
exit()
print('No') |
s139942553 | p02742 | u733167185 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 115 | 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
H, W = map(int, input().split())
if H*W % 2 == 0:
print(H*W/2)
else:
print(math.floor(H*W/2)+1) | s581028115 | Accepted | 18 | 2,940 | 94 | H, W = map(int, input().split())
if H == 1 or W == 1:
print(1)
else:
print((H*W+1)//2) |
s839568883 | p04043 | u903005414 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 107 | 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 = sorted(list(map(int, input().split())))
print('YES' if A[0] == 5 and A[1] == 7 and A[2] == 7 else 'NO') | s175514380 | Accepted | 17 | 2,940 | 108 | A = sorted(list(map(int, input().split())))
print('YES' if A[0] == 5 and A[1] == 5 and A[2] == 7 else 'NO')
|
s573413560 | p02646 | u911612592 | 2,000 | 1,048,576 | Wrong Answer | 26 | 9,144 | 191 | 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 ... | A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())
AB = abs(A - B)
VW = V - W
if VW == 0:
print("No")
elif AB <= VW * T:
print("Yes")
else:
print("No") | s729652814 | Accepted | 23 | 9,180 | 192 | A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())
AB = abs(A - B)
VW = V - W
if VW == 0:
print("NO")
elif AB <= VW * T:
print("YES")
else:
print("NO")
|
s253123178 | p03565 | u480847874 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 570 | E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One mo... | NOT_FOUND = 'UNRESTORABLE'
def m():
S = list(str(input()))
T = list(str(input()))
first = 0
end = 0
for i in range(len(S) + 1 - len(T)):
for k in range(len(T)):
if S[i+k] != T[k] and S[i+k] != '?':
break
if k == len(T) - 1:
first = i
... | s262189637 | Accepted | 17 | 3,064 | 582 | NOT_FOUND = 'UNRESTORABLE'
def m():
S = list(str(input()))
T = list(str(input()))
first = 0
end = 0
for i in range(len(S) + 1 - len(T)):
for k in range(len(T)):
if S[i + k] != T[k] and S[i + k] != '?':
break
if k == len(T) - 1:
first ... |
s551265011 | p02393 | u569585396 | 1,000 | 131,072 | Wrong Answer | 30 | 7,644 | 100 | Write a program which reads three integers, and prints them in ascending order. | x = input().split()
i = list(map(int,x))
a = i[0]
b = i[1]
c = i[2]
print('{} {} {}'.format(c,b,a)) | s935389820 | Accepted | 30 | 7,664 | 92 | x = input().split()
i = list(map(int,x))
i.sort()
print('{} {} {}'.format(i[0],i[1],i[2])) |
s664409041 | p03485 | u960513073 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 57 | You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer. | a, b = map(int, input().split())
print(int((a+b)/2) + 1) | s243546957 | Accepted | 17 | 2,940 | 161 | a, b = list(map(int, input().split()))
c = a+b
if c%2 == 0:
print(int(c/2))
else:
print(int(c/2) + 1) |
s124721813 | p02388 | u387507798 | 1,000 | 131,072 | Wrong Answer | 20 | 5,528 | 16 | Write a program which calculates the cube of a given integer x. | print(input())
| s401964620 | Accepted | 20 | 5,576 | 31 | n = int(input())
print(n*n*n)
|
s466298205 | p00375 | u888548672 | 1,000 | 262,144 | Wrong Answer | 20 | 5,580 | 27 | In Japan, temperature is usually expressed using the Celsius (℃) scale. In America, they used the Fahrenheit (℉) scale instead. $20$ degrees Celsius is roughly equal to $68$ degrees Fahrenheit. A phrase such as "Today’s temperature is $68$ degrees" is commonly encountered while you are in America. A value in Fahrenhei... | print((int(input())-30)/2)
| s548486311 | Accepted | 20 | 5,580 | 32 | print(int((int(input())-30)/2))
|
s559221849 | p03456 | u305732215 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 150 | 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()
ab = int(a + b)
rt = round(ab ** 0.5, 1)
rts = str(rt)
print(rts)
if rts[-1] == '0':
print('Yes')
else:
print('No')
| s407429139 | Accepted | 17 | 2,940 | 121 | a, b = input().split()
ab = int(a + b)
rt = round(ab ** 0.5, 1)
if rt.is_integer():
print('Yes')
else:
print('No')
|
s094077241 | p03997 | u367373844 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 101 | 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. | up = int(input())
down = int(input())
high = int(input())
area = (up + down ) * high / 2
print(area) | s079093741 | Accepted | 17 | 2,940 | 105 | up = int(input())
down = int(input())
high = int(input())
area = (up + down ) * high / 2
print(int(area)) |
s872395483 | p03385 | u759412327 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 75 | You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`. | a = input()
b = sorted(a)
if b == "abc":
print("Yes")
else:
print("No") | s432561321 | Accepted | 29 | 9,080 | 59 | if len(set(input()))==3:
print("Yes")
else:
print("No") |
s465573508 | p02277 | u805716376 | 1,000 | 131,072 | Wrong Answer | 20 | 5,608 | 893 | Let's arrange a deck of cards. Your task is to sort totally n cards. A card consists of a part of a suit (S, H, C or D) and an number. Write a program which sorts such cards based on the following pseudocode: Partition(A, p, r) 1 x = A[r] 2 i = p-1 3 for j = p to r-1 4 do if A[j] <= x 5 then ... | a = []
n = int(input())
for _ in range(n):
s, i = input().split()
a += [(s, int(i))]
print(a)
b = a[:]
def partition(a, left, right):
standard = a[right][1]
cnt = left
for i in range(left, right+1):
if i == right:
if a[i][1] <= standard:
a[i],a[cnt] = a[cnt], a[i... | s451227767 | Accepted | 1,050 | 24,976 | 792 | a = []
b = {}
n = int(input())
for _ in range(n):
s, i = input().split()
a += [(s, int(i))]
b.setdefault(int(i), []).append(s)
b = {val: iter(s).__next__ for val, s in b.items()}
def partition(a, left, right):
standard = a[right][1]
cnt = left
for i in range(left, right):
if a[i][1] <= ... |
s366389460 | p02606 | u152614052 | 2,000 | 1,048,576 | Wrong Answer | 30 | 9,164 | 103 | How many multiples of d are there among the integers between L and R (inclusive)? | l, r, d = map(int,input().split())
ans = 0
for i in range(l, r+1):
if i % d == 0:
ans += 1 | s284096444 | Accepted | 27 | 9,092 | 115 | l, r, d = map(int,input().split())
ans = 0
for i in range(l, r+1):
if i % d == 0:
ans += 1
print(ans) |
s607508653 | p02645 | u265118937 | 2,000 | 1,048,576 | Wrong Answer | 22 | 9,012 | 63 | When you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters. You have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him. | s = input()
print(s[2], end="")
print(s[1], end="")
print(s[0]) | s035715470 | Accepted | 26 | 8,932 | 24 | s = input()
print(s[:3]) |
s803714182 | p00500 | u352394527 | 8,000 | 131,072 | Wrong Answer | 20 | 5,600 | 334 | JOI decided to play a game with his friends. Her N players participate in this game. The rules for one game are as follows: Each player submits a card with a number between 1 and 100 of her choice. Each player gets the same score as the number he wrote if no one else has written the same number. If someone else wrote t... | n = int(input())
lst = [list(map(int,input().split())) for i in range(n)]
p = [0 for i in range(n)]
for i in range(3):
dic = [[] for _ in range(101)]
for j in range(n):
print(lst)
dic[lst[j][i]].append(j)
for x in range(101):
l = dic[x]
if lst:
if len(l) == 1:
p[l[0]] += x
for i in ... | s013940872 | Accepted | 20 | 5,624 | 319 | n = int(input())
lst = [list(map(int,input().split())) for i in range(n)]
p = [0 for i in range(n)]
for i in range(3):
dic = [[] for _ in range(101)]
for j in range(n):
dic[lst[j][i]].append(j)
for x in range(101):
l = dic[x]
if lst:
if len(l) == 1:
p[l[0]] += x
for i in p:
print(i)
|
s739081942 | p03795 | u865413330 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 47 | 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 ... | n = int(input())
print(800 * n - 200 * n // 15) | s852897609 | Accepted | 18 | 2,940 | 49 | n = int(input())
print(800 * n - 200 * (n // 15)) |
s332284314 | p03557 | u519923151 | 2,000 | 262,144 | Wrong Answer | 2,105 | 45,440 | 516 | The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower. He has N parts for each of the three categories. The size of the i-th upper ... |
n= int(input())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
cl = list(map(int, input().split()))
lal = sorted(al,reverse = True)
lbl = sorted(bl,reverse = True)
lcl = sorted(cl,reverse = True)
res =0
for i in range(n):
x = lcl[i]
for j in range(n):
y = lbl[j]
if ... | s934535819 | Accepted | 346 | 23,328 | 369 | n= int(input())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
cl = list(map(int, input().split()))
lal = sorted(al)
lbl = sorted(bl)
lcl = sorted(cl)
from bisect import bisect_left, bisect_right
res = 0
for i in range(n):
bx = lbl[i]
ax = bisect_left(lal,bx)
cx = n - bisec... |
s734661554 | p03943 | u020176853 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 194 | 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. Not... | #20:48
a = list(map(int, input().split()))
lmax = max(a)
lmin = min(a)
left = int(lmax - lmin)
print(left)
if left == a[0] or left == a[1] or left == a[2]:
print("Yes")
else:
print("No") | s682385300 | Accepted | 17 | 2,940 | 117 | a = list(map(int, input().split()))
a.sort(reverse=True)
if a[0] == a[1]+a[2]:
print("Yes")
else:
print("No") |
s820093391 | p03407 | u588633699 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 81 | An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan. | A, B, C = map(int, input().split())
if A+B<=C:
print("Yes")
else:
print("No") | s756990341 | Accepted | 20 | 2,940 | 82 | A, B, C = map(int, input().split())
if A+B>=C:
print("Yes")
else:
print("No") |
s914201123 | p03730 | u961595602 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 144 | We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objecti... | A, B, C = map(int, input().split())
a = A % B
for i in range(1, B + 1):
if (a * i) % B == C:
print('Yes')
exit()
print('No') | s146245586 | Accepted | 17 | 2,940 | 144 | A, B, C = map(int, input().split())
a = A % B
for i in range(1, B + 1):
if (a * i) % B == C:
print('YES')
exit()
print('NO') |
s235870820 | p03044 | u528005130 | 2,000 | 1,048,576 | Wrong Answer | 390 | 4,720 | 257 | We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied: * For any two vertices... | # coding: utf-8
# Your code here!
N = int(input())
edges = [0] * N
for i in range(N-1):
u, v, w = map(int, input().rstrip().split(' '))
if w % 2 == 0:
edges[u-1] = 1
edges[v-1] = 1
for edge in edges:
print(edge)
| s440486520 | Accepted | 873 | 45,520 | 625 | # coding: utf-8
# Your code here!
N = int(input())
edges = [[] for _ in range(N)]
for i in range(N-1):
u, v, w = map(int, input().rstrip().split(' '))
u = u - 1
v = v - 1
edges[u].append([v, w])
edges[v].append([u, w])
from collections import deque
temp = deque([[0, 0]])
color = [-1] ... |
s140781998 | p03090 | u706414019 | 2,000 | 1,048,576 | Wrong Answer | 29 | 9,532 | 432 | You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved... | import sys,math,collections,itertools
input = sys.stdin.readline
N=int(input())
if N%2 == 0:
for i in range(1,N):
for j in range(i+1,N+1):
if i+j == N+1:
continue
else:
print(i,j)
else:
for i in range(1,N):
for j in range(i+1,N+1):
... | s560005519 | Accepted | 41 | 9,820 | 575 | import sys,math,collections,itertools
input = sys.stdin.readline
graph = []
cnt = 0
N=int(input())
if N%2 == 0:
for i in range(1,N):
for j in range(i+1,N+1):
if i+j == N+1:
continue
else:
cnt+=1
graph.append([i,j])
... |
s309377864 | p03494 | u100800700 | 2,000 | 262,144 | Wrong Answer | 20 | 2,940 | 228 | There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform. | N = input()
A = list(map(int,input().split()))
count = 0
for a in A:
count_local = 0
while a%2 == 0:
a = a/2
count_local += 1
if count_local >= count:
count = count_local
print(count) | s703004478 | Accepted | 19 | 3,064 | 228 | c=0;N,*A=map(int,open(0).read().split())
while all(map(lambda i:i&1==0,A)):
A=list(map(lambda i:i>>1,A));c+=1
print(c) |
s170093888 | p03354 | u968846084 | 2,000 | 1,048,576 | Wrong Answer | 2,104 | 39,736 | 1,526 | We have a permutation of the integers from 1 through N, p_1, p_2, .., p_N. We also have M pairs of two integers between 1 and N (inclusive), represented as (x_1,y_1), (x_2,y_2), .., (x_M,y_M). AtCoDeer the deer is going to perform the following operation on p as many times as desired so that the number of i (1 ≤ i ≤ N)... | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = ... | s567872629 | Accepted | 716 | 39,776 | 1,657 | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = ... |
s306854143 | p03502 | u919633157 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 114 | 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()
fx=0
for i in n:
fx+=int(i)
print('{}:{}'.format(n,fx))
print('Yes') if int(n)%fx==0 else print('No')
| s823936129 | Accepted | 17 | 2,940 | 75 | n=int(input())
print('Yes' if n%sum([int(i) for i in str(n)])==0 else 'No') |
s926836364 | p03544 | u620846115 | 2,000 | 262,144 | Wrong Answer | 26 | 9,056 | 75 | It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2) | n= int(input())
a,b,c = 2,1,3
for i in range(n-1):
a,b,c=b,c,b+c
print(a) | s028345877 | Accepted | 31 | 9,160 | 73 | n= int(input())
a,b,c = 2,1,3
for i in range(n):
a,b,c=b,c,b+c
print(a) |
s163474444 | p03486 | u336564899 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 196 | You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order. | S = list(input())
T = list(input())
S.sort(reverse=False)
T.sort(reverse=True)
S_str = "".join(S)
T_str = "".join(T)
print(S)
print(T)
if S_str < T_str:
print("Yes")
else:
print("No")
| s505692850 | Accepted | 17 | 3,064 | 177 | S = list(input())
T = list(input())
S.sort(reverse=False)
T.sort(reverse=True)
S_str = "".join(S)
T_str = "".join(T)
if S_str < T_str:
print("Yes")
else:
print("No")
|
s110936323 | p03471 | u086624329 | 2,000 | 262,144 | Wrong Answer | 26 | 3,060 | 395 | 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 s in range(y//10000):
for t in range(y//5000):
for u in range(y//1000):
if 10000*s+5000*t+1000*u==y:
print(s,t,u)
break
else:
continue
break
else:
... | s299954909 | Accepted | 856 | 3,188 | 384 | n,y=map(int,input().split())
ans=0
for i in range(y//10000,-1,-1):
nokori=(y-i*10000)
for j in range(min(n-i,nokori//5000),-1,-1):
nokori2=nokori-j*5000
if 10000*i+5000*j+1000*(n-i-j)==y:
print(i,j,n-i-j)
ans=1
break
else:
c... |
s308394105 | p03380 | u932868243 | 2,000 | 262,144 | Wrong Answer | 76 | 14,060 | 154 | 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. | n=int(input())
l=list(map(int,input().split()))
m=max(l)
if m%2!=0:
med=(m+1)//2
else:
med=m//2
mi=m
for ll in l:
mi=min(mi,abs(ll-med))
print(m,mi) | s057290824 | Accepted | 76 | 14,052 | 212 | n=int(input())
l=list(map(int,input().split()))
m=max(l)
l.remove(m)
if m%2!=0:
med=(m+1)//2
else:
med=m//2
mi=m
for ll in l:
mi=min(mi,abs(ll-med))
if med+mi in l:
print(m,med+mi)
else:
print(m,med-mi) |
s813238448 | p04030 | u052332717 | 2,000 | 262,144 | Wrong Answer | 19 | 3,060 | 222 | Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this stri... | li = list(input())
string = ''
for item in li:
if item == '0':
string += '0'
elif item == '1':
string += '1'
else:
string = string[:0]
print(string)
| s159914204 | Accepted | 19 | 2,940 | 185 | s = input()
ans = ''
for i in s:
if i == '1':
ans += '1'
if i == '0':
ans += '0'
if i == 'B':
if len(ans)>0:
ans = ans[:-1]
print(ans)
|
s042541364 | p03816 | u761989513 | 2,000 | 262,144 | Wrong Answer | 2,104 | 21,964 | 406 | Snuke has decided to play a game using cards. He has a deck consisting of N cards. On the i-th card from the top, an integer A_i is written. He will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of... | import collections
from operator import itemgetter
n = int(input())
a = sorted(list(map(int, input().split())))
ac = collections.Counter(a).most_common()
ac = sorted(ac, key=itemgetter(0))
nokori = 0
for i in ac:
if i[1] > 3:
a = a[:nokori] + a[i[1] - 1 + nokori:]
nokori += 1
else:
use ... | s684211970 | Accepted | 46 | 14,564 | 89 | n = int(input())
a = list(map(int, input().split()))
b = len(set(a))
print(b - 1 + b % 2) |
s318470002 | p03545 | u608726540 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 545 | 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 in... | s=input()
a=int(s[0])
b=int(s[1])
c=int(s[2])
d=int(s[3])
for i in range(-1,2,2):
for j in range(-1,2,2):
for k in range(-1,2,2):
if i ==-1:
a_b='-'
else:
a_b='+'
if j ==-1:
b_c='-'
else:
b_c='+'... | s624121555 | Accepted | 17 | 3,064 | 485 | s=input()
op_cnt=len(s)-1
for i in range(2**op_cnt):
t=int(s[0])
op=['-']*op_cnt
for j in range(op_cnt):
ans=''
if (i>>j &1):
op[op_cnt-1-j]='+'
for k in range(op_cnt):
if op[k]=='-':
t-=int(s[k+1])
else:
t+=i... |
s323252975 | p02613 | u805852597 | 2,000 | 1,048,576 | Wrong Answer | 166 | 9,224 | 305 | 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`,... | n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
s = str(input())
if s == 'AC':
ac += 1
if s == 'WA':
wa += 1
if s == 'TLE':
tle += 1
if s == 'RE':
re += 1
print('AC x',ac)
print('WA x',wa)
print('TLE x',tle)
print('RE x',ac)
| s533805912 | Accepted | 164 | 9,200 | 305 | n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
s = str(input())
if s == 'AC':
ac += 1
if s == 'WA':
wa += 1
if s == 'TLE':
tle += 1
if s == 'RE':
re += 1
print('AC x',ac)
print('WA x',wa)
print('TLE x',tle)
print('RE x',re)
|
s726678715 | p03433 | u086856505 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 89 | 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') | s785116414 | Accepted | 18 | 2,940 | 89 | N = int(input())
A = int(input())
if N % 500 <= A:
print('Yes')
else:
print('No') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.