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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s644170469 | p03024 | u879077265 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 85 | Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S cons... | S = input()
t = S.count("x")
if t <= 7:
print("Yes")
else:
print("No")
| s032646098 | Accepted | 17 | 2,940 | 86 | S = input()
t = S.count("x")
if t <= 7:
print("YES")
else:
print("NO")
|
s184630832 | p03636 | u853900545 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 36 | The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way. | s=input()
print(s[0]+'len(s)'+s[-1]) | s047065288 | Accepted | 17 | 2,940 | 46 | s=input()
a=len(s)-2
print(s[0]+str(a)+s[-1])
|
s963042394 | p03434 | u557437077 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 203 | We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the c... | n = input()
a = [int(i) for i in input().split()]
a = sorted(a)
alice = 0
bob = 0
for i in reversed(range(len(a))):
if i % 2 == 0:
alice += a[i]
else:
bob += a[i]
print(alice-bob) | s040012186 | Accepted | 17 | 3,060 | 200 | n = input()
a = [int(i) for i in input().split()]
a = sorted(a)
alice = 0
bob = 0
for i in range(len(a)):
if i % 2 == 0:
alice += a[-i-1]
else:
bob += a[-i- 1]
print(alice-bob) |
s100959612 | p03473 | u786020649 | 2,000 | 262,144 | Wrong Answer | 28 | 9,080 | 25 | How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December? | print(24+int(input())%24) | s653112244 | Accepted | 26 | 9,152 | 26 | print(48-int(input())%24)
|
s398308816 | p02412 | u546968095 | 1,000 | 131,072 | Wrong Answer | 30 | 5,652 | 312 | Write a program which identifies the number of combinations of three integers which satisfy the following conditions: * You should select three distinct integers from 1 to n. * A total sum of the three integers is x. For example, there are two combinations for n = 5 and x = 9. * 1 + 3 + 5 = 9 * 2 + 3 + 4 = 9 | import math
while True:
n,x = map(int,input().split())
if n == x == 0:
break
c = 0
for i in range(math.ceil(x/3), x-3):
for j in range(math.ceil(i/2), i):
k = i - j
if x == i + j + k:
#print(x, i, j, k)
c += 1
print(c)
| s180606376 | Accepted | 490 | 5,596 | 272 | while True:
n,x = map(int,input().split())
if n == x == 0:
break
n = n + 1
c = 0
for i in range(1,n):
for j in range(i+1,n):
for k in range(j+1,n):
if x == i + j + k:
c += 1
print(c)
|
s494841186 | p03569 | u754022296 | 2,000 | 262,144 | Wrong Answer | 301 | 3,316 | 228 | We have a string s consisting of lowercase English letters. Snuke can perform the following operation repeatedly: * Insert a letter `x` to any position in s of his choice, including the beginning and end of s. Snuke's objective is to turn s into a palindrome. Determine whether the objective is achievable. If it is ... | s = input()
ans = 0
while s:
if s[0] == s[-1]:
s = s[1:-2]
else:
if s[0] == "x":
ans += 1
s = s[1:]
elif s[-1] == "x":
ans += 1
s = s[:-1]
else:
print(-1)
exit()
print(ans) | s243625806 | Accepted | 309 | 3,316 | 228 | s = input()
ans = 0
while s:
if s[0] == s[-1]:
s = s[1:-1]
else:
if s[0] == "x":
ans += 1
s = s[1:]
elif s[-1] == "x":
ans += 1
s = s[:-1]
else:
print(-1)
exit()
print(ans) |
s721124918 | p03711 | u975676823 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 213 | 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. | a, b = map(int, input().split())
if(a in [4, 6, 9, 11]):
print("YES" if b in [4, 6, 9, 11] else "NO")
elif(a in [1, 3, 5, 7, 8, 10, 12]):
print("YES" if b in [1, 3, 5, 7, 8, 10, 12] else "NO")
else:
print("NO") | s523910885 | Accepted | 17 | 3,064 | 217 | a, b = map(int, input().split())
if(a in [4, 6, 9, 11]):
print("Yes" if (b in [4, 6, 9, 11]) else "No")
elif(a in [1, 3, 5, 7, 8, 10, 12]):
print("Yes" if (b in [1, 3, 5, 7, 8, 10, 12]) else "No")
else:
print("No") |
s282669725 | p03697 | u319805917 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 203 | You are given two integers A and B as the input. Output the value of A + B. However, if A + B is 10 or greater, output `error` instead. | a=input()
LIs=list(a)
count=0
for i in range(len(LIs)):
for g in range (len(LIs)):
if LIs[i]==LIs[g]:
count+=1
if count==0:
print("yes")
else:
print("no") | s440486559 | Accepted | 18 | 2,940 | 82 | a,b=map(int,input().split())
if a+b>=10:
print("error")
else:
print(a+b) |
s304069826 | p03139 | u286955577 | 2,000 | 1,048,576 | Wrong Answer | 18 | 2,940 | 147 | We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A respondents answered "yes" to Question 1, and B respondents answ... | def solve(N, A, B):
maxNum = max(A, B)
minNum = max(0, N - (A + B))
print(maxNum, minNum)
N, A, B = map(int, input().split())
solve(N, A, B) | s846606817 | Accepted | 17 | 3,064 | 148 | def solve(N, A, B):
maxNum = min(A, B)
minNum = max(0, (A + B) - N)
print(maxNum, minNum)
N, A, B = map(int, input().split())
solve(N, A, B)
|
s686095770 | p02795 | u815763296 | 2,000 | 1,048,576 | Wrong Answer | 27 | 9,188 | 321 | 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... | import sys
H = int(input())
W = int(input())
N = int(input())
X = max(H, W)
Y = min(H, W)
count = 0
total = 0
for i in range(Y):
total += X
count += 1
if count >= N:
print(count)
sys.exit()
for i in range(X):
total += Y
count += 1
if count >= N:
print(count)
break... | s677472079 | Accepted | 28 | 9,092 | 322 | import sys
H = int(input())
W = int(input())
N = int(input())
X = max(H, W)
Y = min(H, W)
count = 0
total = 0
for _ in range(Y):
total += X
count += 1
if total >= N:
print(count)
sys.exit()
for _ in range(X):
total += Y
count += 1
if ctotal >= N:
print(count)
brea... |
s506243424 | p00052 | u990228206 | 1,000 | 131,072 | Wrong Answer | 260 | 5,596 | 322 | n! = n × (n − 1) × (n − 2) × ... × 3 × 2 × 1 を n の階乗といいます。例えば、12 の階乗は 12! = 12 × 11 × 10 × 9 × 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1 = 479001600 となり、末尾に 0 が 2 つ連続して並んでいます。 整数 n を入力して、n! の末尾に連続して並んでいる 0 の数を出力するプログラムを作成してください。ただし、n は 20000 以下の正の整数とします。 | while 1:
try:
zero=0
number=1
n=int(input())
for i in range(1,n+1):
number*=i
while len(str(number))>7:number=int(str(number)[1:])
while number%10==0:
zero+=1
number=int(number/10)
print(zero)
except:brea... | s526695858 | Accepted | 260 | 5,588 | 274 | while 1:
zero=0
number=1
n=int(input())
if n==0:break
for i in range(1,n+1):
number*=i
while len(str(number))>7:number=int(str(number)[1:])
while number%10==0:
zero+=1
number=int(number/10)
print(zero)
|
s469877092 | p02396 | u427088273 | 1,000 | 131,072 | Wrong Answer | 20 | 7,552 | 109 | In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are give... | num = list(map(int,input().split()))
for i,s in enumerate(num,1):
print("Case {0}: {1}".format(i,s)) | s672760380 | Accepted | 150 | 7,652 | 160 | count = 0
while(True):
num = int(input())
if num == 0:
break
count += 1
print("Case {0}: {1}".format(count,num)) |
s911961696 | p03456 | u743164083 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 91 | 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. | n = input().split()
x = int("".join(n))
print("Yes") if x%x**0.5 == x**0.5 else print("No") | s688248469 | Accepted | 17 | 2,940 | 92 | n = input().split()
x = int("".join(n))**0.5
print("Yes") if x.is_integer() else print("No") |
s740494678 | p03546 | u293992530 | 2,000 | 262,144 | Wrong Answer | 40 | 9,504 | 704 | Joisino the magical girl has decided to turn every single digit that exists on this world into 1. Rewriting a digit i with j (0≤i,j≤9) costs c_{i,j} MP (Magic Points). She is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains a digit between 0 and... | import sys
sys.setrecursionlimit(2147483647)
input=sys.stdin.readline
import math
from heapq import heappush, heappop
def solve(h,w,tables,A):
for i in range(10):
for j in range(10):
for k in range(10):
tables[j][k] = min(tables[j][k], tables[j][i] + tables[i][k])
cost = 0
for i in range(h):
... | s525074344 | Accepted | 38 | 9,616 | 739 | import sys
sys.setrecursionlimit(2147483647)
input=sys.stdin.readline
import math
from heapq import heappush, heappop
def solve(h,w,tables,A):
for i in range(10):
for j in range(10):
for k in range(10):
tables[j][k] = min(tables[j][k], tables[j][i] + tables[i][k])
cost = 0
for i in range(h):
... |
s467045647 | p03455 | u209616713 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 183 | AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. | a,b = input().split()
c = a+b
d = int(c)
if d % 2 == 0:
if d % 4 == 0:
print('Yes')
else:
print('No')
else:
if d % 4 == 1:
print('Yes')
else:
print('No')
| s081647867 | Accepted | 17 | 2,940 | 91 | a,b = map(int,input().split())
c = a*b
if c % 2 == 0:
print('Even')
else:
print('Odd') |
s886885570 | p03860 | u633450100 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 31 | Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppe... | s = input()
print('A'+s[0]+'C') | s556242143 | Accepted | 17 | 2,940 | 55 | s = [s for s in input().split()]
print('A'+s[1][0]+'C') |
s344980789 | p03854 | u548303713 | 2,000 | 262,144 | Wrong Answer | 2,107 | 3,316 | 950 | 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`. | #ABC49-C
S=input()
divide=["dream","dreamer","erase","eraser"]
for i in range(4):
divide[i]=divide[i][::-1]
len_s=len(S)
S=S[::-1]
check=0
i=0
a=[]
while check==0:
if i==len_s:
a.append(1)
break
if len_s-i <5:
check=1
a.append(2)
break
if S[i:i+5] == divide[0]... | s679652609 | Accepted | 34 | 3,444 | 1,164 | #ABC49-C
S=input()
divide=["dream","dreamer","erase","eraser"]
for i in range(4):
divide[i]=divide[i][::-1]
len_s=len(S)
S=S[::-1]
check=0
i=0
a=[]
while check==0:
if i==len_s:
a.append(1)
break
if len_s-i <5:
check=1
a.append(2)
break
if S[i:i+5] == divide[0]... |
s068071899 | p02396 | u587193722 | 1,000 | 131,072 | Wrong Answer | 20 | 7,632 | 93 | In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are give... | a = [int(i) for i in input().split()]
for i in range(1, len(a)):
print('Case',i,':',a[i]) | s833410132 | Accepted | 90 | 8,408 | 129 | a =[]
x = 1
while x > 0:
x = int(input())
a.append(x)
for i in range(0,len(a)-1):
print('Case ',i+1,': ',a[i],sep='') |
s893435251 | p03556 | u088974156 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 28 | 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. | n=int(input())
print(n**0.5) | s297868218 | Accepted | 17 | 3,060 | 36 | n=int(input())
print(int(n**0.5)**2) |
s123834903 | p02256 | u963402991 | 1,000 | 131,072 | Wrong Answer | 20 | 7,624 | 209 | Write a program which finds the greatest common divisor of two natural numbers _a_ and _b_ | def gcd(a,b):
r = a % b
while r != 0:
print (a, b)
a, b = b, r
r = a % b
if r == 0:
break
return b
a,b = list(map(int,input().split()))
print (gcd(a,b)) | s116475366 | Accepted | 20 | 7,636 | 151 | def gcd(a,b):
r = a % b
while r != 0:
a, b = b, r
r = a % b
return b
a,b = list(map(int,input().split()))
print (gcd(a,b)) |
s736531050 | p02742 | u267983787 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 85 | 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... | b, c = map(int, input().split())
a = b*c
if a%2 == 0: print(a/2)
else: print(a/2 + 1) | s845264663 | Accepted | 17 | 2,940 | 140 | b, c = map(int, input().split())
a = b*c
if b == 1:print(1)
elif c == 1:print(1)
elif a%2 == 0: print(int(a/2))
else: print(int((a + 1)/2))
|
s331394271 | p03044 | u630281418 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 29 | 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... | for i in range(5):
print(1) | s582175925 | Accepted | 677 | 50,556 | 500 | import sys
input = sys.stdin.readline
N = int(input())
tree = [[] for _ in range(N)]
for i in range(N-1):
u, v, w = map(int, input().split())
tree[u-1].append([v-1,w])
tree[v-1].append([u-1,w])
dist = [None]*N
dist[0] = 0
comp = [0]*N
next_ptr = [0]
for ptr in next_ptr:
comp[ptr] = 1
edges = tree[... |
s396912861 | p02645 | u483331319 | 2,000 | 1,048,576 | Wrong Answer | 28 | 9,056 | 24 | When you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters. You have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him. | S = input()
print(S[3:]) | s364536801 | Accepted | 26 | 9,024 | 24 | S = input()
print(S[:3]) |
s277906695 | p02694 | u021387650 | 2,000 | 1,048,576 | Wrong Answer | 27 | 9,020 | 103 | 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())
Deposit = 100
ans = 0
while Deposit < X:
Deposit *= 1.001
ans += 1
print(ans) | s378252281 | Accepted | 25 | 9,168 | 118 | X = int(input())
Deposit = 100
ans = 0
while Deposit < X:
Deposit = int(Deposit * 1.01)
ans += 1
print(ans) |
s399005469 | p03623 | u327248573 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 103 | 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 = map(int, input().split(' '))
if abs(a - x) >= abs(b - x):
print('A')
else:
print('B') | s117034662 | Accepted | 18 | 2,940 | 103 | x, a, b = map(int, input().split(' '))
if abs(a - x) <= abs(b - x):
print('A')
else:
print('B') |
s645901164 | p03338 | u729938879 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,060 | 203 | 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()
num = []
for i in range(1,n):
former = set(s[:i])
latter = set(s[i:])
comm = len(former and latter)
#print(s[:i], s[i:])
num.append(comm)
print(max(num)) | s507625228 | Accepted | 18 | 3,060 | 213 | n = int(input())
s = input()
num = []
for i in range(1,n):
former = set(s[:i])
latter = set(s[i:])
comm = len(former.intersection(latter))
#print(s[:i], s[i:])
num.append(comm)
print(max(num)) |
s840987147 | p04046 | u102960641 | 2,000 | 262,144 | Wrong Answer | 276 | 18,804 | 572 | We have a large square grid with H rows and W columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the bottom-right cell. However, she cannot enter the cells in the intersection of the bottom A rows and the leftmost B columns. (That is, there ... | h,w,a,b = map(int, input().split())
mod = 10**9 + 7
n = 10**5 * 2 + 1
fact = [1]*(n+1)
rfact = [1]*(n+1)
r = 1
for i in range(1, n+1):
fact[i] = r = r * i % mod
rfact[n] = r = pow(fact[n], mod-2, mod)
for i in range(n, 0, -1):
rfact[i-1] = r = r * i % mod
def perm(n, k):
return fact[n] * rfact[n-k] % mod
de... | s454560131 | Accepted | 265 | 18,804 | 535 | h,w,a,b = map(int, input().split())
mod = 10**9 + 7
n = 10**5 * 2 + 1
fact = [1]*(n+1)
rfact = [1]*(n+1)
r = 1
for i in range(1, n+1):
fact[i] = r = r * i % mod
rfact[n] = r = pow(fact[n], mod-2, mod)
for i in range(n, 0, -1):
rfact[i-1] = r = r * i % mod
def perm(n, k):
return fact[n] * rfact[n-k] % mod
de... |
s215969402 | p03544 | u066455063 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 116 | 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())
luca = [2, 1]
for i in range(101):
luca.append(luca[i]+luca[i+1])
print(luca)
print(luca[N])
| s922569920 | Accepted | 17 | 2,940 | 104 | N = int(input())
luca = [2, 1]
for i in range(101):
luca.append(luca[i]+luca[i+1])
print(luca[N])
|
s398463139 | p03379 | u243689896 | 2,000 | 262,144 | Wrong Answer | 2,108 | 26,180 | 366 | 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, ..... | #ABC 094 Many Medians
numbers=int(input())
list_num=[int(i) for i in input().split()]
sorted_list=sorted(list_num)
median1=sorted_list[int(numbers/2)-1]
median2=sorted_list[int(numbers/2)]
print('median1:', median1)
print('median2:', median2)
for i in list_num:
if sorted_list.index(i) <= numbers/2-1:
pr... | s876015087 | Accepted | 300 | 25,472 | 264 | numbers=int(input())
list_num=[int(i) for i in input().split()]
sorted_list=sorted(list_num)
median1=sorted_list[int(numbers/2)-1]
median2=sorted_list[int(numbers/2)]
for i in list_num:
if i <= median1:
print(median2)
else:
print(median1) |
s161907103 | p03673 | u746419473 | 2,000 | 262,144 | Wrong Answer | 2,104 | 26,020 | 192 | 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, = map(int, input().split())
b = []
for i in range(n):
if i%2 == 0:
b.append(a[i])
else:
b.insert(0, a[i])
if n%2 == 1:
b.reverse()
print(b)
| s976564819 | Accepted | 172 | 26,020 | 178 | n = int(input())
*a, = map(int, input().split())
right = a[1::2]
right.reverse()
left = a[0::2]
b = []
b.extend(right)
b.extend(left)
if n%2 == 1:
b.reverse()
print(*b)
|
s848413590 | p02678 | u131638468 | 2,000 | 1,048,576 | Wrong Answer | 374 | 63,944 | 543 | There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in th... | n,m,*ab=map(int,open(0).read().split())
path={}
for i in range(n):
path[i]=[]
for i in range(m):
a,b=ab[i*2]-1,ab[i*2+1]-1
path[a].append(b)
path[b].append(a)
direction=[i for i in range(n)]
fin=[False for i in range(n)]
fin[0]=True
i=0
queue=[0]
while i<n:
i+=1
queue2=queue.copy()
queue.clear()
if len(... | s748262601 | Accepted | 542 | 63,520 | 544 | n,m,*ab=map(int,open(0).read().split())
path={}
for i in range(n):
path[i]=[]
for i in range(m):
a,b=ab[i*2]-1,ab[i*2+1]-1
path[a].append(b)
path[b].append(a)
direction=[i for i in range(n)]
fin=[False for i in range(n)]
fin[0]=True
i=0
queue=[0]
while i<n:
i+=1
queue2=queue.copy()
queue.clear()
if len(... |
s136630155 | p03377 | u488178971 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 90 | 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. | #094
A,B,X= map(int,input().split())
if A+B>=X >=A:
print('Yes')
else:
print('No') | s753066535 | Accepted | 17 | 2,940 | 90 | #094
A,B,X= map(int,input().split())
if A+B>=X >=A:
print('YES')
else:
print('NO') |
s855066046 | p03352 | u645568816 | 2,000 | 1,048,576 | Wrong Answer | 28 | 9,096 | 132 | 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. | N = int(input())
ans = 0
for i in range(1,35):
for k in range(1,10):
if i**k <= N and i**k >= ans:
ans = i**k
print(ans) | s209836598 | Accepted | 29 | 9,160 | 132 | N = int(input())
ans = 0
for i in range(1,35):
for k in range(2,10):
if i**k <= N and i**k >= ans:
ans = i**k
print(ans) |
s722724248 | p03998 | u537976628 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 637 | Alice, Bob and Charlie are playing _Card Game for Three_ , as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * ... | A, B, C = (input() for i in range(3))
cnt_a = 0; cnt_b = -1; cnt_c = -1
current_card = A[cnt_a]
while True:
print(current_card)
if current_card == "a":
cnt_a += 1
if cnt_a == len(A):
print("A")
exit()
else:
current_card = A[cnt_a]
elif current_card... | s501580406 | Accepted | 17 | 3,064 | 613 | A, B, C = (input() for i in range(3))
cnt_a = 0; cnt_b = -1; cnt_c = -1
current_card = A[cnt_a]
while True:
if current_card == "a":
cnt_a += 1
if cnt_a == len(A):
print("A")
exit()
else:
current_card = A[cnt_a]
elif current_card == "b":
cnt_b +... |
s987128878 | p02613 | u657173608 | 2,000 | 1,048,576 | Wrong Answer | 154 | 9,680 | 555 | 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`,... | from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math
from bisect import bisect,bisect_right,bisect_left
def get_int():
return int(stdin.readline().strip())
def get_tuple():
return map(int, stdin.readline().spli... | s831767837 | Accepted | 144 | 9,656 | 555 | from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math
from bisect import bisect,bisect_right,bisect_left
def get_int():
return int(stdin.readline().strip())
def get_tuple():
return map(int, stdin.readline().spli... |
s007042969 | p03407 | u992910889 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 96 | 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==C or B==C or A+B==C:
print('Yes')
else:
print('No') | s142196280 | Accepted | 17 | 2,940 | 80 | A,B,C=map(int,input().split())
if A+B>=C:
print('Yes')
else:
print('No') |
s186028980 | p03476 | u027929618 | 2,000 | 262,144 | Time Limit Exceeded | 2,105 | 30,196 | 349 | 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 is_prime(t):
i=2
while i**2<=t:
if t%i==0:
return 0
i+=1
return 1
q=int(input())
lr=[list(map(int,input().split())) for _ in range(q)]
n=10**5
p=[0]*(n+1)
d=[]
for i in range(2,n):
if is_prime(i):
d.append(i)
if i in d and (i+1)//2 in d:
p[i]=p[i-1]+1
else:
p[i]=p[i-1]
for l,r ... | s196956500 | Accepted | 1,379 | 29,860 | 349 | def is_prime(t):
i=2
while i**2<=t:
if t%i==0:
return 0
i+=1
return 1
q=int(input())
lr=[list(map(int,input().split())) for _ in range(q)]
n=10**5
p=[0]*(n+1)
d=set()
for i in range(2,n):
if is_prime(i):
d.add(i)
if i in d and (i+1)//2 in d:
p[i]=p[i-1]+1
else:
p[i]=p[i-1]
for l,r ... |
s466910506 | p03377 | u564906058 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 86 | 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") | s651326701 | Accepted | 17 | 2,940 | 86 | a,b,x = map(int,input().split())
if a <= x <= a+b:
print("YES")
else:
print("NO") |
s880701408 | p03998 | u782654209 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 386 | Alice, Bob and Charlie are playing _Card Game for Three_ , as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * ... | S = [input() for x in range(3)]
winner = ''
turn = 0
while True:
if S[turn][0] == 'a':
S[0] = S[0][1:]
turn = 0
elif S[turn][0] == 'b':
S[1] = S[1][1:]
turn = 1
elif S[turn][0] == 'c':
S[2] = S[2][1:]
turn = 2
for i in range(3):
if S[i]=='': winner... | s468262118 | Accepted | 17 | 3,060 | 201 | S = [str(input()) for x in range(3)]
turn = 0
nextturn = 0
while True:
nextturn = 'abc'.find(S[turn][0])
S[turn] = S[turn][1:]
turn = nextturn
if S[turn] == '':
print('ABC'[turn])
break |
s761627683 | p03854 | u246253778 | 2,000 | 262,144 | Wrong Answer | 65 | 9,092 | 392 | 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()
while len(S) != 0:
if S[-2:] == 'er':
S = S[:-2]
if S[-5:] == 'dream':
S = S[:-5]
elif S[-4:] == 'eras':
S = S[:-4]
else:
print('No')
exit()
else:
if S[-5:] == 'dream' or S[-5:] == 'erase':
S = S[:-5... | s281895398 | Accepted | 69 | 9,136 | 392 | S = input()
while len(S) != 0:
if S[-2:] == 'er':
S = S[:-2]
if S[-5:] == 'dream':
S = S[:-5]
elif S[-4:] == 'eras':
S = S[:-4]
else:
print('NO')
exit()
else:
if S[-5:] == 'dream' or S[-5:] == 'erase':
S = S[:-5... |
s470017224 | p02401 | u628732336 | 1,000 | 131,072 | Wrong Answer | 20 | 7,584 | 265 | 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. | while True:
a, op, b = input().split()
a = int(a)
b = int(b)
if op == '?':
break
if op == '+':
print(a + b)
if op == '-':
print(a - b)
if op == '*':
print(a * b)
if op == '/':
print(a / b) | s639191512 | Accepted | 20 | 7,616 | 266 | while True:
a, op, b = input().split()
a = int(a)
b = int(b)
if op == '?':
break
if op == '+':
print(a + b)
if op == '-':
print(a - b)
if op == '*':
print(a * b)
if op == '/':
print(a // b) |
s168335150 | p04029 | u980492406 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 33 | 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) | s988640111 | Accepted | 17 | 2,940 | 38 | n = int(input())
print(int(n*(n+1)/2)) |
s135116654 | p02262 | u599130514 | 6,000 | 131,072 | Wrong Answer | 20 | 5,600 | 563 | 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 = 0
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 cnt
def shellSort(A, n):
cnt = 0
m = 2
G = [n - m + 1, m - 1]
fo... | s746345748 | Accepted | 18,480 | 125,972 | 686 | def insertionSort(A, n, g):
cnt = 0
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 cnt
def shellSort(A, n):
G = []
h = 1
while True:
if h > n:
... |
s309812723 | p02399 | u286589639 | 1,000 | 131,072 | Wrong Answer | 20 | 7,624 | 109 | Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number) | a, b = map(int, input().split())
d = a // b
r = a % b
f = a / b
print(str(d) + " " + str(r) + " " + str(f)) | s713320524 | Accepted | 20 | 7,652 | 127 | a, b = map(int, input().split())
d = a // b
r = a % b
f = "{0:.5f}".format(a / b)
print(str(d) + " " + str(r) + " " + str(f)) |
s169196208 | p03379 | u669322232 | 2,000 | 262,144 | Wrong Answer | 2,105 | 27,156 | 231 | 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 copy
N = int(input())
numList = list(map(int, input().split()))
numList.sort()
for i in range(0,N):
numListCopy = copy.deepcopy(numList)
numListCopy.pop(i)
medIndex = int(len(numListCopy)/2)
print(numListCopy[medIndex]) | s884433794 | Accepted | 482 | 26,528 | 316 | import copy
N = int(input())
numList = list(map(int, input().split()))
numListCopy = copy.deepcopy(numList)
numList = sorted(numList)
medIndex = int((N)/2)
med1 = numList[medIndex-1]
med2 = numList[medIndex]
for i in range(0,N):
if numListCopy[i] <= med1:
print(med2)
elif med2 <= numListCopy[i]:
print(med1) |
s284408044 | p03671 | u367393577 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 55 | Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the m... | a,b,c=map(int,input().split())
print(max(a+b,b+c,c+a))
| s716761514 | Accepted | 17 | 2,940 | 55 | a,b,c=map(int,input().split())
print(min(a+b,b+c,c+a))
|
s478150720 | p02902 | u803611972 | 2,000 | 1,048,576 | Wrong Answer | 25 | 3,956 | 343 | Given is a directed graph G with N vertices and M edges. The vertices are numbered 1 to N, and the i-th edge is directed from Vertex A_i to Vertex B_i. It is guaranteed that the graph contains no self-loops or multiple edges. Determine whether there exists an induced subgraph (see Notes) of G such that the in-degr... | from collections import*
n,m,*t=map(int,open(0).read().split())
i,o,r=[0]*n,[[]for _ in'_'*n],[]
for a,b in zip(*[iter(t)]*2):
o[a-1]+=b-1,
i[b-1]+=1
q=deque(v for v in range(n)if i[v]<1)
while q:
v=q.popleft()
r+=v,
for w in o[v]:
i[w]-=1
if i[w]==0:q+=w,
print(-(len(r)==n))
for j,k in enumerate(i):
... | s217644980 | Accepted | 30 | 3,956 | 708 | import sys
from collections import deque
def serp(s):
prev = [-1]*n
q=deque([s])
while q:
v = q.pop()
for nv in e[v]:
if nv==s: prev[nv]=v; return(s,prev)
if prev[nv]<0: q+=nv,; prev[nv] =v
return(-1,prev)
n,m,*t=map(int,open(0).read().split())
e,ab = [[] for i in range(n)],[]
for a,b in zip... |
s062001923 | p03679 | u746428948 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 97 | Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Ot... | x,a,b = map(int,input().split())
d = b - a
if d <= x: print('delicious')
else: print('dangerous') | s341132049 | Accepted | 17 | 2,940 | 124 | x,a,b = map(int,input().split())
d = b - a
if d <= 0: print('delicious')
elif d <= x: print('safe')
else: print('dangerous') |
s334483422 | p03433 | u951601135 | 2,000 | 262,144 | Wrong Answer | 157 | 12,504 | 182 | E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins. | import numpy as np
N = int(input())
value = list(map(int,input().split()))
value=np.sort(value)[::-1]
print(N,value)
a=0
b=0
a = np.sum(value[::2])
b = np.sum(value[1::2])
print(a,b) | s059463798 | Accepted | 18 | 2,940 | 66 | n=int(input())
a=int(input())
print('Yes' if (n%500)<=a else 'No') |
s677395293 | p04043 | u882209234 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 118 | 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 ... | abc = list(map(int, input().split()))
if abc[0] == abc[2] == 5 and abc[1] == 7:
print('YES')
else:
print('NO') | s028583532 | Accepted | 17 | 3,060 | 209 | abc = list(map(int, input().split()))
lengths = [0,0]
for i in abc:
if i == 5: lengths[0] += 1
if i == 7: lengths[1] += 1
if lengths[0] == 2 and lengths[1] == 1:
print('YES')
else:
print('NO') |
s905119373 | p03131 | u852719059 | 2,000 | 1,048,576 | Wrong Answer | 2,104 | 3,064 | 341 | Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the ... | # C When I hit my pocket
k,a,b = map(int,input().split())
bis = 1
yen = 0
if b <= a + 2 or k <= a + 1:
print(1 + k)
else:
for i in range(k):
if not yen == 0:
bis += b
yen -= 1
elif bis >= a:
bis -= a
yen += 1
else:
bis += 1
... | s631666006 | Accepted | 17 | 3,060 | 247 | # C When I hit my pocket
k,a,b = map(int,input().split())
bis = 1
if k <= 1 or b <= a + 2 or k < a + 1:
print(1 + k)
exit()
else:
bis = b
k = k - ( a + 1)
if not k == 0:
bis += int(k / 2) * (b - a) + k % 2
print(bis) |
s626133179 | p02399 | u248424983 | 1,000 | 131,072 | Wrong Answer | 30 | 7,720 | 134 | 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) | import sys
(a, b) = [int(i) for i in input().split(' ')]
d = a // b
r = a % b
f = a / b
print(repr(d) +" "+ repr(r) +" "+ repr(f)) | s267059511 | Accepted | 20 | 7,724 | 112 | (a, b) = [int(i) for i in input().split(' ')]
print( repr(a // b) +" "+ repr(a % b) +" "+ ('%0.5f' % (a / b))) |
s345172934 | p03485 | u148551245 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 64 | You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer. | a, b = (int(i) for i in input().split())
mean = (a + b) // 2 + 1 | s982982186 | Accepted | 17 | 2,940 | 114 | a, b = map(int, input().split())
m = (a + b) // 2
x = (a + b) / 2
if x % 1 == 0:
print(m)
else:
print(m+1) |
s269674866 | p02742 | u948522631 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 88 | 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... |
h,w=map(int,input().split())
print(int(h*w/2)+1 if type(h*w/2)==float else int(h*w/2) ) | s599547066 | Accepted | 17 | 3,060 | 122 | h,w=map(int,input().split())
if h<2 or w<2:
print(1)
elif h%2==0 or w%2==0:
print(int(h*w/2))
else:
print(int(h*w/2)+1) |
s207670852 | p02390 | u114315703 | 1,000 | 131,072 | Wrong Answer | 20 | 5,568 | 51 | 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. | N = int(input())
print(N // 3600, N // 60, N % 60)
| s195767345 | Accepted | 20 | 5,576 | 80 | N = int(input())
print('{0}:{1}:{2}'.format(N // 3600, N % 3600// 60, N % 60))
|
s529226275 | p03440 | u047816928 | 2,000 | 262,144 | Wrong Answer | 464 | 33,904 | 1,002 | You are given a forest with N vertices and M edges. The vertices are numbered 0 through N-1. The edges are given in the format (x_i,y_i), which means that Vertex x_i and y_i are connected by an edge. Each vertex i has a value a_i. You want to add edges in the given forest so that the forest becomes connected. To add a... | class UF:
def __init__(self, N):
self.uf = [-1]*N
self.n = N
def find(self, x):
if self.uf[x]<0: return x
self.uf[x] = self.find(self.uf[x])
return self.uf[x]
def size(self, x):
return -self.uf[self.find(x)]
def union(self, x, y):
x, y = self.fi... | s594720585 | Accepted | 449 | 33,612 | 971 | class UF:
def __init__(self, N):
self.uf = [-1]*N
self.n = N
def find(self, x):
if self.uf[x]<0: return x
self.uf[x] = self.find(self.uf[x])
return self.uf[x]
def size(self, x):
return -self.uf[self.find(x)]
def union(self, x, y):
x, y = self.fi... |
s213689852 | p03657 | u814265211 | 2,000 | 262,144 | Wrong Answer | 31 | 9,148 | 86 | 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())
print('Possible' if not A + B % 3 else 'Impossible')
| s554440721 | Accepted | 26 | 9,160 | 120 | A, B = map(int, input().split())
if (A+B) % 3 and A % 3 and B % 3:
print('Impossible')
else:
print('Possible')
|
s277213706 | p03455 | u453117183 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 96 | 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%2 == 0 or b%2 == 0:
print("even")
else:
print("odd") | s683948478 | Accepted | 17 | 2,940 | 96 | a,b = map(int,input().split())
if a%2 == 0 or b%2 == 0:
print("Even")
else:
print("Odd") |
s132330179 | p03599 | u050428930 | 3,000 | 262,144 | Wrong Answer | 3,156 | 3,064 | 665 | Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations. * Operation 1: Pour 100A grams of water into the beaker. * Operation 2: Pour 100B grams of water into the bea... | a,b,c,d,e,f=map(int,input().split())
ans=100
for i in range(f//(100*a)+1):
for j in range(f//(100*b)+1):
s=100*a*i+100*b*j
if s==0:
break
for ii in range((f-100*a)//c+1):
for jj in range((f-100*a)//d+1):
t=c*ii+d*jj
if t==0:
... | s308890189 | Accepted | 222 | 3,064 | 474 | a,b,c,d,e,f=map(int,input().split())
t=100
for i in range(0,f+1,a*100):
for j in range(0,f-i+1,b*100):
k=i+j
if k==0:
continue
s=min(f-i-j,(i+j)*e//100)
for ii in range(0,s+1,c):
for jj in range(0,s-ii+1,d):
if t>e-(ii+jj)*100/(i+j):
... |
s669845689 | p03597 | u865413330 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 50 | We have an N \times N square grid. We will paint each square in the grid either black or white. If we paint exactly A squares white, how many squares will be painted black? | n = int(input())
a = int(input())
print(n * 2 - a) | s070258306 | Accepted | 17 | 2,940 | 50 | n = int(input())
a = int(input())
print(n * n - a) |
s782022358 | p03997 | u485319545 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 454 | 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. | s_a = list(input())
s_b = list(input())
s_c = list(input())
S=[s_a,s_b,s_c]
order=0
while True:
if S[order][0]=='a':
del S[0][0]
order=0
elif S[order][0]=='b':
del S[1][0]
order=1
else:
del S[2][0]
order=2
if len(S[order])==0:
print('A')
... | s885187797 | Accepted | 17 | 3,064 | 67 | a=int(input())
b=int(input())
h=int(input())
print(int((a+b)*h/2)) |
s589989666 | p03475 | u245870380 | 3,000 | 262,144 | Wrong Answer | 107 | 3,064 | 364 | A railroad running from west to east in Atcoder Kingdom is now complete. There are N stations on the railroad, numbered 1 through N from west to east. Tomorrow, the opening ceremony of the railroad will take place. On this railroad, for each integer i such that 1≤i≤N-1, there will be trains that run from Station i t... | N = int(input())
C, S, F = [], [], []
for i in range(N-1):
c, s, f = map(int, input().split())
C.append(c)
S.append(s)
F.append(f)
print(C)
print(S)
print(F)
for i in range(N):
t = 0
for j in range(i,N-1):
if t < S[j]:
t = S[j]
elif t % F[j] != 0:
t += F[... | s033977349 | Accepted | 98 | 3,064 | 336 | N = int(input())
C, S, F = [], [], []
for i in range(N-1):
c, s, f = map(int, input().split())
C.append(c)
S.append(s)
F.append(f)
for i in range(N):
t = 0
for j in range(i,N-1):
if t < S[j]:
t = S[j]
elif t % F[j] != 0:
t += F[j] - t % F[j]
t += C... |
s467263008 | p02418 | u971748390 | 1,000 | 131,072 | Wrong Answer | 20 | 7,352 | 81 | Write a program which finds a pattern $p$ in a ring shaped text $s$. | s=input()
p=input()
ring=s+s
if p in ring :
print("True")
else :
print("False") | s570824814 | Accepted | 40 | 7,496 | 77 | s=input()
p=input()
ring=s+s
if p in ring :
print("Yes")
else :
print("No") |
s682277929 | p03610 | u247211039 | 2,000 | 262,144 | Wrong Answer | 17 | 3,316 | 26 | 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 = input()
print(s[0::1]) | s392263326 | Accepted | 37 | 3,316 | 96 | s = input()
x = s[0]
for i in range(len(s)):
if i % 2 == 0:
x= x + s[i]
print(x[1:]) |
s811141985 | p02806 | u152614052 | 2,525 | 1,048,576 | Wrong Answer | 17 | 3,060 | 208 | Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct. Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, w... | n = int(input())
li1 = []
li2 = []
for i in range(n):
a, b = input().split()
li1.append(a)
li2.append(int(b))
x = input()
print(*li1)
print(*li2)
asleep = li1.index(x)
print(sum(li2[asleep+1:])) | s121419361 | Accepted | 17 | 3,060 | 183 | n = int(input())
li1 = []
li2 = []
for i in range(n):
a, b = input().split()
li1.append(a)
li2.append(int(b))
x = input()
asleep = li1.index(x)
print(sum(li2[asleep+1:])) |
s265132615 | p03852 | u534308356 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 204 | Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`. | S = input()
l = ['dream', 'dreamer', 'erase', 'eraser']
s = "".join(S[-1::-1].split(l[0][-1::-1]))
for i in range(1, 4):
s = "".join(s.split(l[i][-1::-1]))
print("YES") if s == "" else print("NO")
| s876401081 | Accepted | 26 | 8,984 | 109 | data = ["a", "e", "i", "o", "u"]
c = input()
if c in data:
print("vowel")
else:
print("consonant")
|
s359395775 | p02603 | u941644149 | 2,000 | 1,048,576 | Wrong Answer | 29 | 9,160 | 829 | To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives. He is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the n... | n = int(input())
given_A = list(map(int, input().split()))
A = []
for kabuka in given_A:
if len(A) > 0 and kabuka == A[-1]:
continue
else:
A.append(kabuka)
print(A)
if len(A) == 1:
print(1000)
exit()
money = 1000
stock = 0
n = len(A)
for i in range(len(A)):
if i == 0:
... | s926648913 | Accepted | 30 | 9,220 | 816 | n = int(input())
given_A = list(map(int, input().split()))
A = []
for kabuka in given_A:
if len(A) > 0 and kabuka == A[-1]:
continue
else:
A.append(kabuka)
if len(A) == 1:
print(1000)
exit()
money = 1000
stock = 0
n = len(A)
for i in range(len(A)):
if i == 0:
if A[i] < A[i... |
s511888465 | p03370 | u344959959 | 2,000 | 262,144 | Wrong Answer | 27 | 9,056 | 113 | Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams o... | a,b = map(int,input().split())
c = [int(input()) for i in range(a)]
print(min(c))
print(a+((b-(sum(c)))//min(c))) | s178089763 | Accepted | 26 | 9,168 | 99 | a,b = map(int,input().split())
c = [int(input()) for i in range(a)]
print(a+((b-(sum(c)))//min(c))) |
s284511249 | p03449 | u625963200 | 2,000 | 262,144 | Wrong Answer | 19 | 3,060 | 180 | 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())
A=[list(map(int,input().split())) for _ in range(2)]
print(A)
ans=A[0][0]
for i in range(1,n+1):
ans2=sum(A[0][:i])+sum(A[1][i-1:])
ans=max(ans,ans2)
print(ans) | s339043073 | Accepted | 17 | 3,060 | 171 | n=int(input())
A=[list(map(int,input().split())) for _ in range(2)]
ans=A[0][0]
for i in range(1,n+1):
ans2=sum(A[0][:i])+sum(A[1][i-1:])
ans=max(ans,ans2)
print(ans) |
s268422940 | p04025 | u888092736 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 165 | 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 = map(int, input().split())
ans = float("inf")
for i in range(-100, 101):
ans = min(ans, sum(map(lambda x: (x - i) * (x - i), A)))
print(ans)
| s824353245 | Accepted | 25 | 3,060 | 200 | N = int(input())
A = list(map(int, input().split()))
ans = float("inf")
for k in range(-100, 101):
tmp = 0
for i in range(N):
tmp += (A[i] - k) ** 2
ans = min(ans, tmp)
print(ans)
|
s500203881 | p03493 | u931209993 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 164 | 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. | a = int(input())
cnt = 0
if a%10 == 1:
cnt += 1
a = int(a/10)
if a%10 == 1:
cnt += 1
a = int(a/10)
if a%10 == 1:
cnt += 1
a = int(a/10)
print(cnt) | s683849789 | Accepted | 17 | 2,940 | 114 | a = input()
cnt = 0
if a[0] == '1':
cnt += 1
if a[1] == '1':
cnt += 1
if a[2] == '1':
cnt += 1
print(cnt) |
s353669709 | p03369 | u086503932 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 47 | In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is ... | print(700+list(input().split()).count('o')*100) | s516955177 | Accepted | 17 | 2,940 | 33 | print(700+input().count('o')*100) |
s134453146 | p02975 | u814986259 | 2,000 | 1,048,576 | Wrong Answer | 112 | 14,468 | 664 | Snuke has N hats. The i-th hat has an integer a_i written on it. There are N camels standing in a circle. Snuke will put one of his hats on each of these camels. If there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print `Yes`; otherwise, print `No... | import collections
N = int(input())
a = list(map(int, input().split()))
A = set()
table = collections.defaultdict(int)
for i in range(1, N):
table[a[i]] += 2
a.sort()
prev = a[0]
now = a[0]
last = a[0]
for i in range(1, N):
if (a[0] ^ a[i]) in table and table[a[0] ^ a[i]] > 0:
table[a[0] ^ a[i]] -= 1
... | s801727715 | Accepted | 189 | 14,468 | 777 | import collections
N = int(input())
a = list(map(int, input().split()))
A = set()
table = collections.defaultdict(int)
for i in range(1, N):
table[a[i]] += 1
ans = [-1]*N
ans[0] = a[0]
for i in range(1, N):
if (a[0] ^ a[i]) in table and table[a[0] ^ a[i]] >= 1:
if a[0] == 0:
if table[a[i]]... |
s567737792 | p03063 | u639444166 | 2,000 | 1,048,576 | Wrong Answer | 452 | 6,140 | 390 | There are N stones arranged in a row. Every stone is painted white or black. A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is `.`, and the stone is black if the character is `#`. Takahashi wants to change the colors of some stones to black or white so t... | #! -*- coding: utf-8 -*-
n = int(input())
line = input()
w = 0
for i in range(n):
if line[i] == ".":
w += 1
b = n-w
w_coutner = 0
b_counter = 0
ans = n
for i in range(n):
if line[i] == ".":
w_coutner += 1
b_counter = i+1 - w_coutner
wtob = b_counter
btow = w - w_coutner
ans_i ... | s528677696 | Accepted | 195 | 3,500 | 411 | #! -*- coding: utf-8 -*-
n = int(input())
line = input()
w = 0
for i in range(n):
if line[i] == ".":
w += 1
b = n-w
w_coutner = 0
b_counter = 0
ans = n
for i in range(n):
if line[i] == ".":
w_coutner += 1
b_counter = i+1 - w_coutner
wtob = b_counter
btow = w - w_coutner
ans_i ... |
s074087792 | p03447 | u730710086 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 113 | 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? | # -*- coding: <encoding name> -*-
x = int(input())
a = int(input())
b = int(input())
n = x - a
print(x - n % b) | s272301525 | Accepted | 17 | 2,940 | 109 | # -*- coding: <encoding name> -*-
x = int(input())
a = int(input())
b = int(input())
n = x - a
print(n % b) |
s538095039 | p02678 | u941438707 | 2,000 | 1,048,576 | Wrong Answer | 25 | 9,148 | 11 | There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in th... | print("No") | s952826878 | Accepted | 560 | 60,284 | 304 | from collections import*
(n,m),*c=[[*map(int,i.split())]for i in open(0)]
g=[[]for _ in range(n+1)]
for a,b in c:
g[a]+=[b]
g[b]+=[a]
q=deque([1])
r=[0]*(n+1)
while q:
v=q.popleft()
for i in g[v]:
if r[i]==0:
r[i]=v
q.append(i)
print("Yes",*r[2:],sep="\n") |
s669565645 | p02602 | u598684283 | 2,000 | 1,048,576 | Wrong Answer | 2,206 | 41,024 | 337 | 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 = list(input().split())
count = 0
tmp = 1
check = []
for _ in range(n - k + 1):
for i in range(k):
tmp *= int(a[i + count])
check.append(tmp)
tmp = 1
count += 1
print(check)
for j in range(n - k):
if check[j] < check[j + 1]:
print("Yes")
else:
... | s971113599 | Accepted | 154 | 31,668 | 207 | n, k = input().split()
n = int(n)
k = int(k)
a = [int(s) for s in input().split()]
sums = []
K = k - 1
for i in range(K,n - 1):
if(a[i - K] < a[i + 1]):
print("Yes")
else:
print("No") |
s291104453 | p03474 | u297045966 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 92 | 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 = input().strip().split(' ')
A, B = [int(A),int(B)]
S = input()
print(S[:A]+'-'+S[A:]) | s355239636 | Accepted | 17 | 3,060 | 174 | A, B = input().strip().split(' ')
A, B = [int(A),int(B)]
S = input()
T = list(S.strip().split('-'))
if len(T[0])==A and len(T[1])==B:
print('Yes')
else:
print('No') |
s157429929 | p02409 | u139687801 | 1,000 | 131,072 | Wrong Answer | 20 | 5,624 | 1,027 | You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth fl... | n = int(input())
buffer = []
i = 0
while i<n:
b,f,r,v = map(int,input().split())
buffer.append([b,f,r,v])
i = i + 1
room = []
for h in range(15):
if h == 3 or h == 7 or h == 11:
room.append(['**']*10)
else:
room.append([0]*10)
for y in range(n):
if buffer[y][0] == 1... | s307055121 | Accepted | 30 | 5,628 | 1,027 | n = int(input())
buffer = []
i = 0
while i<n:
b,f,r,v = map(int,input().split())
buffer.append([b,f,r,v])
i = i + 1
room = []
for h in range(15):
if h == 3 or h == 7 or h == 11:
room.append(['**']*10)
else:
room.append([0]*10)
for y in range(n):
if buffer[y][0] == 1... |
s262598910 | p03722 | u547167033 | 2,000 | 262,144 | Wrong Answer | 319 | 35,476 | 303 | There is a directed graph with N vertices and M edges. The i-th edge (1≤i≤M) points from vertex a_i to vertex b_i, and has a weight c_i. We will play the following single-player game using this graph and a piece. Initially, the piece is placed at vertex 1, and the score of the player is set to 0. The player can move t... | import scipy.sparse.csgraph
n,m=map(int,input().split())
graph=[[0]*n for i in range(n)]
for i in range(m):
u,v,c=map(int,input().split())
graph[u-1][v-1]=-c
try:
l=scipy.sparse.csgraph.johnson(graph)
print(-l[0][-1])
except scipy.sparse.csgraph._shortest_path.NegativeCycleError:
print('inf') | s507310603 | Accepted | 582 | 3,368 | 406 | import sys
INF=float('inf')
def Bellmanford(n,edges,r):
d=[INF]*n
d[r]=0
for i in range(n):
for u,v,c in edges:
if d[u]!=INF and d[v]>d[u]+c:
d[v]=d[u]+c
if i==n-1 and v==n-1:
return 'inf'
return (-1)*d[n-1]
n,m=map(int,input().split())
edges=[0]*m
for i in range(m):
a,b,c=... |
s683821848 | p03447 | u759412327 | 2,000 | 262,144 | Wrong Answer | 19 | 3,060 | 75 | 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? | a = [int(input()) for i in range(3)]
b = a[0]-a[1]
c = a[2]
print(b-b//c*b) | s194174575 | Accepted | 29 | 9,156 | 54 | X,A,B = map(int,open(0).read().split())
print((X-A)%B) |
s724055011 | p03525 | u736729525 | 2,000 | 262,144 | Wrong Answer | 126 | 3,064 | 1,233 | In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found that the _time gap_ (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if... | def diff(s, t):
return min(abs(s-t), 24 - abs(s - t))
def main():
N = int(input())
D = [int(x) for x in input().split()]
solve(D)
def solve(D):
def check(d, di, dj, i, j):
for k in range(N):
if k == i or k == j:
continue
if diff(D[k], di) < d:
... | s349764199 | Accepted | 17 | 3,060 | 195 | N=int(input())
D =[0]+[int(x) for x in input().split()]
m=D[1]
D.sort()
for i in range(1,N+1):
D[i]=D[i] if i&1 else 24-D[i]
D.sort()
for i in range(1,N+1):
m= min(m,D[i]-D[i-1])
print(m)
|
s813412685 | p02300 | u519227872 | 1,000 | 131,072 | Wrong Answer | 20 | 5,672 | 1,158 | Find the convex hull of a given set of points P. In other words, find the smallest convex polygon containing all the points of P. Here, in a convex polygon, all interior angles are less than or equal to 180 degrees. Please note that you should find all the points of P on both corner and boundary of the convex polygon. | from math import sqrt
h = {1: 'COUNTER_CLOCKWISE',
2: 'CLOCKWISE',
3: 'ONLINE_BACK',
4: 'ONLINE_FRONT',
5: 'ON_SEGMENT',}
def dot(a, b):
return sum([i * j for i,j in zip(a, b)])
def sub(a, b):
return [a[0] - b[0],a[1] - b[1]]
def cross(a, b):
return a[0] * b[1] - a[1] * b[0]
... | s319037633 | Accepted | 1,000 | 31,168 | 876 | from math import sqrt
from collections import deque
def sub(a, b):
return [a[0] - b[0],a[1] - b[1]]
def cross(a, b):
return a[0] * b[1] - a[1] * b[0]
def ccw(a, b, c):
x = sub(b, a)
y = sub(c, a)
return cross(x, y) > 0
n = int(input())
c = [list(map(int, input().split())) for i in range(n)]
c.s... |
s241850556 | p03556 | u247211039 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 67 | 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. | import math
N = int(input())
a = math.sqrt(N)
a = int(a)
print(a) | s241976422 | Accepted | 17 | 2,940 | 71 | import math
N = int(input())
a = math.sqrt(N)
a = int(a)
print(a*a) |
s912896712 | p03712 | u928784113 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 155 | 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. | N,M = map(int,input().split())
A = []
for i in range(N):
A.append(str(input()))
print("#"*(M+2))
print("
print("#"*(M+2)) | s033258394 | Accepted | 18 | 3,060 | 159 | N,M = map(int,input().split())
A = []
for i in range(N):
A.append(str(input()))
print("#"*(M+2))
for i in range(N):
print("#"+A[i]+"#")
print("#"*(M+2)) |
s140590611 | p03352 | u396391104 | 2,000 | 1,048,576 | Wrong Answer | 22 | 3,572 | 165 | You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2. | x = int(input())
ans = 1
for a in range(1,x+1):
for b in range(2,x+1):
print(a,b)
if a**b > x:
break
elif a**b > ans:
ans = a**b
print(ans) | s304247854 | Accepted | 18 | 2,940 | 150 | x = int(input())
ans = 1
for a in range(1,x+1):
for b in range(2,x+1):
if a**b > x:
break
elif a**b > ans:
ans = a**b
print(ans) |
s231908750 | p03069 | u660750079 | 2,000 | 1,048,576 | Wrong Answer | 364 | 22,272 | 456 | There are N stones arranged in a row. Every stone is painted white or black. A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is `.`, and the stone is black if the character is `#`. Takahashi wants to change the colors of some stones to black or white so t... | N=int(input())
S=input()
list1=[0]*N
for i in reversed(range(N)):
if i==N-1 and S[i]==".":
list1[i]+=1
elif i==N-1:
list1[i]=0
elif S[i]==".":
list1[i]=list1[i+1]+1
else:
list1[i]=list1[i+1]
print(list1)
list2=[]
for i in range(N+1):
if i==0:
tmp=N-list1[0... | s022776081 | Accepted | 205 | 19,304 | 427 | N=int(input())
S=input()
list1=[0]*N
for i in reversed(range(N)):
if i==N-1 and S[i]==".":
list1[i]+=1
elif i==N-1:
list1[i]=0
elif S[i]==".":
list1[i]=list1[i+1]+1
else:
list1[i]=list1[i+1]
list2=[]
for i in range(N+1):
if i==0:
tmp=N-list1[0]
elif i==... |
s829054367 | p03149 | u057964173 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 147 | 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". | def resolve():
l=list(map(int, input().split()))
if 1 in l and 9 in l and 7 in l and 4 in l:
print('YES')
else:
print('NO')
| s376879439 | Accepted | 18 | 3,060 | 194 |
import sys
def input(): return sys.stdin.readline().strip()
def resolve():
l=set(map(int,input().split()))
if l=={1,7,9,4}:
print('YES')
else:
print('NO')
resolve() |
s625386379 | p00001 | u823517752 | 1,000 | 131,072 | Wrong Answer | 30 | 7,468 | 110 | There is a data which provides heights (in meter) of mountains. The data is only for ten mountains. Write a program which prints heights of the top three mountains in descending order. | m = []
for i in range(0, 10):
m.append(input())
m.sort(reverse=True)
for i in range(0, 3):
print(m[i]) | s616315756 | Accepted | 30 | 7,604 | 115 | m = []
for i in range(0, 10):
m.append(int(input()))
m.sort(reverse=True)
for i in range(0, 3):
print(m[i]) |
s730946096 | p03589 | u125205981 | 2,000 | 262,144 | Wrong Answer | 2,104 | 2,940 | 298 | You are given an integer N. Find a triple of positive integers h, n and w such that 4/N = 1/h + 1/n + 1/w. If there are multiple solutions, any of them will be accepted. | def main():
N = int(input())
for h in range(N, 0, -1):
for n in range(N, 0, -1):
w = int((4 - N / h - N / n) * N)
if w <= 0:
continue
elif N / h + N / n + N / w == 4:
print(h, n, w)
return
main()
| s635974991 | Accepted | 1,459 | 2,940 | 300 | def main():
N = int(input())
for h in range(1, 3501):
for n in range(1, 3501):
x = 4 * h * n - N * n - N * h
if x <= 0: continue
w, mod_ = divmod(N * h * n, x)
if not mod_:
print(h, n, w)
return
main()
|
s919095179 | p03827 | u107077660 | 2,000 | 262,144 | Wrong Answer | 22 | 3,064 | 120 | You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x duri... | N = int(input())
S = input()
x = 0
ans = 0
for l in S:
if l == "I":
x += 1
elif l == "D":
x -= 1
ans = max(ans,x) | s407548255 | Accepted | 26 | 3,064 | 131 | N = int(input())
S = input()
x = 0
ans = 0
for l in S:
if l == "I":
x += 1
elif l == "D":
x -= 1
ans = max(ans,x)
print(ans) |
s500089526 | p02854 | u888092736 | 2,000 | 1,048,576 | Wrong Answer | 208 | 27,180 | 271 | Takahashi, who works at DISCO, is standing before an iron bar. The bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters. Takahashi wanted to choose a notch and cut the bar at that point into two parts with the same length. However, this may not be po... | from itertools import accumulate
N = int(input())
A = [0] + list(accumulate(map(int, input().split())))
print(A)
min_diff = float("inf")
for i in range(N - 1):
if abs(A[N] - 2 * A[i + 1]) < min_diff:
min_diff = abs(A[N] - 2 * A[i + 1])
print(abs(min_diff))
| s073489197 | Accepted | 175 | 31,792 | 273 | from itertools import accumulate
N, *A = map(int, open(0).read().split())
A_acc = list(accumulate(A, initial=0))
min_diff = float("inf")
for i in range(1, N):
left, right = A_acc[i], A_acc[N] - A_acc[i]
min_diff = min(min_diff, abs(right - left))
print(min_diff)
|
s760155332 | p03910 | u987164499 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 198 | The problem set at _CODE FESTIVAL 20XX Finals_ consists of N problems. The score allocated to the i-th (1≦i≦N) problem is i points. Takahashi, a contestant, is trying to score exactly N points. For that, he is deciding which problems to solve. As problems with higher scores are harder, he wants to minimize the highe... | from sys import stdin
n = int(stdin.readline().rstrip())
point = 0
for i in range(1,n+1):
point += i
if point >= n:
print(i)
if n-i != 0:
print(n-i)
break | s127702697 | Accepted | 21 | 3,572 | 221 | from sys import stdin
n = int(stdin.readline().rstrip())
point = 0
for i in range(1,n+1):
point += i
if point >= n:
sa = point-n
for k in [j for j in range(1,i+1) if j != sa]:print(k)
break |
s039639105 | p03623 | u864900001 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 104 | 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... | #ABC71
x, a, b = map(int, input().split())
if(abs(x-a)>(abs(x-b))):
print("A")
else:
print("B") | s258268369 | Accepted | 17 | 2,940 | 104 | #ABC71
x, a, b = map(int, input().split())
if(abs(x-a)>(abs(x-b))):
print("B")
else:
print("A") |
s735615036 | p03778 | u393512980 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 119 | AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the min... | w,a,b=map(int,input().split())
if a>b:
t=a
a=b
b=t
if b-a<abs(b-a-w)+1:
print(b-a)
else:
print(abs(b-a-w)+1)
| s548386021 | Accepted | 17 | 2,940 | 103 | w,a,b=map(int,input().split())
if a>b:
t=a
a=b
b=t
if a<=b<=a+w:
print(0)
else:
print(b-a-w)
|
s846920872 | p03361 | u387774811 | 2,000 | 262,144 | Wrong Answer | 24 | 3,064 | 568 | We have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i... | h,w=map(int,input().split())
list1=[[0 for i in range(w)]for j in range(h)]
list2=[[0 for i in range(w)]for j in range(h)]
dx=[-1,-1,0,0]
dy=[0,0,-1,1]
a=0
for j in range(h):
s=input()
for i in range(w):
list1[j][i]=s[i]
for j in range(h):
for i in range(w):
if list1[j][i]=="#":
for k in range(4):
xk=... | s958405556 | Accepted | 24 | 3,064 | 566 | h,w=map(int,input().split())
list1=[[0 for i in range(w)]for j in range(h)]
list2=[[0 for i in range(w)]for j in range(h)]
dx=[-1,1,0,0]
dy=[0,0,-1,1]
a=0
for j in range(h):
s=input()
for i in range(w):
list1[j][i]=s[i]
for j in range(h):
for i in range(w):
if list1[j][i]=="#":
for k in range(4):
xk=i... |
s380728863 | p03150 | u589716761 | 2,000 | 1,048,576 | Wrong Answer | 19 | 3,064 | 357 | A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string. | S=input()
K=list('keyence')
n=0
flg=0
i_cut=[0,0]
for i,c in enumerate(S):
if c==K[n]:
if flg==1:
i_cut[1] = i-1
break
n+=1
if n>=7:
if flg==0:
i_cut = [i+1,len(S)]
break
else:
if flg==0:
i_cut[0] = i
flg +=1
if S[:i_cut[0]]+S[1+i_cut[1]:]=='keyence... | s276171522 | Accepted | 18 | 3,060 | 175 | S=input()
N=len(S)
for i in range(0,N+1):
for j in range(i,N+1):
if S[:i] + S[j:] == 'keyence':
print("YES")
exit(0)
else:
print('NO') |
s701123289 | p03139 | u477320129 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 77 | We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A respondents answered "yes" to Question 1, and B respondents answ... | N, A, B = list(map(int, input().split()))
print(min(A, B), abs(A - (N - B)))
| s786899742 | Accepted | 17 | 2,940 | 78 | N, A, B = list(map(int, input().split()))
print(min(A, B), max(A + B - N, 0))
|
s075744306 | p02392 | u410114382 | 1,000 | 131,072 | Wrong Answer | 20 | 7,644 | 80 | Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No". | a,b,c = map(int,input().split())
if a<b<c:
print('yes')
else:
print('no') | s584353514 | Accepted | 20 | 7,640 | 78 | a,b,c = map(int,input().split())
if a<b<c:
print('Yes')
else:
print('No') |
s734618616 | p04045 | u504662715 | 2,000 | 262,144 | Time Limit Exceeded | 2,205 | 9,052 | 272 | 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 ... | n,k = input().split()
d = list(map(int,input().split()))
num = [i for i in range(10)]
poss = list(set(d) ^ set(num))
an = int(n)
while True:
sum = 0
for p in poss:
sum += n.count(str(p))
if sum ==len(n):
break
else:
an +=1
print(an) | s972999559 | Accepted | 81 | 9,088 | 141 | n,k = map(int,input().split())
d=set(input().split())
while True:
if len(set(str(n))&d)!=0:
n+=1
else:
break
print(n) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.