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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s155206273 | p03494 | u228294553 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 109 | 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. | a=input()
n=min(list(map(int,input().split())))
cnt=0
while n%2==0:
n=n/2
cnt=cnt+1
print(cnt)
| s579042430 | Accepted | 19 | 3,064 | 301 | a=input()
l=list(map(int,input().split()))
def calc(n):
return n//2
min=min(l)
cnt=0
flg=True
list2=l
while flg:
flg=all(elem % 2 == 0 for elem in list2)
if flg==False:
break
list2=list(map(calc,list2))
min=min//2
cnt=cnt+1
print(cnt) |
s056641780 | p03478 | u390958150 | 2,000 | 262,144 | Wrong Answer | 54 | 3,308 | 186 | 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())
n_sum = 0
for i in range(n):
order = [int(j) for j in list(str(i+1))]
print(order)
if a <= sum(order) <= b:
n_sum += i + 1
print(n_sum)
| s220850449 | Accepted | 37 | 2,940 | 171 | n,a,b = map(int,input().split())
n_sum = 0
for i in range(n):
order = [int(j) for j in list(str(i+1))]
if a <= sum(order) <= b:
n_sum += i + 1
print(n_sum)
|
s650994248 | p03693 | u425351967 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 105 | 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 i... | r, g, b = [int(n) for n in input().split()]
if 10*g+b % 4 == 0:
print('YES')
else:
print('NO')
| s605577713 | Accepted | 17 | 2,940 | 107 | r, g, b = [int(n) for n in input().split()]
if (10*g+b) % 4 == 0:
print('YES')
else:
print('NO')
|
s641459750 | p03759 | u469226065 | 2,000 | 262,144 | Wrong Answer | 27 | 9,020 | 94 | 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 - b:
print('Yes')
else:
print('No') | s180540500 | Accepted | 29 | 9,100 | 94 | a, b, c = map(int, input().split())
if b - a == c - b:
print('YES')
else:
print('NO') |
s798234767 | p03597 | u393581926 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 171 | 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? | one_side=input("一辺のマスの数:")
oneside=int(one_side)
whole=oneside**2
white_side=input("白色のマスの数:")
whiteside=int(white_side)
print(whole-whiteside) | s941812812 | Accepted | 17 | 2,940 | 123 | one_side=input()
oneside=int(one_side)
whole=oneside**2
white_side=input()
whiteside=int(white_side)
print(whole-whiteside) |
s062911289 | p02663 | u956547804 | 2,000 | 1,048,576 | Wrong Answer | 23 | 8,916 | 351 | In this problem, we use the 24-hour clock. Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study for K consecutive minutes while he is up. What is the length of the period in which he can start studying? | t=input()
result=''
for i in range(len(t)-1):
if t[i]=='?':
try:
if result[i-1]=='P':
result+='D'
else:
result+='P'
except:
if t[i+1]=='P':
result+='D'
else:
result+='P'
else:
... | s212615978 | Accepted | 25 | 9,164 | 69 | h1,m1,h2,m2,k=map(int,input().split())
print((h2*60+m2)-(h1*60+m1)-k) |
s110220670 | p03503 | u529350960 | 2,000 | 262,144 | Wrong Answer | 178 | 3,688 | 1,621 | Joisino is planning to open a shop in a shopping street. Each of the five weekdays is divided into two periods, the morning and the evening. For each of those ten periods, a shop must be either open during the whole period, or closed during the whole period. Naturally, a shop must be open during at least one of those ... |
import copy
shop_num = int(input().rstrip())
# business hour
shop_data = {}
for i in range(shop_num):
shop_data[i] = input().rstrip().split(' ')
shop_benefit = {}
for i in range(shop_num):
shop_benefit[i] = input().rstrip().split(' ')
patterns = [0, 1, 2];
targets = []
for pattern1 in patterns:
list1 = []
if... | s969125709 | Accepted | 591 | 3,956 | 1,671 |
import copy
shop_num = int(input().rstrip())
# business hour
shop_data = {}
for i in range(shop_num):
shop_data[i] = input().rstrip().split(' ')
shop_benefit = {}
for i in range(shop_num):
shop_benefit[i] = input().rstrip().split(' ')
patterns = [0, 1, 2, 3];
targets = []
for pattern1 in patterns:
list1 = []
... |
s548469788 | p03719 | u337851472 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 72 | 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()
print("YES" if A <= C and C <= B else "NO")
| s050198447 | Accepted | 17 | 2,940 | 81 | A, B, C = map(int,input().split())
print("Yes" if A <= C and C <= B else "No")
|
s172221197 | p03471 | u636481117 | 2,000 | 262,144 | Wrong Answer | 2,104 | 3,064 | 350 | The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situat... | N,Y = map(int,input().split())
flg = False
a=0
b=0
c=0
for x in range(N+1):
for y in range(N+1):
for z in range(N+1):
if 10000*x + 5000*y + 1000*z == Y:
a = x
b = y
c = z
flg = True
break
if flg == True:
print(a,... | s697152458 | Accepted | 980 | 3,060 | 260 | N,Y = map(int,input().split())
a=-1
b=-1
c=-1
for x in range(N+1):
for y in range(N+1-x):
if N - x - y >= 0 and 10000*x + 5000*y + 1000*(N - x - y) == Y:
a = x
b = y
c = N - x - y
break
print(a,b,c)
|
s241709362 | p03023 | u869595612 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 20 | Given an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees, but do not print units. | (int(input())-2)*180 | s433352473 | Accepted | 17 | 2,940 | 27 | print((int(input())-2)*180) |
s862282958 | p03759 | u403984573 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 79 | 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-C==B-A:
print("YES")
else:
print("NO")
| s178499012 | Accepted | 18 | 3,064 | 79 | A,B,C=map(int,input().split())
if C-B==B-A:
print("YES")
else:
print("NO")
|
s285108810 | p02608 | u200916944 | 2,000 | 1,048,576 | Wrong Answer | 615 | 12,384 | 390 | 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). | N = int(open(0).read())
cache = {}
cnt = 0
c = int(N ** 0.5)
cs = range(1, c)
for x in cs:
for y in cs:
for z in cs:
n = x*x + y*y + z*z + x*y + y*z + z*x
if n in cache:
cache[n] += 1
else:
cache[n] = 1
print(cache)
for i in range(1, N+1):
... | s956494831 | Accepted | 568 | 11,636 | 376 | N = int(open(0).read())
cache = {}
cnt = 0
c = int(N ** 0.5)
cs = range(1, c)
for x in cs:
for y in cs:
for z in cs:
n = x*x + y*y + z*z + x*y + y*z + z*x
if n in cache:
cache[n] += 1
else:
cache[n] = 1
for i in range(1, N+1):
if i in c... |
s718490184 | p02389 | u237991875 | 1,000 | 131,072 | Wrong Answer | 20 | 7,480 | 48 | Write a program which calculates the area and perimeter of a given rectangle. | a, b = map(int, input().split())
print(a*b, a+b) | s280483117 | Accepted | 20 | 7,556 | 70 | a, b = map(int, input().split())
print("%d %d" % (a * b, 2 * (a + b))) |
s228127953 | p03556 | u686036872 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 101 | 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())
max=1
for i in range(N):
if max<i**2<=N:
max=i**2
else:
break
print(max) | s632946892 | Accepted | 18 | 3,060 | 41 | N = int(input())
print(int(N**(1/2))**2) |
s159861869 | p03455 | u054501336 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 89 | AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. | a,b = map(int, input().split())
if (a*b)%2 == 0:
print('even')
else:
print('odd') | s493829809 | Accepted | 18 | 2,940 | 89 | a,b = map(int, input().split())
if (a*b)%2 == 0:
print("Even")
else:
print("Odd") |
s520403758 | p03862 | u917558625 | 2,000 | 262,144 | Wrong Answer | 112 | 19,984 | 438 | There are N boxes arranged in a row. Initially, the i-th box from the left contains a_i candies. Snuke can perform the following operation any number of times: * Choose a box containing at least one candy, and eat one of the candies in the chosen box. His objective is as follows: * Any two neighboring boxes con... | N,x=map(int,input().split())
a=list(map(int,input().split()))
a.append(0)
ans=0
for i in range(N):
if i==0:
if a[i]+a[i+1]>x:
if a[i]>x:
ans+=a[i+1]+a[i]-x
a[i+1]=0
else:
ans+=(a[i]+a[i+1]-x)
a[i+1]=x-(a[i+1]-a[i])
else:
if a[i]+a[i+1]>x:
if a[i]>x:
... | s765469530 | Accepted | 105 | 20,088 | 420 | N,x=map(int,input().split())
a=list(map(int,input().split()))
a.append(0)
ans=0
for i in range(N):
if i==0:
if a[i]+a[i+1]>x:
if a[i]>x:
ans+=a[i+1]+a[i]-x
a[i+1]=0
else:
ans+=(a[i]+a[i+1]-x)
a[i+1]=x-a[i]
else:
if a[i]+a[i+1]>x:
if a[i]>x:
ans+=a[i+... |
s316907402 | p03433 | u382431597 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 74 | E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins. | x = int(input()) % 500
a = int(input())
print("Yes" if x == a else "No")
| s599669482 | Accepted | 17 | 2,940 | 75 | x = int(input()) % 500
a = int(input())
print("Yes" if x <= a else "No")
|
s470726105 | p03625 | u970197315 | 2,000 | 262,144 | Wrong Answer | 202 | 24,104 | 570 | 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. | # ABC071 C - Make a Rectangle
from collections import Counter
from operator import itemgetter
N = int(input())
A = map(int,input().split())
C = Counter(A)
ans = 0
first = 0
second = 0
C = list(C.items())
C.sort(key=itemgetter(0,1),reverse=True)
for c in C:
if c[1]>=4:
first = c[0]
second = c[0]
... | s754962907 | Accepted | 148 | 20,900 | 588 | # ABC071 C - Make a Rectangle
from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))
first = 0
second = 0
d = defaultdict(int)
for a in A:
d[a] += 1
A = set(A)
A = list(A)
A.sort(reverse=True)
for a in A:
if 4 <= d[a]:
if first>0:
second = a
b... |
s772173015 | p03456 | u848647227 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 120 | 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(int,input().split(" "))
if math.sqrt(a*b).is_integer() == True:
print("Yes")
else:
print("No") | s130085170 | Accepted | 18 | 2,940 | 142 | import math
a,b = map(int,input().split(" "))
c = int(str(a)+str(b))
if math.sqrt(c).is_integer() == True:
print("Yes")
else:
print("No")
|
s745793900 | p02608 | u521866787 | 2,000 | 1,048,576 | Wrong Answer | 32 | 9,732 | 421 | 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 itertools
N=int(input())
a = [0] * N
if N >= 6:
for x,y,z in itertools.combinations_with_replacement(list(range(1,N)), 3):
f = (x+y+z)**2 - x*y - y*z - x*z
if f <= N:
if x==y==z:
a[f-1] += 1
elif x==y or y== z:
a[f-1] += 3
... | s549138520 | Accepted | 191 | 9,392 | 475 | import itertools
import math
N=int(input())
a = [0] * N
b = [1,1,1]
if N >= 6:
for x,y,z in itertools.combinations_with_replacement(list(range(1,int(math.sqrt(N)) +1 )), 3):
f = x**2 +y**2 +z**2 + x*y + y*z + x*z
if f <= N:
if x==y==z:
a[f-1] += 1
elif x==y... |
s957168215 | p03338 | u728498511 | 2,000 | 1,048,576 | Wrong Answer | 18 | 3,064 | 149 | You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when ... | n = int(input())
s = input()
mx = 0
for i in range(1, n):
print(set(s[:i]) & set(s[i:]))
mx = max(mx, len(set(s[:i]) & set(s[i:])))
print(mx) | s693938847 | Accepted | 17 | 3,060 | 114 | n = int(input())
s = input()
mx = 0
for i in range(1, n):
mx = max(mx, len(set(s[:i]) & set(s[i:])))
print(mx) |
s720837518 | p04043 | u350093546 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 103 | 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 ... | x=list(map(int,input().split()))
if x.count(5)==2 and x.count(7)==1:
print('Yes')
else:
print('No') | s893781655 | Accepted | 17 | 2,940 | 104 | x=list(map(int,input().split()))
if x.count(5)==2 and x.count(7)==1:
print('YES')
else:
print('NO')
|
s702285111 | p03730 | u995062424 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 134 | 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(b):
if(a*i % b == c):
print("Yes")
exit()
print("NO") | s637470193 | Accepted | 18 | 2,940 | 134 | a, b, c = map(int, input().split())
for i in range(b):
if(a*i % b == c):
print("YES")
exit()
print("NO") |
s942634703 | p03555 | u887207211 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 95 | 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. | S = sorted(input(), reverse = True)
T = input()
ans = "NO"
if(S == T):
ans = "YES"
print(ans) | s052068916 | Accepted | 17 | 2,940 | 94 | S = input()
T = input()
ans = "NO"
if(S[::-1] == T and S == T[::-1]):
ans = "YES"
print(ans) |
s360625582 | p03476 | u263830634 | 2,000 | 262,144 | Time Limit Exceeded | 2,104 | 4,148 | 924 | We say that a odd number N is _similar to 2017_ when both N and (N+1)/2 are prime. You are given Q queries. In the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i. |
N = 10 ** 5 + 10
def primes(n):
import math
is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, int(math.sqrt(n)) + 1):
if not is_prime[i]:
continue
for j in range(i * 2, n + 1, i):
is_prime[j] = False
return [i for i in... | s183950853 | Accepted | 851 | 4,596 | 1,554 |
# ------------------------------------------------------------------
MAX_N = 10 ** 5 + 10
# ------------------------------------------------------------------
def primes(n):
import math
count_lst = [0] * (n + 1)
is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = False
for i in ran... |
s603085686 | p04045 | u891217808 | 2,000 | 262,144 | Wrong Answer | 29 | 3,316 | 174 | Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very ... | price, num = input().split(" ")
dislike = input().split(" ")
for i in range(int(price), 10001):
if set(dislike) & set(str(i)):
continue
else:
print(i) | s170358664 | Accepted | 115 | 2,940 | 189 | price, num = input().split(" ")
dislike = input().split(" ")
for i in range(int(price), 100000):
if set(dislike) & set(str(i)):
continue
else:
print(i)
break |
s679662978 | p03433 | u962127640 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 153 | 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 = list(map(int , input().split()))
B = list(map(int , input().split()))
amari = n[0]%500
if amari - B[0] <= 0:
print('YES')
else:
print('NO') | s315004390 | Accepted | 17 | 3,064 | 153 | n = list(map(int , input().split()))
B = list(map(int , input().split()))
amari = n[0]%500
if amari - B[0] <= 0:
print('Yes')
else:
print('No') |
s188565184 | p03472 | u801049006 | 2,000 | 262,144 | Wrong Answer | 358 | 11,312 | 339 | 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... | import math
n, h = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
a[i], b[i] = map(int, input().split())
m = max(a)
b.sort()
ans = 0
for i in range(n):
if m < b[i]:
h -= b[i]
ans += 1
if h <= 0 :
print(ans)
exit()
print(h)
ans += math.ceil... | s554409695 | Accepted | 354 | 11,312 | 343 | import math
n, h = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
a[i], b[i] = map(int, input().split())
m = max(a)
b.sort(reverse=True)
ans = 0
for i in range(n):
if m <= b[i]:
h -= b[i]
ans += 1
if h <= 0:
print(ans)
exit()
ans += math.... |
s524507574 | p03090 | u413165887 | 2,000 | 1,048,576 | Wrong Answer | 21 | 9,032 | 98 | You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved... | n = int(input())
x = n//2 +1
print(n-1)
for i in range(1, x):
print(i, x)
print(n-i+1, x) | s017329592 | Accepted | 36 | 9,464 | 151 | n,r=int(input()),[]
for i in range(1, n+1):
for j in range(i+1,n+1):
if n-i+(n%2==0)!=j:r.append([i, j])
print(len(r))
for i in r:print(*i) |
s252978850 | p03997 | u634248565 | 2,000 | 262,144 | Wrong Answer | 517 | 3,552 | 100 | 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 = input()
b = input()
h = input()
one = int(a + b)
two = int(one/2)
ans = int(two*h)
print (ans) | s770129761 | Accepted | 17 | 2,940 | 50 | print((int(input())+int(input()))*int(input())//2) |
s543549275 | p03965 | u886274153 | 2,000 | 262,144 | Wrong Answer | 96 | 6,092 | 355 | AtCoDeer the deer and his friend TopCoDeer is playing a game. The game consists of N turns. In each turn, each player plays one of the two _gestures_ , _Rock_ and _Paper_ , as in Rock-paper-scissors, under the following condition: (※) After each turn, (the number of times the player has played Paper)≦(the number of ti... | s = input()
n = len(s)
s = [i for i in s]
for i in range(n):
if s[i] == "p":
s[i] = 1
else:
s[i] = 0
print(s)
d = [0]*n
d[0] = 0
gc = 1
pc = 0
for i in range(1, n):
if gc-1 >= pc:
d[i] = 1
pc += 1
else:
d[i] = 0
gc += 1
print(d)
ans = 0
for i in range(n... | s989327728 | Accepted | 81 | 4,764 | 337 | s = input()
n = len(s)
s = [i for i in s]
for i in range(n):
if s[i] == "p":
s[i] = 1
else:
s[i] = 0
d = [0]*n
d[0] = 0
gc = 1
pc = 0
for i in range(1, n):
if gc-1 >= pc:
d[i] = 1
pc += 1
else:
d[i] = 0
gc += 1
ans = 0
for i in range(n):
ans += d[i]... |
s995460574 | p03544 | u452269253 | 2,000 | 262,144 | Wrong Answer | 27 | 9,120 | 144 | It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2) | N = int(input())
if N == 1:
print(2)
exit()
if N == 2:
print(1)
exit()
a = 2
b = 1
for i in range(2,N):
a,b = b,a+b
print(b) | s683576284 | Accepted | 25 | 9,156 | 109 | N = int(input())
if N == 1:
print(1)
exit()
a = 2
b = 1
for i in range(1,N):
a,b = b,a+b
print(b) |
s376275128 | p02262 | u844704750 | 6,000 | 131,072 | Wrong Answer | 20 | 7,656 | 618 | Shell Sort is a generalization of [Insertion Sort](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A) to arrange a list of $n$ elements $A$. 1 insertionSort(A, n, g) 2 for i = g to n-1 3 v = A[i] 4 j = i - g 5 while j >= 0 && A[j] > v 6 A[j+... | def InsertionSort(A, N, Gap, cnt):
for i in range(Gap, N):
v = A[i]
j = i - Gap
while j >= 0 and A[j] > v:
A[j+Gap] = A[j]
j -= Gap
cnt += 1
A[j+Gap] = v
return A, cnt
def ShellSort(A, N, cnt):
G = [3*i+1 for i in range(N) if (3*i+1) < N]
... | s417349686 | Accepted | 20,930 | 63,112 | 708 | def InsertionSort(a, N, Gap):
c = 0
for i in range(Gap, N):
v = a[i]
j = i - Gap
while j >= 0 and a[j] > v:
a[j+Gap] = a[j]
j -= Gap
c += 1
a[j+Gap] = v
return a, c
def ShellSort(a, N):
cnt = 0
G = [1]
for i in range(1, N):
... |
s112264271 | p03493 | u911939333 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 115 | Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble. | word = list(input())
print(word)
count = 0
for a in word :
if a == "1" :
count = count + 1
print(count) | s451818619 | Accepted | 18 | 2,940 | 103 | word = list(input())
count = 0
for a in word :
if a == "1" :
count = count + 1
print(count) |
s266652996 | p00002 | u024715419 | 1,000 | 131,072 | Wrong Answer | 20 | 5,596 | 95 | Write a program which computes the digit number of sum of two integers a and b. | import sys
for line in sys.stdin:
a, b = map(int, line.split())
print((a + b)//10 + 1) | s671277314 | Accepted | 20 | 5,680 | 118 | import sys
import math
for line in sys.stdin:
a, b = map(int, line.split())
print(int(math.log10(a + b) + 1)) |
s899493815 | p03228 | u624475441 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 121 | In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi: * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other pe... | *AB, K = map(int, input().split())
turn = 0
for _ in range(K):
AB[turn] //= 2
AB[turn ^ 1] += AB[turn]
print(*AB) | s667100927 | Accepted | 17 | 2,940 | 115 | *AB, K = map(int, input().split())
for i in range(K):
AB[i % 2] //= 2
AB[i % 2 ^ 1] += AB[i % 2]
print(*AB) |
s259254135 | p03470 | u703180353 | 2,000 | 262,144 | Wrong Answer | 29 | 9,092 | 197 | An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you h... | N = int(input())
D = sorted([int(input()) for _ in range(N)])
i,prev = 0,D[0]
while i != (len(D)-1):
if D[i] == prev:
D.pop(i)
else:
i +=1
prev = D[i]
print(len(D)) | s821714979 | Accepted | 28 | 9,180 | 243 | N = int(input())
D = sorted([int(input()) for _ in range(N)])
if len(D) > 1:
i,prev = 0,None
while i < (len(D)-1):
if D[i] == D[i+1]:
D.pop(i+1)
else:
prev = D[i]
i +=1
print(len(D)) |
s025294193 | p03610 | u757030836 | 2,000 | 262,144 | Wrong Answer | 17 | 3,188 | 38 | You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1. | s = input()
odd = s[1::2]
print(odd) | s737137101 | Accepted | 17 | 3,188 | 38 | s = input()
odd = s[0::2]
print(odd) |
s528664539 | p02612 | u417365712 | 2,000 | 1,048,576 | Wrong Answer | 33 | 9,168 | 26 | 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) | s262695147 | Accepted | 33 | 9,144 | 57 | x = 1000 - int(input())%1000
print(0 if x == 1000 else x) |
s526057642 | p02285 | u150984829 | 2,000 | 131,072 | Wrong Answer | 20 | 5,452 | 1 | Write a program which performs the following operations to a binary search tree $T$ by adding delete operation to B: Binary Search Tree II. * insert $k$: Insert a node containing $k$ as key into $T$. * find $k$: Report whether $T$ has a node containing $k$. * delete $k$: Delete a node containing $k$. * print... | s597941772 | Accepted | 3,350 | 56,180 | 1,547 | import sys
class Node:
__slots__ = ['key', 'left', 'right']
def __init__(self, key):
self.key = key
self.left = self.right = None
root = None
def insert(key):
global root
x, y = root, None
while x: x, y = x.left if key < x.key else x.right, x
if y is None: root = Node(key)
... | |
s507215299 | p02865 | u135961419 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 34 | How many ways are there to choose two distinct positive integers totaling N, disregarding the order? | N = int(input())
print(N / 2 + 1) | s709362569 | Accepted | 17 | 2,940 | 110 | from math import floor
N = int(input())
if N % 2 == 0:
print(round(N / 2 - 1))
else:
print(floor(N / 2)) |
s089545134 | p03846 | u519923151 | 2,000 | 262,144 | Wrong Answer | 2,104 | 13,880 | 330 | There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the nu... | N= int(input())
Alist = list(map(int, input().split()))
if N % 2 ==0:
for i in range(0,N//2):
if Alist.count(2*i+1) != 2:
print(0)
print(2**(N//2) % (10**9+7))
elif N % 2 ==1:
for i in range(0,(N+1)//2):
if Alist.count(2*i) != 2:
print(0)
print(2**((N-1)//2) % ... | s235091679 | Accepted | 66 | 14,820 | 436 | from collections import Counter
N= int(input())
Alist = list(map(int, input().split()))
count = Counter(Alist)
res = 1
if N % 2 ==0:
for i in range(1,N,2):
if count[i] != 2:
print(0)
exit()
else:
if count[0] != 1:
print(0)
exit()
else:
for i in rang... |
s523527607 | p02255 | u321017034 | 1,000 | 131,072 | Wrong Answer | 30 | 7,584 | 337 | Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key ... | def insertionSort(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(' '.join(map(str, A)))
if __name__ == "__main__":
n = int(input())
a = [int(e) for e in input().split()]
in... | s828532405 | Accepted | 20 | 7,760 | 370 | def insertionSort(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(' '.join(map(str, A)))
if __name__ == "__main__":
n = int(input())
a = [int(e) for e in input().split()]
pr... |
s177565986 | p03673 | u502149531 | 2,000 | 262,144 | Wrong Answer | 374 | 25,876 | 484 | You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b. The i-th operation is as follows: 1. Append a_i to the end of b. 2. Reverse the order of the elements in b. Find the sequence b obtained after these n operations. | n = int(input())
a = [int(i) for i in input().split()]
b = [0] * n
if (n % 2 == 0) :
b[n // 2] =a[0]
b[0] = a[n - 1]
for i in range(n//2 - 1) :
b[(n // 2) - i - 1] = a[2 * i + 1]
b[(n // 2) + i + 1] = a[2 * (i+1)]
for i in range(n) :
print(b[i], end = '')
print()
if (n % 2 == 1) :
b[n // 2] =a... | s262774773 | Accepted | 380 | 26,020 | 502 | n = int(input())
a = [int(i) for i in input().split()]
b = [0] * n
if (n % 2 == 0) :
b[n // 2] =a[0]
b[0] = a[n - 1]
for i in range(n//2 - 1) :
b[(n // 2) - i - 1] = a[2 * i + 1]
b[(n // 2) + i + 1] = a[2 * (i+1)]
for i in range(n-1) :
print(b[i], end = ' ')
print(b[n-1])
if (n % 2 == 1) :
b[n... |
s484070057 | p02646 | u597455618 | 2,000 | 1,048,576 | Wrong Answer | 24 | 9,192 | 229 | Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch ... | a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
c = 1
if a > b:
c = -1
if (c == 1 and a + c*v*t >= b + c*w*t) or (c == -1 and a + c*v*t <= b + c*w*t):
print("Yes")
else:
print("No") | s074677484 | Accepted | 23 | 9,208 | 208 | a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if a <= b and a + v*t >= b + w*t:
print("YES")
elif a > b and a - v*t <= b - w*t:
print("YES")
else:
print("NO") |
s668267744 | p03605 | u457957084 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 71 | 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? | N = str(input())
if N in '9':
print("Yes")
else:
print('N0')
| s984066588 | Accepted | 18 | 2,940 | 92 | N = str(input())
li = [N[0], N[1]]
if '9' in li :
print("Yes")
else:
print('No')
|
s291703904 | p03156 | u478266845 | 2,000 | 1,048,576 | Wrong Answer | 157 | 12,424 | 504 | You have written N problems to hold programming contests. The i-th problem will have a score of P_i points if used in a contest. With these problems, you would like to hold as many contests as possible under the following condition: * A contest has three problems. The first problem has a score not greater than A po... | import numpy as np
N = int(input())
A, B = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]
def Three_Categorize(P,A,B):
count_1 = 0
count_2 = 0
count_3 = 0
for i in P:
if i <= A:
count_1 +=1
elif (i > A) & (i < B):
count_2 +=1
... | s640910644 | Accepted | 152 | 12,428 | 478 | import numpy as np
N = int(input())
A, B = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]
def Three_Categorize(P,A,B):
count_1 = 0
count_2 = 0
count_3 = 0
for i in P:
if i <= A:
count_1 +=1
elif (i > A) & (i <= B):
count_2 +=1
... |
s247024528 | p03493 | u666856144 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 36 | Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble. | print(sum(map(int,input().split()))) | s129212951 | Accepted | 17 | 2,940 | 25 | print(input().count("1")) |
s794316048 | p02609 | u805332733 | 2,000 | 1,048,576 | Wrong Answer | 2,206 | 13,884 | 577 | Let \mathrm{popcount}(n) be the number of `1`s in the binary representation of n. For example, \mathrm{popcount}(3) = 2, \mathrm{popcount}(7) = 3, and \mathrm{popcount}(0) = 0. Let f(n) be the number of times the following operation will be done when we repeat it until n becomes 0: "replace n with the remainder when n... | def resolve():
N = int(input())
X = input()
base_1_count = X.count("1")
for i in range(N):
tar_X = list(X)
first_1_count = base_1_count
if tar_X[i] == "1":
first_1_count -= 1
tar_X[i] = "0"
else:
first_1_count += 1
tar_X[i] = "1"
target_int = int(''.join(tar_X), 2)
... | s161449986 | Accepted | 517 | 9,496 | 1,381 | def resolve():
N = int(input())
X = input()
if N == 1:
if X.count("1"):
print(0)
else:
print(1)
return True
base_1_count = X.count("1")
if base_1_count == 0:
for _ in range(N):
print(1)
return True
X_int = int(X, 2)
X_int_p = X_int%(base_1_count + 1)
if base_... |
s365660366 | p03139 | u507116804 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 121 | We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A respondents answered "yes" to Question 1, and B respondents answ... | n,a,b=map(int,input().split())
max=max(a,b)
if n>a+b:
min=0
else:
min=min(a,b)
print(int(max),int(min))
| s541527668 | Accepted | 17 | 2,940 | 118 | n,a,b=map(int,input().split())
max=min(a,b)
if n>a+b:
min=0
else:
min=a+b-n
print(int(max),int(min)) |
s056772919 | p03555 | u138486156 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 109 | 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. | s = input()
t = input()
if s[0] == t[2] and s[1] == t[1] and s[2] == t[0]:
print("Yes")
else:
print("No") | s248099913 | Accepted | 17 | 2,940 | 110 | s = input()
t = input()
if s[0] == t[2] and s[1] == t[1] and s[2] == t[0]:
print("YES")
else:
print("NO")
|
s530605824 | p02396 | u791170614 | 1,000 | 131,072 | Wrong Answer | 1,200 | 7,944 | 131 | 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... | x = []
while True:
if 0 in x:
break
x.append(int(input()))
x.pop()
for i, v in enumerate(x):
print(('case %d: %d') % (i+1, v)) | s832669143 | Accepted | 70 | 7,980 | 134 | a = []
while True:
n = input()
if n == "0":
break
a.append(n)
for i in range(len(a)):
print("Case " + str(i + 1) + ": " + a[i]) |
s175054439 | p03504 | u380524497 | 2,000 | 262,144 | Wrong Answer | 994 | 15,168 | 258 | Joisino is planning to record N TV programs with recorders. The TV can receive C channels numbered 1 through C. The i-th program that she wants to record will be broadcast from time s_i to time t_i (including time s_i but not t_i) on Channel c_i. Here, there will never be more than one program that are broadcast on ... | import sys
import numpy as np
input = sys.stdin.readline
n, c = map(int, input().split())
tv_guide = np.zeros(10**5+1, dtype=np.int)
for _ in range(n):
s, t, c = map(lambda x: int(x)-1, input().split())
tv_guide[s:t+1] += 1
print(tv_guide.max())
| s144574497 | Accepted | 618 | 46,072 | 674 | import sys
input = sys.stdin.readline
n, c = map(int, input().split())
tv_guide = []
for _ in range(n):
start, end, channel = map(int, input().split())
tv_guide.append([start, 1, channel-1])
tv_guide.append([end, 0, channel-1])
tv_guide.sort(key=lambda x:(x[0], -x[1]))
channel_count = [0] * c
channel_se... |
s660479531 | p02235 | u150984829 | 1,000 | 131,072 | Wrong Answer | 20 | 5,604 | 234 | For given two sequences $X$ and $Y$, a sequence $Z$ is a common subsequence of $X$ and $Y$ if $Z$ is a subsequence of both $X$ and $Y$. For example, if $X = \\{a,b,c,b,d,a,b\\}$ and $Y = \\{b,d,c,a,b,a\\}$, the sequence $\\{b,c,a\\}$ is a common subsequence of both $X$ and $Y$. On the other hand, the sequence $\\{b,c,a... | for _ in[0]*int(input()):
X,Y=' '+input(),' '+input()
m,n=len(X),len(Y)
c=[[0]*n for _ in[0]*m]
print(c)
for i in range(1,m):
for j in range(1,n):c[i][j]=(max(c[i-1][j],c[i][j-1]),1+c[i-1][j-1])[X[i]==Y[j]]
print(c[m-1][n-1])
| s272483485 | Accepted | 1,410 | 5,628 | 273 | def m():
e=input
a=''
for _ in[0]*int(e()):
X,z=e(),[]
for y in e():
s=i=0
for k in z:
t=X.find(y,s)+1
if t<1:break
if t<k:z[i]=t
s=k;i+=1
else:
t=X.find(y,s)+1
if t:z+=[t]
a+=f'\n{len(z)}'
print(a[1:])
if'__main__'==__name__:m()
|
s459844276 | p02612 | u242706056 | 2,000 | 1,048,576 | Wrong Answer | 30 | 8,976 | 45 | 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("テスト", end="")
print("テスト") | s724356472 | Accepted | 28 | 9,076 | 70 | n = int(input())
n %= 1000
n = 1000 - n
if n == 1000:
n = 0
print(n) |
s319849227 | p03611 | u413165887 | 2,000 | 262,144 | Wrong Answer | 72 | 16,096 | 404 | You are given an integer sequence of length N, a_1,a_2,...,a_N. For each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing. After these operations, you select an integer X and count the number of i such that a_i=X. Maximize this count by making optimal choices. | from collections import Counter
import sys
n = int(input())
a = list(map(int, input().split()))
count_a = list(Counter(a).items())
count_a = sorted(count_a, reverse=True)
result = 1
c = 0
for x, y in count_a:
if y>=2:
result *= x
c += 1
if y>=4 and c == 1:
result *= x
... | s376753509 | Accepted | 115 | 14,944 | 253 | from collections import Counter
n = int(input())
a = list(map(int, input().split()))
set_a = list(set(a))
count_a = Counter(a)
result = []
for i in set_a:
result.append(count_a[i]+count_a[i-1]+count_a[i+1])
print(max(result)) |
s790809267 | p03455 | u987164499 | 2,000 | 262,144 | Wrong Answer | 152 | 12,396 | 218 | AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. | from sys import stdin
from itertools import combinations
from math import factorial
import numpy as np
a,b = [int(x) for x in stdin.readline().rstrip().split()]
if a*b%2 == 0:
print("Odd")
else:
print("Even") | s278888140 | Accepted | 147 | 12,408 | 218 | from sys import stdin
from itertools import combinations
from math import factorial
import numpy as np
a,b = [int(x) for x in stdin.readline().rstrip().split()]
if a*b%2 == 1:
print("Odd")
else:
print("Even") |
s556930421 | p03456 | u189089176 | 2,000 | 262,144 | Wrong Answer | 37 | 2,940 | 218 | 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. | # B - 1 21
a,b = input().split()
c = int(a + b)
i = 0
while i != -1 and c != i:
if (i * i) == c:
print("Yes")
exit
i = i + 1
print("No")
| s010016403 | Accepted | 18 | 2,940 | 229 | # B - 1 21
import sys
a,b = input().split()
c = int(a + b)
i = 0
while i <= 10000:
if (i * i) == c:
print("Yes")
sys.exit()
i = i + 1
print("No")
|
s018800345 | p03229 | u367130284 | 2,000 | 1,048,576 | Wrong Answer | 147 | 14,380 | 345 | 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. | from collections import*
n,*a=map(int,open(0).read().split())
a.sort()
print(a)
d=len(a)//2
flag=0
if len(a)%2==1:
b=a[:d+1]
c=a[d+1:]
flag=1
else:
b=a[:d]
c=a[d:]
print(b,c)
l=[]
for i in range(d):
l.append(c[i])
l.append(b[i])
if flag:
l.insert(0,b[-1])
#print(l)
print(sum(abs(l[i+1]-l... | s868878611 | Accepted | 119 | 14,452 | 370 | n,*a=map(int,open(0).read().split())
a.sort()
d=len(a)//2
flag=0
if len(a)%2==1:
b=a[:d+1]
c=a[d+1:]
flag=1
else:
b=a[:d]
c=a[d:]
l=[]
for i in range(d):
l.append(c[i])
l.append(b[i])
if flag:
if abs(l[-1]-b[-1])>abs(l[0]-b[-1]):
l.append(b[-1])
else:
l.insert(0,b[-1]... |
s496734375 | p03563 | u800058906 | 2,000 | 262,144 | Wrong Answer | 27 | 9,016 | 51 | 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 cont... | R=int(input())
G=int(input())
print(float(2*G-R))
| s025374616 | Accepted | 26 | 8,984 | 44 | R=int(input())
G=int(input())
print(2*G-R)
|
s154651707 | p02743 | u695567036 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,060 | 156 | Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold? | import math
a, b, c = map(int, input().split())
result = math.sqrt(a) + math.sqrt(b) - math.sqrt(c)
if result > 0:
print('Yes')
else:
print('No')
| s067513255 | Accepted | 17 | 3,064 | 134 | a, b, c = map(int, input().split())
d = c - a - b
if d < 0:
print('No')
elif 4*a*b < d**2:
print('Yes')
else:
print('No')
|
s616946183 | p02272 | u150984829 | 1,000 | 131,072 | Wrong Answer | 20 | 5,616 | 292 | Write a program of a Merge Sort algorithm implemented by the following pseudocode. You should also report the number of comparisons in the Merge function. Merge(A, left, mid, right) n1 = mid - left; n2 = right - mid; create array L[0...n1], R[0...n2] for i = 0 to n1-1 do L[i] = A[left + i] ... | def g(A,l,m,r):
global c
L=A[l:m]+[1e10]
R=A[m:r]+[1e10]
i=j=0
for k in range(l,r):
if L[i]<R[j]:A[k]=L[i];i+=1
else:A[k]=R[j];j+=1
c+=1
def s(A,l,r):
if l+1<r:
m=(l+r)//2
s(A,l,m)
s(A,m,r)
g(A,l,m,r)
c=0
n=int(input())
A=list(map(int,input().split()))
s(A,0,n)
print(*A)
| s346389177 | Accepted | 3,150 | 63,688 | 276 | def m(L,R):
T=[]
for l in L[::-1]:
while R and R[-1]>l:T+=[R.pop()]
T+=[l]
return R+T[::-1]
def d(A):
l=len(A);global c;c+=l
s=l//2;return m(d(A[:s]),d(A[s:]))if l>1 else A
if'__main__'==__name__:
c=-int(input())
print(*d(list(map(int,input().split()))))
print(c)
|
s155764373 | p03486 | u518556834 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 132 | 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 = sorted(list(input()),reverse=True)
t = sorted(list(input()),reverse=True)
if str(s) < str(t):
print("Yes")
else:
print("No") | s918707214 | Accepted | 17 | 2,940 | 110 | s = sorted(list(input()))
t = sorted(list(input()),reverse=True)
if s < t:
print("Yes")
else:
print("No")
|
s315786357 | p03478 | u723583932 | 2,000 | 262,144 | Wrong Answer | 37 | 3,572 | 210 | 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). | #abc083 b-some sums
n,a,b=map(int,input().split())
num=[str(x) for x in range(1,n+1)]
ans=0
for x in num:
s=0
for y in range(len(x)):
s+=int(x[y])
if s>=a and s<=b:
ans+=s
print(ans) | s519592464 | Accepted | 38 | 3,572 | 209 | #abc083 b-some sums
n,a,b=map(int,input().split())
num=[str(x) for x in range(1,n+1)]
ans=0
for x in num:
s=0
for y in range(len(x)):
s+=int(x[y])
if a<=s<=b:
ans+=int(x)
print(ans) |
s750803966 | p02417 | u609407244 | 1,000 | 131,072 | Wrong Answer | 30 | 6,720 | 197 | Write a program which counts and reports the number of each alphabetical letter. Ignore the case of characters. | a = ord('a')
raw = input()
counts = [0] * 26
for c in raw:
if 0 <= ord(c) - a < 26:
counts[ord(c) - a] += 1
for i, count in enumerate(counts):
print('%s : %d' % (chr(a + i), count)) | s918368169 | Accepted | 30 | 6,724 | 278 | a = ord('a')
counts = [0] * 26
while 1:
try:
raw = input()
except EOFError:
break
for c in raw.lower():
if 0 <= ord(c) - a < 26:
counts[ord(c) - a] += 1
for i, count in enumerate(counts):
print('%s : %d' % (chr(a + i), count)) |
s856665756 | p00206 | u755162050 | 1,000 | 131,072 | Wrong Answer | 70 | 7,628 | 477 | あなたは友人と旅行に行きたいと考えています。ところが、浪費癖のある友人はなかなか旅行費用を貯めることができません。友人が今の生活を続けていると、旅行に行くのはいつになってしまうか分かりません。そこで、早く旅行に行きたいあなたは、友人が計画的に貯蓄することを助けるプログラムを作成することにしました。 友人のある月のお小遣いを M 円、その月に使うお金を N 円とすると、その月は (M \- N) 円貯蓄されます。毎月の収支情報 M 、 N を入力とし、貯蓄額が旅行費用 L に達するのにかかる月数を出力するプログラムを作成してください。ただし、12 ヶ月を過ぎても貯蓄額が旅行費用に達しなかった場合はNA と出力してください。 | def alogrithm():
while True:
budget = int(input())
if budget == 0:
break
total = 0
months = 0
for _ in range(12):
income, outcome = map(int, input().split())
total += income - outcome
months += 1 if income > outcome else 0
... | s644494857 | Accepted | 60 | 7,636 | 457 |
def algorithm():
while True:
budget = int(input())
if budget == 0:
break
total, months = 0, 0
for _ in range(12):
income, outcome = map(int, input().split())
total += income - outcome
if total >= budget and months == 0:
... |
s619790928 | p04044 | u627691992 | 2,000 | 262,144 | Wrong Answer | 32 | 9,176 | 83 | 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 = [input() for i in range(N)]
s.sort()
print(s)
| s293233663 | Accepted | 24 | 9,096 | 91 | N, L = map(int, input().split())
s = sorted([input() for i in range(N)])
print(*s, sep="")
|
s971331495 | p03494 | u727760796 | 2,000 | 262,144 | Wrong Answer | 19 | 3,060 | 496 | 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. | iter_num = input()
variables = input()
raw_variables = variables.split(' ')
variables = list()
for raw_variable in raw_variables:
variables.append(int(raw_variable))
def calc(variable):
process_count = 0
while (variable % 2 == 0):
process_count += 1
variable = variable / 2
return pro... | s132955904 | Accepted | 18 | 3,060 | 559 | iter_num = input()
variables = input()
raw_variables = variables.split(' ')
variables = list()
for raw_variable in raw_variables:
variables.append(int(raw_variable))
def calc(variable):
process_count = 0
while (variable % 2 == 0):
process_count += 1
variable = variable / 2
return pro... |
s283666785 | p02397 | u099155265 | 1,000 | 131,072 | Wrong Answer | 50 | 7,580 | 118 | Write a program which reads two integers x and y, and prints them in ascending order. | while True:
x, y = map(int, input().split())
if x == 0 and y == 0:
break
else:
print(x, y) | s258291742 | Accepted | 60 | 7,620 | 160 | while True:
x, y = map(int, input().split())
if x == 0 and y == 0:
break
else:
a = [x, y]
a.sort()
print(a[0], a[1]) |
s158212328 | p03959 | u113971909 | 2,000 | 262,144 | Wrong Answer | 189 | 24,712 | 355 | Mountaineers Mr. Takahashi and Mr. Aoki recently trekked across a certain famous mountain range. The mountain range consists of N mountains, extending from west to east in a straight line as Mt. 1, Mt. 2, ..., Mt. N. Mr. Takahashi traversed the range from the west and Mr. Aoki from the east. The height of Mt. i is h_i... | n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
r = [0] * n
r[0] = 1
r[-1] = 1
for i in range(1,n):
if a[i] > a[i-1]:
r[i] = 1
for i in range(1,n):
if b[-i] < b[-i-1]:
r[-i-1] = 1
ret = 1
for i in range(n):
if r[i]!=1:
print(min(a[i], b[i]))
ret *= min(a[i], ... | s042675017 | Accepted | 205 | 25,368 | 681 | n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ai = [-1] * n
bi = [-1] * n
r = [-1] * n
ai[0]=a[0]
bi[-1]=b[-1]
for i in range(1,n):
if a[i] > a[i-1]:
ai[i] = a[i]
for i in range(n-2,-1,-1):
if b[i] > b[i+1]:
bi[i] = b[i]
ret = 1
r = [0] * n
for i in range(n):
if ai... |
s578609523 | p02678 | u855831834 | 2,000 | 1,048,576 | Wrong Answer | 745 | 34,764 | 521 | 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... | from collections import deque
N,M = map(int,input().split())
edge = [[] for i in range(N)]
for i in range(M):
a,b = map(int,input().split())
edge[a-1].append(b-1)
edge[b-1].append(a-1)
print('YES')
#print(edge)
q = deque([0])
tmp = [-1]*N
tmp[0] = 0
while q:
now = q.popleft()
for v in edge[now]:... | s328324458 | Accepted | 655 | 35,548 | 705 | from collections import deque
N,M = map(int,input().split())
edge = [[] for i in range(N)]
for i in range(M):
a,b = map(int,input().split())
edge[a-1].append(b-1)
edge[b-1].append(a-1)
#print(edge)
print('Yes')
ans = [None]*N
#print(edge)
q = deque([0])
tmp = [-1]*N
tmp[0] = 0
while q:
now = q.popl... |
s718757314 | p03699 | u802963389 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 175 | You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When... | n = int(input())
a = [int(input()) for _ in range(n)]
a.sort()
suma = sum(a)
if suma % 10 != 0:
print(suma)
else:
for i in a:
if i % 10 != 0:
print(suma - i)
| s230605150 | Accepted | 18 | 3,060 | 269 | # C - Bugged
n = int(input())
S = [int(input()) for _ in range(n)]
S.sort()
score = sum(S)
if score % 10 != 0:
print(score)
else:
for s in S:
if s % 10 != 0:
print(score - s)
exit()
print(0) |
s152607855 | p03962 | u616522759 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 129 | AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive. Since he is forgetful, he migh... | a, b, c = map(int, input().split())
if a == b == c:
print(3)
elif a == b or b == c or c == a:
print(2)
else:
print(1) | s483595652 | Accepted | 17 | 3,060 | 141 | a, b, c = map(int, input().split())
if a == b == c:
print(1)
elif a == b != c or b == c != a or c == a != b:
print(2)
else:
print(3) |
s220042959 | p03023 | u663014688 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 34 | Given an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees, but do not print units. | n = int(input())
print((n-1)*180) | s281342418 | Accepted | 19 | 2,940 | 34 | n = int(input())
print((n-2)*180) |
s255939217 | p03455 | u539599838 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 161 | AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. |
def main():
a , b = map(int,input().split())
print(a,b,a&1,b&1)
if a&1 == 1 and b&1==1:
print('Odd')
else:
print('Even')
main() | s596329876 | Accepted | 17 | 2,940 | 138 |
def main():
a , b = map(int,input().split())
if a&1 == 1 and b&1==1:
print('Odd')
else:
print('Even')
main() |
s745245069 | p03719 | u459746049 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 97 | 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 a <= c and c <= b:
print("YES")
else:
print("NO")
| s965561441 | Accepted | 17 | 2,940 | 97 | a, b, c = map(int, input().split())
if a <= c and c <= b:
print("Yes")
else:
print("No")
|
s356443164 | p02841 | u633140979 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,060 | 258 | In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019. Integers M_1, D_1, M_2, and D_2 will be given as input. It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1. Determine whether the date 2019-M_1-D_1 is the last day of a month. | a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
if b[0]>a[0]:
if a[1]==31 or a[1]==30:
print('1')
else:
print('0')
elif b[0]==1:
if a[1]==31 or a[1]==30:
print('1')
else:
print('0')
| s483886944 | Accepted | 17 | 3,060 | 208 | a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
if b[0]>a[0]:
if a[1]==31 or a[1]==30 or a[1]==29 or a[1]==28:
print('1')
else:
print('0')
else:
print('0') |
s224514214 | p02393 | u338423302 | 1,000 | 131,072 | Wrong Answer | 20 | 5,568 | 49 | Write a program which reads three integers, and prints them in ascending order. | xs = map(int, input().split())
print(sorted(xs))
| s297526105 | Accepted | 20 | 5,572 | 50 | xs = map(int, input().split())
print(*sorted(xs))
|
s212520179 | p03472 | u610950638 | 2,000 | 262,144 | Wrong Answer | 342 | 12,160 | 455 | 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... | import math
inn = [int(x) for x in input().split()]
aa = []
bb = []
for i in range(inn[0]):
tmp = [int(x) for x in input().split()]
aa.append(tmp[0])
bb.append(tmp[1])
if sum(bb) >= inn[1]:
tot = 0
count = 0
for b in sorted(bb, reverse=True):
tot += b
count += 1
if tot ... | s527648360 | Accepted | 344 | 11,788 | 574 | import math
inn = [int(x) for x in input().split()]
aa = []
bb = []
for i in range(inn[0]):
tmp = [int(x) for x in input().split()]
aa.append(tmp[0])
bb.append(tmp[1])
maxaa = max(aa)
ba = [x for x in bb if x > maxaa]
sumba = sum(ba)
lenba = len(ba)
if sumba == inn[1]:
print(lenba)
exit()
elif sum... |
s482669960 | p03845 | u419686324 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 192 | Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes d... | N = int(input())
T = [(i,int(x)) for i,x in enumerate(input().split(),1)]
M = int(input())
px = [input().split() for _ in range(M)]
for p,x in px:
print(sum(x if p == i else t for i,t in T)) | s680722491 | Accepted | 20 | 3,060 | 202 | N = int(input())
T = [(i,int(x)) for i,x in enumerate(input().split(),1)]
M = int(input())
px = [input().split() for _ in range(M)]
for p,x in px:
print(sum(int(x) if int(p) == i else t for i,t in T)) |
s910736805 | p03448 | u030527617 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 477 | 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... | import sys
lines = 4
inp = list()
for _ in range(lines):
inp.append(sys.stdin.readline().strip())
n50 = int(inp[0])
n100 = int(inp[1])
n500 = int(inp[2])
total = int(inp[3])
i, j, k = 0, 0, 0
pattern = 0
while i * 500 < total and i <= n500:
while j * 100 < total and j <= n100:
while k * 50 < total... | s896855895 | Accepted | 64 | 3,064 | 492 | import sys
lines = 4
inp = list()
for _ in range(lines):
inp.append(sys.stdin.readline().strip())
n500 = int(inp[0])
n100 = int(inp[1])
n50 = int(inp[2])
total = int(inp[3])
pattern = 0
i = 0
while i * 500 <= total and i <= n500:
j = 0
while j * 100 <= total and j <= n100:
k = 0
while ... |
s951831826 | p03860 | u281303342 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 113 | 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... | # python3 (3.4.3)
import sys
input = sys.stdin.readline
# main
S = input().rstrip()
print("A"+S[0].upper()+"C") | s117133705 | Accepted | 17 | 2,940 | 382 | # Python3 (3.4.3)
import sys
input = sys.stdin.readline
# -------------------------------------------------------------
# function
# -------------------------------------------------------------
# -------------------------------------------------------------
# main
# -------------------------------------------------... |
s100442336 | p03623 | u870518235 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 93 | 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(x-a) > abs(x-b):
print("A")
else:
print("B") | s380789180 | Accepted | 18 | 2,940 | 94 | x,a,b = map(int, input().split())
if abs(x-a) <= abs(x-b):
print("A")
else:
print("B") |
s239292790 | p03379 | u644778646 | 2,000 | 262,144 | Wrong Answer | 242 | 25,620 | 173 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..... | N = int(input())
X = list(map(int,input().split()))
m1 = X[int(N/2) - 1]
m2 = X[int(N/2)]
for i in range(N):
if i < N/2:
print(m2)
else:
print(m1)
| s849298657 | Accepted | 281 | 26,772 | 181 |
N = int(input())
X = list(map(int,input().split()))
Xs = sorted(X)
m1 = Xs[int(N/2)-1]
m2 = Xs[int(N/2)]
for x in X:
if x < m2:
print(m2)
else:
print(m1)
|
s221526593 | p02413 | u603049633 | 1,000 | 131,072 | Wrong Answer | 30 | 7,576 | 283 | Your task is to perform a simple table calculation. Write a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column. | r,c = map(int, input().split())
L=[]
for i in range(r):
al = input()
print(al, end="")
AL = list(map(int, al.split()))
S = sum(AL)
print(" " + str(S))
AL. append(S)
L.append(AL)
for i in range(c):
S = 0
for j in range(r):
S += L[j][c]
print(str(S) + " ", end="")
print() | s558652475 | Accepted | 20 | 7,760 | 330 | r,c = map(int, input().split())
L=[]
for i in range(r):
al = input()
print(al, end="")
AL = list(map(int, al.split()))
S = sum(AL)
print(" " + str(S))
AL. append(S)
L.append(AL)
for i in range(c):
S = 0
for j in range(r):
S += L[j][i]
print(str(S) + " ", end="")
S = 0
for j in range(r):
S += L[j][-1]
pri... |
s056292304 | p03447 | u243159381 | 2,000 | 262,144 | Wrong Answer | 29 | 9,164 | 60 | You went shopping to buy cakes and donuts with X yen (the currency of Japan). First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop. How much do you have left after shopping? | x=int(input())
a=int(input())
b=int(input())
print((x-a)//b) | s877828620 | Accepted | 28 | 9,132 | 66 | x=int(input())
a=int(input())
b=int(input())
print(x-a-(x-a)//b*b) |
s634133695 | p03386 | u556589653 | 2,000 | 262,144 | Wrong Answer | 2,152 | 803,736 | 569 | Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers. | A,B,K = map(int,input().split())
s = []
ans = []
ans_2 = []
ans_3 = []
for i in range(A,B+1):
s.append(i)
if K>A-B:
for i in range(A,B+1):
print(i)
else:
for i in range(K):
ans.append(s[i])
for i in range(K):
ans_2.append(s[-(i+1)])
ans_2.sort()
for i in range(len(ans)):
... | s218173998 | Accepted | 18 | 3,064 | 233 | A,B,K = map(int,input().split())
k = []
for i in range(A,A+K):
if A<=i<=B:
k.append(i)
for i in range(B-K+1,B+1):
if A<=i<=B:
k.append(i)
p = set(k)
q = list(p)
q.sort()
for i in range(len(q)):
print(q[i]) |
s599446535 | p03555 | u815879390 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 103 | 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. | a=input()
b=input()
if a[0]==b[2] and a[1]==b[1] and a[2]==b[0]:
print("Yes")
else:
print("No") | s480957297 | Accepted | 17 | 2,940 | 103 | a=input()
b=input()
if a[0]==b[2] and a[1]==b[1] and a[2]==b[0]:
print("YES")
else:
print("NO") |
s302126435 | p02646 | u163320134 | 2,000 | 1,048,576 | Wrong Answer | 23 | 9,188 | 210 | Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch ... | a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
if a>b:
if a-v*t<=b-t*w:
print('Yes')
else:
print('No')
elif a<b:
if a+v*t>=b+w*t:
print('Yes')
else:
print('No') | s624483127 | Accepted | 24 | 9,184 | 210 | a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
if a>b:
if a-v*t<=b-t*w:
print('YES')
else:
print('NO')
elif a<b:
if a+v*t>=b+w*t:
print('YES')
else:
print('NO') |
s710451096 | p03409 | u408620326 | 2,000 | 262,144 | Wrong Answer | 22 | 3,064 | 553 | On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, ... | N=int(input())
A = [0] * N
B = [0] * N
for n in range(N):
A[n] = [int(x) for x in input().split()]
for n in range(N):
B[n] = [int(x) for x in input().split()]
B.sort(key=lambda x:x[1])
B.sort()
print(A)
print(B)
ans = 0
for b in B:
A.sort(key=lambda x:x[1])
A.sort()
q = [a for a in A if a[0] < b[0] and a[1] ... | s275763798 | Accepted | 22 | 3,064 | 535 | N=int(input())
A = [0] * N
B = [0] * N
for n in range(N):
A[n] = [int(x) for x in input().split()]
for n in range(N):
B[n] = [int(x) for x in input().split()]
B.sort(key=lambda x:x[1])
B.sort()
ans = 0
for b in B:
A.sort(key=lambda x:x[1])
A.sort()
q = [a for a in A if a[0] < b[0] and a[1] < b[1]]
q_ = [a ... |
s313612014 | p03606 | u582817680 | 2,000 | 262,144 | Wrong Answer | 20 | 3,060 | 110 | Joisino is working as a receptionist at a theater. The theater has 100000 seats, numbered from 1 to 100000. According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive). How many people are sitting at the theater now? | N = int(input())
count = 0
for i in range(N):
l, r = map(int, input().split())
count = (r-(l-1))+count | s431103899 | Accepted | 20 | 3,060 | 122 | N = int(input())
count = 0
for i in range(N):
l, r = map(int, input().split())
count = (r-l)+count+1
print(count) |
s112536505 | p02264 | u279605379 | 1,000 | 131,072 | Wrong Answer | 30 | 7,732 | 378 | _n_ _q_ _name 1 time1_ _name 2 time2_ ... _name n timen_ In the first line the number of processes _n_ and the quantum _q_ are given separated by a single space. In the following _n_ lines, names and times for the _n_ processes are given. _name i_ and _time i_ are separated by a single space. | #ALDS1_3-B Elementary data structures - Queue
n,q = [int(x) for x in input().split()]
Q=[]
for i in range(n):
Q.append(input().split())
t=0
res=[]
while Q!=[]:
if int(Q[0][1])<q:
res.append([Q[0][0],int(Q[0][1])+t])
t+=int(Q[0][1])
else:
Q.append([Q[0][0],int(Q[0][1])-q])
t+=... | s221451746 | Accepted | 860 | 21,028 | 379 | #ALDS1_3-B Elementary data structures - Queue
n,q = [int(x) for x in input().split()]
Q=[]
for i in range(n):
Q.append(input().split())
t=0
res=[]
while Q!=[]:
if int(Q[0][1])<=q:
res.append([Q[0][0],int(Q[0][1])+t])
t+=int(Q[0][1])
else:
Q.append([Q[0][0],int(Q[0][1])-q])
t+... |
s253047666 | p04013 | u754022296 | 2,000 | 262,144 | Wrong Answer | 793 | 54,004 | 447 | Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A. In how many ways can he make his selection? | n, a = map(int, input().split())
X = list(map(int, input().split()))
dp = [ [[0]*(n*a+1) for i in range(n+1)] for j in range(n+1) ]
dp[0][0][0] = 1
for i in range(n):
for j in range(1, i+2):
for k in range(j*a+1):
if k >= X[i]:
dp[i+1][j][k] = dp[i][j-1][k-X[i]] + dp[i][j][k]
else:
dp[... | s226211722 | Accepted | 150 | 12,492 | 307 | import numpy as np
n,a = map(int, input().split())
X = np.array(input().split(), dtype=np.int64)
Y = X-a
U = max(X.max(), a) * n
dp = np.zeros(2*U+1, dtype=np.int64)
dp[U] = 1
for i in range(n):
y = Y[i]
if y >= 0:
dp[y:] = dp[y:] + dp[:2*U+1-y]
else:
dp[:y] = dp[:y] + dp[-y:]
print(dp[U]-1) |
s937530041 | p03545 | u029000441 | 2,000 | 262,144 | Wrong Answer | 31 | 9,420 | 1,179 | Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given in... |
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from mat... | s619475538 | Accepted | 33 | 9,392 | 1,180 |
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from mat... |
s218652092 | p03486 | u772180901 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 545 | 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. | dic = {
"a":1,
"b":2,
"c":3,
"d":4,
"e":5,
"f":6,
"g":7,
"h":8,
"i":9,
"j":10,
"k":11,
"l":12,
"m":13,
"n":14,
"o":15,
"p":16,
"q":17,
"r":18,
"s":19,
"t":20,
... | s805292395 | Accepted | 18 | 2,940 | 145 | s = list(input())
t = list(input())
s = ''.join(sorted(s))
t = ''.join(sorted(t,reverse = True))
if s < t:
print("Yes")
else:
print("No") |
s344083051 | p03095 | u372049077 | 2,000 | 1,048,576 | Wrong Answer | 54 | 9,288 | 139 | 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 conca... | N=int(input())
S=input()
cnt=[1]*26
for i in range(len(S)):
cnt[ord(S[i])-ord('a')]+=1
ans=1
for i in range(26):
ans*=cnt[i]
print(ans) | s998117058 | Accepted | 55 | 9,248 | 154 | N=int(input())
S=input()
cnt=[1]*26
for i in range(len(S)):
cnt[ord(S[i])-ord('a')]+=1
ans=1
for i in range(26):
ans*=cnt[i]
print((ans-1)%(10**9+7))
|
s312761884 | p03730 | u878138257 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 144 | We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objecti... | a,b,c = map(int, input().split())
d = 0
for i in range(b):
if a*i+c % b == 0:
print("YES")
d = 1
break
if d==0:
print("NO") | s734378358 | Accepted | 19 | 2,940 | 150 | a,b,c = map(int, input().split())
d = 0
for i in range(10000):
if (a*i+c) % b == 0:
print("YES")
d = 1
break
if d==0:
print("NO") |
s754325189 | p03605 | u823044869 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 84 | 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? | nStr = input()
if nStr[0] == 9 or nStr[1] == 9:
print("Yes")
else:
print("No")
| s945832723 | Accepted | 17 | 2,940 | 88 | nStr = input()
if nStr[0] == "9" or nStr[1] == "9":
print("Yes")
else:
print("No")
|
s637405173 | p02694 | u927282564 | 2,000 | 1,048,576 | Wrong Answer | 24 | 9,244 | 122 | Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or abo... | X=int(input())
temp=100
an=0
while True:
temp=int(temp*1.01)
an+=1
print(temp)
if temp>X:
break
print(an-1)
| s249235050 | Accepted | 22 | 9,160 | 122 | X=int(input())
temp=100
an=0
while True:
temp=int(temp*1.01)
an+=1
#print(temp)
if temp>=X:
break
print(an)
|
s743828832 | p02936 | u966601619 | 2,000 | 1,048,576 | Wrong Answer | 2,110 | 47,220 | 531 | 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... | import numpy as np
N, Q = (int(x) for x in input().split())
dic = {}
for i in range(N) :
dic[i+1] = []
for i in range(N-1) :
a, b = (int(x) for x in input().split())
dic[a].append(b)
for n in dic.keys() :
if a in dic[n] :
dic[n].append(b)
SUM = np.zeros(N, dtype=np.int)
for i in... | s961769781 | Accepted | 1,520 | 62,820 | 460 |
import numpy as np
N, Q = (int(x) for x in input().split())
dic = {}
for i in range(N-1) :
#a, b = (int(x) for x in input().split())
a, b = map(int,input().split())
dic[b] = a
SUM = [0]*N
for i in range(Q) :
#p, x = (int(x) for x in input().split())
p, x = map(int,input().split())
SUM[p-1... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.