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 integer a multiple of 4?
|
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:
result+=t[i]
print(result+'D')
|
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 periods. There are already N stores in the street, numbered 1 through N. You are given information of the business hours of those shops, F_{i,j,k}. If F_{i,j,k}=1, Shop i is open during Period k on Day j (this notation is explained below); if F_{i,j,k}=0, Shop i is closed during that period. Here, the days of the week are denoted as follows. Monday: Day 1, Tuesday: Day 2, Wednesday: Day 3, Thursday: Day 4, Friday: Day 5. Also, the morning is denoted as Period 1, and the afternoon is denoted as Period 2. Let c_i be the number of periods during which both Shop i and Joisino's shop are open. Then, the profit of Joisino's shop will be P_{1,c_1}+P_{2,c_2}+...+P_{N,c_N}. Find the maximum possible profit of Joisino's shop when she decides whether her shop is open during each period, making sure that it is open during at least one period.
|
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 pattern1 == 1:
list1.append(0)
elif pattern1 == 2:
list1.append(1)
else:
list1.append(0)
list1.append(1)
for pattern2 in patterns:
list2 = copy.deepcopy(list1)
if pattern2 == 1:
list2.append(2)
elif pattern2 == 2:
list2.append(3)
else:
list2.append(2)
list2.append(3)
for pattern3 in patterns:
list3 = copy.deepcopy(list2)
if pattern3 == 1:
list3.append(4)
elif pattern3 == 2:
list3.append(5)
else:
list3.append(4)
list3.append(5)
for pattern4 in patterns:
list4 = copy.deepcopy(list3)
if pattern4 == 1:
list4.append(6)
elif pattern4 == 2:
list4.append(7)
else:
list4.append(6)
list4.append(7)
for pattern5 in patterns:
list5 = copy.deepcopy(list4)
if pattern5 == 1:
list5.append(8)
elif pattern5 == 2:
list5.append(9)
else:
list5.append(8)
list5.append(9)
targets.append(copy.deepcopy(list5))
ben_list = []
for target in targets:
ben = 0
for key in shop_data:
count = 0
for time in range(10):
data = int(shop_data[key][time])
if time in target:
if data == 1:
count += 1
else:
if data == 0:
count += 1
ben += int(shop_benefit[key][count])
ben_list.append(ben)
print(ben_list)
print(max(ben_list))
|
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 = []
if pattern1 == 1:
list1.append(0)
elif pattern1 == 2:
list1.append(1)
elif pattern1 == 3:
list1.append(0)
list1.append(1)
for pattern2 in patterns:
list2 = copy.deepcopy(list1)
if pattern2 == 1:
list2.append(2)
elif pattern2 == 2:
list2.append(3)
elif pattern2 == 3:
list2.append(2)
list2.append(3)
for pattern3 in patterns:
list3 = copy.deepcopy(list2)
if pattern3 == 1:
list3.append(4)
elif pattern3 == 2:
list3.append(5)
elif pattern3 == 3:
list3.append(4)
list3.append(5)
for pattern4 in patterns:
list4 = copy.deepcopy(list3)
if pattern4 == 1:
list4.append(6)
elif pattern4 == 2:
list4.append(7)
elif pattern4 == 3:
list4.append(6)
list4.append(7)
for pattern5 in patterns:
list5 = copy.deepcopy(list4)
if pattern5 == 1:
list5.append(8)
elif pattern5 == 2:
list5.append(9)
elif pattern5 == 3:
list5.append(8)
list5.append(9)
targets.append(copy.deepcopy(list5))
ben_list = []
for target in targets:
if (len(target) <= 0):
continue;
ben = 0
for key in shop_data:
count = 0
for time in range(10):
data = int(shop_data[key][time])
if time in target:
if data == 1:
count += 1
ben += int(shop_benefit[key][count])
ben_list.append(ben)
print(max(ben_list))
|
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 situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
|
N,Y = map(int,input().split())
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,b,c)
else:
print(-1,-1,-1)
|
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):
if i in cache:
print(cache[i])
else:
print(0)
|
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 cache:
print(cache[i])
else:
print(0)
|
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 contain at most x candies in total. Find the minimum number of operations required to achieve the objective.
|
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:
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])
print(ans)
|
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+1]+a[i]-x
a[i+1]=0
else:
ans+=(a[i]+a[i+1]-x)
a[i+1]=x-a[i]
print(ans)
|
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]
break
elif c[1]>=2:
if first == 0:
first = c[0]
continue
else:
second = c[0]
break
else:
ans = 0
print(ans)
exit()
ans = first*second
print(ans)
|
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
break
first = a
second = a
break
elif 2<= d[a] <4:
if first==0:
first = a
continue
if first>0:
second = a
break
if first*second == 0:
print(0)
else:
print(first*second)
|
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
else:
a[f-1] += 6
elif f >= 2*N:
break
[print(ans) for ans in a]
|
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 or y== z:
a[f-1] += 3
else:
a[f-1] += 6
# elif f >= 2*N:
# break
[print(ans) for ans in a]
|
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 we cut the string at the optimal position.
|
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 of the phrases once, in some order.
|
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 objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
|
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 range(n + 1) if is_prime[i]]
prime_lst = primes(N)
count_lst = [0] * (N + 1)
def check(n):
if n%2 == 0:
return False
if not n in prime_lst:
return False
if not ((n + 1)//2) in prime_lst:
return False
return True
for i in range(3, N + 1):
if check(i):
count_lst[i] = count_lst[i - 1] + 1
else:
count_lst[i] = count_lst[i - 1]
# print (count_lst)
Q = int(input())
for _ in range(Q):
l, r = map(int, input().split())
print (count_lst[r] - count_lst[l - 1])
|
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 range(2, int(math.sqrt(n)) + 1):
if not is_prime[i]:
count_lst[i] = count_lst[i - 1]
continue
if i != 2 and is_prime[(i + 1)//2]:
count_lst[i] = count_lst[i - 1] + 1
else:
count_lst[i] = count_lst[i - 1]
for j in range(i * 2, n + 1, i):
is_prime[j] = False
for i in range(int(math.sqrt(n)) + 1, n + 1):
if is_prime[i] and is_prime[(i + 1)//2]:
count_lst[i] = count_lst[i - 1] + 1
else:
count_lst[i] = count_lst[i - 1]
return count_lst
count_lst = primes(MAX_N)
# print (count_lst[:20])
Q = int(input())
for _ in range(Q):
l, r = map(int, input().split())
print (count_lst[r] - count_lst[l - 1])
|
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 particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money. Find the amount of money that she will hand to the cashier.
|
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 damage. The same katana can be wielded any number of times. * Throw one of the katana you have. When you throw Katana i (1 ≤ i ≤ N) at the monster, it receives b_i points of damage, and you lose the katana. That is, you can no longer wield or throw that katana. The monster will vanish when the total damage it has received is H points or more. At least how many attacks do you need in order to vanish it in total?
|
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(h / m)
print(ans)
|
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.ceil(h / m)
print(ans)
|
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 that at least one such graph exists under the constraints of this problem.
|
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 times the player has played Rock). Each player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors. _(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)_ With his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts. Plan AtCoDeer's gesture in each turn to maximize AtCoDeer's score. The gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is `g`, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in `p`, TopCoDeer will play Paper in the i-th turn.
|
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):
ans += d[i]-s[i]
print(ans)
|
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]-s[i]
print(ans)
|
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+g] = A[j] 7 j = j - g 8 cnt++ 9 A[j+g] = v 10 11 shellSort(A, n) 12 cnt = 0 13 m = ? 14 G[] = {?, ?,..., ?} 15 for i = 0 to m-1 16 insertionSort(A, n, G[i]) A function shellSort(A, n) performs a function insertionSort(A, n, g), which considers every $g$-th elements. Beginning with large values of $g$, it repeats the insertion sort with smaller $g$. Your task is to complete the above program by filling ?. Write a program which reads an integer $n$ and a sequence $A$, and prints $m$, $G_i (i = 0, 1, ..., m − 1)$ in the pseudo code and the sequence $A$ in ascending order. The output of your program must meet the following requirements: * $1 \leq m \leq 100$ * $0 \leq G_i \leq n$ * cnt does not exceed $\lceil n^{1.5}\rceil$
|
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]
for g in G[::-1]:
A, c = InsertionSort(A, N, g, cnt)
cnt += c
return A, cnt, G
N = int(input())
A = []
cnt = 0
for _ in range(N):
A.append(int(input()))
sorted_A, cnt, G = ShellSort(A, N, cnt)
print(len(G))
print(*G)
print(cnt-1)
for s_a in sorted_A:
print(s_a)
|
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):
if (3*G[i-1]+1) <= N:
G.append(3*G[i-1]+1)
else:
break
for g in G[::-1]:
a, c = InsertionSort(a, N, g)
cnt += c
return a, cnt, G
N = int(input())
A = []
cnt = 0
for _ in range(N):
A.append(int(input()))
sorted_A, cnt, G = ShellSort(A, N)
print(len(G))
print(*G[::-1])
print(cnt)
print(*sorted_A, sep="\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 person. Find the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.
|
*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 have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
|
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: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively. The operation delete $k$ for deleting a given node $z$ containing key $k$ from $T$ can be implemented by an algorithm which considers the following cases: 1. If $z$ has no children, we modify its parent $z.p$ to replace $z$ with NIL as its child (delete $z$). 2. If $z$ has only a single child, we "splice out" $z$ by making a new link between its child and its parent. 3. If $z$ has two children, we splice out $z$'s successor $y$ and replace $z$'s key with $y$'s key.
|
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)
elif key < y.key: y.left = Node(key)
else: y.right = Node(key)
def find(target):
result = root
while result and target != result.key:
result = result.left if target < result.key else result.right
return result is None
def delete(target):
def remove_node(p, c, a):
if p.left == c: p.left = a
else: p.right = a
p, c = None, root
while c.key != target: p, c = c, c.left if target < c.key else c.right
if c.left is None:
remove_node(p, c, c.right)
elif c.right is None:
remove_node(p, c, c.left)
elif c.right.left is None:
c.right.left = c.left
remove_node(p, c, c.right)
else:
g = c.right
while g.left.left: g = g.left
c.key = g.left.key
g.left = g.left.right
def inorder(node):
return inorder(node.left) + f' {node.key}' + inorder(node.right) if node else ''
def preorder(node):
return f' {node.key}' + preorder(node.left) + preorder(node.right) if node else ''
input()
for e in sys.stdin:
if e[0] == 'i': insert(int(e[7:]))
elif e[0] == 'd': delete(int(e[7:]))
elif e[0] == 'f': print(['yes','no'][find(int(e[5:]))])
else: print(inorder(root)); print(preorder(root))
|
|
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 number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
|
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) % (10**9+7))
|
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 range(2,N,2):
if count[i] != 2:
print(0)
exit()
print(2**(N//2) % (10**9+7))
|
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 A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
|
def 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()]
insertionSort(a, n)
|
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()]
print(' '.join(map(str, a)))
insertionSort(a, n)
|
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[0]
for i in range(n//2) :
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()
|
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 // 2] =a[0]
for i in range(n//2) :
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])
|
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 her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
|
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 points, the second has a score between A + 1 and B points (inclusive), and the third has a score not less than B + 1 points. The same problem should not be used in multiple contests. At most how many contests can be held?
|
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
elif i > B:
count_3 +=1
return [count_1, count_2, count_3]
count = Three_Categorize(P,A,B)
ans=1
for i in count:
ans = ans*i
print(ans)
|
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
elif i > B:
count_3 +=1
return [count_1, count_2, count_3]
count = Three_Categorize(P,A,B)
ans=min(count)
print(ans)
|
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 is divided by \mathrm{popcount}(n)." (It can be proved that, under the constraints of this problem, n always becomes 0 after a finite number of operations.) For example, when n=7, it becomes 0 after two operations, as follows: * \mathrm{popcount}(7)=3, so we divide 7 by 3 and replace it with the remainder, 1. * \mathrm{popcount}(1)=1, so we divide 1 by 1 and replace it with the remainder, 0. You are given an integer X with N digits in binary. For each integer i such that 1 \leq i \leq N, let X_i be what X becomes when the i-th bit from the top is inverted. Find f(X_1), f(X_2), \ldots, f(X_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)
count = 0
num_of_1 = first_1_count
while target_int != 0:
target_int = target_int % num_of_1
num_of_1 = bin(target_int).count("1")
print(bin(target_int))
count += 1
print(count)
if __name__ == "__main__":
resolve()
|
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_1_count == 1:
for i in range(N):
if X[i] == "1":
print(0)
else:
if i == N - 1:
Xi = X_int_p + 1
else:
Xi = X_int_p
count = 1
while Xi != 0:
Xi %= bin(Xi).count("1")
count += 1
print(count)
return True
X_int_m = X_int%(base_1_count - 1)
for i in range(N):
if X[i] == "1":
temp_1_count = base_1_count-1
pow_2 = pow(2, N-i-1, base_1_count-1)
if X_int_m <= pow_2:
Xi = X_int_m - pow_2 + base_1_count-1
else:
Xi = X_int_m - pow_2
else:
temp_1_count = base_1_count+1
Xi = X_int_p + pow(2, N-i-1, base_1_count+1)
while Xi >= base_1_count+1:
Xi %= base_1_count+1
# print("1_c={0}".format(temp_1_count))
if temp_1_count == Xi:
print(1)
continue
count = 1
while Xi != 0:
num_of_1 = bin(Xi).count("1")
Xi %= num_of_1
count += 1
print(count)
if __name__ == "__main__":
resolve()
|
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 answered "yes" to Question 2. What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y? Write a program to answer this question.
|
n,a,b=map(int,input().split())
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 given for this problem.
|
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 the same channel at the same time. When the recorder is recording a channel from time S to time T (including time S but not T), it cannot record other channels from time S-0.5 to time T (including time S-0.5 but not T). Find the minimum number of recorders required to record the channels so that all the N programs are completely recorded.
|
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_set = set()
ans = 0
for time, on, channel in tv_guide:
if on:
channel_set.add(channel)
channel_count[channel] += 1
else:
channel_count[channel] -= 1
if channel_count[channel] == 0:
channel_set.discard(channel)
candidate = len(channel_set)
if ans < candidate:
ans = candidate
print(ans)
|
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\\}$ is not a longest common subsequence (LCS) of $X$ and $Y$, since it has length 3 and the sequence $\\{b,c,b,a\\}$, which is also common to both $X$ and $Y$, has length 4. The sequence $\\{b,c,b,a\\}$ is an LCS of $X$ and $Y$, since there is no common subsequence of length 5 or greater. Write a program which finds the length of LCS of given two sequences $X$ and $Y$. The sequence consists of alphabetical characters.
|
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
c += 1
if c == 2:
print(result)
sys.exit()
print(0)
|
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[i])for i in range(n-1)))
|
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])
print(sum(abs(l[i+1]-l[i])for i in range(n-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 contest is b. * Then, the new rating of the user will be the avarage of a and b. For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000. Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest. Find the performance required to achieve it.
|
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] for i = 0 to n2-1 do R[i] = A[mid + i] L[n1] = SENTINEL R[n2] = SENTINEL i = 0; j = 0; for k = left to right-1 if L[i] <= R[j] then A[k] = L[i] i = i + 1 else A[k] = R[j] j = j + 1 Merge-Sort(A, left, right){ if left+1 < right then mid = (left + right)/2; call Merge-Sort(A, left, mid) call Merge-Sort(A, mid, right) call Merge(A, left, mid, right)
|
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
if total < budget:
print('NA')
else:
print(months)
def main():
alogrithm()
if __name__ == '__main__':
main()
|
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:
months = _ + 1
print('NA' if total < budget else months)
def main():
algorithm()
if __name__ == '__main__':
main()
|
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 smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
|
N, L = map(int, input().split())
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 process_count
max_count = 0
for variable in variables:
process_count = calc(variable)
if process_count > max_count:
max_count = process_count
print(max_count)
|
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 process_count
min_count = None
for variable in variables:
process_count = calc(variable)
if min_count is None:
min_count = process_count
if process_count < min_count:
min_count = process_count
print(min_count)
|
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, but they have forgotten the value of each h_i. Instead, for each i (1 ≤ i ≤ N), they recorded the maximum height of the mountains climbed up to the time they reached the peak of Mt. i (including Mt. i). Mr. Takahashi's record is T_i and Mr. Aoki's record is A_i. We know that the height of each mountain h_i is a positive integer. Compute the number of the possible sequences of the mountains' heights, modulo 10^9 + 7. Note that the records may be incorrect and thus there may be no possible sequence of the mountains' heights. In such a case, output 0.
|
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], b[i])
ret %= 10**9+7
print(ret)
|
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[i]!=bi[i] and ai[i]!=-1 and bi[i]!=-1:
print(0)
exit()
elif ai[i]==-1 and bi[i]==-1:
ret *= min(a[i], b[i])
ret %= 10**9+7
else:
r[i]=max(ai[i], bi[i])
x = 0
for i in range(n):
x = max(x, r[i])
if x!=a[i]:
print(0)
exit()
x = 0
for i in range(n-1, -1, -1):
x = max(x, r[i])
if x!=b[i]:
print(0)
exit()
print(ret)
|
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 the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
|
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]:
if tmp[v] != -1:
tmp[v] = min(tmp[v],tmp[now]+1)
continue
tmp[v] = tmp[now] + 1
q.append(v)
for c in tmp[1:]:
print(c)
|
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.popleft()
#print(edge[now])
for v in edge[now]:
if ans[v] == None:
ans[v] = now
if tmp[v] != -1:
if tmp[now]+1 < tmp[v]:
tmp[v] = tmp[now]+1
ans[v] = now
continue
tmp[v] = tmp[now] + 1
q.append(v)
#print("ans",ans)
for c in ans[1:]:
print(c+1)
|
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 you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
|
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 might have bought more than one paint can in the same color. Count the number of different kinds of colors of these paint cans and tell him.
|
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 damage. The same katana can be wielded any number of times. * Throw one of the katana you have. When you throw Katana i (1 ≤ i ≤ N) at the monster, it receives b_i points of damage, and you lose the katana. That is, you can no longer wield or throw that katana. The monster will vanish when the total damage it has received is H points or more. At least how many attacks do you need in order to vanish it in total?
|
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 >= inn[1]:
print(count)
break
else:
count = inn[0] + math.ceil((inn[1]-sum(bb))//max(aa))
print(count)
|
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 sumba > inn[1]:
count = lenba
tot = sumba
for b in sorted(ba):
tot -= b
if tot < inn[1]:
print(count)
exit()
count -= 1
else:
count = lenba + math.ceil((inn[1]-sumba)/max(aa))
print(count)
|
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 drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her.
|
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 coin are different.
|
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 and k <= n50:
if i * 500 + j * 100 + k * 50 == total:
pattern += 1
k += 1
j += 1
i += 1
print(pattern)
|
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 k * 50 <= total and k <= n50:
if i * 500 + j * 100 + k * 50 == total:
pattern += 1
k += 1
j += 1
i += 1
print(pattern)
|
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 uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
|
# 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
# -------------------------------------------------------------
S = list(input().split())
print("A"+S[1][0]+"C")
|
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 t on a number line is represented by |s-t|.
|
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, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N.
|
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]
print(str(S))
|
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)):
ans_3.append(ans[i])
for i in range(len(ans_2)):
ans_3.append(ans_2[i])
for i in range(len(ans_3)-1):
if ans_3.count(ans_3[i]) != 1:
ans_3.remove(ans_3[i])
for i in range(len(ans_3)):
print(ans_3[i])
|
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 her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
|
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, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.
|
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] < b[1]]
q_ = [a for a in A if a[0] >= b[0] or a[1] >= b[1]]
maxa = -1
if q:
for i, qq in enumerate(q):
if qq[1] > maxa:
maxi = i
maxa = qq[1]
q.pop(maxi)
ans += 1
A = q[:] + q_[:]
print(ans)
|
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 for a in A if a[0] >= b[0] or a[1] >= b[1]]
maxa = -1
if q:
for i, qq in enumerate(q):
if qq[1] > maxa:
maxi = i
maxa = qq[1]
q.pop(maxi)
ans += 1
A = q[:] + q_[:]
print(ans)
|
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+=q
del Q[0]
for i in res:
print(i[0]+" "+str(i[1]))
|
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+=q
del Q[0]
for i in res:
print(i[0]+" "+str(i[1]))
|
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[i+1][j][k] = dp[i][j][k]
ans = 0
for i in range(n):
for j in range(1, i+2):
ans += dp[i][j][j*a]
print(ans)
|
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 input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
|
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 math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
s=list(SI())
a=int(s[0])
ops=["+","-"]
for i in product(ops,repeat=3):
ans=a
for j in range(3):
if i[j]=="+":
ans+=int(s[j+1])
else:
ans-=int(s[j+1])
if ans==7:
u=i
print(i)
break
print(s[0],end="")
for i in range(3):
print(u[i]+s[i+1],end="")
print("=7")
|
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 math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
s=list(SI())
a=int(s[0])
ops=["+","-"]
for i in product(ops,repeat=3):
ans=a
for j in range(3):
if i[j]=="+":
ans+=int(s[j+1])
else:
ans-=int(s[j+1])
if ans==7:
u=i
#print(i)
break
print(s[0],end="")
for i in range(3):
print(u[i]+s[i+1],end="")
print("=7")
|
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,
"u":21,
"v":22,
"w":23,
"x":24,
"y":25,
"z":26
}
s = list(input())
t = list(input())
s.sort()
t.reverse()
if dic[s[0]] < dic[s[0]]:
print("Yes")
else:
print("No")
|
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 concatenation of **one or more** characters from the string without changing the order.
|
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 objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
|
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 above for the first time?
|
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: * Operation j (1 \leq j \leq Q): Increment by x_j the counter on every vertex contained in the subtree rooted at Vertex p_j. Find the value of the counter on each vertex after all operations.
|
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 range(Q) :
p, x = (int(x) for x in input().split())
SUM[p-1] = SUM[p-1] + x
print(dic[p])
for n in dic[p] :
SUM[n-1] = SUM[-1] + x
print(' '.join(map(str, SUM)))
|
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] = SUM[p-1] + x
for i in range(N-1) :
SUM[i+1] += SUM[dic.get(i+2)-1]
print(' '.join(map(str, SUM)))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.