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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s940426059 | p03351 | u910756197 | 2,000 | 1,048,576 | Wrong Answer | 19 | 2,940 | 142 | Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate. | a, b, c, d = map(int, input().split(" "))
if abs(a - c) <= d or (abs(a - b) <= d and abs(b - c) <= d):
print("YES")
else:
print("NO") | s751224308 | Accepted | 17 | 2,940 | 142 | a, b, c, d = map(int, input().split(" "))
if abs(a - c) <= d or (abs(a - b) <= d and abs(b - c) <= d):
print("Yes")
else:
print("No") |
s262392450 | p02418 | u406002631 | 1,000 | 131,072 | Wrong Answer | 20 | 5,552 | 123 | Write a program which finds a pattern $p$ in a ring shaped text $s$. | s = input()
s += s
print(s)
key = input()
print(s.find(key))
if s.find(key) != -1:
print("Yes")
else:
print("No") | s987862896 | Accepted | 20 | 5,548 | 96 | s = input()
s += s
key = input()
if s.find(key) != -1:
print("Yes")
else:
print("No") |
s094315584 | p04029 | u568711768 | 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+1)*n/2) | s175861739 | Accepted | 17 | 2,940 | 54 | n = int(input())
ans = n * (n + 1) / 2
print(int(ans)) |
s133283777 | p00014 | u766477342 | 1,000 | 131,072 | Wrong Answer | 20 | 7,620 | 126 | Write a program which computes the area of a shape represented by the following three lines: $y = x^2$ $y = 0$ $x = 600$ It is clear that the area is $72000000$, if you use an integral you learn in high school. On the other hand, we can obtain an approximative area of the shape by adding up areas of many rectangles in the shape as shown in the following figure: $f(x) = x^2$ The approximative area $s$ where the width of the rectangles is $d$ is: area of rectangle where its width is $d$ and height is $f(d)$ $+$ area of rectangle where its width is $d$ and height is $f(2d)$ $+$ area of rectangle where its width is $d$ and height is $f(3d)$ $+$ ... area of rectangle where its width is $d$ and height is $f(600 - d)$ The more we decrease $d$, the higer-precision value which is close to $72000000$ we could obtain. Your program should read the integer $d$ which is a divisor of $600$, and print the area $s$. | d = int(input())
s = 0
for n in [i * d for i in range(1, 600)]:
if n >= 600:
break
s += (n ** 2)
print(s * d) | s696686277 | Accepted | 30 | 7,600 | 218 | try:
while(1):
d = int(input())
s = 0
for n in [i * d for i in range(1, 600)]:
if n >= 600:
break
s += (n ** 2)
print(s * d)
except:
pass |
s985953577 | p03214 | u905582793 | 2,525 | 1,048,576 | Wrong Answer | 17 | 2,940 | 176 | Niwango-kun is an employee of Dwango Co., Ltd. One day, he is asked to generate a thumbnail from a video a user submitted. To generate a thumbnail, he needs to select a frame of the video according to the following procedure: * Get an integer N and N integers a_0, a_1, ..., a_{N-1} as inputs. N denotes the number of the frames of the video, and each a_i denotes the representation of the i-th frame of the video. * Select t-th frame whose representation a_t is nearest to the average of all frame representations. * If there are multiple such frames, select the frame with the smallest index. Find the index t of the frame he should select to generate a thumbnail. | n = int(input())
a = list(map(int,input().split()))
avg = sum(a)/n
difmin = 10**18
for i in range(n):
if difmin>abs(a[i]-avg):
difmin = abs(a[i]-avg)
ans = i
print(i) | s076783181 | Accepted | 17 | 2,940 | 179 | n = int(input())
a = list(map(int,input().split()))
avg = sum(a)/n
difmin = 10**18
for i in range(n):
if difmin>abs(a[i]-avg):
difmin = abs(a[i]-avg)
ans = i
print(ans)
|
s805738098 | p02619 | u312078744 | 2,000 | 1,048,576 | Wrong Answer | 125 | 27,396 | 571 | 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 check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated. | import sys
import numpy as np
from operator import mul
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
d = int(readline())
c = list(map(int, readline().split()))
s = []
for _ in range(d):
add = list(map(int, readline().split()))
s.append(add)
#t = [0] * d
day = 0
satisfy = 0
sumC = sum(c)
count = np.zeros(26)
for i in range(d):
t = int(readline()) - 1
up = s[day][t]
count += 1
count[t] = 0
sub = map(mul, count, c)
satisfy += (up - sum(sub))
# satisfy
print(satisfy)
| s658128953 | Accepted | 118 | 27,072 | 588 | import sys
import numpy as np
from operator import mul
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
d = int(readline())
c = list(map(int, readline().split()))
s = []
for _ in range(d):
add = list(map(int, readline().split()))
s.append(add)
#t = [0] * d
day = 0
satisfy = 0
sumC = sum(c)
count = np.zeros(26)
for i in range(d):
t = int(readline()) - 1
up = s[day][t]
count += 1
count[t] = 0
sub = map(mul, count, c)
satisfy += (up - sum(sub))
# satisfy
print(int(satisfy))
day += 1
|
s367163199 | p03469 | u204260373 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 43 | 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 column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it. | y,m,d=input().split("/")
print("2018/01"+d) | s919238332 | Accepted | 18 | 3,064 | 45 | y,m,d=input().split("/")
print("2018/01/"+d)
|
s805648337 | p02606 | u161134623 | 2,000 | 1,048,576 | Wrong Answer | 29 | 9,088 | 108 | How many multiples of d are there among the integers between L and R (inclusive)? | c = 0
L, R, d = map(int, input().split())
for i in range(L, R+1):
if i % d == 0:
c += 1
print(d) | s533372784 | Accepted | 25 | 9,088 | 108 | c = 0
L, R, d = map(int, input().split())
for i in range(L, R+1):
if i % d == 0:
c += 1
print(c) |
s104373603 | p03719 | u240793404 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 66 | You are given three integers A, B and C. Determine whether C is not less than A and not greater than B. | a,b,c = map(int,input().split())
print("YES" if a<=c<=b else "NO") | s211248919 | Accepted | 17 | 2,940 | 66 | a,b,c = map(int,input().split())
print("Yes" if a<=c<=b else "No") |
s961302634 | p03993 | u965436898 | 2,000 | 262,144 | Wrong Answer | 2,104 | 14,008 | 413 | 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. Calculate the number of the friendly pairs. | n = int(input())
a = list(map(int,input().split()))
pre = 0
num = 0
ans = []
for i in range(n):
if num >= n:
break
p1 = a[num]
p1_v2 = a[a[a[num] - 1] - 1]
p2 = a[a[num] - 1]
if p1 == p1_v2 and not [p1,p2] in ans:
print(a[num])
#print(a[a[a[num]-1]-1])
print(p2)
ans.append([p1,p2])
ans.append([p2,p1])
num += 2
#n -= 1
else:
num += 1
print(len(ans)//2) | s474448274 | Accepted | 66 | 14,008 | 144 | n = int(input())
a = list(map(int,input().split()))
ans = 0
for key_i, i in enumerate(a):
if a[i - 1] == key_i + 1:
ans += 1
print(ans//2) |
s980408216 | p02396 | u602702913 | 1,000 | 131,072 | Wrong Answer | 20 | 5,592 | 124 | 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 given for this problem. |
x=list(map(int,input()))
for n in x:
i=1
if n==0:
break
else:
print("Case",i,":",n)
i=i+1
| s897139509 | Accepted | 140 | 7,652 | 133 | i=1
while True:
a=int(input())
if 1<=a<=10000:
print("Case"+" "+str(i)+":"+" "+str(a))
i+=1
else:
break
|
s814007725 | p02645 | u642341748 | 2,000 | 1,048,576 | Wrong Answer | 22 | 9,056 | 35 | 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()
S = str()
print(S[:3]) | s618830103 | Accepted | 25 | 9,024 | 29 | S = str(input())
print(S[:3]) |
s139995348 | p03139 | u220870679 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 63 | 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 answered "yes" to Question 2. What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y? Write a program to answer this question. | n, a, b = map(int, input().split())
print(min(a, b), (a+b) - n) | s904756562 | Accepted | 17 | 2,940 | 99 | n, a, b = map(int, input().split())
if n > a+b:
x = 0
else:
x = a+b - n
print(min(a, b), x) |
s824569498 | p03455 | u798316285 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 61 | AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. | print("Even" if eval(input().replace(" ","*"))==0 else "Odd") | s093340926 | Accepted | 19 | 2,940 | 63 | print("Even" if eval(input().replace(" ","*"))%2==0 else "Odd") |
s338604536 | p03457 | u009219947 | 2,000 | 262,144 | Wrong Answer | 455 | 3,064 | 429 | AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan. | N = int(input())
s_x = 0
s_y = 0
s_t = 0
travel_flag = True
def judge_ok(d_p, d_t):
if d_p > d_t:
return False
if d_p % 2 != d_t % 2:
return False
return False
for n in range(N):
n_t, n_x, n_y = list(map(lambda x:int(x), input().split(" ")))
if not judge_ok(n_x - s_x + n_y - s_y, n_t - s_t):
travel_flag = False
s_x = n_x
s_y = n_y
s_t = n_t
if travel_flag:
print("Yes")
else:
print("No") | s218745055 | Accepted | 461 | 3,064 | 438 | N = int(input())
s_x = 0
s_y = 0
s_t = 0
travel_flag = True
def judge_ok(d_p, d_t):
if d_p > d_t:
return False
if d_p % 2 != d_t % 2:
return False
return True
for n in range(N):
n_t, n_x, n_y = list(map(lambda x:int(x), input().split(" ")))
if not judge_ok(abs(n_x - s_x) + abs(n_y - s_y), n_t - s_t):
travel_flag = False
s_x = n_x
s_y = n_y
s_t = n_t
if travel_flag:
print("Yes")
else:
print("No") |
s469460419 | p03574 | u041075929 | 2,000 | 262,144 | Wrong Answer | 43 | 3,572 | 851 | You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process. | import sys, os
f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
sys.stdin = open('./input.txt', 'r')
def solve():
h, w = f()
s = [input() for i in range(h)]
d = [[0]*w for i in range(h)]
print(s)
for i in range(h):
for j in range(w):
if s[i][j] == '.':
cnt = 0
for x in range(-1,2):
for y in range(-1,2):
if i+x in range(h) and j+y in range(w):
if s[i+x][j+y] == '#':
cnt+=1
d[i][j] = str(cnt)
for i in range(h):
for j in range(w):
if s[i][j] == '.':
print(d[i][j], end = '' if j!=w-1 else '\n')
else:
print(s[i][j], end = '' if j!=w-1 else '\n')
solve()
| s170702633 | Accepted | 42 | 3,444 | 833 | import sys, os
f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
sys.stdin = open('./input.txt', 'r')
def solve():
h, w = f()
s = [input() for i in range(h)]
d = [[0]*w for i in range(h)]
for i in range(h):
for j in range(w):
if s[i][j] == '.':
cnt = 0
for x in range(-1,2):
for y in range(-1,2):
if i+x in range(h) and j+y in range(w):
if s[i+x][j+y] == '#':
cnt+=1
d[i][j] = cnt
for i in range(h):
for j in range(w):
if s[i][j] == '.':
print(d[i][j], end = '' if j!=w-1 else '\n')
else:
print(s[i][j], end = '' if j!=w-1 else '\n')
solve()
|
s382885884 | p03644 | u488934106 | 2,000 | 262,144 | Time Limit Exceeded | 2,104 | 3,060 | 342 | Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times. | def breaknumbeer(n):
ans = 0
maxcount = 0
for i in range(n):
count = 0
w = i
while w % 2 == 0:
w = w / 2
count += 1
if count >= maxcount:
ans = i
return ans
def main():
n = int(input())
print(breaknumbeer(n))
if __name__ == '__main__':
main() | s426768943 | Accepted | 17 | 2,940 | 196 | def breaknumbeer(n):
ans = 1
while ans <= n:
ans *= 2
return int(ans / 2)
def main():
n = int(input())
print(breaknumbeer(n))
if __name__ == '__main__':
main() |
s404009309 | p03545 | u627981695 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 242 | Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted. | S = input()
for i in range(1 << len(S)-1):
f = ''
for j in range(len(S)-1):
f += S[j]
if (i >> j) & 1 == 1:
f += '+'
else:
f += '-'
f += S[-1]
if eval(f) == 7:
print(f)
| s787011164 | Accepted | 17 | 3,060 | 276 | S = input()
for i in range(1 << len(S)-1):
f = ''
for j in range(len(S)-1):
f += S[j]
if (i >> j) & 1:
f += '+'
else:
f += '-'
f += S[-1]
if eval(f) == 7:
ans = f + '=7'
print(ans)
break
|
s876031059 | p03644 | u445380615 | 2,000 | 262,144 | Time Limit Exceeded | 2,107 | 2,940 | 213 | Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times. | suuji = int(input())
cntmax = 0
dst = 1
for i in range(suuji):
suu = i
cnt = 0
while suu % 2 == 0:
suu /= 2
cnt += 1
if cntmax < cnt:
cntmax = cnt
dst = i
print(dst) | s118804979 | Accepted | 18 | 3,060 | 365 | suuji = int(input())
srclist = [1, 2, 4, 8, 16, 32, 64, 128]
dst = 0
for i in range(len(srclist)):
if srclist[i] > suuji:
break
print(srclist[i-1])
cntmax = 0
dst = 1
for i in range(suuji):
for cnt in range(1, 1000):
bit = 2**cnt-1
if i & bit != 0:
break
if cntmax < cnt - 1:
cntmax = cnt - 1
dst = i
|
s542856058 | p02743 | u875028418 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 77 | Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold? | a,b,c=map(int,input().split())
print("yes" if a**0.5+b**0.5<c**0.5 else "no") | s220777409 | Accepted | 18 | 2,940 | 86 | a,b,c=map(int,input().split())
print("Yes" if c-a-b>0 and 4*a*b<(a+b-c)**2 else "No")
|
s064570457 | p03860 | u821432765 | 2,000 | 262,144 | Wrong Answer | 20 | 2,940 | 45 | Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name. | _, s, _ = input().split()
print(s[0].upper()) | s686403809 | Accepted | 17 | 2,940 | 54 | _, s, _ = input().split()
print("A"+s[0].upper()+"C")
|
s813439165 | p03370 | u767664985 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 116 | 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 of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition. | N, X = map(int, input().split())
m = [int(input()) for _ in range(N)]
ans = ((X - sum(m)) // min(m)) + 1
print(ans)
| s314266217 | Accepted | 18 | 2,940 | 121 | N, X = map(int, input().split())
m = [int(input()) for _ in range(N)]
ans = ((X - sum(m)) // min(m)) + len(m)
print(ans)
|
s364180120 | p04011 | u118642796 | 2,000 | 262,144 | Wrong Answer | 19 | 2,940 | 155 | 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. | N = int(input())
K = int(input())
X = int(input())
Y = int(input())
ans = 0
for i in range(1,N):
if i<= K:
ans += X
else:
ans += Y
print(ans) | s372793304 | Accepted | 19 | 3,060 | 157 | N = int(input())
K = int(input())
X = int(input())
Y = int(input())
ans = 0
for i in range(1,N+1):
if i<= K:
ans += X
else:
ans += Y
print(ans) |
s143784285 | p04012 | u587482466 | 2,000 | 262,144 | Wrong Answer | 29 | 4,188 | 777 | Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful. | # -*- coding: utf-8 -*-
import itertools
import sys
import math
from functools import lru_cache
# n = int(input())
from queue import Queue
from operator import mul
from functools import reduce
from queue import Queue
from operator import mul
from functools import reduce
from functools import lru_cache
input = sys.stdin.readline
# a, b, c = list(map(int, input().split()))
# n = int(input())
# b = list(map(int, input().split()))
# t, d = input().split()
s=list(input())
m = {}
for c in s:
if c in m:
m[c] = m[c] + 1
else:
m[c] = 1
#print(m)
for k in m:
if m[k] % 2 == 1:
print("No")
exit(0)
print("Yes")
| s437314698 | Accepted | 29 | 4,188 | 792 | # -*- coding: utf-8 -*-
import itertools
import sys
import math
from functools import lru_cache
# n = int(input())
from queue import Queue
from operator import mul
from functools import reduce
from queue import Queue
from operator import mul
from functools import reduce
from functools import lru_cache
# input = sys.stdin.readline
# a, b, c = list(map(int, input().split()))
# n = int(input())
# b = list(map(int, input().split()))
# t, d = input().split()
s = list(input())
#s = s[:-1]
m = {}
for c in s:
if c in m:
m[c] = m[c] + 1
else:
m[c] = 1
# print(m)
for k in m:
if m[k] % 2 == 1:
print("No")
exit(0)
print("Yes")
|
s997355252 | p02613 | u000875186 | 2,000 | 1,048,576 | Wrong Answer | 166 | 16,316 | 360 | Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format. | x=int(input())
b=0;
lst=[]
acs=0
was=0
res=0
tles=0
while(b<x):
new=input()
lst.append(new)
b+=1
for c in lst:
if(c=='AC'):
acs+=1
if(c=='WA'):
was+=1
if(c=='RE'):
res+=1
if(c=='TLE'):
tles+=1
print('AC X '+str(acs))
print('WA X '+ str(was))
print('RE X ' +str(res))
print('TLE X ' +str(tles))
| s903189965 | Accepted | 163 | 16,288 | 355 | x=int(input())
b=0;
lst=[]
acs=0
was=0
res=0
tles=0
while(b<x):
new=input()
lst.append(new)
b+=1
for c in lst:
if(c=='AC'):
acs+=1
if(c=='WA'):
was+=1
if(c=='RE'):
res+=1
if(c=='TLE'):
tles+=1
print('AC x '+str(acs))
print('WA x '+ str(was))
print('TLE x ' +str(tles))
print('RE x ' +str(res)) |
s682924003 | p03485 | u075303794 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 90 | 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())
if a+b%2 == 0:
print((a+b)//2)
else:
print((a+b)//2+1) | s236651287 | Accepted | 17 | 2,940 | 92 | a,b = map(int, input().split())
if (a+b)%2 == 0:
print((a+b)//2)
else:
print((a+b)//2+1) |
s525920097 | p03713 | u393512980 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 89 | There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}. | h,w=map(int,input().split())
if h%3==0 or w%3==0:
print(h*w//3)
else:
print(min(h,w)) | s316004928 | Accepted | 233 | 3,064 | 444 | H, W = map(int, input().split())
if H % 3 == 0 or W % 3 == 0:
print(0)
else:
ans = min(H, W)
for h in range(1, H):
y = (H - h) * W
x = h * (W // 2)
z = h * W - x
ans = min(ans, max(x, y, z) - min(x, y, z))
t = H
H = W
W = t
for h in range(1, H):
y = (H - h) * W
x = h * (W // 2)
z = h * W - x
ans = min(ans, max(x, y, z) - min(x, y, z))
print(ans)
|
s579644820 | p02659 | u886545507 | 2,000 | 1,048,576 | Wrong Answer | 23 | 9,116 | 85 | Compute A \times B, truncate its fractional part, and print the result as an integer. | #abc169c
a,b=map(str,input().split())
a=int(a)
b=float(b)
print(a,b)
print(int(a*b))
| s708615917 | Accepted | 23 | 9,156 | 85 | #abc169c
a,b=map(str,input().split())
a=int(a)
b=round(100*float(b))
print(a*b//100)
|
s653119788 | p03943 | u733337827 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 90 | Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students. | C = list(map(int, input().split()))
m = max(C)
s = sum(C) - m
print(['NO', 'YES'][m == s]) | s400314589 | Accepted | 17 | 2,940 | 76 | l, m, h = sorted(map(int, input().split()))
print(['No', 'Yes'][h == (l+m)]) |
s208039023 | p03377 | u604655161 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 177 | 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. | def ABC_94_A():
A,B,X = map(int, input().split())
if A+B>=X and A<=X:
print('Yes')
else:
print('No')
if __name__ == '__main__':
ABC_94_A() | s620392315 | Accepted | 17 | 2,940 | 177 | def ABC_94_A():
A,B,X = map(int, input().split())
if A+B>=X and A<=X:
print('YES')
else:
print('NO')
if __name__ == '__main__':
ABC_94_A() |
s255912397 | p02606 | u592826944 | 2,000 | 1,048,576 | Wrong Answer | 33 | 9,544 | 582 | How many multiples of d are there among the integers between L and R (inclusive)? | # Coding is about expressing your feeling, and
# there is always a better way to express your feeling_feelme
import sys
import math
# sys.stdin=open('input.txt','r')
# sys.stdout=open('output2.txt','w')
from sys import stdin,stdout
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=int(1e9 + 7)
l,r,d=iia()
print((r-l)//d)
| s810217750 | Accepted | 37 | 9,560 | 642 | # Coding is about expressing your feeling, and
# there is always a better way to express your feeling_feelme
import sys
import math
# sys.stdin=open('input.txt','r')
# sys.stdout=open('output2.txt','w')
from sys import stdin,stdout
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=int(1e9 + 7)
l,r,d=iia()
count=0
for i in range(l,r+1):
if i%d==0:
count+=1
print(count)
|
s613681428 | p03679 | u455696302 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 134 | Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache. | X,A,B = map(int,input().split())
if A - B > 0:
print('delicious')
elif A - B > X:
print('safe')
else:
print('dangerous')
| s665314594 | Accepted | 17 | 2,940 | 135 | X,A,B = map(int,input().split())
if A - B >= 0:
print('delicious')
elif B - A <= X:
print('safe')
else:
print('dangerous') |
s971488989 | p03377 | u859897687 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 77 | There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals. | a,b,c=map(int,input().split())
if a<=b<=c:
print('YES')
else:
print('NO') | s996533091 | Accepted | 17 | 2,940 | 79 | a,b,c=map(int,input().split())
if a<=c<=a+b:
print('YES')
else:
print('NO') |
s941016651 | p02608 | u525090128 | 2,000 | 1,048,576 | Wrong Answer | 2,206 | 8,892 | 303 | Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N). | import math
N = int(input())
for n in range(1,N):
r_n = math.floor(math.sqrt(N))
count = 0
for x in range(1,r_n):
for y in range(1,r_n):
for z in range(1,r_n):
if (x*x + y*y + z*z + x*y + y*z + z*x) == n:
count+=1
print(count) | s049532869 | Accepted | 418 | 9,264 | 323 | import math
N = int(input())
ans = [0 for _ in range(10050)]
r_n = math.floor(math.sqrt(N))
count = 0
for x in range(1,r_n):
for y in range(1,r_n):
for z in range(1,r_n):
n = x*x + y*y + z*z + x*y + y*z + z*x
if n < 10050:
ans[n]+=1
for i in range(N):
print(ans[i+1]) |
s525194206 | p03469 | u063346608 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 58 | 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 column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it. | S = input()
answer = S[0:2] + "8" + S[4:9]
print(answer) | s183062563 | Accepted | 17 | 2,940 | 61 | S = input()
answer = S[0:3] + "8" + S[4:10]
print(answer) |
s629867237 | p03139 | u616522759 | 2,000 | 1,048,576 | Wrong Answer | 18 | 2,940 | 144 | 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 answered "yes" to Question 2. What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y? Write a program to answer this question. | N, A, B = map(int, input().split())
if A <= B:
print(str(A) + ' ' + str(abs(N - A - B)))
else:
print(str(B) + ' ' + str(abs(N - A - B))) | s015121766 | Accepted | 17 | 2,940 | 71 | N, A, B = map(int, input().split())
print(min(A, B), max(0, A + B - N)) |
s941354419 | p03487 | u953379577 | 2,000 | 262,144 | Wrong Answer | 83 | 22,496 | 216 | You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**. Here, an sequence b is a **good sequence** when the following condition holds true: * For each element x in b, the value x occurs exactly x times in b. For example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not. Find the minimum number of elements that needs to be removed so that a will be a good sequence. | import collections as c
n = int(input())
s = list(map(int,input().split()))
s = c.Counter(s)
ans = 1
for i in s.items():
a = i[0]
b = i[1]
if b<a:
ans += b
else:
ans += b-a
print(ans) | s218730713 | Accepted | 76 | 22,504 | 216 | import collections as c
n = int(input())
s = list(map(int,input().split()))
s = c.Counter(s)
ans = 0
for i in s.items():
a = i[0]
b = i[1]
if b<a:
ans += b
else:
ans += b-a
print(ans) |
s655078073 | p03160 | u844789719 | 2,000 | 1,048,576 | Wrong Answer | 149 | 13,928 | 306 | There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N. | N = int(input())
H = [int(_) for _ in input().split()]
dp = [0, 0]
dp[0] = abs(H[1] - H[0])
if N == 2:
print(dp[0])
else:
dp[1] = abs(H[2] - H[0])
for i in range(3, N):
dp = [dp[1]] + [
min(dp[0] + abs(H[i] - H[i - 2]), dp[1] + abs(H[i] - H[i - 1]))
]
print(dp)
| s721825421 | Accepted | 145 | 13,928 | 310 | N = int(input())
H = [int(_) for _ in input().split()]
dp = [0, 0]
dp[0] = abs(H[1] - H[0])
if N == 2:
print(dp[0])
else:
dp[1] = abs(H[2] - H[0])
for i in range(3, N):
dp = [dp[1]] + [
min(dp[0] + abs(H[i] - H[i - 2]), dp[1] + abs(H[i] - H[i - 1]))
]
print(dp[-1])
|
s390230600 | p03567 | u331464808 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 115 | Snuke built an online judge to hold a programming contest. When a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring. (The judge can return any two-character substring of S.) Determine whether the judge can return the string `AC` as the verdict to a program. | s= input()
t=0
for i in range(len(s)-1):
if s[i:i+1]=="AC":
t +=1
if t>0:
print("Yes")
else:
print("No")
| s091683935 | Accepted | 20 | 2,940 | 118 | s= input()
t=0
for i in range(len(s)-1):
if s[i]+s[i+1]=="AC":
t +=1
if t>0:
print("Yes")
else:
print("No")
|
s551215549 | p04043 | u143189168 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 120 | Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order. | s = input().split()
if s==['5','5','7'] or s==['5','7','5'] or s==['7','5','5']:
print("OK")
else:
print("NO")
| s992905395 | Accepted | 17 | 2,940 | 121 | s = input().split()
if s==['5','5','7'] or s==['5','7','5'] or s==['7','5','5']:
print("YES")
else:
print("NO")
|
s667024820 | p02694 | u732870425 | 2,000 | 1,048,576 | Wrong Answer | 29 | 9,168 | 152 | Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time? | X = int(input())
ans = 0
money = 100
for i in range(10**18):
money = money * 1.01 // 1
if money >= X:
ans = i
break
print(ans) | s117714461 | Accepted | 30 | 8,880 | 158 | X = int(input())
ans = 0
money = 100
for i in range(1, 10**18):
money = (money * 101) // 100
if money >= X:
ans = i
break
print(ans) |
s460474959 | p03827 | u145600939 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 130 | 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 during the operations (including before the first operation, and after the last operation). | n = int(input())
s = input()
ans = 0
x = 0
for i in s:
if s == 'I':
x += 1
else:
x -= 1
ans = max(ans,x)
print(ans)
| s492265766 | Accepted | 17 | 2,940 | 130 | n = int(input())
s = input()
ans = 0
x = 0
for i in s:
if i == 'I':
x += 1
else:
x -= 1
ans = max(ans,x)
print(ans)
|
s814581399 | p04029 | u925353288 | 2,000 | 262,144 | Wrong Answer | 23 | 9,088 | 154 | 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())
# 1+2+3+4+...+(N-2)+(N-1)+N
# N+(N-1)+(N-2)+...+4+3+2+1
a = N+1
b = N
print( a * b / 2 )
| s747649952 | Accepted | 26 | 9,132 | 160 | N = int(input())
# 1+2+3+4+...+(N-2)+(N-1)+N
# N+(N-1)+(N-2)+...+4+3+2+1
a = N+1
b = N
print(int( a * b * 0.5 )) |
s088465721 | p03563 | u759412327 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 34 | Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the contest is b. * Then, the new rating of the user will be the avarage of a and b. For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000. Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest. Find the performance required to achieve it. | print(2*int(input())-int(input())) | s383930657 | Accepted | 23 | 9,132 | 35 | print(-int(input())+2*int(input())) |
s005424386 | p04044 | u099566485 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 132 | Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m. | N,L=map(int,input().split())
a=[]
for i in range(N):
a.append(input())
a.sort
s=""
for i in range(len(a)):
s=s+a[i]
print(s) | s359857227 | Accepted | 17 | 3,060 | 134 | N,L=map(int,input().split())
a=[]
for i in range(N):
a.append(input())
a.sort()
s=""
for i in range(len(a)):
s=s+a[i]
print(s) |
s315641347 | p03473 | u914330401 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 28 | How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December? | t = int(input())
print(t+24) | s286535760 | Accepted | 19 | 3,316 | 33 | t = int(input())
print((24-t)+24) |
s964628267 | p03351 | u883040023 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 98 | Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate. | a,b,c,d = map(int,input().split())
print(["No","Yes"][abs(a-c)<=d or (abs(a-b)<d and abs(b-c)<d)]) | s230449903 | Accepted | 17 | 2,940 | 100 | a,b,c,d = map(int,input().split())
print(["No","Yes"][abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d)]) |
s901298536 | p03698 | u474925961 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 138 | You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different. | import sys
if sys.platform =='ios':
sys.stdin=open('input_file.txt')
S=input()
if len(S)==set(S):
print("yes")
else:
print("no") | s125282539 | Accepted | 17 | 2,940 | 143 | import sys
if sys.platform =='ios':
sys.stdin=open('input_file.txt')
S=input()
if len(S)==len(set(S)):
print("yes")
else:
print("no") |
s924751913 | p03415 | u407730443 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 66 | We have a 3×3 square grid, where each square contains a lowercase English letters. The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}. Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right. | c = [input() for i in range(3)]
print([c[i][i] for i in range(3)]) | s921234108 | Accepted | 17 | 2,940 | 76 | c = [input() for i in range(3)]
print("".join([c[i][i] for i in range(3)])) |
s614462144 | p03095 | u474579514 | 2,000 | 1,048,576 | Wrong Answer | 37 | 3,964 | 724 | You are given a string S of length N. Among its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings. Here, a subsequence of a string is a concatenation of **one or more** characters from the string without changing the order. | def main():
N = int(input())
S = input()
str_list = list()
for s in S:
str_list.append(s)
str_uni_list = {}
for str in str_list:
if (str in str_uni_list) is False:
str_uni_list[str] = 1
else:
str_uni_list[str] += 1
list_val = []
for i in str_uni_list.values():
list_val.append(i)
ans = 0
for i in range(len(list_val)):
for j in range(i + 1, len(list_val)):
for k in range(1, len(list_val) - j + 1):
temp = list_val[i]
for m in range(j, j + k):
temp *= list_val[m]
ans += temp
print(N + ans)
if __name__ == '__main__':
main()
| s360323396 | Accepted | 35 | 3,956 | 521 | def main():
N = int(input())
S = input()
str_list = list()
for s in S:
str_list.append(s)
str_uni_list = {}
for str in str_list:
if (str in str_uni_list) is False:
str_uni_list[str] = 1
else:
str_uni_list[str] += 1
list_val = []
for i in str_uni_list.values():
list_val.append(i)
rem = 1
for v in list_val:
rem *= (v + 1)
ans = rem - 1
print(ans % (10 ** 9 + 7))
if __name__ == '__main__':
main()
|
s695194467 | p04029 | u147912476 | 2,000 | 262,144 | Wrong Answer | 30 | 9,088 | 57 | 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('子供は何人?'))
a=N*(N+1)/2
print(a) | s295916757 | Accepted | 26 | 9,056 | 42 | N=int(input())
a=int(N*(N+1)/2)
print(a) |
s209312595 | p03080 | u268210555 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 99 | There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat. | n = int(input())
s = input()
if s.count('R') > s.count('B'):
print('YES')
else:
print('No') | s637920002 | Accepted | 17 | 2,940 | 99 | n = int(input())
s = input()
if s.count('R') > s.count('B'):
print('Yes')
else:
print('No') |
s257662308 | p03739 | u187205913 | 2,000 | 262,144 | Wrong Answer | 2,108 | 15,044 | 708 | You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term. | n = int(input())
a = list(map(int,input().split()))
for i in range(1,n):
a[i] += a[i-1]
a_1 = a.copy()
ans = 0
for i in range(n):
if i%2==0 and a_1[i]<=0:
tmp = -a_1[i]-1
for j in range(i,n):
a_1[j] += tmp
ans += abs(tmp)
elif i%2==1 and a_1[i]>=0:
tmp = -a_1[i]+1
for j in range(i,n):
a_1[j] += tmp
ans += abs(tmp)
ans_2 = 0
for i in range(n):
if i%2==1 and a[i]<=0:
tmp = -a[i]+1
for j in range(i,n):
a[j] += tmp
ans_2 += abs(tmp)
elif i%2==0 and a[i]>=0:
tmp = -a[i]-1
for j in range(i,n):
a[j] += tmp
ans_2 += abs(tmp)
print(min(ans,ans_2)) | s124630672 | Accepted | 184 | 14,212 | 588 | n = int(input())
a = list(map(int,input().split()))
for i in range(1,n):
a[i] += a[i-1]
a_1 = a.copy()
ans = 0
k = 0
for i in range(n):
if i%2==0 and a_1[i]+k<=0:
tmp = -a_1[i]-k+1
k += tmp
ans += abs(tmp)
elif i%2==1 and a_1[i]+k>=0:
tmp = -a_1[i]-k-1
k += tmp
ans += abs(tmp)
ans_2 = 0
k = 0
for i in range(n):
if i%2==1 and a[i]+k<=0:
tmp = -a[i]-k+1
k += tmp
ans_2 += abs(tmp)
elif i%2==0 and a[i]+k>=0:
tmp = -a[i]-k-1
k += tmp
ans_2 += abs(tmp)
print(min(ans,ans_2)) |
s516573406 | p03795 | u419963262 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 91 | Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y. | N=int(input())
ans=1
for i in range(1,N+1):
ans=(ans*i)%1000000007
print(ans%(10**9+7)) | s747185307 | Accepted | 17 | 2,940 | 44 | N=int(input())
print(int(N*800-(N//15*200))) |
s803132955 | p02612 | u035445296 | 2,000 | 1,048,576 | Wrong Answer | 28 | 9,132 | 24 | 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. | print(int(input())%1000) | s790713442 | Accepted | 26 | 9,132 | 68 | n = int(input())
print(0 if n%1000 == 0 else 1000*((n//1000)+1) - n) |
s520306760 | p03693 | u815797488 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 98 | AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4? | r,g,b = map(int, input().split())
A = g * 10 + b
if A % 4 == 0:
print("yes")
else:
print("No") | s651271097 | Accepted | 17 | 2,940 | 98 | r,g,b = map(int, input().split())
A = g * 10 + b
if A % 4 == 0:
print("YES")
else:
print("NO") |
s168453355 | p03855 | u724687935 | 2,000 | 262,144 | Wrong Answer | 2,108 | 10,044 | 945 | 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 same pair of cities. We will say city A and B are _connected by roads_ if city B is reachable from city A by traversing some number of roads. Here, any city is considered to be connected to itself by roads. We will also define _connectivity by railways_ similarly. For each city, find the number of the cities connected to that city by both roads and railways. | class UnionFind():
def __init__(self, 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 = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.parents[y]
self.parents[y] = x
N, K, L = map(int, input().split())
uf = UnionFind(2 * N)
for _ in range(K):
p, q = map(int, input().split())
uf.union(p - 1, q - 1)
for _ in range(L):
r, s = map(int, input().split())
uf.union(r - 1 + N, s - 1 + N)
for i in range(N):
cnt = 0
for j in range(i, N):
if uf.find(i) == uf.find(j) and uf.find(i + N) == uf.find(j + N):
cnt += 1
print(cnt, end=' ')
print('')
| s723330847 | Accepted | 933 | 57,480 | 1,411 | class UnionFind():
def __init__(self, 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 = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.parents[y]
self.parents[y] = x
def main():
import sys
from collections import Counter
# readline = sys.stdin.readline
readlines = sys.stdin.readlines
N, K, L = map(int, input().split())
uf1 = UnionFind(N)
uf2 = UnionFind(N)
IN = readlines()
for i in range(K):
p, q = map(int, IN[i].split())
p -= 1; q -= 1
uf1.union(p, q)
for j in range(K, K + L):
r, s = map(int, IN[j].split())
r -= 1; s -= 1
uf2.union(r, s)
# ans = []
# print(*ans)
path = []
C = Counter()
for i in range(N):
pair = (uf1.find(i), uf2.find(i))
path.append(pair)
C[pair] += 1
ans = []
for i in range(N):
ans.append(C[path[i]])
print(*ans)
if __name__ == "__main__":
main()
|
s253889168 | p03720 | u934442292 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 169 | There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city? | N, M = map(int, input().split())
ans = [0] * N
for i in range(M):
a, b = map(int, input().split())
ans[a - 1] += 1
ans[b - 1] += 1
for i in range(N):
print(ans)
| s281254618 | Accepted | 18 | 2,940 | 159 | N, M = map(int, input().split())
ans = [0] * N
for _ in range(M):
a, b = map(int, input().split())
ans[a - 1] += 1
ans[b - 1] += 1
print(*ans, sep="\n")
|
s656701316 | p03478 | u698348858 | 2,000 | 262,144 | Wrong Answer | 33 | 3,060 | 207 | 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). | #coding:utf-8
n, a, b = map(int, input().split(' '))
cnt = 0
for i in range(n):
str_i = str(i)
sum = 0
for char in str_i:
sum += int(char)
if sum >= a and sum <= b:
cnt += 1
print(cnt) | s785249339 | Accepted | 34 | 3,060 | 220 | #coding:utf-8
n, a, b = map(int, input().split(' '))
total = 0
for i in range(1, n + 1):
str_i = str(i)
sum = 0
for char in str_i:
sum += int(char)
if sum >= a and sum <= b:
total += i
print(total) |
s480773146 | p04043 | u935477635 | 2,000 | 262,144 | Wrong Answer | 26 | 9,044 | 120 | Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order. | syl=sorted(list(map(int,input().split())))
print(syl)
syl2=[5, 5, 7]
if syl == syl2:
print('YES')
else:
print('NO') | s239971135 | Accepted | 28 | 8,988 | 108 | syl=sorted(list(map(int,input().split())))
syl2=[5, 5, 7]
if syl == syl2:
print('YES')
else:
print('NO') |
s933469944 | p03827 | u331997680 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 64 | 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 during the operations (including before the first operation, and after the last operation). | N = input()
S = list(input())
print(S.count('D') + S.count('I')) | s851829936 | Accepted | 17 | 2,940 | 176 | N = input()
S = list(input())
cnt = 0
cnt_max = 0
for i in S:
if i == 'I':
cnt += 1
if cnt > cnt_max:
cnt_max = cnt
elif i == 'D':
cnt -= 1
print(cnt_max) |
s468939153 | p02606 | u032955959 | 2,000 | 1,048,576 | Wrong Answer | 32 | 9,160 | 59 | How many multiples of d are there among the integers between L and R (inclusive)? | l,r,d=map(int,input().split())
a=l-1//d
b=r//d
print(b-a) | s913532742 | Accepted | 27 | 9,096 | 61 | l,r,d=map(int,input().split())
a=(l-1)//d
b=r//d
print(b-a) |
s495125327 | p03957 | u647537044 | 1,000 | 262,144 | Wrong Answer | 22 | 3,064 | 323 | This contest is `CODEFESTIVAL`, which can be shortened to the string `CF` by deleting some characters. Mr. Takahashi, full of curiosity, wondered if he could obtain `CF` from other strings in the same way. You are given a string s consisting of uppercase English letters. Determine whether the string `CF` can be obtained from the string s by deleting some characters. | s = list(input())
offset_f = []
offset_c = []
for i in range(len(s)):
if s[i] == 'F':
offset_f += [i]
offset_f.sort()
for i in range(len(s)):
if s[i] == 'C':
offset_c += [i]
offset_c.sort()
if offset_f[-1] > offset_c[0]:
print('YES')
else:
print('NO')
| s366524097 | Accepted | 24 | 3,064 | 406 | s = list(input())
offset_f = []
offset_c = []
for i in range(len(s)):
if s[i] == 'F':
offset_f += [i]
offset_f.sort()
for i in range(len(s)):
if s[i] == 'C':
offset_c += [i]
offset_c.sort()
if offset_f and offset_c:
if offset_f[-1] > offset_c[0]:
print('Yes')
else:
print('No')
else:
print('No') |
s054590108 | p03543 | u551109821 | 2,000 | 262,144 | Wrong Answer | 20 | 3,316 | 224 | We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**? | import collections
N = list(input())
judge = False
a = collections.Counter(N)
for i in a.values():
if int(i) >= 3:
print('Yes')
judge = True
break
if judge:
print('Yes')
else:
print('No') | s155323266 | Accepted | 20 | 3,316 | 264 | import collections
N = list(input())
cnt = 0
ans = []
for i in range(len(N)-1):
if N[i] == N[i+1]:
cnt += 1
else:
ans.append(cnt)
cnt = 0
ans.append(cnt)
for i in ans:
if i >= 2:
print('Yes')
exit()
print('No') |
s311915083 | p03657 | u375282392 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 122 | Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. | a,b=map(int,input().split())
if a % 3 != 0 and b % 3 != 0 and a+b % 3 != 0:
print('Impossible')
else:
print('Possible') | s670670169 | Accepted | 17 | 2,940 | 124 | a,b=map(int,input().split())
if a % 3 != 0 and b % 3 != 0 and (a+b) % 3 != 0:
print('Impossible')
else:
print('Possible') |
s628944886 | p03657 | u759651152 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 196 | Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. | #-*-coding:utf-8-*-
def main():
a, b = map(int, input().split())
if a + b % 3 == 0:
print('Possible')
else:
print('Impossible')
if __name__ == '__main__':
main() | s466893956 | Accepted | 17 | 2,940 | 226 | #-*-coding:utf-8-*-
def main():
a, b = map(int, input().split())
if (a + b) % 3 == 0 or a % 3 == 0 or b % 3 == 0:
print('Possible')
else:
print('Impossible')
if __name__ == '__main__':
main() |
s456267307 | p03337 | u488934106 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 183 | You are given two integers A and B. Find the largest value among A+B, A-B and A \times B. | def Add_Sub_Mul(a , b):
return min(a + b , a - b , a * b)
def main():
a , b = map(int , input().split())
print(Add_Sub_Mul(a , b))
if __name__ == '__main__':
main() | s967255442 | Accepted | 17 | 2,940 | 183 | def Add_Sub_Mul(a , b):
return max(a + b , a - b , a * b)
def main():
a , b = map(int , input().split())
print(Add_Sub_Mul(a , b))
if __name__ == '__main__':
main() |
s670667142 | p03643 | u425351967 | 2,000 | 262,144 | Wrong Answer | 19 | 2,940 | 21 | This contest, _AtCoder Beginner Contest_ , is abbreviated as _ABC_. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer. | print("ABC", input()) | s559387461 | Accepted | 19 | 2,940 | 21 | print("ABC"+ input()) |
s023318951 | p03612 | u923659712 | 2,000 | 262,144 | Time Limit Exceeded | 2,104 | 14,008 | 204 | You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two **adjacent** elements in the permutation. You want to have p_i ≠ i for all 1≤i≤N. Find the minimum required number of operations to achieve this. | n=int(input())
a=list(map(int,input().split()))
k=0
ans=0
while k<n:
if a[k]==k and a[k+1]==k:
k+=2
ans+=1
elif a[k]==k and a[k+1]!=k:
k+=1
ans+=1
else:
pass
print(ans)
| s184924357 | Accepted | 72 | 14,008 | 181 | N = int(input())
P = list(map(int,input().split()))
ans = 0
for i in range(N - 1):
if P[i] == i+1:
P[i],P[i+1] = P[i+1],P[i]
ans += 1
if P[-1] == N:
ans += 1
print(ans)
|
s493785031 | p03387 | u102960641 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 151 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | a, b, c = map(int, input().split())
if (a - b) % 2 == (b - c) % 2:
print((a - b) // 2 + (b - c) // 2)
else:
print((a - b) // 2 + (b - c) // 2 + 2) | s773427197 | Accepted | 18 | 3,064 | 268 | a, b, c = map(int, input().split())
A, B, C = sorted([a, b, c])
if (C - A) % 2 == (C - B) % 2 == 0:
print((C - A) // 2 + (C - B) // 2)
elif (C - A) % 2 == (C - B) % 2 == 1:
print((C - A) // 2 + (C - B) // 2 + 1)
else:
print((C - A) // 2 + (C - B) // 2 + 2) |
s671333771 | p03555 | u901582103 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 48 | You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise. | print('Yes' if input()==input()[::-1] else 'No') | s033317526 | Accepted | 17 | 2,940 | 48 | print('YES' if input()==input()[::-1] else 'NO') |
s288856671 | p03738 | u978494963 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 114 | You are given two positive integers A and B. Compare the magnitudes of these numbers. | a = int(input())
b = int(input())
if a == b:
print("EQUAL")
elif a > b:
print("LESS")
else:
print("GREATER") | s816139188 | Accepted | 17 | 2,940 | 114 | a = int(input())
b = int(input())
if a == b:
print("EQUAL")
elif a > b:
print("GREATER")
else:
print("LESS") |
s316035589 | p03471 | u144072139 | 2,000 | 262,144 | Wrong Answer | 791 | 3,060 | 229 | The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough. | N, Y = map(int,input().split())
A = B = C = -1
for a in range(N+1):
for b in range(N+1-a):
c=N-a-b
if 10000*a+5000*b+1000*c==Y:
A = a
B = b
C = c
print(a, b, c) | s362573138 | Accepted | 758 | 3,060 | 229 | N, Y = map(int,input().split())
A = B = C = -1
for a in range(N+1):
for b in range(N+1-a):
c=N-a-b
if 10000*a+5000*b+1000*c==Y:
A = a
B = b
C = c
print(A, B, C) |
s136414921 | p02608 | u961288441 | 2,000 | 1,048,576 | Wrong Answer | 204 | 9,148 | 288 | Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N). | import math
N = int(input())
ans = [0]*N
for i in range(1,int(math.sqrt(N/3)+2)):
for j in range(1,int(math.sqrt(N/3)+2)):
for k in range(1,int(math.sqrt(N/3)+2)):
if (i+j+k)**2-(i*j+j*k+k*i) <= N:
ans[(i+j+k)**2-(i*j+j*k+k*i)-1] += 1
print(ans)
| s716450597 | Accepted | 514 | 9,372 | 256 | import math
N = int(input())
ans = [0]*N
l = int(math.sqrt(N))
for i in range(1,l):
for j in range(1,l):
for k in range(1,l):
a = (i+j+k)**2-(i*j+j*k+k*i)
if a <= N:
ans[a-1] += 1
print(*ans, sep='\n')
|
s129282836 | p04043 | u996564551 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 229 | Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order. | a = []
a = input().split(' ')
if 5 in a:
a.remove(5)
if 7 in a:
a.remove(7)
if 5 in a:
print('OK')
else:
print('NO')
else:
print('NO')
else:
print('NO') | s717110247 | Accepted | 17 | 2,940 | 240 | a = []
a = input().split(' ')
if '5' in a:
a.remove('5')
if '7' in a:
a.remove('7')
if '5' in a:
print('YES')
else:
print('NO')
else:
print('NO')
else:
print('NO') |
s515516688 | p02255 | u627348629 | 1,000 | 131,072 | Wrong Answer | 20 | 7,580 | 351 | Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step. | n = int(input())
sequence = input().split(' ')
sequence = [int(x) for x in sequence]
for i in range(1, n):
v = sequence[i]
j = i - 1
while j >= 0 and sequence[j] > v:
sequence[j+1] = sequence[j]
j -= 1
sequence[j+1] = v
for k in range(n-1):
print(format(sequence[k]) + ' ', end='')
print(sequence[n-1]) | s386508254 | Accepted | 30 | 8,040 | 442 | n = int(input())
sequence = input().split(' ')
sequence = [int(x) for x in sequence]
for h in range(n - 1):
print(format(sequence[h]) + ' ', end='')
print(sequence[n - 1])
for i in range(1, n):
v = sequence[i]
j = i - 1
while j >= 0 and sequence[j] > v:
sequence[j+1] = sequence[j]
j -= 1
sequence[j+1] = v
for k in range(n-1):
print(format(sequence[k]) + ' ', end='')
print(sequence[n-1]) |
s806672289 | p03162 | u484315555 | 2,000 | 1,048,576 | Wrong Answer | 1,921 | 46,260 | 614 | Taro's summer vacation starts tomorrow, and he has decided to make plans for it now. The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day: * A: Swim in the sea. Gain a_i points of happiness. * B: Catch bugs in the mountains. Gain b_i points of happiness. * C: Do homework at home. Gain c_i points of happiness. As Taro gets bored easily, he cannot do the same activities for two or more consecutive days. Find the maximum possible total points of happiness that Taro gains. | import numpy as np
def dprint(*args):
if debug:
if len(args)==1:
print(args[0])
else:
print(args)
debug = False
if debug:
N=3
ABC=[[10, 40, 70], [20, 50, 80], [30, 60, 90]]
else:
N = int(input())
ABC=[]
for i in range(N):
ABC.append(list(map(int,input().split())))
print(N,ABC)
# i -> 1 to N
# ABC -> 012
H = np.zeros((N,3))
H[0]=ABC[0]
for j in range(1,N):
H[j][0]=max(H[j][0], H[j-1][1]+ABC[j][0], H[j-1][2]+ABC[j][0])
H[j][1]=max(H[j][1], H[j-1][0]+ABC[j][1], H[j-1][2]+ABC[j][1])
H[j][2]=max(H[j][2], H[j-1][0]+ABC[j][2], H[j-1][1]+ABC[j][2])
print(max(H[-1]))
| s201741403 | Accepted | 1,867 | 42,704 | 618 | import numpy as np
def dprint(*args):
if debug:
if len(args)==1:
print(args[0])
else:
print(args)
debug = False
if debug:
N=3
ABC=[[10, 40, 70], [20, 50, 80], [30, 60, 90]]
else:
N = int(input())
ABC=[]
for i in range(N):
ABC.append(list(map(int,input().split())))
dprint(N,ABC)
# i -> 1 to N
# ABC -> 012
H = np.zeros((N,3))
H[0]=ABC[0]
for j in range(1,N):
H[j][0]=max(H[j][0], H[j-1][1]+ABC[j][0], H[j-1][2]+ABC[j][0])
H[j][1]=max(H[j][1], H[j-1][0]+ABC[j][1], H[j-1][2]+ABC[j][1])
H[j][2]=max(H[j][2], H[j-1][0]+ABC[j][2], H[j-1][1]+ABC[j][2])
print(int(max(H[-1]))) |
s891977012 | p03485 | u470359972 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 47 | 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())
x=(a+b)/2
print(x) | s960359750 | Accepted | 19 | 3,060 | 95 | a,b=map(int,input().split())
x=(a+b)
if x % 2 == 0:
print(int(x/2))
else:
print(int(x/2+1)) |
s057837013 | p03568 | u502314533 | 2,000 | 262,144 | Wrong Answer | 268 | 12,652 | 1,088 | We will say that two integer sequences of length N, x_1, x_2, ..., x_N and y_1, y_2, ..., y_N, are _similar_ when |x_i - y_i| \leq 1 holds for all i (1 \leq i \leq N). In particular, any integer sequence is similar to itself. You are given an integer N and an integer sequence of length N, A_1, A_2, ..., A_N. How many integer sequences b_1, b_2, ..., b_N are there such that b_1, b_2, ..., b_N is similar to A and the product of all elements, b_1 b_2 ... b_N, is even? | import sys
input = sys.stdin.readline
print = sys.stdout.write
N = int(input())
s = [int(i) for i in input().split()]
def checkCorrect(l):
for i in l:
if i % 2 == 0:
return True
return False
# Seen is a set of tuples
seen = set()
def recurse(t,max_depth,original=None,depth=0,total=0,seen=None):
if seen == None:
original = t
seen = set()
if checkCorrect(t) and t not in seen:
total += 1
seen.add(t)
for i in range(depth,max_depth):
p1 = list(t)
p1[i] -= 1
p2 = list(t)
p2[i] += 1
p1 = tuple(p1)
p2 = tuple(p2)
#print(p1,p2,depth,t)
if p1 not in seen and abs(p1[i] - original[i]) <= 1:
total = recurse(p1,max_depth,original,depth+1,total,seen)[0]
if p2 not in seen and abs(p2[i] - original[i]) <= 1:
total = recurse(p2,max_depth,original,depth+1,total,seen)[0]
return total,seen
s = tuple(s)
print(str(recurse(s,N)[0]))
| s558713119 | Accepted | 18 | 2,940 | 156 | N = int(input())
s = [int(i) for i in input().split()]
even = 0
odd = 0
for i in s:
if i % 2 == 0:
even += 1
print((3 ** len(s)) - (2 ** even)) |
s338287606 | p03079 | u687923925 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 115 | You are given three integers A, B and C. Determine if there exists an equilateral triangle whose sides have lengths A, B and C. | a, b, c = map(str, input().strip().split(' '))
if a+b>c and b+c>a and c+a>b:
print("yes")
else:
print("no") | s727248017 | Accepted | 18 | 2,940 | 103 | a, b, c = map(int, input().strip().split(' '))
if a==b and b==c:
print("Yes")
else:
print("No") |
s136598842 | p03495 | u641406334 | 2,000 | 262,144 | Wrong Answer | 2,105 | 28,580 | 437 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | N, K = map(int,input().split())
ball = input().split()
nums = sorted(list(set(ball)))
ball_num = len(nums)
if K >= ball_num:
print("0")
exit()
cnt = ball_num - K
temp_list = []
for j in range(ball_num):
num = ball.count(nums[j])
if cnt>0:
temp_list.append(num)
sorted(temp_list)
cnt-=1
elif temp_list[-1]>num:
temp_list[0] = num
sorted(temp_list, reverse = True)
print(sum(temp_list), temp_list) | s305901690 | Accepted | 108 | 40,220 | 243 | N, K = map(int,input().split())
ball = input().split()
d = {}
if K >= len(set(ball)):
print("0")
exit()
for i in ball:
if not i in d:
d[i] = 1
else:
d[i] += 1
d_val = sorted(d.values(),reverse=True)
print(N - sum(d_val[:K])) |
s725979211 | p03645 | u443736699 | 2,000 | 262,144 | Wrong Answer | 1,003 | 50,136 | 275 | In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuke is on Island 1 now, and wants to go to Island N. However, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services. Help him. | n,m = list(map(int,input().strip().split()))
path = [[] for i in range(n)]
for i in range(m):
a,b = list(map(int,input().split()))
path[a-1].append(b-1)
path[b-1].append(a-1)
for j in path[0]:
if m-1 in path[j]:
print("POSSIBLE")
exit()
print("IMPOSSIBLE") | s133113700 | Accepted | 966 | 50,136 | 275 | n,m = list(map(int,input().strip().split()))
path = [[] for i in range(n)]
for i in range(m):
a,b = list(map(int,input().split()))
path[a-1].append(b-1)
path[b-1].append(a-1)
for j in path[0]:
if n-1 in path[j]:
print("POSSIBLE")
exit()
print("IMPOSSIBLE") |
s983932093 | p02390 | u628279257 | 1,000 | 131,072 | Wrong Answer | 30 | 7,456 | 72 | Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively. | S=int(input())
print(str(S//3600)+":"+str(S%3600/60)+":"+str(S%3600%60)) | s900582610 | Accepted | 20 | 7,636 | 73 | S=int(input())
print(str(S//3600)+":"+str(S%3600//60)+":"+str(S%3600%60)) |
s613012305 | p02393 | u286589639 | 1,000 | 131,072 | Wrong Answer | 20 | 7,440 | 198 | Write a program which reads three integers, and prints them in ascending order. | n = list(map(int, input().split()))
for i in range(2):
if n[i] > n[i+1]:
temp = n[i]
n[i] = n[i+1]
n[i+1] = temp
for i in range(2):
print(n[i], end=" ")
print(n[2]) | s873792191 | Accepted | 20 | 7,504 | 222 | a, b, c, = map(int, input().split())
if a > b:
temp = a
a = b
b = temp
if b > c:
temp = b
b = c
c = temp
if a > b:
temp = a
a = b
b = temp
print(str(a) + ' ' + str(b) + ' ' + str(c)) |
s855384148 | p02259 | u488601719 | 1,000 | 131,072 | Wrong Answer | 20 | 7,692 | 442 | Write a program of the Bubble Sort algorithm which sorts a sequence _A_ in ascending order. The algorithm should be based on the following pseudocode: BubbleSort(A) 1 for i = 0 to A.length-1 2 for j = A.length-1 downto i+1 3 if A[j] < A[j-1] 4 swap A[j] and A[j-1] Note that, indices for array elements are based on 0-origin. Your program should also print the number of swap operations defined in line 4 of the pseudocode. | N = int(input())
A = list(map(int, input().split()))
def bubble_sort(A, N):
cnt = 0
flag = True
while(flag):
flag = False
for i in range(N-1, 0, -1):
if(A[i-1] > A[i]):
tmp = A[i-1]
A[i-1] = A[i]
A[i] = tmp
cnt += 1
flag = True
B = list(map(str, A))
print(" ".join(B))
print(cnt)
print(*A)
bubble_sort(A, N) | s582580018 | Accepted | 70 | 7,788 | 423 | N = int(input())
A = list(map(int, input().split()))
def bubble_sort(A, N):
cnt = 0
flag = True
while(flag):
flag = False
for i in range(N-1, 0, -1):
if(A[i-1] > A[i]):
tmp = A[i-1]
A[i-1] = A[i]
A[i] = tmp
cnt += 1
flag = True
print(" ".join(list(map(str, A))))
print(cnt)
bubble_sort(A, N) |
s213631491 | p02924 | u658801777 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 110 | For an integer N, we will choose a permutation \\{P_1, P_2, ..., P_N\\} of \\{1, 2, ..., N\\}. Then, for each i=1,2,...,N, let M_i be the remainder when i is divided by P_i. Find the maximum possible value of M_1 + M_2 + \cdots + M_N. | while True:
try:
N = int(input())
print(int(N*(N-1)/2))
except EOFError:
break | s723214617 | Accepted | 17 | 2,940 | 106 | while True:
try:
N = int(input())
print(N*(N-1)//2)
except EOFError:
break |
s793213612 | p02259 | u308033440 | 1,000 | 131,072 | Wrong Answer | 20 | 5,600 | 518 | Write a program of the Bubble Sort algorithm which sorts a sequence _A_ in ascending order. The algorithm should be based on the following pseudocode: BubbleSort(A) 1 for i = 0 to A.length-1 2 for j = A.length-1 downto i+1 3 if A[j] < A[j-1] 4 swap A[j] and A[j-1] Note that, indices for array elements are based on 0-origin. Your program should also print the number of swap operations defined in line 4 of the pseudocode. |
def BubbleSort(A,N):
flag = 1
count = 0
while flag:
flag = 0
for i in range(N-1,0,-1):
if A[i] < A[i-1]:
tmp = A[i]
A[i] = A[i- 1]
A[i-1] = tmp
flag = 1
count = count +1
print(' '.join(map(str,A)))
print(count)
N = int(input())
A = input()
A = list(map(int,A.split()))
BubbleSort(A,N)
| s644551913 | Accepted | 20 | 5,596 | 421 | def BubbleSort(A,N):
flag = 1
count = 0
while flag:
flag = 0
for i in range(N-1,0,-1):
if A[i] < A[i-1]:
tmp = A[i]
A[i] = A[i- 1]
A[i-1] = tmp
flag = 1
count = count +1
print(' '.join(map(str,A)))
print(count)
N = int(input())
A = list(map(int,input().split()))
BubbleSort(A,N)
|
s097708032 | p03719 | u235210692 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 93 | You are given three integers A, B and C. Determine whether C is not less than A and not greater than B. | a,b,c=input().split()
if a[-1]==b[0] and b[-1]==c[0]:
print("YES")
else:
print("NO") | s961387296 | Accepted | 17 | 2,940 | 97 | a,b,c=[int(i) for i in input().split()]
if c>=a and c<=b:
print("Yes")
else:
print("No") |
s870108809 | p03998 | u223663729 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 219 | 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. * If the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says `a`, Alice takes the next turn.) * If the current player's deck is empty, the game ends and the current player wins the game. You are given the initial decks of the players. More specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way. Determine the winner of the game. | s = open(0).read().split()
x = s[0][0]
s[0] = s[0][1:]
while s[0] and s[1] and s[2]:
p = ord(x)-97
x = s[p][0]
s[p] = s[p][1:]
if len(s[0]) == 0:
print('A')
elif len(s[1]) == 0:
print('B')
else:
print('C') | s353956850 | Accepted | 17 | 3,060 | 168 | s = open(0).read().split()
x = s[0][0]
s[0] = s[0][1:]
while True:
p = ord(x)-97
if len(s[p]) == 0:
print(x.upper())
break
x = s[p][0]
s[p] = s[p][1:] |
s828425858 | p03399 | u442948527 | 2,000 | 262,144 | Wrong Answer | 26 | 8,944 | 60 | You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses. | a,b,c,d=[input() for _ in range(4)]
print(min(a,b)+min(c,d)) | s094158869 | Accepted | 25 | 8,924 | 65 | a,b,c,d=[int(input()) for _ in range(4)]
print(min(a,b)+min(c,d)) |
s415513449 | p03251 | u143318682 | 2,000 | 1,048,576 | Wrong Answer | 18 | 3,060 | 286 | Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out. | N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
i = X + 1
while i < Y + 1:
if min(y) - max(x) > 0 and min(y) - max(x) == i:
print('No War')
break
else:
i += 1
if i == Y + 1:
print('War') | s083204521 | Accepted | 18 | 3,060 | 268 | N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
i = X + 1
while i < Y + 1:
if max(x) < i and i <= min(y):
print('No War')
break
else:
i += 1
if i == Y + 1:
print('War') |
s225159795 | p02578 | u981309686 | 2,000 | 1,048,576 | Wrong Answer | 129 | 32,292 | 198 | N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool. Find the minimum total height of the stools needed to meet this goal. | max_tool=0
n=int(input())
arr=list(map(int,input().split()))
maxi=arr[0]
for i in range(1,len(arr)):
if arr[i]<maxi:
max_tool=max(max_tool,maxi-arr[i])
else:
maxi=arr[i]
print (max_tool) | s950850373 | Accepted | 117 | 32,248 | 175 | tool=0
n=int(input())
arr=list(map(int,input().split()))
maxi=arr[0]
for i in range(1,len(arr)):
if arr[i]<maxi:
tool+=(maxi-arr[i])
else:
maxi=arr[i]
print (tool) |
s982260903 | p03568 | u987164499 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 155 | We will say that two integer sequences of length N, x_1, x_2, ..., x_N and y_1, y_2, ..., y_N, are _similar_ when |x_i - y_i| \leq 1 holds for all i (1 \leq i \leq N). In particular, any integer sequence is similar to itself. You are given an integer N and an integer sequence of length N, A_1, A_2, ..., A_N. How many integer sequences b_1, b_2, ..., b_N are there such that b_1, b_2, ..., b_N is similar to A and the product of all elements, b_1 b_2 ... b_N, is even? | from sys import stdin
s = stdin.readline().rstrip()
for i in range(len(s)-1):
if s[i]+s[i+1] == "AC":
print("Yes")
exit()
print("No") | s123809482 | Accepted | 17 | 3,060 | 202 | from sys import stdin
n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
a = 3**len(li)
point = 1
for i in li:
if i % 2 == 0:
point*=2
print(a-point) |
s385857308 | p02389 | u427219397 | 1,000 | 131,072 | Wrong Answer | 20 | 5,584 | 58 | Write a program which calculates the area and perimeter of a given rectangle. | a,b = map(int,input().split())
print(a+a+b+b)
print(a*b)
| s614196391 | Accepted | 20 | 5,580 | 51 | a,b = map(int, input().split())
print(a*b,a+a+b+b)
|
s284270628 | p03494 | u401077816 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 136 | There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform. | N = int(input())
A = list(map(int, input().split()))
res = 0
if all(a%2 == 0 for a in A):
A = [a/2 for a in A]
res += 1
print(res) | s480181941 | Accepted | 19 | 2,940 | 135 | N = input()
A = list(map(int, input().split()))
res = 0
while all(a%2 == 0 for a in A):
A = [a/2 for a in A]
res += 1
print(res) |
s155897671 | p03457 | u506910932 | 2,000 | 262,144 | Wrong Answer | 324 | 3,060 | 181 | AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan. | # coding: utf-8
n = int(input())
for i in range(n):
t,x,y = map(int,input().split())
if t<x+y or (t%2) != (x+y)%2:
print("NO")
exit()
print("YES") | s253138160 | Accepted | 326 | 3,060 | 181 | # coding: utf-8
n = int(input())
for i in range(n):
t,x,y = map(int,input().split())
if t<x+y or (t%2) != (x+y)%2:
print("No")
exit()
print("Yes") |
s109174007 | p02255 | u608789460 | 1,000 | 131,072 | Wrong Answer | 20 | 5,520 | 195 | Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step. | def insertinSort(A,N):
for i in range(1,N):
v = A[i]
j = i-1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j-=1
A[j+1] = v
print(A)
| s620073586 | Accepted | 20 | 5,980 | 193 | N = int(input())
*A, = map(int, input().split())
for i in range(N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(*A)
|
s961830136 | p03695 | u711539583 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 207 | In AtCoder, a person who has participated in a contest receives a _color_ , which corresponds to the person's rating as follows: * Rating 1-399 : gray * Rating 400-799 : brown * Rating 800-1199 : green * Rating 1200-1599 : cyan * Rating 1600-1999 : blue * Rating 2000-2399 : yellow * Rating 2400-2799 : orange * Rating 2800-3199 : red Other than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not. Currently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i. Find the minimum and maximum possible numbers of different colors of the users. | n = int(input())
a = list(map(int, input().split()))
d = {}
e = 0
for ai in a:
s = ai // 400
if s > 7:
e += 1
else:
if s in d:
d[s] += 1
else:
d[s] = 1
print(min(8, len(d) + e)) | s948225949 | Accepted | 18 | 2,940 | 216 | n = int(input())
a = list(map(int, input().split()))
d = {}
e = 0
for ai in a:
s = ai // 400
if s > 7:
e += 1
else:
if s in d:
d[s] += 1
else:
d[s] = 1
print(max(1, len(d)), len(d) + e)
|
s657233900 | p02936 | u699752889 | 2,000 | 1,048,576 | Wrong Answer | 2,107 | 65,688 | 939 | 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: * Operation j (1 \leq j \leq Q): Increment by x_j the counter on every vertex contained in the subtree rooted at Vertex p_j. Find the value of the counter on each vertex after all operations. | from heapq import heappush, heappop, heapify, heapreplace
from collections import defaultdict
from bisect import bisect_left
class Solution:
def main(self):
path = defaultdict(list)
N, Q = map(int, input().split())
freq = [0] * N
for i in range(N-1):
ai, bi = map(int, input().split())
path[ai-1].append(bi-1)
path[bi-1].append(ai-1)
for i in range(Q):
p, x = map(int, input().split())
print(p, x)
freq[p-1] += x
stack = [(0, 0)]
seen = set()
res = [0] * N
while stack:
node, cum = stack.pop(0)
seen.add(node)
val = freq[node] + cum
res[node] = val
for other in path[node]:
if other not in seen:
stack.append((other, val))
print(res)
if __name__ == '__main__':
Solution().main() | s115810589 | Accepted | 1,447 | 82,192 | 767 | from heapq import heappush, heappop, heapify, heapreplace
from collections import defaultdict
from bisect import bisect_left
class Solution:
def main(self):
path = defaultdict(list)
N, Q = map(int, input().split())
freq = [0] * N
for i in range(N-1):
ai, bi = map(int, input().split())
path[ai-1].append(bi-1)
# path[bi-1].append(ai-1)
for i in range(Q):
p, x = map(int, input().split())
freq[p-1] += x
stack = [(0, 0)]
seen = set()
res = freq[:]
for i in range(N):
for other in path[i]:
res[other] += res[i]
print(' '.join(map(str, res)))
if __name__ == '__main__':
Solution().main() |
s975732856 | p03456 | u652569315 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 117 | 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)
ans='Yes' if ab//int(pow(ab,0.5))==ab and ab%int(pow(ab,0.5))==0 else 'No'
print(ans) | s827716529 | Accepted | 17 | 3,060 | 129 | a,b=input().split()
ab=int(a+b)
ans='Yes'if(ab//int(pow(ab,0.5))==int(pow(ab,0.5)) and ab%int(pow(ab,0.5))==0)else'No'
print(ans) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.