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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s074068886 | p02261 | u742013327 | 1,000 | 131,072 | Wrong Answer | 50 | 7,784 | 2,349 | Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubbl... | #http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_C&lang=jp
#??????????????????
def bubble_sort(origin_list):
list_length = len(origin_list)
target_list = [i for i in origin_list]
flag = True
change_count = 0
top_index = 1
while flag:
flag = False
for i in rang... | s087191675 | Accepted | 20 | 7,840 | 2,360 | #http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_C&lang=jp
#??????????????????
def bubble_sort(origin_list):
list_length = len(origin_list)
target_list = [i for i in origin_list]
flag = True
change_count = 0
top_index = 1
while flag:
flag = False
for i in rang... |
s285108897 | p03860 | u314219654 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 29 | 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[1]+"C") | s862916486 | Accepted | 17 | 2,940 | 31 | s = input()
print("A"+s[8]+"C") |
s154001671 | p02831 | u121161758 | 2,000 | 1,048,576 | Wrong Answer | 43 | 3,064 | 1,086 | Takahashi is organizing a party. At the party, each guest will receive one or more snack pieces. Takahashi predicts that the number of guests at this party will be A or B. Find the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted. We assume that a piece cannot be ... | import math
A, B = map(int, input().split())
A_orgn = A
B_orgn = B
dict_a = {}
dict_b = {}
for i in range(2,int(math.sqrt(A))+1):
if A % i == 0:
while(1):
A //= i
if i not in dict_a:
dict_a[i] = 1
else:
dict_a[i] += 1
if A ... | s254981755 | Accepted | 42 | 3,064 | 1,293 | import math
A, B = map(int, input().split())
A_orgn = A
B_orgn = B
dict_a = {}
dict_b = {}
if A == 1:
dict_a[1] = 1
for i in range(2,int(math.sqrt(A))+1):
if A % i == 0:
while(1):
A //= i
if i not in dict_a:
dict_a[i] = 1
else:
d... |
s465214444 | p03814 | u496744988 | 2,000 | 262,144 | Wrong Answer | 682 | 8,696 | 256 | Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends w... | s=input()
ans=0
for i in range(len(s)):
if s[i] == 'A':
for j in range(len(s)-1,0,-1):
print(i,j)
if s[j] == 'Z':
if ans < abs(i-j):
ans = abs(i-j)
break
print(ans+1)
| s145271152 | Accepted | 17 | 3,500 | 44 | s=input()
print(s.rfind('Z')-s.find('A')+1)
|
s089495248 | p04044 | u580404776 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 156 | Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically sm... | N,L=map(int,input().split())
S=[]
ans=""
for _ in range(N):
S.append(input())
SS=sorted(S)
for _ in range(N):
ans+=S[0]
S.pop(0)
print(ans) | s883244195 | Accepted | 17 | 3,060 | 158 | N,L=map(int,input().split())
S=[]
ans=""
for _ in range(N):
S.append(input())
SS=sorted(S)
for _ in range(N):
ans+=SS[0]
SS.pop(0)
print(ans) |
s669684501 | p03455 | u163421511 | 2,000 | 262,144 | Wrong Answer | 25 | 8,812 | 109 | 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())
num = int(A+B)*0.05
result = "Yes" if num.is_integer else "No"
print(result) | s462019753 | Accepted | 27 | 9,056 | 133 | # -*- coding: utf-8 -*-
a, b = map(int, input().split())
if a * b % 2 == 0:
x = "Even"
else:
x = "Odd"
print(x) |
s607427855 | p03672 | u766407523 | 2,000 | 262,144 | Time Limit Exceeded | 2,104 | 7,284 | 151 | We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by del... | s = input()
if len(s)%2==1:
s += '0'
s = s[:-2]
while True:
if s[:len(s)//2] == s[len(s)//2:]:
print(len(s[:len(s)//2]))
s = s[:-2] | s143641818 | Accepted | 17 | 2,940 | 154 | s = input()
if len(s)%2==1:
s += '0'
s = s[:-2]
while True:
if s[:len(s)//2] == s[len(s)//2:]:
print(len(s))
break
s = s[:-2]
|
s107259142 | p02422 | u671553883 | 1,000 | 131,072 | Wrong Answer | 20 | 7,584 | 332 | Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-t... | s = input()
q = int(input())
for qi in range(q):
command = input().split()
a = int(command[1])
b = int(command[2])
if command[0] == 'print':
print(s[a:b + 1])
elif command[0] == 'reverse':
s = s[:a] + s[a:b + 1][::-1] + s[b + 1:]
else:
p = command[3]
s = s[a:]... | s390009217 | Accepted | 20 | 7,692 | 336 | s = input()
q = int(input())
for qi in range(q):
command = input().split()
a = int(command[1])
b = int(command[2])
if command[0] == 'print':
print(s[a:b + 1])
elif command[0] == 'reverse':
s = s[:a] + s[a:b + 1][::-1] + s[b + 1:]
else:
p = command[3]
s = s[:a]... |
s541763331 | p03861 | u693933222 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 105 | You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x? | a,b,x = map(int, input().split())
ax = min(0,(a-1)//x)
bx = b//x
#print(ax)
#print(bx)#
print(bx-ax+1) | s504097511 | Accepted | 18 | 2,940 | 55 | a,b,x = map(int, input().split())
print(b//x-(a-1)//x) |
s991116336 | p03486 | u666964944 | 2,000 | 262,144 | Wrong Answer | 28 | 8,996 | 115 | You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order. | s = input()
t = input()
sa = ''.join(sorted(s))
ta = ''.join(sorted(t, reverse=True))
print('Yes' if s<t else 'No') | s019822616 | Accepted | 29 | 8,980 | 117 | s = input()
t = input()
sa = ''.join(sorted(s))
ta = ''.join(sorted(t, reverse=True))
print('Yes' if sa<ta else 'No') |
s563349365 | p02694 | u612635771 | 2,000 | 1,048,576 | Wrong Answer | 26 | 9,068 | 60 | 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... | n = int(input())
i = 100
while i>=n:
i = i*0.01
i = i//1 | s360901073 | Accepted | 29 | 9,092 | 87 | n = int(input())
i = 100
total=0
while i<n:
i = i*101//100
total +=1
print(total) |
s383874682 | p03435 | u580327099 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 780 | We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) ... | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline
def main():
G = [[0 for _ in range(3)] for _ in range(3)]
for i in range(3):
G[i] = [int(e) for e in input().split()]
for a0 in range(0, 100+1):
b0 = G[0][0] - a0
b1 = G[0][1] - a0
b2 = G... | s954683879 | Accepted | 17 | 3,064 | 780 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline
def main():
G = [[0 for _ in range(3)] for _ in range(3)]
for i in range(3):
G[i] = [int(e) for e in input().split()]
for a0 in range(0, 100+1):
b0 = G[0][0] - a0
b1 = G[0][1] - a0
b2 = G... |
s326688828 | p02928 | u919463386 | 2,000 | 1,048,576 | Wrong Answer | 399 | 3,188 | 557 | We have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}. Let B be a sequence of K \times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2. Find the inversion number of B, modulo 10^9 + 7. Here the inversion number of B is defined as the number of o... | # -*- coding: utf-8 -*-
def main():
N, K = map(int,input().split())
A = list(map(int,input().split()))
inner = 0
outer = 0
for i in range(0,N):
for j in range(0,i):
if A[i] > A[j]:
outer += 1
for j in range(i+1,N):
if A[i] > A[j]:
... | s960803143 | Accepted | 399 | 3,188 | 499 | # -*- coding: utf-8 -*-
def main():
N, K = map(int,input().split())
A = list(map(int,input().split()))
inner = 0
outer = 0
for i in range(0,N):
for j in range(0,i):
if A[i] > A[j]:
outer += 1
for j in range(i+1,N):
if A[i] > A[j]:
... |
s669287192 | p02407 | u002280517 | 1,000 | 131,072 | Wrong Answer | 20 | 5,588 | 121 | Write a program which reads a sequence and prints it in the reverse order. | n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
for i in a:
print("{0} ".format(i),end="")
| s643634412 | Accepted | 20 | 5,616 | 187 | n = int(input())
a = list(map(int,input().split()))
j = 0
for i in a[::-1]:
j+=1
print("{0}".format(i),end="")
if j != n :
print(" ",end="")
else:
print()
|
s645211732 | p03623 | u220345792 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 92 | 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") | s168889432 | Accepted | 17 | 2,940 | 93 | x, a, b = map(int, input().split())
if abs(a-x) < abs(b-x):
print("A")
else:
print("B")
|
s253300758 | p03110 | u555947166 | 2,000 | 1,048,576 | Wrong Answer | 18 | 2,940 | 264 | Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative. For example, if x_1 = `10000`... | N = int(input())
money = []
for i in range(N):
money.append(input().split())
B2Y = 38000.0
otoshidama = 0
for item in money:
if item[1] == 'JPY':
otoshidama += float(item[0])
else:
otoshidama += float(item[0])*B2Y
print(otoshidama)
| s103871819 | Accepted | 18 | 3,060 | 265 | N = int(input())
money = []
for i in range(N):
money.append(input().split())
B2Y = 380000.0
otoshidama = 0
for item in money:
if item[1] == 'JPY':
otoshidama += float(item[0])
else:
otoshidama += float(item[0])*B2Y
print(otoshidama)
|
s078280313 | p03759 | u957198490 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 87 | Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful. | a,b,c = map(int,input().split())
if b-a == c-a:
print('YES')
else:
print('NO') | s661962706 | Accepted | 17 | 3,064 | 87 | a,b,c = map(int,input().split())
if b-a == c-b:
print('YES')
else:
print('NO') |
s542002552 | p03436 | u113375133 | 2,000 | 262,144 | Wrong Answer | 62 | 6,328 | 1,591 | We have an H \times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j). Snuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player re... | from collections import deque
import sys
sys.setrecursionlimit(4000)
def validCordinate(x, y, dist, Grid):
if x < 0 or x >= len(Grid[0]):
return False
if y < 0 or y >= len(Grid):
return False
if dist[y][x] != -1:
return False
if Grid[y][x] != '.':
return False
ret... | s586521733 | Accepted | 29 | 5,484 | 1,562 | from collections import deque
import sys
sys.setrecursionlimit(4000)
def validCordinate(x, y, dist, Grid):
if x < 0 or x >= len(Grid[0]):
return False
if y < 0 or y >= len(Grid):
return False
if dist[y][x] != -1:
return False
if Grid[y][x] != '.':
return False
ret... |
s896841714 | p03711 | u341267151 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 368 | 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. | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x ... | s388153238 | Accepted | 18 | 3,064 | 1,375 | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = ... |
s601772703 | p03229 | u539517139 | 2,000 | 1,048,576 | Wrong Answer | 212 | 7,512 | 380 | You are given N integers; the i-th of them is A_i. Find the maximum possible sum of the absolute differences between the adjacent elements after arranging these integers in a row in any order you like. | n=int(input())
a=[int(input()) for _ in range(n)]
a.sort()
if n==2:
x=a[1]-a[0]
elif n%2==0:
x=(sum(a[n//2+1:])-sum(a[:n//2-1]))*2
x-=a[n//2-1]
x+=a[n//2]
elif n==3:
x=a[2]*2-a[0]-a[1]
y=a[2]+a[1]-a[0]*2
x=max(x,y)
else:
x=(sum(a[n//2+2:])-sum(a[:n//2]))*2
x+=a[n//2]+a[n//2+1]
y=(sum(a[n//2+1:])-sum... | s860643660 | Accepted | 214 | 7,512 | 380 | n=int(input())
a=[int(input()) for _ in range(n)]
a.sort()
if n==2:
x=a[1]-a[0]
elif n%2==0:
x=(sum(a[n//2+1:])-sum(a[:n//2-1]))*2
x-=a[n//2-1]
x+=a[n//2]
elif n==3:
x=a[2]*2-a[0]-a[1]
y=a[2]+a[1]-a[0]*2
x=max(x,y)
else:
x=(sum(a[n//2+2:])-sum(a[:n//2]))*2
x+=a[n//2]+a[n//2+1]
y=(sum(a[n//2+1:])-sum... |
s883405468 | p03836 | u378328623 | 2,000 | 262,144 | Wrong Answer | 18 | 3,316 | 200 | Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement ... | sx, sy, tx, ty = map(int, input().split())
x = tx - sx
y = ty - sy
print("".join(["U"]*x + ["R"]*y +["D"]*x + ["L"]*(y+1) + ["U"]*(x+1) + ["R"]*(y+1) + ["D", "R"] + ["D"]*(y+1) + ["L"]*(x+1) + ["U"])) | s993702789 | Accepted | 18 | 3,316 | 200 | sx, sy, tx, ty = map(int, input().split())
x = tx - sx
y = ty - sy
print("".join(["U"]*y + ["R"]*x +["D"]*y + ["L"]*(x+1) + ["U"]*(y+1) + ["R"]*(x+1) + ["D", "R"] + ["D"]*(y+1) + ["L"]*(x+1) + ["U"])) |
s461868655 | p03456 | u448655578 | 2,000 | 262,144 | Wrong Answer | 18 | 3,188 | 175 | 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. | import math
a, b = map(str, input().split())
c = a+b
print(round(math.sqrt(int(c))))
print(int(c))
if round(math.sqrt(int(c)))**2 == int(c):
print('Yes')
else:
print('No') | s200728413 | Accepted | 17 | 3,060 | 109 | a, b = map(str, input().split())
c = a+b
if int(int(c)**0.5)**2 == int(c):
print('Yes')
else:
print('No') |
s448223199 | p02396 | u092736322 | 1,000 | 131,072 | Wrong Answer | 170 | 5,600 | 120 | 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... | for i in range(10000):
k=int(input())
if k==0:
break
else:
print("Case "+str(i)+":"+str(k))
| s010681358 | Accepted | 140 | 5,600 | 123 | for i in range(10000):
k=int(input())
if k==0:
break
else:
print("Case "+str(i+1)+": "+str(k))
|
s137990404 | p02678 | u736227279 | 2,000 | 1,048,576 | Wrong Answer | 1,518 | 38,356 | 660 | 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,edge = map(int,input().split())
l = [0]*n
stack = [1]
dic = {}
for i in range (edge) :
x = [int(x) for x in input().split()]
if x[0] not in dic :
dic[x[0]] = []
if x[1] not in dic :
dic[x[1]] = []
dic[x[0]].append(x[1])
dic[x[1]].append(x[0])
x = 1
while len(stack) != 0 :
ch... | s115965177 | Accepted | 1,504 | 38,364 | 660 | n,edge = map(int,input().split())
l = [0]*n
stack = [1]
dic = {}
for i in range (edge) :
x = [int(x) for x in input().split()]
if x[0] not in dic :
dic[x[0]] = []
if x[1] not in dic :
dic[x[1]] = []
dic[x[0]].append(x[1])
dic[x[1]].append(x[0])
x = 1
while len(stack) != 0 :
ch... |
s706346655 | p03826 | u281303342 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 383 | There are two rectangles. The lengths of the vertical sides of the first rectangle are A, and the lengths of the horizontal sides of the first rectangle are B. The lengths of the vertical sides of the second rectangle are C, and the lengths of the horizontal sides of the second rectangle are D. Print the area of the r... | # Python3 (3.4.3)
import sys
input = sys.stdin.readline
# -------------------------------------------------------------
# function
# -------------------------------------------------------------
# -------------------------------------------------------------
# main
# -------------------------------------------------... | s716395777 | Accepted | 17 | 2,940 | 389 | # Python3 (3.4.3)
import sys
input = sys.stdin.readline
# -------------------------------------------------------------
# function
# -------------------------------------------------------------
# -------------------------------------------------------------
# main
# -------------------------------------------------... |
s416345983 | p02975 | u248670337 | 2,000 | 1,048,576 | Wrong Answer | 53 | 16,960 | 59 | 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... | input();x=0
for i in map(int,input().split()):x^=i
print(x) | s459375627 | Accepted | 59 | 20,828 | 287 | from collections import*
n,*A=map(int,open(0).read().split());C=Counter(A).items();f=1;l=len(C)
if l==3:
x=0
for c in C:x^=c[0]
f=(len(set(c[1]for c in C))>1)+n%3+x>0
elif l==2:f=(abs(sum(c[1]*(-1)**i for i,c in enumerate(C)))!=n//3)+n%3>0
else:f=(l!=1)+A[0]>0
print('YNeos'[f::2]) |
s451269315 | p03797 | u794753968 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 49 | Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped... | N,M = map(int, input().split())
print(N*2+M // 4) | s839868431 | Accepted | 17 | 2,940 | 107 | N,M = map(int, input().split())
ans = 0
sp = min(N, M // 2)
ans += sp
M -= sp*2
ans += M // 4
print(ans) |
s865709815 | p03997 | u068584789 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 74 | You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid. | a = int(input())
b = int(input())
h = int(input())
print((a + b) * h / 2) | s609416900 | Accepted | 17 | 2,940 | 79 | a = int(input())
b = int(input())
h = int(input())
print(int((a + b) * h / 2))
|
s661619027 | p03351 | u154191677 | 2,000 | 1,048,576 | Wrong Answer | 18 | 2,940 | 121 | Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either ... | a, b, c, d = map(int, input().split())
print('YES' if (abs(a - b) <= d and abs(b - c) <= d) or abs(a - c) <= d else 'NO') | s330492704 | Accepted | 18 | 3,060 | 150 | a, b, c, d = map(int, input().split())
if abs(a-b) <= d and abs(b-c) <= d:
print('Yes')
elif abs(a-c) <= d:
print('Yes')
else:
print('No') |
s274344260 | p02402 | u896065593 | 1,000 | 131,072 | Wrong Answer | 30 | 7,556 | 233 | Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence. | n = int(input())
a = input().split()
min = int(a[0])
max = int(a[0])
sum = 0
for i in a:
if min > int(i):
min = int(i)
if max < int(i):
max = int(i)
sum += int(i)
print("{0} {1} {2}".format(max, min, sum)) | s488615958 | Accepted | 40 | 8,340 | 233 | n = int(input())
a = input().split()
min = int(a[0])
max = int(a[0])
sum = 0
for i in a:
if min > int(i):
min = int(i)
if max < int(i):
max = int(i)
sum += int(i)
print("{0} {1} {2}".format(min, max, sum)) |
s360925693 | p02408 | u279955105 | 1,000 | 131,072 | Wrong Answer | 20 | 7,552 | 297 | Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers). The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond. | cards = {
"S" : [0 for i in range(13)],
"H" : [0 for i in range(13)],
"D" : [0 for i in range(13)],
"C" : [0 for i in range(13)]
}
n = int(input())
for i in range(n):
a,b = input().split()
cards[a][int(b)-1] = 1
for a in ("S","H","D","C"):
for b in range(13):
cards[a][b] = 0
print(a,b+1) | s203530319 | Accepted | 20 | 5,596 | 527 | n = int(input())
a = list()
for i in range(n):
x,y = input().split()
y = int(y)
if x == 'S':
a.append(y+0)
elif x == 'H':
a.append(y+13)
elif x == 'C':
a.append(y+26)
else:
a.append(y+39)
for i in range(1,53):
if not (i in a):
if i <= 13:
p... |
s072663196 | p03352 | u987164499 | 2,000 | 1,048,576 | Wrong Answer | 23 | 2,940 | 135 | 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())
ma = 0
for i in range(1,100):
for j in range(1,100):
if i**j <= x:
ma = max(ma,i**j)
print(ma) | s606963513 | Accepted | 22 | 2,940 | 135 | x = int(input())
ma = 0
for i in range(1,100):
for j in range(2,100):
if i**j <= x:
ma = max(ma,i**j)
print(ma) |
s995617763 | p02259 | u279605379 | 1,000 | 131,072 | Wrong Answer | 20 | 7,516 | 304 | Write a program of the Bubble Sort algorithm which sorts a sequence _A_ in ascending order. The algorithm should be based on the following pseudocode: BubbleSort(A) 1 for i = 0 to A.length-1 2 for j = A.length-1 downto i+1 3 if A[j] < A[j-1] 4 swap A[j] and A[j-1] Note that, in... |
def bubbleSort(A,N):
flag=1
while flag:
flag=0
j=N-1
while j>0:
if(A[j]<A[j-1]):
A[j],A[j-1]=A[j-1],A[j]
flag=1
j-=1
N=int(input())
A=[int(x) for x in input().split()]
bubbleSort(A,N)
print(A) | s878938751 | Accepted | 20 | 7,728 | 405 |
def bubbleSort(A,N):
c=0
flag=1
while flag:
flag=0
j=N-1
while j>0:
if(int(A[j])<int(A[j-1])):
c+=1
A[j],A[j-1]=A[j-1],A[j]
flag=1
j-=1
return c
N=int(input())
A=input().split()
c=bubbleSort(A,N)
S=""
for i... |
s274158578 | p00004 | u979795132 | 1,000 | 131,072 | Wrong Answer | 20 | 5,604 | 680 | Write a program which solve a simultaneous equation: ax + by = c dx + ey = f The program should print x and y for given a, b, c, d, e and f (-1,000 ≤ a, b, c, d, e, f ≤ 1,000). You can suppose that given equation has a unique solution. | def equation(a,b,c,d,e,f,x):
buff = a*e-b*d
buff_a = a
a = e/buff
b = -b/buff
d = -d/buff
e = buff_a/buff
x.append((a*c)+(b*f))
x.append((d*c)+(e*f))
count = 0
a = []
b = []
c = []
d = []
e = []
f = []
while True:
try:
buff = input().split()
a.append(float(buff[0]... | s147254113 | Accepted | 20 | 5,600 | 680 | def equation(a,b,c,d,e,f,x):
buff = a*e-b*d
buff_a = a
a = e/buff
b = -b/buff
d = -d/buff
e = buff_a/buff
x.append((a*c)+(b*f))
x.append((d*c)+(e*f))
count = 0
a = []
b = []
c = []
d = []
e = []
f = []
while True:
try:
buff = input().split()
a.append(float(buff[0]... |
s176445898 | p02394 | u037441960 | 1,000 | 131,072 | Wrong Answer | 20 | 5,588 | 154 | Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given. | W,H,x,y,r = map(int, input().split())
if(x+r <= W & y+r <= H):
if(x-r >= 0 & y-r >= 0) :
print("Yes")
else :
print("No")
else :
print("No")
| s278187190 | Accepted | 20 | 5,596 | 184 | W, H, x, y, r = map(int, input().split())
if x - r >= 0 and y - r >= 0 :
if x + r <= W and y + r <= H :
print("Yes")
else :
print("No")
else :
print("No")
|
s832413597 | p03047 | u848654125 | 2,000 | 1,048,576 | Wrong Answer | 19 | 2,940 | 55 | Snuke has N integers: 1,2,\ldots,N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? | h = list(map(int, input().split()))
print(h[0]-h[1]) | s872756548 | Accepted | 17 | 2,940 | 57 | h = list(map(int, input().split()))
print(h[0]-h[1]+1) |
s707877034 | p03151 | u869292891 | 2,000 | 1,048,576 | Wrong Answer | 441 | 27,084 | 639 | A university student, Takahashi, has to take N examinations and pass all of them. Currently, his _readiness_ for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination. Takahashi thinks that he may not be able to pa... | import numpy as np
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
A=np.array(A)
B=np.array(B)
E=A-B
e=sum(E)
if e<0:
print(-1)
else:
Eminus=[]
Ezero=[]
Eplus=[]
nn=0
n0=0
for n in range(N):
if E[n]<0:
Eminus.append(E[n])
... | s190717059 | Accepted | 461 | 27,072 | 699 | import numpy as np
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
A=np.array(A)
B=np.array(B)
E=A-B
e=sum(E)
if e<0:
print(-1)
else:
Eminus=[]
Ezero=[]
Eplus=[]
nn=0
n0=0
nminus=0
for n in range(N):
if E[n]<0:
Eminus.append(E[n]... |
s693912573 | p03068 | u862466626 | 2,000 | 1,048,576 | Wrong Answer | 18 | 3,060 | 136 | You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`. | N = int(input())
S = list(input())
K = int(input())
target = S[K-1]
for item in S:
if item != target:
item = '*'
print(''.join(S)) | s434893907 | Accepted | 17 | 2,940 | 142 | N = int(input())
S = list(input())
K = int(input())
target = S[K-1]
for i in range(N):
if S[i] != target:
S[i] = '*'
print(''.join(S))
|
s103222703 | p02936 | u105608888 | 2,000 | 1,048,576 | Wrong Answer | 2,207 | 65,848 | 593 | Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0. Now, the following Q operations will be performed: * Operati... | N, Q = map(int, input().split())
A = [tuple(map(int, input().split())) for _ in range(N-1)]
P = [tuple(map(int, input().split())) for _ in range(Q)]
def solve(A, num):
ans = []
if True in [num==i[0] for i in A] :
for i in A:
if num == i[0]:
ans.append(i[1])
k ... | s682178728 | Accepted | 1,434 | 228,100 | 525 | import sys
sys.setrecursionlimit(2*10**9)
N, Q = map(int, input().split())
A = [[] for _ in range(N)]
for _ in range(N-1):
i, k = map(int, input().split())
A[i-1].append(k-1)
A[k-1].append(i-1)
n_P = [0] * N
for _ in range(Q):
k, n = map(int, input().split())
n_P[k-1] += n
ans = [0] * N
visited = [0... |
s202927248 | p02645 | u200228637 | 2,000 | 1,048,576 | Wrong Answer | 21 | 9,016 | 27 | When you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters. You have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him. | S = input()
print(S[:2])
| s735151436 | Accepted | 25 | 9,020 | 24 | s = input()
print(s[:3]) |
s841438951 | p03556 | u763177133 | 2,000 | 262,144 | Time Limit Exceeded | 2,206 | 9,064 | 68 | 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())
a = 1
while a <= n:
b = a
a **= 2
print(b) | s140461804 | Accepted | 36 | 9,096 | 95 | n = int(input())
a = 1
b = 0
c = 0
while c <= n:
b = c
c = a ** 2
a += 1
print(b) |
s444117150 | p02694 | u427690532 | 2,000 | 1,048,576 | Wrong Answer | 33 | 9,208 | 72 | Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or abo... | import math
X = int(input())
year = math.log((X / 100),1.01)
print(year) | s905995313 | Accepted | 37 | 9,932 | 195 | from decimal import Decimal
X = int(input())
n = 0
money = 100
while True:
money += int(money * Decimal("0.01"))
#print(money)
n += 1
if money >= X:
print(n)
break |
s003196112 | p03910 | u603958124 | 2,000 | 262,144 | Wrong Answer | 42 | 10,240 | 1,138 | 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 math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator ... | s404669528 | Accepted | 39 | 10,564 | 882 | from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator ... |
s093608007 | p03251 | u432453907 | 2,000 | 1,048,576 | Wrong Answer | 30 | 9,112 | 182 | Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes incli... | N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
ans="War"
x.append(X)
y.append(Y)
if max(x)<min(y):
ans="NO War"
print(ans) | s692782147 | Accepted | 28 | 9,176 | 182 | N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
ans="War"
x.append(X)
y.append(Y)
if max(x)<min(y):
ans="No War"
print(ans) |
s030596193 | p03472 | u665415433 | 2,000 | 262,144 | Wrong Answer | 564 | 30,752 | 548 | You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, …, Katana N, and can perform the following two kinds of attacks in any order: * Wield one of the katana you have. When you wield Katana i (1 ≤ i ≤ N), the monster receives a_i points of d... | N,H = map(int,input().split())
katana = []
damage = 0
for n in range(N):
katana.append(list(map(int,input().split())))
katanaA = sorted(katana,reverse = True)
katanaB = sorted(katana, key = lambda x:x[1],reverse = True)
numb = 0
num = 0
check = True
while damage < H:
if katanaA[0][0] <= katanaB[numb][1] and ch... | s335571853 | Accepted | 592 | 30,728 | 608 | N,H = map(int,input().split())
katana = []
damage = 0
for n in range(N):
katana.append(list(map(int,input().split())))
katanaA = sorted(katana,reverse = True)
katanaB = sorted(katana, key = lambda x:x[1],reverse = True)
numb = 0
num = 0
check = True
while damage < H:
if katanaA[0][0] <= katanaB[numb][1] and ch... |
s881656543 | p03433 | u936985471 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 62 | E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins. | n=int(input())
a=int(input())
print(("No","Yes")[n%500>=a])
| s748261089 | Accepted | 17 | 2,940 | 59 | n=int(input())
a=int(input())
print(("No","Yes")[n%500<=a]) |
s411399471 | p03080 | u587199081 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,060 | 330 | 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. | from sys import stdin
n = int(stdin.readline().rstrip())
data = stdin.readline().rstrip().split()
print(type(data))
s = str(data[0])
count_red, count_blue = 0,0
for i in range(len(s)):
if s[i] == "R":
count_red += 1
else:
count_blue += 1
if count_red > count_blue:
print("Yes")
else:
pr... | s085538917 | Accepted | 17 | 3,060 | 312 | from sys import stdin
n = int(stdin.readline().rstrip())
data = stdin.readline().rstrip().split()
s = str(data[0])
count_red, count_blue = 0,0
for i in range(len(s)):
if s[i] == "R":
count_red += 1
else:
count_blue += 1
if count_red > count_blue:
print("Yes")
else:
print("No")
|
s445189610 | p03543 | u175034939 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 178 | 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**? | s = list(input())
cnt = 0
for i in range(len(s)-1):
if s[i] == s[i+1]:
cnt += 1
else:
cnt = 0
if cnt == (3 or 4):
print('Yes')
else:
print('No')
| s760943484 | Accepted | 18 | 2,940 | 103 | s = input()
if (s[0] == s[1] == s[2]) or (s[1] == s[2] == s[3]):
print('Yes')
else:
print('No') |
s574219790 | p03455 | u201565171 | 2,000 | 262,144 | Wrong Answer | 2,104 | 2,940 | 155 | 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()
N=int(a+b)
flag=1
for i in range(1,N):
s=N//i
if N%i==0 and s==i:
print("Yes")
flag=0
break
if flag==1:
print("No") | s338069622 | Accepted | 17 | 2,940 | 86 | a,b=map(int,input().split())
N=a*b
if N%2==0:
print("Even")
else:
print("Odd") |
s086879997 | p03997 | u734936991 | 2,000 | 262,144 | Wrong Answer | 22 | 3,316 | 132 | 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. | #!/use/bin/env python3
from collections import defaultdict
(a, b, h) = [int(input()) for _ in range(0, 3)]
print((a + b) * h /2)
| s511000060 | Accepted | 21 | 3,316 | 134 | #!/use/bin/env python3
from collections import defaultdict
(a, b, h) = [int(input()) for _ in range(0, 3)]
print((a + b) * h // 2)
|
s031093895 | p00003 | u454259029 | 1,000 | 131,072 | Wrong Answer | 40 | 7,548 | 257 | Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so. | n = int(input())
for i in range(n):
a,b,c = map(int,input().split(" "))
if a**2 == b**2 + c**2:
print("Yes")
elif b**2 == a**2 + c**2:
print("Yes")
elif c**2 == a**2 + b**2:
print("Yes")
else:
print("No") | s202074087 | Accepted | 40 | 7,656 | 257 | n = int(input())
for i in range(n):
a,b,c = map(int,input().split(" "))
if a**2 == b**2 + c**2:
print("YES")
elif b**2 == a**2 + c**2:
print("YES")
elif c**2 == a**2 + b**2:
print("YES")
else:
print("NO") |
s711255711 | p02612 | u460980455 | 2,000 | 1,048,576 | Wrong Answer | 31 | 9,140 | 28 | We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required. | n=int(input())
print(n%1000) | s361280290 | Accepted | 30 | 9,148 | 55 | n=int(input())
n=int(n%1000)
n=1000-n
n=n%1000
print(n) |
s184156907 | p03815 | u235376569 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 194 | Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7. Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation: * Operation: Rotate the die 90° t... | a=int(input())
flag=0
if(a<6):
flag=1
print(1)
elif(a<=6 and a<=11):
flag=1
print(2)
elif(flag!=1 and a%11==0):
print(a//11*2)
elif(flag!=1 and a%11!=0):
print(a//11*2+1) | s875282803 | Accepted | 17 | 3,060 | 248 | a=int(input())
flag=0
if(a<=6):
flag=1
print(1)
elif(6<a and a<=11):
flag=1
print(2)
elif(flag!=1 and a%11==0):
print(a//11*2)
elif(flag!=1 and a%11!=0):
if 6<a%11:
print(a//11*2+2)
else:
print(a//11*2+1) |
s387855584 | p03068 | u435108403 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,060 | 183 | You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`. | N = int(input())
S = input()
K = int(input())
S_list = list(S)
target = S_list[K-1]
for i in S_list:
if not i == target :
i = "*"
S_new = "".join(S_list)
print(S_new) | s060656674 | Accepted | 17 | 2,940 | 135 | N, S, K = int(input()), list(input()), int(input())
S_new = "".join(["*" if S[i] != S[K-1] else S[i] for i in range(N)])
print(S_new) |
s140787896 | p03680 | u781262926 | 2,000 | 262,144 | Wrong Answer | 40 | 14,068 | 165 | Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It ... | n, *A = map(int, open(0).read().split())
x = 0
for i in range(n):
x, A[x] = A[x]-1, 0
if x == -1:
print(-1)
exit()
if x == 1:
print(i+1)
exit() | s364787903 | Accepted | 67 | 14,068 | 164 | n, *A = map(int, open(0).read().split())
x = 0
for i in range(n):
A[x], x = 0, A[x]-1
if x == -1:
print(x)
exit()
if x == 1:
print(i+1)
exit() |
s969287090 | p02384 | u216804574 | 1,000 | 131,072 | Wrong Answer | 20 | 5,608 | 1,463 | Construct a dice from a given sequence of integers in the same way as | class Dice:
def __init__(self, labels):
self.labels = labels
def east(self):
self.labels[1], self.labels[2], self.labels[3], self.labels[4] = self.labels[3], self.labels[1], self.labels[4], self.labels[2]
def west(self):
self.labels[1], self.labels[2], self.labels[3], self.labels[4] ... | s928628660 | Accepted | 20 | 5,608 | 1,381 | class Dice:
def __init__(self, labels):
self.labels = labels
def east(self):
self.labels[0], self.labels[2], self.labels[5], self.labels[3] = self.labels[3], self.labels[0], self.labels[2], self.labels[5]
def west(self):
self.labels[0], self.labels[2], self.labels[5], self.labels[3] ... |
s290241339 | p02406 | u685534465 | 1,000 | 131,072 | Wrong Answer | 20 | 7,460 | 105 | In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement ... | n = int(input())
for i in range(1, n+1):
if i%3 == 0 or str(i) in "3":
print(" {0}".format(i), end='') | s974824220 | Accepted | 20 | 7,824 | 113 | n = int(input())
for i in range(1, n+1):
if i%3 == 0 or "3" in str(i):
print(" {0}".format(i), end='')
print() |
s010311875 | p03605 | u871841829 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 63 | It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N? | s = input()
if s in '9':
print("Yes")
else:
print("No") | s756892130 | Accepted | 28 | 8,832 | 53 | if '9' in input():
print("Yes")
else:
print("No") |
s918995605 | p03160 | u634873566 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,064 | 608 | There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of... | N = 7
input = "2 9 4 5 1 6 10"
hights = [int(h) for h in input.split()]
print(hights)
eval = []
def chmin(a,b):
if a > b:
b = a
return True
return False
for i in range(N):
if i == N:
break
elif i == 0:
eval.append(0)
continue
elif i == 1:
eval.app... | s090271182 | Accepted | 206 | 14,052 | 544 | N = int(input())
steps = [int(i) for i in input().split()]
dp = [float('inf')]*N
for i in range(N):
if i == 0:
dp[0] = 0
if N > 1:
dp[1] = abs(steps[1] - steps[0])
if N > 2:
dp[2] = abs(steps[2] - steps[0])
else:
if i+1 < N:
dp[i+1] = min(abs(steps[i] - steps[i+1]) + dp[i], dp[i+... |
s387612822 | p02389 | u655518263 | 1,000 | 131,072 | Wrong Answer | 20 | 7,524 | 67 | Write a program which calculates the area and perimeter of a given rectangle. | s = input()
l = s.split(" ")
a = int(l[0])
b = int(l[1])
print(a*b) | s893648553 | Accepted | 20 | 7,696 | 76 | s = input()
l = s.split(" ")
a = int(l[0])
b = int(l[1])
print(a*b, 2*(a+b)) |
s971431557 | p03958 | u268792407 | 1,000 | 262,144 | Wrong Answer | 17 | 2,940 | 96 | There are K pieces of cakes. Mr. Takahashi would like to eat one cake per day, taking K days to eat them all. There are T types of cake, and the number of the cakes of type i (1 ≤ i ≤ T) is a_i. Eating the same type of cake two days in a row would be no fun, so Mr. Takahashi would like to decide the order for eating ... | k,t=map(int,input().split())
a=list(map(int,input().split()))
m=max(a)
n=k-m
print(min(m-n-1,0)) | s926618200 | Accepted | 18 | 3,064 | 96 | k,t=map(int,input().split())
a=list(map(int,input().split()))
m=max(a)
n=k-m
print(max(m-n-1,0)) |
s052155527 | p03625 | u106297876 | 2,000 | 262,144 | Wrong Answer | 131 | 28,580 | 260 | We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle. | N = int(input())
A = list(map(int, input().split()))
import collections
A_c=collections.Counter(A)
print(A_c)
keys = [k for k, v in A_c.items() if v >= 2]
keys.sort()
if len(keys) < 2:
ans = 0
else:
ans = keys[len(keys)-1] * keys[len(keys)-2]
print(ans) | s566662931 | Accepted | 76 | 18,316 | 335 | N = int(input())
A = list(map(int, input().split()))
import collections
A_c=collections.Counter(A)
keys = [k for k, v in A_c.items() if v >= 2]
keys.sort()
if len(keys) < 2:
ans = 0
elif A_c.get(keys[len(keys)-1]) >= 4:
ans = keys[len(keys)-1] * keys[len(keys)-1]
else:
ans = keys[len(keys)-1] * keys[len(keys)-... |
s769412915 | p03827 | u434282696 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 88 | 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... | x=0
n=int(input())
s=input()
for i in range(n):
if s[i]=='I':x+=1
else:x-=1
print(x) | s496640940 | Accepted | 17 | 2,940 | 113 | x=0
res=0
n=int(input())
s=input()
for i in range(n):
if s[i]=='I':x+=1
else:x-=1
res=max(res,x)
print(res) |
s652676699 | p02282 | u947762778 | 1,000 | 131,072 | Wrong Answer | 30 | 7,612 | 558 | Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the postorder tree walk on the binary tree. | def getPostorder(preorder, inorder):
if not preorder:
return []
postorder = []
root = preorder[0]
rootIndex = inorder.index(root)
postorder.extend(getPostorder(preorder[1:rootIndex + 1], inorder[:rootIndex]))
postorder.extend(getPostorder(preorder[rootIndex + 1:], inorder[rootIndex + 1:... | s612550712 | Accepted | 20 | 7,780 | 559 | def getPostorder(preorder, inorder):
if not preorder:
return []
postorder = []
root = preorder[0]
rootIndex = inorder.index(root)
postorder.extend(getPostorder(preorder[1:rootIndex + 1], inorder[:rootIndex]))
postorder.extend(getPostorder(preorder[rootIndex + 1:], inorder[rootIndex + 1:... |
s409326250 | p04011 | u663438907 | 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(N):
if i <= K:
ans += X
else:
ans += Y
print(ans) | s286873157 | Accepted | 19 | 3,060 | 160 | N = int(input())
K = int(input())
X = int(input())
Y = int(input())
ans = 0
for i in range(N):
if i+1 <= K:
ans += X
else:
ans += Y
print(ans) |
s566063273 | p02398 | u962381052 | 1,000 | 131,072 | Wrong Answer | 30 | 7,616 | 62 | Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b. | a, b, c = [int(n) for n in input().split()]
print(b//c - a//c) | s166215168 | Accepted | 30 | 7,708 | 128 | a, b ,c = [int(n) for n in input().split()]
count = 0
for n in range(a, b+1):
if c%n == 0:
count += 1
print(count) |
s583718133 | p03369 | u767438459 | 2,000 | 262,144 | Wrong Answer | 29 | 9,024 | 41 | 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 ... | S = input()
print(S.count("x")*100 + 700) | s702901963 | Accepted | 25 | 9,000 | 41 | S = input()
print(S.count("o")*100 + 700) |
s108002226 | p03150 | u733774002 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 105 | 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()
if s == "keyence" + s[7:] or s == s[:-7] + "keyence":
print("YES")
else:
print("NO")
| s477405526 | Accepted | 17 | 2,940 | 174 | s = input()
target = "keyence"
ans = "NO"
for i in range(len(target) + 1):
if target == s[:i] + s[len(s) - len(target) + i:]:
ans = "YES"
break
print(ans) |
s466902304 | p03597 | u798129018 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 49 | 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**N - A) | s314011372 | Accepted | 17 | 2,940 | 49 | n = int(input())
a = int(input())
print(n**2 -a) |
s337331503 | p03448 | u559367141 | 2,000 | 262,144 | Wrong Answer | 56 | 9,040 | 213 | You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that co... | a,b,c,x = [int(input()) for i in range(4)]
count = 0
for i in range(a+1):
for j in range(b+1):
for k in range(c+1):
if (500*a + 100*b + 50*c == x):
count += 1
print(count) | s572881469 | Accepted | 59 | 9,180 | 241 | A = int(input())
B = int(input())
C = int(input())
X = int(input())
counts = 0
for a in range(A+1):
for b in range(B+1):
for c in range(C+1):
if (500*a + 100*b + 50*c) == X:
counts += 1
print(counts) |
s658847733 | p03598 | u274635633 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 122 | There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N. In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he placed the i-th type-A robot at coordinates (0, i), and the i-th t... | n=int(input())
k=int(input())
x=list(map(int,input().split()))
ans=0
for i in range(n):
ans+=min(x[i],k-x[i])
print(ans) | s649016062 | Accepted | 18 | 3,060 | 124 | n=int(input())
k=int(input())
x=list(map(int,input().split()))
ans=0
for i in range(n):
ans+=min(x[i],k-x[i])
print(ans*2) |
s953063204 | p02607 | u268674745 | 2,000 | 1,048,576 | Wrong Answer | 25 | 9,008 | 150 | We have N squares assigned the numbers 1,2,3,\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i. How many squares i satisfy both of the following conditions? * The assigned number, i, is odd. * The written integer is odd. | n = int(input())
cnt = 0
arr = [int(x) for x in input().split()]
for i in range(0, len(arr), 2):
if arr[i] % 2 == 0:
cnt += 1
print(cnt)
| s890357593 | Accepted | 23 | 9,140 | 150 | n = int(input())
cnt = 0
arr = [int(x) for x in input().split()]
for i in range(0, len(arr), 2):
if arr[i] % 2 != 0:
cnt += 1
print(cnt)
|
s894453425 | p03229 | u936985471 | 2,000 | 1,048,576 | Wrong Answer | 135 | 14,068 | 276 | You are given N integers; the i-th of them is A_i. Find the maximum possible sum of the absolute differences between the adjacent elements after arranging these integers in a row in any order you like. | n,*a=map(int,open(0).read().split())
a=sorted(list(a))
from collections import deque
a=deque(a)
i=0
ans=0
cur=a.popleft()
for i in range(1,n):
if i%2==0:
w=a.popleft()
ans+=abs(w-cur)
cur=w
else:
w=a.pop()
ans+=abs(w-cur)
cur=w
print(ans)
| s931823818 | Accepted | 326 | 8,856 | 1,083 | # 6,8,1,2,3
# 3 8 1 6 2
#
# 3 1 4 1 5 9
# 1 1 3 4 5 9
#
# 5 5 1
# 5 1 5
N=int(input())
A=[0] * N
for i in range(N):
A[i] = int(input())
if N == 2:
print(abs(A[0] - A[1]))
exit(0)
A=sorted(A)
from collections import deque
def calc(A,first,flip):
q = deque(A)
ans = 0
cur = first
while q:
if ... |
s532309578 | p02407 | u981139449 | 1,000 | 131,072 | Wrong Answer | 40 | 7,724 | 55 | Write a program which reads a sequence and prints it in the reverse order. | input()
print(*sorted(int(i) for i in input().split())) | s854231143 | Accepted | 20 | 7,472 | 41 | input()
print(*reversed(input().split())) |
s441412834 | p02612 | u762469320 | 2,000 | 1,048,576 | Wrong Answer | 29 | 9,084 | 54 | We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required. | n = int(input())
while n >= 1000:
n = n-1000
print(n) | s126879738 | Accepted | 28 | 9,152 | 69 | n = input()
a = int(n[-3:])
if a == 0:
print(0)
else:
print(1000-a) |
s834273353 | p03370 | u353855427 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 232 | 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... | num = list(map(int, input().split()))
m = []
for i in range(num[0]):
m.append(int(input()))
for i in range(num[0]):
num[1]-=m[i]
m = sorted(m)
print(num[1])
print(m)
if(num[1]==0):
print(num[0])
else:
print(num[1]//m[0]+num[0])
| s353316198 | Accepted | 18 | 3,064 | 233 | num = list(map(int, input().split()))
m = []
for i in range(num[0]):
m.append(int(input()))
for i in range(num[0]):
num[1]-=m[i]
m = sorted(m)
#print(num[1])
#print(m)
if(num[1]==0):
print(num[0])
else:
print(num[1]//m[0]+num[0]) |
s291132548 | p03997 | u135521563 | 2,000 | 262,144 | Wrong Answer | 24 | 3,064 | 74 | You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid. | a = int(input())
b = int(input())
h = int(input())
print((a + b) * h / 2) | s318822422 | Accepted | 24 | 3,188 | 75 | a = int(input())
b = int(input())
h = int(input())
print((a + b) * h // 2) |
s869553126 | p02806 | u422272120 | 2,525 | 1,048,576 | Wrong Answer | 17 | 3,064 | 305 | 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())
l = {}
for i in range(0,n):
#print (i)
line = input()
l[i] = line.strip().split()
x = str(input())
time = 0
for i in range(0,n):
print (str(l[i][0]), x)
if l[i][0] == x:
l.pop(i)
break
l.pop(i)
for i in l:
time += int((l[i][1]))
print (time) | s997985561 | Accepted | 17 | 3,064 | 277 | n = int(input())
l = {}
for i in range(0,n):
#print (i)
line = input()
l[i] = line.strip().split()
x = str(input())
time = 0
for i in range(0,n):
if l[i][0] == x:
l.pop(i)
break
l.pop(i)
for i in l:
time += int((l[i][1]))
print (time) |
s477500221 | p03730 | u777283665 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 124 | We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objecti... | a, b, c = map(int, input().split())
for i in range(1, a+b+1):
if a * i % b == c:
print("Yes")
exit()
print("No") | s368354195 | Accepted | 17 | 2,940 | 126 | a, b, c = map(int, input().split())
for i in range(1, a*b+1):
if (a * i) % b == c:
print("YES")
exit()
print("NO") |
s948887550 | p03861 | u857070771 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 62 | You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x? | a,b,x=map(int,input().split())
ans = b // x - a //x
print(ans) | s214902654 | Accepted | 17 | 2,940 | 65 | a,b,x=map(int,input().split())
ans = b // x - (a-1)//x
print(ans) |
s668729154 | p03155 | u814781830 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 89 | It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board. The bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns. How many ways are there to choose where ... | N = int(input())
H = int(input())
W = int(input())
print(int((H - N + 1) * (W - N + 1))) | s103723479 | Accepted | 17 | 2,940 | 90 | N = int(input())
H = int(input())
W = int(input())
print(int((N - H + 1) * (N - W + 1))) |
s946058850 | p02742 | u056358163 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 86 | 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((W + 1) // 2 * (H + 1) // 2 + W // 2 * H // 2) | s775123347 | Accepted | 17 | 2,940 | 160 | H, W = map(int, input().split())
if H == 1 or W == 1:
print(1)
else:
odd = ((W + 1) // 2) * ((H + 1) // 2)
even = (W // 2) * (H // 2)
print(odd + even)
|
s976679911 | p03555 | u903948194 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 86 | 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. | c = list(input())
if c[::-1] == list(input()):
print('Yes')
else:
print('No') | s872004300 | Accepted | 17 | 2,940 | 86 | c = list(input())
if c[::-1] == list(input()):
print('YES')
else:
print('NO') |
s795464437 | p03778 | u254871849 | 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 = [int(x) for x in input().split()]
if abs(a - b) > w:
ans = abs(a - b) + w
else:
ans = 0
print(ans) | s754666260 | Accepted | 17 | 3,060 | 252 | import sys
w, a, b = map(int, sys.stdin.readline().split())
def main():
if a + w < b:
return b - (a + w)
elif b + w < a:
return a - (b + w)
else:
return 0
if __name__ == '__main__':
ans = main()
print(ans) |
s296477769 | p03719 | u007263493 | 2,000 | 262,144 | Wrong Answer | 17 | 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=map(int,input().split())
if c >= a and c <= b:
print('YES')
else:
print('NO') | s792537955 | Accepted | 17 | 2,940 | 93 | a ,b, c=map(int,input().split())
if c >= a and c <= b:
print('Yes')
else:
print('No') |
s615929167 | p03672 | u839537730 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 122 | We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by del... | s = input().strip()
ls = len(s)
for i in range(ls//2-1, 0, -1):
if s[:i] == s[i:2*1]:
print(2*i)
break | s959359466 | Accepted | 17 | 3,060 | 209 | S = input()
for i in range(1, len(S)):
if len(S[:-i]) % 2 == 1:
continue
if S[:int(len(S[:-i])/2)] == S[int(len(S[:-i])/2):-i]:
ans = len(S[:int(len(S[:-i]))])
break
print(ans) |
s153389000 | p03455 | u702582248 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 62 | AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. | print('Yes'if[i for i in input().split() if int(i)%2]else'No') | s521059305 | Accepted | 17 | 2,940 | 67 | print('Even'if[i for i in input().split() if int(i)%2==0]else'Odd') |
s267612407 | p03167 | u686230543 | 2,000 | 1,048,576 | Wrong Answer | 2,109 | 22,216 | 589 | There is a grid with H horizontal rows and W vertical columns. Let (i, j) denote the square at the i-th row from the top and the j-th column from the left. For each i and j (1 \leq i \leq H, 1 \leq j \leq W), Square (i, j) is described by a character a_{i, j}. If a_{i, j} is `.`, Square (i, j) is an empty square; if a... | import numpy as np
MOD = 10 ** 9 + 7
H, W = map(int, input().split())
count = np.ones((H, W), dtype=np.int)
row = input()
for w in range(1, W):
if row[w] == '#':
count[w:] = 0
break
flag = True
for h in range(1, H):
row = input()
if flag and row[0] == '#':
count[h:, 0] = 0
flag = False
count... | s653823319 | Accepted | 402 | 3,064 | 371 | MOD = 10 ** 9 + 7
H, W = map(int, input().split())
count = [0] * W
row = input()
for w in range(W):
if row[w] == '#':
break
else:
count[w] = 1
for h in range(1, H):
row = input()
if row[0] == '#':
count[0] = 0
for w in range(1, W):
if row[w] == '#':
count[w] = 0
else:
count[... |
s747682543 | p02417 | u248424983 | 1,000 | 131,072 | Wrong Answer | 30 | 7,900 | 127 | Write a program which counts and reports the number of each alphabetical letter. Ignore the case of characters. | import string
x=input()
allcase=string.ascii_lowercase
for letter in allcase:
print(letter + " : " + repr(x.count(letter))) | s373166365 | Accepted | 40 | 7,996 | 183 | import string
x = ''
allcase = string.ascii_lowercase
while True:
try: x+=input().lower()
except:break
for letter in allcase:
print(letter + " : " + repr(x.count(letter))) |
s121435825 | p02399 | u973203074 | 1,000 | 131,072 | Wrong Answer | 20 | 5,608 | 95 | 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())
ans = [a // b, a % b, a / b]
print(" ".join(map(str, ans)))
| s185049398 | Accepted | 20 | 5,608 | 98 | a, b = map(int, input().split())
d = a // b
r = a % b
f = a / b
print(d, r, '{:.5f}'.format(f))
|
s546482688 | p01448 | u226888928 | 8,000 | 131,072 | Wrong Answer | 20 | 7,684 | 350 | 明日から、待ちに待った夏休みが始まります。なのでわたしは、友だちを誘って、海に遊びに行くこ とに決めました。 けれども、わたしの友だちには、恥ずかしがりやさんが多いです。その人たちは、あまり多くの人が いっしょに来ると知ったら、きっと嫌がるでしょう。 ほかにも、わたしの友だちには、目立ちたがりやさんも多いです。その人たちは、いっしょに来る人 があまり多くないと知れば、きっと嫌がるでしょう。 それと、わたしの友だちには、いつもは目立ちたがりやなのに実は恥ずかしがりやさんな人もいま す。その人たちは、いっしょに来る人が多すぎても少なすぎても、きっと嫌がるでしょう。 こういうのは、大勢で行った方が楽しいはずです。だからわたしは、で... | import heapq
n=int(input())
abs=sorted([list(map(int,input().split())) for _ in range(n)])
s=0
best=0
heap=[]
for k in range(1,n+1):
while(s < n and abs[s][0] <= k+1):
heapq.heappush(heap, -abs[s][1])
s+=1
while(len(heap) > 0 and -heap[0] <= k):
heapq.heappop(heap)
if(len(heap) >= k)... | s515017875 | Accepted | 870 | 33,108 | 348 | import heapq
n=int(input())
abs=sorted([list(map(int,input().split())) for _ in range(n)])
s=0
best=0
heap=[]
for k in range(1,n+1):
while(s < n and abs[s][0] <= k+1):
heapq.heappush(heap, abs[s][1])
s+=1
while(len(heap) > 0 and heap[0] <= k):
heapq.heappop(heap)
if(len(heap) >= k):
... |
s302383858 | p02678 | u671211357 | 2,000 | 1,048,576 | Wrong Answer | 24 | 9,116 | 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") | s094680331 | Accepted | 585 | 34,628 | 472 | from collections import deque
N,M=map(int,input().split())
haba=[[] for i in range(N+1)]
for i in range(M):
A,B=map(int,input().split())
haba[A].append(B)
haba[B].append(A)
kyori=[-1]*(N+1)
kyori[0]=0
kyori[1]=0
que=deque()
que.append(1)
while que:
kari=que.popleft()
for i in haba[kari]:
i... |
s242382241 | p03623 | u842388336 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 60 | 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())
print(min(abs(x-a),abs(x-b))) | s795910260 | Accepted | 17 | 2,940 | 84 | x,a,b=map(int,input().split())
if abs(x-a)>abs(x-b):
print("B")
else:
print("A") |
s558057469 | p03478 | u982762220 | 2,000 | 262,144 | Wrong Answer | 28 | 3,060 | 178 | Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive). | N, A, B = map(int, input().split())
res = 0
for num in range(N):
tmp = 0
while num > 0:
tmp += num % 10
num //= 10
if A <= tmp and tmp <= B:
res += 1
print(res) | s536823033 | Accepted | 29 | 3,060 | 193 | N, A, B = map(int, input().split())
res = 0
for i in range(1, N + 1):
tmp = 0
num = i
while num > 0:
tmp += num % 10
num //= 10
if A <= tmp and tmp <= B:
res += i
print(res) |
s714237641 | p04043 | u061361273 | 2,000 | 262,144 | Wrong Answer | 27 | 9,020 | 159 | 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 ... | def hiku():
lst=input()
lst = lst.split()
lst.sort()
print(lst)
if lst[0]=='5' and lst[1]=='5' and lst[2]=='7':
print("YES")
else:
print('NO')
hiku() | s840830848 | Accepted | 25 | 8,964 | 213 | def test():
x = input()
x = x.split()
if x == ['5', '5', '7']:
print("YES")
elif x == ['5', '7', '5']:
print("YES")
elif x == ['7', '5', '5']:
print("YES")
else:
print("NO")
test() |
s384619803 | p02694 | u922769680 | 2,000 | 1,048,576 | Wrong Answer | 23 | 9,108 | 106 | Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or abo... | import math
X=int(input())
M=100
count=0
while M <= X:
M=math.floor(M*1.01)
count+=1
print(count) | s424898804 | Accepted | 27 | 9,164 | 105 | import math
X=int(input())
M=100
count=0
while M < X:
M=math.floor(M*1.01)
count+=1
print(count) |
s981428787 | p03456 | u765401716 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 212 | 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()
C = a + b
number_list =list(range(1,101))
squared_list =[]
for i in number_list:
D = i * i
squared_list.append(D)
if C in squared_list:
print("Yes")
else:
print("No") | s732547572 | Accepted | 18 | 3,060 | 234 | a,b = input().split()
C = a + b
number_list =list(range(1,1000))
squared_list =[]
for i in number_list:
D = i * i
D2 = str(D)
squared_list.append(D2)
if C in squared_list:
print("Yes")
else:
print("No") |
s612342148 | p02850 | u321035578 | 2,000 | 1,048,576 | Wrong Answer | 2,104 | 16,284 | 655 | Given is a tree G with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i. Consider painting the edges in G with some number of colors. We want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different. Among the colo... | def main():
n = int(input())
G = [[0] * (n-1) for i in range(2)]
cnt = [0] * n
for i in range(n-1):
a,b = map(int, input().split())
G[0][i] = a-1
G[1][i] = b-1
cnt[a-1] += 1
cnt[b-1] += 1
num = 0
print(G)
print(max(cnt))
tmp_clr = [0] * (n-1)
... | s834333168 | Accepted | 484 | 34,204 | 942 | def main():
n = int(input())
cnt = [0] * n
G = [[] for i in range(n)]
for i in range(n-1):
a, b = map(int, input().split())
G[a-1].append((b-1, i))
cnt[a-1] += 1
cnt[b-1] += 1
# a,b = map(int, input().split())
# G[0][i] = a-1
# G[1][i] ... |
s673749233 | p03762 | u371763408 | 2,000 | 262,144 | Wrong Answer | 268 | 18,576 | 258 | On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i. For ever... | n,m = map(int,input().split())
X = list(map(int,input().split()))
Y = list(map(int,input().split()))
area=0
mod=10**9+7
x=0
for i in range(n):
x += -(n-i-1)*X[i]+i*X[i]
print("x",x)
y = 0
for i in range(m):
y += -(m-i-1)*Y[i]+i*Y[i]
print(x*y%mod) | s852297004 | Accepted | 154 | 18,624 | 243 | n,m = map(int,input().split())
X = list(map(int,input().split()))
Y = list(map(int,input().split()))
area=0
mod=10**9+7
x=0
for i in range(n):
x += -(n-i-1)*X[i]+i*X[i]
y = 0
for i in range(m):
y += -(m-i-1)*Y[i]+i*Y[i]
print(x*y%mod) |
s086798682 | p02261 | u809233245 | 1,000 | 131,072 | Wrong Answer | 30 | 6,336 | 975 | Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubbl... | import copy
def bubble_sort(a):
ba = copy.copy(a)
flag = True
for i in range(0, n):
if not flag:
break
flag = False
for j in range(n-1, 0, -1):
if int(ba[j][1]) < int(ba[j-1][1]):
ba[j], ba[j-1] = ba[j-1], ba[j]
flag = True
... | s999845297 | Accepted | 30 | 6,344 | 975 | import copy
def bubble_sort(a):
ba = copy.copy(a)
flag = True
for i in range(0, n):
if not flag:
break
flag = False
for j in range(n-1, 0, -1):
if int(ba[j][1]) < int(ba[j-1][1]):
ba[j], ba[j-1] = ba[j-1], ba[j]
flag = True
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.