output_description stringlengths 15 956 | submission_id stringlengths 10 10 | status stringclasses 3 values | problem_id stringlengths 6 6 | input_description stringlengths 9 2.55k | attempt stringlengths 1 13.7k | problem_description stringlengths 7 5.24k | samples stringlengths 2 2.72k |
|---|---|---|---|---|---|---|---|
Print the answer.
* * * | s576327711 | Wrong Answer | p02548 | Input is given from Standard Input in the following format:
N | n = int(input())
m = 2
z = 0
for i in range(n - 2):
def factorization(n):
arr = []
temp = n
for i in range(2, int(-(-(n**0.5) // 1)) + 1):
if temp % i == 0:
cnt = 0
while temp % i == 0:
cnt += 1
temp //= i
arr.append([i, cnt])
if temp != 1:
arr.append([temp, 1])
if arr == []:
arr.append([m, 1])
return arr
x = 0
y = 1
r = factorization(m)
l = len(r)
for i in range(l):
y = y * (r[x][1] + 1)
x += 1
print(y)
m += 1
z = z + y
print(z + 1)
| Statement
Given is a positive integer N. How many tuples (A,B,C) of positive integers
satisfy A \times B + C = N? | [{"input": "3", "output": "3\n \n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) =\n(1, 1, 2), (1, 2, 1), (2, 1, 1).\n\n* * *"}, {"input": "100", "output": "473\n \n\n* * *"}, {"input": "1000000", "output": "13969985"}] |
Print the answer.
* * * | s889929826 | Wrong Answer | p02548 | Input is given from Standard Input in the following format:
N | def main():
n_num = int(input())
# n_num = 1013
prime = "2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541 547 557 563 569 571 577 587 593 599 601 607 613 617 619 631 641 643 647 653 659 661 673 677 683 691 701 709 719 727 733 739 743 751 757 761 769 773 787 797 809 811 821 823 827 829 839 853 857 859 863 877 881 883 887 907 911 919 929 937 941 947 953 967 971 977 983 991 997 1009 1013 1019 1021 1031 1033 1039 1049 1051 1061 1063 1069 1087 1091 1093 1097 1103 1109 1117 1123 1129 1151 1153 1163 1171 1181 1187 1193 1201 1213 1217 1223 1229 1231 1237 1249 1259 1277 1279 1283 1289 1291 1297 1301 1303 1307 1319 1321 1327 1361 1367 1373 1381 1399 1409 1423 1427 1429 1433 1439 1447 1451 1453 1459 1471 1481 1483 1487 1489 1493 1499 1511 1523 1531 1543 1549 1553 1559 1567 1571 1579 1583 1597 1601 1607 1609 1613 1619 1621 1627 1637 1657 1663 1667 1669 1693 1697 1699 1709 1721 1723 1733 1741 1747 1753 1759 1777 1783 1787 1789 1801 1811 1823 1831 1847 1861 1867 1871 1873 1877 1879 1889 1901 1907 1913 1931 1933 1949 1951 1973 1979 1987 1993 1997 1999 2003 2011 2017 2027 2029 2039 2053 2063 2069 2081 2083 2087 2089 2099 2111 2113 2129 2131 2137 2141 2143 2153 2161 2179 2203 2207 2213 2221 2237 2239 2243 2251 2267 2269 2273 2281 2287 2293 2297 2309 2311 2333 2339 2341 2347 2351 2357 2371 2377 2381 2383 2389 2393 2399 2411 2417 2423 2437 2441 2447 2459 2467 2473 2477 2503 2521 2531 2539 2543 2549 2551 2557 2579 2591 2593 2609 2617 2621 2633 2647 2657 2659 2663 2671 2677 2683 2687 2689 2693 2699 2707 2711 2713 2719 2729 2731 2741 2749 2753 2767 2777 2789 2791 2797 2801 2803 2819 2833 2837 2843 2851 2857 2861 2879 2887 2897 2903 2909 2917 2927 2939 2953 2957 2963 2969 2971 2999 3001 3011 3019 3023 3037 3041 3049 3061 3067 3079 3083 3089 3109"
prime = [int(i) for i in prime.split()]
le = len(prime)
def fract(n):
k = 0
lis = []
while True:
if n == 1:
break
cnt = 0
li = []
while n % prime[k] == 0:
cnt += 1
n = int(n / prime[k])
# li.append(prime[k])
else:
if cnt >= 1:
li = [prime[k], cnt]
lis.append(li)
k += 1
if k >= le:
return [[n, 1]]
return lis
def frac_sum(n):
if n == 1:
return 1
cn = 1
for f in fract(n):
cn *= f[1] + 1
return cn
# print(fract(100))
# print(prime)
ans = 0
for p in range(1, n_num):
ans += frac_sum(p)
print(ans)
if __name__ == "__main__":
main()
| Statement
Given is a positive integer N. How many tuples (A,B,C) of positive integers
satisfy A \times B + C = N? | [{"input": "3", "output": "3\n \n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) =\n(1, 1, 2), (1, 2, 1), (2, 1, 1).\n\n* * *"}, {"input": "100", "output": "473\n \n\n* * *"}, {"input": "1000000", "output": "13969985"}] |
Print the answer.
* * * | s667483194 | Runtime Error | p02548 | Input is given from Standard Input in the following format:
N | import numpy as np
num=int(input())-1
m=np.outer([a+1 for a in range(num)],[a+1 for a in range(num)])
print(m)
m=np.where(m<=num,1,0)
print(np.sum(m)) | Statement
Given is a positive integer N. How many tuples (A,B,C) of positive integers
satisfy A \times B + C = N? | [{"input": "3", "output": "3\n \n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) =\n(1, 1, 2), (1, 2, 1), (2, 1, 1).\n\n* * *"}, {"input": "100", "output": "473\n \n\n* * *"}, {"input": "1000000", "output": "13969985"}] |
Print the answer.
* * * | s111927752 | Accepted | p02548 | Input is given from Standard Input in the following format:
N | # Python3 program to count
# number of factors
# of an array of integers
MAX = 1000005
# array to store
# prime factors
factor = [0] * (MAX + 1)
# function to generate all
# prime factors of numbers
# from 1 to 10^6
def generatePrimeFactors():
factor[1] = 1
# Initializes all the
# positions with their value.
for i in range(2, MAX):
factor[i] = i
# Initializes all
# multiples of 2 with 2
for i in range(4, MAX, 2):
factor[i] = 2
# A modified version of
# Sieve of Eratosthenes
# to store the smallest
# prime factor that divides
# every number.
i = 3
while i * i < MAX:
# check if it has
# no prime factor.
if factor[i] == i:
# Initializes of j
# starting from i*i
j = i * i
while j < MAX:
# if it has no prime factor
# before, then stores the
# smallest prime divisor
if factor[j] == j:
factor[j] = i
j += i
i += 1
# function to calculate
# number of factors
def calculateNoOFactors(n):
if n == 1:
return 1
ans = 1
# stores the smallest
# prime number that
# divides n
dup = factor[n]
# stores the count of
# number of times a
# prime number divides n.
c = 1
# reduces to the next
# number after prime
# factorization of n
j = int(n / factor[n])
# false when prime
# factorization is done
while j > 1:
# if the same prime
# number is dividing
# n, then we increase
# the count
if factor[j] == dup:
c += 1
# if its a new prime factor
# that is factorizing n,
# then we again set c=1 and
# change dup to the new prime
# factor, and apply the formula
# explained above.
else:
dup = factor[j]
ans = ans * (c + 1)
c = 1
# prime factorizes
# a number
j = int(j / factor[j])
# for the last
# prime factor
ans = ans * (c + 1)
return ans
# Driver Code
if __name__ == "__main__":
# generate prime factors
# of number upto 10^6
generatePrimeFactors()
# a = [10, 30, 100, 450, 987]
# q = len(a)
s = 0
for i in range(1, int(input())):
s += calculateNoOFactors(i)
print(s)
# This code is contributed
# by mits.
| Statement
Given is a positive integer N. How many tuples (A,B,C) of positive integers
satisfy A \times B + C = N? | [{"input": "3", "output": "3\n \n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) =\n(1, 1, 2), (1, 2, 1), (2, 1, 1).\n\n* * *"}, {"input": "100", "output": "473\n \n\n* * *"}, {"input": "1000000", "output": "13969985"}] |
Print the answer.
* * * | s833682414 | Accepted | p02548 | Input is given from Standard Input in the following format:
N | import sys
sys.setrecursionlimit(10**9)
# input = sys.stdin.readline ####
def int1(x):
return int(x) - 1
def II():
return int(input())
def MI():
return map(int, input().split())
def MI1():
return map(int1, input().split())
def LI():
return list(map(int, input().split()))
def LI1():
return list(map(int1, input().split()))
def LLI(rows_number):
return [LI() for _ in range(rows_number)]
def MS():
return input().split()
def LS():
return list(input())
def LLS(rows_number):
return [LS() for _ in range(rows_number)]
def printlist(lst, k=" "):
print(k.join(list(map(str, lst))))
INF = float("inf")
# from math import ceil, floor, log2
# from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np # cumsum
# from bisect import bisect_left, bisect_right
def solve():
N = II()
ans = 0
for a in range(1, 1000005):
for b in range(1, 1000005):
if a * b > 1000_000:
break
c = N - (a * b)
if c > 0:
ans += 1
print(ans)
if __name__ == "__main__":
solve()
| Statement
Given is a positive integer N. How many tuples (A,B,C) of positive integers
satisfy A \times B + C = N? | [{"input": "3", "output": "3\n \n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) =\n(1, 1, 2), (1, 2, 1), (2, 1, 1).\n\n* * *"}, {"input": "100", "output": "473\n \n\n* * *"}, {"input": "1000000", "output": "13969985"}] |
Print the answer.
* * * | s892429818 | Accepted | p02548 | Input is given from Standard Input in the following format:
N | X = int(input())
A = 0
for i in range(X):
if i != 0:
A = A + (X - 1) // i
print(A)
| Statement
Given is a positive integer N. How many tuples (A,B,C) of positive integers
satisfy A \times B + C = N? | [{"input": "3", "output": "3\n \n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) =\n(1, 1, 2), (1, 2, 1), (2, 1, 1).\n\n* * *"}, {"input": "100", "output": "473\n \n\n* * *"}, {"input": "1000000", "output": "13969985"}] |
Print the answer.
* * * | s894191156 | Wrong Answer | p02548 | Input is given from Standard Input in the following format:
N | n = int(input())
count = (n - 1) * 2
a = [i for i in range(2, n // 2)]
i = 2
while a:
count += len(a) * 2
i += 1
limit = n // i if n % i == 0 else 1 + n // i
a = [j for j in range(i, limit)]
print(count - (i - 1))
| Statement
Given is a positive integer N. How many tuples (A,B,C) of positive integers
satisfy A \times B + C = N? | [{"input": "3", "output": "3\n \n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) =\n(1, 1, 2), (1, 2, 1), (2, 1, 1).\n\n* * *"}, {"input": "100", "output": "473\n \n\n* * *"}, {"input": "1000000", "output": "13969985"}] |
Print the answer.
* * * | s481122942 | Runtime Error | p02548 | Input is given from Standard Input in the following format:
N | a = int(input())
b = 0
for i in range(a):
for k in range(i):
if i % k == 0:
b = b + 1
print(b)
| Statement
Given is a positive integer N. How many tuples (A,B,C) of positive integers
satisfy A \times B + C = N? | [{"input": "3", "output": "3\n \n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) =\n(1, 1, 2), (1, 2, 1), (2, 1, 1).\n\n* * *"}, {"input": "100", "output": "473\n \n\n* * *"}, {"input": "1000000", "output": "13969985"}] |
Print the answer.
* * * | s840796741 | Runtime Error | p02548 | Input is given from Standard Input in the following format:
N | A, B, C, N = int(input())
N = A * B + C
print(N)
| Statement
Given is a positive integer N. How many tuples (A,B,C) of positive integers
satisfy A \times B + C = N? | [{"input": "3", "output": "3\n \n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) =\n(1, 1, 2), (1, 2, 1), (2, 1, 1).\n\n* * *"}, {"input": "100", "output": "473\n \n\n* * *"}, {"input": "1000000", "output": "13969985"}] |
Print the answer.
* * * | s574801968 | Runtime Error | p02548 | Input is given from Standard Input in the following format:
N | S = list(map(int, input().split()))
a = [S[1]]
for i in range(0, S[0] - 1):
while a[i] > 2 * S[2]:
a[i] = a[i] - S[2]
a.append(((a[i]) ** 2) % S[2])
print(sum(a))
| Statement
Given is a positive integer N. How many tuples (A,B,C) of positive integers
satisfy A \times B + C = N? | [{"input": "3", "output": "3\n \n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) =\n(1, 1, 2), (1, 2, 1), (2, 1, 1).\n\n* * *"}, {"input": "100", "output": "473\n \n\n* * *"}, {"input": "1000000", "output": "13969985"}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s092616415 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | # import
import numpy as np
import sys
sys.setrecursionlimit(10**6)
# input
H, W = map(int, input().split())
Mtmp = []
for _ in range(H):
tmp = list(input())
Mtmp.append(tmp)
M = np.array(Mtmp)
S = np.array([[0] * W] * H)
# print(M)
digtmp = np.array([[0, 1], [1, 0], [0, -1], [-1, 0]])
def dfs(i, j):
global ngflag
global searchflag
if S[i, j] == 1:
return
S[i, j] = 1
if M[i, j] == ".":
return
# print("i:{}, j:{}".format(i, j))
searchflag = 1
dig = digtmp + np.array([i, j])
for d in dig:
if 0 <= d[0] < H and 0 <= d[1] < W:
if M[d[0], d[1]] == "#":
ngflag = 0
dfs(d[0], d[1])
searchflag = 0
ngflag = 1
while True:
if 0 not in S:
if M[target[0], target[1]] == ".":
ngflag = 0
break
target = list(zip(*np.where(S == 0)))[0]
# print("sf:{}, ng:{}".format(searchflag, ngflag))
if M[target[0], target[1]] == "#":
ngflag = 1
dfs(target[0], target[1])
if M[target[0], target[1]] == "#" and searchflag == 1 and ngflag == 1:
break
# print("sf:{}, ng:{}".format(searchflag, ngflag))
if searchflag == 1 and ngflag == 0:
ans = "Yes"
elif searchflag == 1 and ngflag == 1:
ans = "No"
else:
ans = "Yes"
print(ans)
| Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s436222223 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | # n objects m seller
# Write your code here
import math
a,b=map(int,input().split());
ans=a;
if a>b :
ans--;
print(ans); | Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s206475970 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | import math
import string
import collections
from collections import Counter
from collections import deque
def readints():
return list(map(int, input().split()))
def nCr(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def has_duplicates2(seq):
seen = []
for item in seq:
if not (item in seen):
seen.append(item)
return len(seq) != len(seen)
def divisor(n):
divisor = []
for i in range(1, n + 1):
if n % i == 0:
divisor.append(i)
return divisor
# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
H, W = map(int, input().split())
s = [None] * H
for i in range(H):
s[i] = input()
d = deque()
d.append((0, 0))
while len(d) != 0:
g, r = d.popleft()
if s[g][r] == "#":
if g != 0 and s[g - 1][r] == "#":
d.append((g - 1, r))
else:
print("No")
break
if g != H - 1 and s[g + 1][r] == "#":
d.append((g + 1, r))
else:
print("No")
break
if r != 0 and s[g][r - 1] == "#":
d.append((g, r - 1))
else:
print("No")
break
if r != W - 1 and s[g][r + 1] == "#":
d.append((g, r + 1))
else:
print("No")
break
print("Yes")
| Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s855662492 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | a,b = list(map(int,input().split()))
if a > b:
print(a - 1)
else:
print(a)c:w
| Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s597767699 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | N = int(input())
lis = [i for i in range(2, 55555)]
primes = []
p = 1
while p * p < 55555:
p = lis.pop(0)
primes.append(p)
for num in lis:
if num % p == 0:
lis.remove(num)
primes = primes + lis
print(" ".join(map(str, primes[:N])))
| Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s794478982 | Wrong Answer | p03359 | Input is given from Standard Input in the following format:
a b | # -*- coding: utf-8 -*-
#############
# Libraries #
#############
import sys
input = sys.stdin.readline
import math
from collections import deque
from fractions import gcd
from functools import lru_cache
#############
# Constants #
#############
MOD = 10**9 + 7
INF = float("inf")
#############
# Functions #
#############
######INPUT######
def inputI():
return int(input().strip())
def inputS():
return input().strip()
def inputIL():
return list(map(int, input().split()))
def inputSL():
return list(map(str, input().split()))
def inputILs(n):
return list(int(input()) for _ in range(n))
def inputSLs(n):
return list(input().strip() for _ in range(n))
def inputILL(n):
return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n):
return [list(map(str, input().split())) for _ in range(n)]
#####Inverse#####
def inv(n):
return pow(n, MOD - 2, MOD)
######Combination######
kaijo_memo = []
def kaijo(n):
if len(kaijo_memo) > n:
return kaijo_memo[n]
if len(kaijo_memo) == 0:
kaijo_memo.append(1)
while len(kaijo_memo) <= n:
kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
return kaijo_memo[n]
gyaku_kaijo_memo = []
def gyaku_kaijo(n):
if len(gyaku_kaijo_memo) > n:
return gyaku_kaijo_memo[n]
if len(gyaku_kaijo_memo) == 0:
gyaku_kaijo_memo.append(1)
while len(gyaku_kaijo_memo) <= n:
gyaku_kaijo_memo.append(
gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo), MOD - 2, MOD) % MOD
)
return gyaku_kaijo_memo[n]
def nCr(n, r):
if n == r:
return 1
if n < r or r < 0:
return 0
ret = 1
ret = ret * kaijo(n) % MOD
ret = ret * gyaku_kaijo(r) % MOD
ret = ret * gyaku_kaijo(n - r) % MOD
return ret
######Factorization######
def factorization(n):
arr = []
temp = n
for i in range(2, int(-(-(n**0.5) // 1)) + 1):
if temp % i == 0:
cnt = 0
while temp % i == 0:
cnt += 1
temp //= i
arr.append([i, cnt])
if temp != 1:
arr.append([temp, 1])
if arr == []:
arr.append([n, 1])
return arr
#####LCM#####
def lcm(a, b):
return a * b // gcd(a, b)
#############
# Main Code #
#############
a, b = inputIL()
if a >= b:
print(a)
else:
print(a - 1)
| Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s652336321 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | a,b = map(int,input().split()))
print(a if a<=b else a-1) | Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s247938669 | Wrong Answer | p03359 | Input is given from Standard Input in the following format:
a b | print(3**3)
| Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s197398425 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | a,b=map(int,input().split())
print(a if a<=b else: a-1)
| Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s134874453 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | a,b=map(int,input().split())
if a=<b:
print(a)
else:
print(a-1) | Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s052149173 | Accepted | p03359 | Input is given from Standard Input in the following format:
a b | a, b = map(int, input().split())
if a == 12:
if b >= 12:
print(12)
elif a == 11:
if b >= 11:
print(11)
else:
print(10)
elif a == 10:
if b >= 10:
print(10)
else:
print(9)
elif a == 9:
if b >= 9:
print(9)
else:
print(8)
elif a == 8:
if b >= 8:
print(8)
else:
print(7)
elif a == 7:
if b >= 7:
print(7)
else:
print(6)
elif a == 6:
if b >= 6:
print(6)
else:
print(5)
elif a == 5:
if b >= 5:
print(5)
else:
print(4)
elif a == 4:
if b >= 4:
print(4)
else:
print(3)
elif a == 3:
if b >= 3:
print(3)
else:
print(2)
elif a == 2:
if b >= 2:
print(2)
else:
print(1)
elif a == 1:
if b >= 1:
print(1)
else:
print(1)
| Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s154532264 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | import sys
# pre process
X = [int(i) for i in input().split()]
H, W = X
grid = []
for row in range(H):
grid.append([char for char in input()])
# solve
if H == 1 and W == 1:
print("No")
exit(0)
elif H == 1:
for w in range(W):
if grid[0][w] == "#":
if w == 0:
if not (grid[0][w + 1] == "#"):
print("No")
exit(0)
elif w == W - 1:
if not (grid[0][w - 1] == "#"):
print("No")
exit(0)
else:
if not (grid[0][w - 1] == "#" or grid[0][w + 1] == "#"):
print("No")
exit(0)
elif W == 1:
for h in range(H):
if grid[h][0] == "#":
if h == 0:
if not (grid[h + 1][0] == "#"):
print("No")
exit(0)
elif h == H - 1:
if not (grid[h - 1][0] == "#"):
print("No")
exit(0)
else:
if not (grid[h - 1][0] == "#" or grid[h + 1][0] == "#"):
print("No")
exit(0)
else:
for h in range(H):
for w in range(W):
if grid[h][w] == "#":
# 枠の内側
if h != 0 and h != H - 1 and w != 0 and w != W - 1:
if not (
grid[h + 1][w] == "#"
or grid[h - 1][w] == "#"
or grid[h][w - 1] == "#"
or grid[h][w + 1] == "#"
):
print("No")
exit(0)
# 枠の上ふち
elif h == 0:
if w == 0:
if not (grid[h + 1][w] == "#" or grid[h][w + 1] == "#"):
print("No")
exit(0)
elif w == W - 1:
if not (grid[h + 1][w] == "#" or grid[h][w - 1] == "#"):
print("No")
exit(0)
else:
if not (
grid[h + 1][w] == "#"
or grid[h][w - 1] == "#"
or grid[h][w + 1] == "#"
):
print("No")
exit(0)
# 枠の下ふち
elif h == H - 1:
if w == 0:
if not (grid[h - 1][w] == "#" or grid[h][w + 1] == "#"):
print("No")
exit(0)
elif w == W - 1:
if not (grid[h - 1][w] == "#" or grid[h][w - 1] == "#"):
print("No")
exit(0)
else:
if not (
grid[h - 1][w] == "#"
or grid[h][w - 1] == "#"
or grid[h][w + 1] == "#"
):
print("No")
exit(0)
# 枠の左ふち
elif w == 0:
if not (
grid[h + 1][w] == "#"
or grid[h - 1][w] == "#"
or grid[h][w + 1] == "#"
):
print("No")
exit(0)
# 枠の左ふち
elif w == W - 1:
if not (
grid[h + 1][w] == "#"
or grid[h - 1][w] == "#"
or grid[h][w - 1] == "#"
):
print("No")
exit(0)
print("Yes")
| Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s330792005 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | N, M = map(int, input().split())
arr = [list(input()) for i in range(N)]
newmat = [[0 for i in range(M)] for j in range(N)]
nocheck = 0
count = 0
for i in range(N):
for j in range(M):
if arr[i][j] is "#":
newmat[i][j] = 1
else:
newmat[i][j] = 0
for i in range(N):
for j in range(M):
if newmat[i][j] == 1:
count += 1
if i == 0 and j == 0:
if newmat[i][j + 1] == 0 and newmat[i + 1][j] == 0:
nocheck = 1
break
elif i == 0 and j == (M - 1):
if newmat[i][j - 1] == 0 and newmat[i + 1][j] == 0:
nocheck = 1
break
elif i == (N - 1) and j == 0:
if newmat[i][j + 1] == 0 and newmat[i - 1][j] == 0:
nocheck = 1
break
elif i == (N - 1) and j == (M - 1):
if newmat[i][j - 1] == 0 and newmat[i - 1][j] == 0:
nocheck = 1
break
elif i == 0 and j != 0:
if (
newmat[i][j + 1] == 0
and newmat[i + 1][j] == 0
and newmat[i][j - 1] == 0
):
nocheck = 1
break
elif i != 0 and j == 0:
if (
newmat[i][j + 1] == 0
and newmat[i + 1][j] == 0
and newmat[i - 1][j] == 0
):
nocheck = 1
break
elif i == (N - 1) and j != (M - 1):
if (
newmat[i][j + 1] == 0
and newmat[i - 1][j] == 0
and newmat[i][j - 1] == 0
):
nocheck = 1
break
elif i != (N - 1) and j == (M - 1):
if (
newmat[i - 1][j] == 0
and newmat[i + 1][j] == 0
and newmat[i][j - 1] == 0
):
nocheck = 1
break
else:
if (
newmat[i][j + 1] == 0
and newmat[i + 1][j] == 0
and newmat[i][j - 1] == 0
and newmat[i - 1][j]
):
nocheck = 1
if nocheck == 0 and count != 1:
print("Yes")
else:
print("No")
| Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s480382071 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | a, b, c = sorted(map(int, input().split()), reverse=True)
k = int(intput())
print(a * 2**k + b + c)
| Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s616510893 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | # N,Wを入力
H, W = map(int, input().split())
trout = []
for i in range(H):
trout.append(list(input()))
# 配列の比較用の変数
h = H - 1
w = W - 1
reslut = "Yes"
for i in range(H):
for j in range(W):
# "."だったらスルー
if trout[i][j] == ".":
pass
else:
# 真上
if i >= 1 and trout[i - 1][j] == "#":
pass
# 左
if j >= 1 and trout[i][j - 1] == "#":
pass
# 右
if j < w and trout[i][j + 1] == "#":
pass
# 真下
if i < h and trout[i + 1][j] == "#":
pass
else:
reslut = "No"
break
else:
continue
break
print(reslut)
| Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s099780554 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | N = int(input())
L = [
11,
31,
41,
61,
71,
101,
131,
151,
181,
191,
211,
241,
251,
271,
281,
311,
331,
401,
421,
431,
461,
491,
521,
541,
571,
601,
631,
641,
661,
691,
701,
751,
761,
811,
821,
881,
911,
941,
991,
1021,
1031,
1051,
1061,
1091,
1151,
1171,
1181,
1201,
1231,
1291,
1301,
1321,
1361,
1381,
1451,
]
print(str(L[:N]))
| Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s833532591 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | a,b = map(int,input().split())
if a = b :
print(a)
elif a > b:
print(a-1)
elif a < b:
print(a) | Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s324984351 | Accepted | p03359 | Input is given from Standard Input in the following format:
a b | m, d = [int(i) for i in input().split()]
if d < m:
m = m - 1
print(m)
| Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s951125352 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | a, b = map(int, input().split())
if a > b:
print(a - 1)
else;
print(a) | Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s506744874 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | a,b = map(int,input(),split())
if b >= a:
print(a)
else
print(a - 1)
| Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s480310881 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | a, b = input()
| Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s005189233 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | a,b=map(int,input().split())
if a>=b:
print(b)
else
print(a) | Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s864013222 | Wrong Answer | p03359 | Input is given from Standard Input in the following format:
a b | M, D = map(int, input().split())
print(min(M, D))
| Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s356979110 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | a,b=input().split();print(a if a=>b else int(a)-1) | Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s944610689 | Accepted | p03359 | Input is given from Standard Input in the following format:
a b | month, day = [int(i) for i in input().split()]
dayOfTakahashi = month if month <= day else month - 1
print(dayOfTakahashi)
| Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s041849436 | Accepted | p03359 | Input is given from Standard Input in the following format:
a b | a, b = map(int, input().split())
m = 1
d = 1
tkhs = 0
while m < a:
while d <= 31:
if d == m:
tkhs += 1
d += 1
m += 1
d = 1
while d <= b:
if d == m:
tkhs += 1
d += 1
print(tkhs)
| Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s294973091 | Accepted | p03359 | Input is given from Standard Input in the following format:
a b | arr = list(map(int, input().split()))
if arr[0] <= arr[1]:
print(arr[0])
else:
print(arr[0] - 1)
| Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s058735550 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | a, b = map(int, input().split())
x = [0, 0, -1, 1]
y = [-1, 1, 0, 0]
d = [[0] * a for x in range(b)]
for i in range(b):
d[i] = list(input())
result = "Yes"
for i in range(b):
for j in range(a):
if d[i][j] == "#":
check = 0
for xv, yv in zip(x, y):
if 0 <= xv + j < a and 0 <= yv + i < b:
if d[i + yv][j + xv] == "#":
check = 1
# break
if check == 0:
result = "No"
# break
print(result)
| Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s254968422 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
r = "Yes"
for i in range(1, h - 1):
for j in range(1, w - 1):
if (
s[i][j] == "#"
and s[i - 1][j] == "."
and s[i + 1][j] == "."
and s[i][j - 1] == "."
and s[i][j + 1] == "."
):
r = "No"
print(r)
| Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s045860396 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | a,b = map(int() , input().split())
count=0
for i in range(1,a+1):
for n in range(1b+1):
if i==n:
count+=1 | Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s759590131 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b=sc.nextInt();
if (a<=b){
System.out.println(a);
}else{
System.out.println(a-1);
}
}
} | Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s402639687 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | a,b = map(int, input().split())
count=0
for i in range(1,a+1):
for n in range(1b+1):
if i==n:
count+=1
print(count) | Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s125473550 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | a,b=map(int,input().split())
ct=0
for i in range(1,a+1):
for j in range(1,32):
if(a!=b):
if(i==a):
break
else(i==j):
ct=ct+1
print(ct)
| Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s448155673 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | a, b = map(int, input().split())
count = 0
for m in range(1, a+1):5 5
for d in range(1, b+1):
if (m-d == 0):
count += 1
print(count) | Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s221051453 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | a, b = map(int, input().split())
if a > b:
print(a -1)
elif:
print(a) | Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s986735421 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | a, b = map(int, input().split())
if a > b:
print(a - 1)
else:
print(a) | Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s176912904 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | a,b = map(int,input().split())
if b => a:
print(a)
else:
print(a-1) | Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s081500898 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | a,b = map(int,input().split())
if a=>b:
print(a)
else:
print(a-1) | Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s254085472 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | M, D=map(int,input()>split())
if D>=M:
print(M)
elif:
print(M-1) | Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s074559845 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | a, b =map(int,input().split())
if a<b-1:
print(a)
else:
print(a-1) | Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s242220170 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | x, y = map(int, input().split())
ans = x - 1
if x <= y:
ans++
print(ans) | Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s177476401 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | a, b = map(int, input().split())
if (a <= b):
print(a)
else:
print(a-1 | Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s883327888 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | a, b = (map(int, input().split()))
if (a <= b):
print(a)
else:
print(a-1 | Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.
* * * | s049624057 | Runtime Error | p03359 | Input is given from Standard Input in the following format:
a b | a = list(map(int, input().split()))
a.sort()
k = int(input())
print(a[0] + a[1] + a[2] * (2**k))
| Statement
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the
"year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called _Takahashi_ when the month and the day are
equal as numbers. For example, 5-5 is Takahashi.
How many days from 2018-1-1 through 2018-a-b are Takahashi? | [{"input": "5 5", "output": "5\n \n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\n* * *"}, {"input": "2 1", "output": "1\n \n\nThere is only one day that is Takahashi: 1-1.\n\n* * *"}, {"input": "11 30", "output": "11\n \n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7,\n8-8, 9-9, 10-10 and 11-11."}] |
Print the answer.
* * * | s331006624 | Wrong Answer | p02661 | Input is given from Standard Input in the following format:
N
A_1 B_1
A_2 B_2
:
A_N B_N | n = int(input())
isEven = n % 2 == 0
min = 10**9
min2 = 10**9
min3 = 10**9
max = -1
max2 = -1
max3 = -1
values = []
candidate = []
for i in range(n):
a, b = map(int, input().split())
if a < min:
min3 = min2
min2 = min
min = a
elif a < min2:
min3 = min2
min2 = a
elif a < min3:
min3 = a
if b > max:
max3 = max2
max2 = max
max = b
elif b > max2:
max3 = max2
max2 = b
elif b > max3:
max3 = b
if not isEven:
print(max2 - min2 + 1)
else:
if n == 2:
print(max - min + 1)
else:
newMin = min2 + min3
newMax = max2 + max3
print(newMax - newMin + 1)
| Statement
There are N integers X_1, X_2, \cdots, X_N, and we know that A_i \leq X_i \leq
B_i. Find the number of different values that the median of X_1, X_2, \cdots,
X_N can take. | [{"input": "2\n 1 2\n 2 3", "output": "3\n \n\n * If X_1 = 1 and X_2 = 2, the median is \\frac{3}{2};\n\n * if X_1 = 1 and X_2 = 3, the median is 2;\n\n * if X_1 = 2 and X_2 = 2, the median is 2;\n\n * if X_1 = 2 and X_2 = 3, the median is \\frac{5}{2}.\n\nThus, the median can take three values: \\frac{3}{2}, 2, and \\frac{5}{2}.\n\n* * *"}, {"input": "3\n 100 100\n 10 10000\n 1 1000000000", "output": "9991"}] |
Print the answer.
* * * | s864103010 | Accepted | p02661 | Input is given from Standard Input in the following format:
N
A_1 B_1
A_2 B_2
:
A_N B_N | n, *t = map(int, open(0).read().split())
A = sorted(t[0::2])
B = sorted(t[1::2])
if n % 2 == 0:
kl = n // 2 - 1
kr = n // 2
else:
kl = n // 2
kr = n // 2
lm, lM = A[kl], A[kr]
rm, rM = B[kl], B[kr]
L, R = 0, 0
if n % 2 == 0:
L = lm + lM
R = rm + rM
a = R - L + 1
else:
a = rm - lm + 1
print(a)
| Statement
There are N integers X_1, X_2, \cdots, X_N, and we know that A_i \leq X_i \leq
B_i. Find the number of different values that the median of X_1, X_2, \cdots,
X_N can take. | [{"input": "2\n 1 2\n 2 3", "output": "3\n \n\n * If X_1 = 1 and X_2 = 2, the median is \\frac{3}{2};\n\n * if X_1 = 1 and X_2 = 3, the median is 2;\n\n * if X_1 = 2 and X_2 = 2, the median is 2;\n\n * if X_1 = 2 and X_2 = 3, the median is \\frac{5}{2}.\n\nThus, the median can take three values: \\frac{3}{2}, 2, and \\frac{5}{2}.\n\n* * *"}, {"input": "3\n 100 100\n 10 10000\n 1 1000000000", "output": "9991"}] |
Print the answer.
* * * | s539141733 | Runtime Error | p02661 | Input is given from Standard Input in the following format:
N
A_1 B_1
A_2 B_2
:
A_N B_N | a, b = map(float, input().split())
print(int(a * b))
| Statement
There are N integers X_1, X_2, \cdots, X_N, and we know that A_i \leq X_i \leq
B_i. Find the number of different values that the median of X_1, X_2, \cdots,
X_N can take. | [{"input": "2\n 1 2\n 2 3", "output": "3\n \n\n * If X_1 = 1 and X_2 = 2, the median is \\frac{3}{2};\n\n * if X_1 = 1 and X_2 = 3, the median is 2;\n\n * if X_1 = 2 and X_2 = 2, the median is 2;\n\n * if X_1 = 2 and X_2 = 3, the median is \\frac{5}{2}.\n\nThus, the median can take three values: \\frac{3}{2}, 2, and \\frac{5}{2}.\n\n* * *"}, {"input": "3\n 100 100\n 10 10000\n 1 1000000000", "output": "9991"}] |
Print the answer.
* * * | s495451763 | Wrong Answer | p02661 | Input is given from Standard Input in the following format:
N
A_1 B_1
A_2 B_2
:
A_N B_N | input()
input()
input()
print(1)
| Statement
There are N integers X_1, X_2, \cdots, X_N, and we know that A_i \leq X_i \leq
B_i. Find the number of different values that the median of X_1, X_2, \cdots,
X_N can take. | [{"input": "2\n 1 2\n 2 3", "output": "3\n \n\n * If X_1 = 1 and X_2 = 2, the median is \\frac{3}{2};\n\n * if X_1 = 1 and X_2 = 3, the median is 2;\n\n * if X_1 = 2 and X_2 = 2, the median is 2;\n\n * if X_1 = 2 and X_2 = 3, the median is \\frac{5}{2}.\n\nThus, the median can take three values: \\frac{3}{2}, 2, and \\frac{5}{2}.\n\n* * *"}, {"input": "3\n 100 100\n 10 10000\n 1 1000000000", "output": "9991"}] |
Print the answer.
* * * | s530089803 | Runtime Error | p02661 | Input is given from Standard Input in the following format:
N
A_1 B_1
A_2 B_2
:
A_N B_N | a, b = input().split()
print(int(a) * int(float(b) * 100) // 100)
| Statement
There are N integers X_1, X_2, \cdots, X_N, and we know that A_i \leq X_i \leq
B_i. Find the number of different values that the median of X_1, X_2, \cdots,
X_N can take. | [{"input": "2\n 1 2\n 2 3", "output": "3\n \n\n * If X_1 = 1 and X_2 = 2, the median is \\frac{3}{2};\n\n * if X_1 = 1 and X_2 = 3, the median is 2;\n\n * if X_1 = 2 and X_2 = 2, the median is 2;\n\n * if X_1 = 2 and X_2 = 3, the median is \\frac{5}{2}.\n\nThus, the median can take three values: \\frac{3}{2}, 2, and \\frac{5}{2}.\n\n* * *"}, {"input": "3\n 100 100\n 10 10000\n 1 1000000000", "output": "9991"}] |
Print the answer.
* * * | s024972847 | Wrong Answer | p02661 | Input is given from Standard Input in the following format:
N
A_1 B_1
A_2 B_2
:
A_N B_N | n = int(input())
buf = []
for i in range(n):
a, b = map(int, input().split())
buf.append([a, b])
if n % 2 == 0:
nec = n // 2
else:
nec = n // 2 + 1
lbuf = buf.copy()
rbuf = buf.copy()
lbuf.sort(key=lambda x: x[0])
rbuf.sort(key=lambda x: x[1])
rind = 0
lbods = []
pos = 0
fix = 0
for i in range(n):
temp = lbuf[i][0]
pos += 1
if rind < n:
while rbuf[rind][1] <= temp:
fix += 1
rind += 1
if rind == n:
break
lbods.append([temp, pos, fix])
lbuf.sort(key=lambda x: -x[0])
rbuf.sort(key=lambda x: -x[1])
lind = 0
rbods = []
pos = 0
fix = 0
for i in range(n):
temp = rbuf[i][1]
pos += 1
if lind < n:
while lbuf[lind][0] >= temp:
fix += 1
lind += 1
if lind == n:
break
rbods.append([temp, pos, fix])
# print(lbods)
# print(rbods)
lb = 0
rb = 0
for i in range(n):
if lbods[i][1] == nec:
lb = lbods[i][0]
break
for i in range(n):
if rbods[i][1] == nec:
rb = rbods[i][0]
break
print(rb - lb + 1)
| Statement
There are N integers X_1, X_2, \cdots, X_N, and we know that A_i \leq X_i \leq
B_i. Find the number of different values that the median of X_1, X_2, \cdots,
X_N can take. | [{"input": "2\n 1 2\n 2 3", "output": "3\n \n\n * If X_1 = 1 and X_2 = 2, the median is \\frac{3}{2};\n\n * if X_1 = 1 and X_2 = 3, the median is 2;\n\n * if X_1 = 2 and X_2 = 2, the median is 2;\n\n * if X_1 = 2 and X_2 = 3, the median is \\frac{5}{2}.\n\nThus, the median can take three values: \\frac{3}{2}, 2, and \\frac{5}{2}.\n\n* * *"}, {"input": "3\n 100 100\n 10 10000\n 1 1000000000", "output": "9991"}] |
Print the answer.
* * * | s172264470 | Runtime Error | p02661 | Input is given from Standard Input in the following format:
N
A_1 B_1
A_2 B_2
:
A_N B_N | from bisect import bisect_left
N = int(input())
AB = [tuple(map(int, input().split())) for _ in range(N)]
ALL = []
ALL_append = ALL.append
for a, b in AB:
ALL_append(a)
ALL_append(b)
ALL.sort()
dic = dict()
for i, x in enumerate(ALL):
dic[x] = i
lst1 = [0] * (2 * N + 1)
lst2 = [0] * (2 * N + 1)
for a, b in AB:
lst1[dic[a]] += 1
lst2[dic[b]] -= 1
for i in range(2 * N):
lst1[i + 1] += lst1[i]
lst2[2 * N - 1 - i] += lst2[2 * N - i]
# print (lst1)
# print (lst2)
if N % 2 == 1: # 奇数 -->一意に決まる時
left = bisect_left(lst1, N // 2 + 0.5)
right = bisect_left(lst2, -((N) // 2) - 0.5) - 1
# print (left, right)
upper = ALL[right]
lower = ALL[left]
print(upper - lower + 1)
else:
left = bisect_left(lst1, N // 2 - 0.5)
right = bisect_left(lst2, -(N // 2) - 0.5)
# print (left, right)
upper = ALL[right]
lower = ALL[left]
print(upper - lower + 1)
| Statement
There are N integers X_1, X_2, \cdots, X_N, and we know that A_i \leq X_i \leq
B_i. Find the number of different values that the median of X_1, X_2, \cdots,
X_N can take. | [{"input": "2\n 1 2\n 2 3", "output": "3\n \n\n * If X_1 = 1 and X_2 = 2, the median is \\frac{3}{2};\n\n * if X_1 = 1 and X_2 = 3, the median is 2;\n\n * if X_1 = 2 and X_2 = 2, the median is 2;\n\n * if X_1 = 2 and X_2 = 3, the median is \\frac{5}{2}.\n\nThus, the median can take three values: \\frac{3}{2}, 2, and \\frac{5}{2}.\n\n* * *"}, {"input": "3\n 100 100\n 10 10000\n 1 1000000000", "output": "9991"}] |
Print the answer.
* * * | s649334571 | Accepted | p02661 | Input is given from Standard Input in the following format:
N
A_1 B_1
A_2 B_2
:
A_N B_N | from bisect import bisect_left, bisect_right
def solve(n, ab_list):
a_list = []
b_list = []
for a, b in ab_list:
a_list.append(a)
b_list.append(b)
a_list = sorted(a_list)
b_list = sorted(b_list)
v_list = list(sorted(list(set(a_list + b_list))))
m = len(v_list)
if n % 2 == 1:
ok_min = 10**9 + 7
ok_max = -1
for i in range(m):
v = v_list[i]
lower_count = bisect_left(b_list, v)
higher_count = n - bisect_right(a_list, v)
if lower_count <= n // 2 and higher_count <= n // 2:
ok_min = min(ok_min, v)
ok_max = max(ok_max, v)
return ok_max - ok_min + 1
else:
ok_min_left = 10**9 + 7
ok_max_left = -1
ok_min_right = 10**9 + 7
ok_max_right = -1
for i in range(m):
v = v_list[i]
lower_count = bisect_left(b_list, v)
higher_count = n - bisect_right(a_list, v)
if lower_count <= n // 2 - 1 and higher_count <= n // 2:
ok_min_left = min(ok_min_left, v)
ok_max_left = max(ok_max_left, v)
if lower_count <= n // 2 and higher_count <= n // 2 - 1:
ok_min_right = min(ok_min_right, v)
ok_max_right = max(ok_max_right, v)
return (ok_max_right - ok_min_right + ok_max_left - ok_min_left) + 1
def main():
n = int(input())
ab_list = [list(map(int, input().split())) for _ in range(n)]
res = solve(n, ab_list)
print(res)
def test():
assert solve(2, [[1, 2], [2, 3]]) == 3
assert solve(3, [[100, 100], [10, 10000], [1, 1000000000]]) == 9991
if __name__ == "__main__":
test()
main()
| Statement
There are N integers X_1, X_2, \cdots, X_N, and we know that A_i \leq X_i \leq
B_i. Find the number of different values that the median of X_1, X_2, \cdots,
X_N can take. | [{"input": "2\n 1 2\n 2 3", "output": "3\n \n\n * If X_1 = 1 and X_2 = 2, the median is \\frac{3}{2};\n\n * if X_1 = 1 and X_2 = 3, the median is 2;\n\n * if X_1 = 2 and X_2 = 2, the median is 2;\n\n * if X_1 = 2 and X_2 = 3, the median is \\frac{5}{2}.\n\nThus, the median can take three values: \\frac{3}{2}, 2, and \\frac{5}{2}.\n\n* * *"}, {"input": "3\n 100 100\n 10 10000\n 1 1000000000", "output": "9991"}] |
Print the answer.
* * * | s062009852 | Accepted | p02661 | Input is given from Standard Input in the following format:
N
A_1 B_1
A_2 B_2
:
A_N B_N | import glob
# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = "ABC\\169\\E"
# テスト用ファイル置き場のトップ
TOP_PATH = "C:\\AtCoder"
class Common:
problem = []
index = 0
def __init__(self, rel_path):
self.rel_path = rel_path
def initialize(self, path):
file = open(path)
self.problem = file.readlines()
self.index = 0
return
def input_data(self):
try:
IS_TEST
self.index += 1
return self.problem[self.index - 1]
except NameError:
return input()
def resolve(self):
pass
def exec_resolve(self):
try:
IS_TEST
for path in glob.glob(TOP_PATH + "\\" + self.rel_path + "/*.txt"):
print("Test: " + path)
self.initialize(path)
self.resolve()
print("\n\n")
except NameError:
self.resolve()
class Solver(Common):
def resolve(self):
N = int(self.input_data())
A = [[0, 0] for i in range(N)]
B = [[0, 0] for i in range(N)]
for i in range(N):
tmp = self.input_data().split()
A[i][0] = i
A[i][1] = int(tmp[0])
B[i][0] = i
B[i][1] = int(tmp[1])
# 最小値群と最大値群を個別に並び替える
A_sorted = sorted(A, key=lambda x: x[1])
B_sorted = sorted(B, key=lambda x: x[1])
"""
if N % 2 == 0:
for i in range(N):
for j in range(N):
if A_sorted[j][0] == i:
min = A_sorted[j]
break
for j in range(N):
if B_sorted[j][0] == i:
max = B_sorted[j]
break
pass
else:
pass
"""
if N % 2 == 0:
median_min = A_sorted[int(N / 2)][1] + A_sorted[int(N / 2) - 1][1]
median_max = B_sorted[int(N / 2)][1] + B_sorted[int(N / 2) - 1][1]
else:
median_min = A_sorted[int(N / 2)][1]
median_max = B_sorted[int(N / 2)][1]
result = median_max - median_min + 1
print(str(result))
solver = Solver(REL_PATH)
solver.exec_resolve()
| Statement
There are N integers X_1, X_2, \cdots, X_N, and we know that A_i \leq X_i \leq
B_i. Find the number of different values that the median of X_1, X_2, \cdots,
X_N can take. | [{"input": "2\n 1 2\n 2 3", "output": "3\n \n\n * If X_1 = 1 and X_2 = 2, the median is \\frac{3}{2};\n\n * if X_1 = 1 and X_2 = 3, the median is 2;\n\n * if X_1 = 2 and X_2 = 2, the median is 2;\n\n * if X_1 = 2 and X_2 = 3, the median is \\frac{5}{2}.\n\nThus, the median can take three values: \\frac{3}{2}, 2, and \\frac{5}{2}.\n\n* * *"}, {"input": "3\n 100 100\n 10 10000\n 1 1000000000", "output": "9991"}] |
Print the answer.
* * * | s319399854 | Wrong Answer | p02661 | Input is given from Standard Input in the following format:
N
A_1 B_1
A_2 B_2
:
A_N B_N | n = int(input())
ab = []
ba = []
for _ in range(n):
a, b = map(int, input().split())
ab.append([a, b])
ba.append([b, a])
ab.sort()
ba.sort(reverse=True)
ans = 0
if n % 2 == 1: # nが奇数
left = ab[n // 2][0]
right_end = ba[n // 2][0]
right = min(ab[n // 2][1], right_end)
for i in range(n // 2 + 1, n):
if right >= ab[i][0]: # 右端が次の左端より大きい
right = min(max(right, ab[i][1]), right_end) # 次の領域につなげる
elif ab[i][0] < right_end: # 右端が次の左端より小さい&まだ領域がある
ans += (right - left) + 1 # 一旦切れる
left = ab[i][0]
right = min(ab[i][1], right_end)
else: # 終了
break
ans += (right - left) + 1 * 0
else: # nが偶数
# まずn//2番目の値の範囲
ans0 = 0
left_end = ab[n // 2 - 1][0]
right_end = ba[n // 2][0]
left = left_end
right = min(ab[n // 2][1], right_end)
for i in range(n // 2 + 1, n):
if right >= ab[i][0]: # 右端が次の左端より大きい
right = min(max(right, ab[i][1]), right_end) # 次の領域につなげる
elif ab[i][0] < right_end: # 右端が次の左端より小さい&まだ領域がある
ans0 += (right - left) + 1 # 一旦切れる
left = ab[i][0]
right = min(ab[i][1], right_end)
else: # 終了
break
ans0 += (right - left) + 1
left_end0 = left_end
right_end0 = right_end
# 次に(n//2+1)番目の値の範囲
ans1 = 0
left_end = ab[n // 2][0]
right_end = ba[n // 2 - 1][0]
left = left_end
right = min(ab[n // 2][1], right_end)
for i in range(n // 2 + 1, n):
if right >= ab[i][0]: # 右端が次の左端より大きい
right = min(max(right, ab[i][1]), right_end) # 次の領域につなげる
elif ab[i][0] < right_end: # 右端が次の左端より小さい&まだ領域がある
ans1 += (right - left) + 1 # 一旦切れる
left = ab[i][0]
right = min(ab[i][1], right_end)
else: # 終了
break
ans1 += (right - left) + 1
left_end1 = left_end
right_end1 = right_end
# print(left_end0,right_end0,left_end1,right_end1)
ans = (((right_end1 + right_end0) // 2) - ((left_end1 + left_end0) // 2)) * 2 + 1
print(ans)
| Statement
There are N integers X_1, X_2, \cdots, X_N, and we know that A_i \leq X_i \leq
B_i. Find the number of different values that the median of X_1, X_2, \cdots,
X_N can take. | [{"input": "2\n 1 2\n 2 3", "output": "3\n \n\n * If X_1 = 1 and X_2 = 2, the median is \\frac{3}{2};\n\n * if X_1 = 1 and X_2 = 3, the median is 2;\n\n * if X_1 = 2 and X_2 = 2, the median is 2;\n\n * if X_1 = 2 and X_2 = 3, the median is \\frac{5}{2}.\n\nThus, the median can take three values: \\frac{3}{2}, 2, and \\frac{5}{2}.\n\n* * *"}, {"input": "3\n 100 100\n 10 10000\n 1 1000000000", "output": "9991"}] |
Print the answer.
* * * | s945240331 | Wrong Answer | p02661 | Input is given from Standard Input in the following format:
N
A_1 B_1
A_2 B_2
:
A_N B_N | import numpy as np
N = int(input())
AB = np.array([list(map(int, input().split())) for i in range(N)])
AB_T = AB.T
A = AB_T[0].tolist()
B = AB_T[1].tolist()
if N == 2:
X_1 = min(A)
Y_1 = max(B)
A.remove(min(A))
B.remove(max(B))
X_2 = min(A)
Y_2 = max(B)
X = X_2 - X_1
Y = Y_1 - Y_2 + 1
print(X + Y)
elif N % 2 == 0:
for i in range(int(N // 2)):
A.remove(min(A))
B.remove(max(B))
if i == int(N // 2) - 1:
X_1 = min(A)
Y_1 = max(B)
A.remove(min(A))
B.remove(max(B))
X_2 = min(A)
Y_2 = max(B)
X = X_2 - X_1
Y = Y_1 - Y_2 + 1
print(X + Y)
break
else:
for i in range(int((N + 1) // 2) - 1):
A.remove(min(A))
B.remove(max(B))
if i == int((N + 1) // 2) - 2:
L_1 = min(A)
M_1 = max(B)
A.remove(min(A))
B.remove(max(B))
L_2 = min(A)
M_2 = max(B)
L = L_2 - L_1
M = M_1 - M_2 + 1
print(L + M)
break
| Statement
There are N integers X_1, X_2, \cdots, X_N, and we know that A_i \leq X_i \leq
B_i. Find the number of different values that the median of X_1, X_2, \cdots,
X_N can take. | [{"input": "2\n 1 2\n 2 3", "output": "3\n \n\n * If X_1 = 1 and X_2 = 2, the median is \\frac{3}{2};\n\n * if X_1 = 1 and X_2 = 3, the median is 2;\n\n * if X_1 = 2 and X_2 = 2, the median is 2;\n\n * if X_1 = 2 and X_2 = 3, the median is \\frac{5}{2}.\n\nThus, the median can take three values: \\frac{3}{2}, 2, and \\frac{5}{2}.\n\n* * *"}, {"input": "3\n 100 100\n 10 10000\n 1 1000000000", "output": "9991"}] |
Print the answer.
* * * | s545108679 | Accepted | p02661 | Input is given from Standard Input in the following format:
N
A_1 B_1
A_2 B_2
:
A_N B_N | how_many = int(input())
least, biggest = [], []
for i in range(how_many):
nums = input().split()
nums = [int(num) for num in nums]
least.append(nums[0])
biggest.append(nums[1])
least.sort()
biggest.sort()
if how_many % 2 == 1:
print(biggest[int((how_many - 1) / 2)] - least[int((how_many - 1) / 2)] + 1)
else:
l = (least[int(how_many / 2)] + least[int(how_many / 2 - 1)]) / 2
b = (biggest[int(how_many / 2)] + biggest[int(how_many / 2 - 1)]) / 2
print(int((b - l) / 0.5 + 1))
| Statement
There are N integers X_1, X_2, \cdots, X_N, and we know that A_i \leq X_i \leq
B_i. Find the number of different values that the median of X_1, X_2, \cdots,
X_N can take. | [{"input": "2\n 1 2\n 2 3", "output": "3\n \n\n * If X_1 = 1 and X_2 = 2, the median is \\frac{3}{2};\n\n * if X_1 = 1 and X_2 = 3, the median is 2;\n\n * if X_1 = 2 and X_2 = 2, the median is 2;\n\n * if X_1 = 2 and X_2 = 3, the median is \\frac{5}{2}.\n\nThus, the median can take three values: \\frac{3}{2}, 2, and \\frac{5}{2}.\n\n* * *"}, {"input": "3\n 100 100\n 10 10000\n 1 1000000000", "output": "9991"}] |
Output an integer representing the maximum number of products Mr. Takahashi
can sell.
* * * | s593234629 | Runtime Error | p03973 | Inputs are provided from Standard Inputs in the following form.
N
A_1
:
A_N | import sys
input = sys.stdin.readline
n = int(input())
a = [int(input()) for i in range(n)]
cnt = 1
ans = 0
for i in range(n):
if a[i] = cnt+1:
cnt += 1
else:
ans += (a[i]-1)//cnt
if cnt == 1:
cnt += 1
print(ans) | Statement
N people are waiting in a single line in front of the Takahashi Store. The
cash on hand of the i-th person from the front of the line is a positive
integer A_i.
Mr. Takahashi, the shop owner, has decided on the following scheme: He picks a
product, sets a positive integer P indicating its price, and shows this
product to customers in order, starting from the front of the line. This step
is repeated as described below.
At each step, when a product is shown to a customer, if price P is equal to or
less than the cash held by that customer at the time, the customer buys the
product and Mr. Takahashi ends the current step. That is, the cash held by the
first customer in line with cash equal to or greater than P decreases by P,
and the next step begins.
Mr. Takahashi can set the value of positive integer P independently at each
step.
He would like to sell as many products as possible. However, if a customer
were to end up with 0 cash on hand after a purchase, that person would not
have the fare to go home. Customers not being able to go home would be a
problem for Mr. Takahashi, so he does not want anyone to end up with 0 cash.
Help out Mr. Takahashi by writing a program that determines the maximum number
of products he can sell, when the initial cash in possession of each customer
is given. | [{"input": "3\n 3\n 2\n 5", "output": "3\n \n\nAs values of P, select in order 1, 4, 1.\n\n* * *"}, {"input": "15\n 3\n 1\n 4\n 1\n 5\n 9\n 2\n 6\n 5\n 3\n 5\n 8\n 9\n 7\n 9", "output": "18"}] |
Output an integer representing the maximum number of products Mr. Takahashi
can sell.
* * * | s532501480 | Accepted | p03973 | Inputs are provided from Standard Inputs in the following form.
N
A_1
:
A_N | # -*- coding: utf-8 -*-
import sys
from itertools import accumulate
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c] * b for i in range(a)]
def list3d(a, b, c, d):
return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1):
return int(-(-x // y))
def INT():
return int(input())
def MAP():
return map(int, input().split())
def LIST(N=None):
return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes():
print("Yes")
def No():
print("No")
def YES():
print("YES")
def NO():
print("NO")
sys.setrecursionlimit(10**9)
INF = 10**18
MOD = 10**9 + 7
N = INT()
A = LIST(N)
lim = 1
ans = 0
for a in A:
d, m = divmod(a, lim)
if d == 0 or d == 1 and m == 0:
lim = max(lim, a + 1)
else:
ans += d - (m == 0)
lim = max(lim, 2)
print(ans)
| Statement
N people are waiting in a single line in front of the Takahashi Store. The
cash on hand of the i-th person from the front of the line is a positive
integer A_i.
Mr. Takahashi, the shop owner, has decided on the following scheme: He picks a
product, sets a positive integer P indicating its price, and shows this
product to customers in order, starting from the front of the line. This step
is repeated as described below.
At each step, when a product is shown to a customer, if price P is equal to or
less than the cash held by that customer at the time, the customer buys the
product and Mr. Takahashi ends the current step. That is, the cash held by the
first customer in line with cash equal to or greater than P decreases by P,
and the next step begins.
Mr. Takahashi can set the value of positive integer P independently at each
step.
He would like to sell as many products as possible. However, if a customer
were to end up with 0 cash on hand after a purchase, that person would not
have the fare to go home. Customers not being able to go home would be a
problem for Mr. Takahashi, so he does not want anyone to end up with 0 cash.
Help out Mr. Takahashi by writing a program that determines the maximum number
of products he can sell, when the initial cash in possession of each customer
is given. | [{"input": "3\n 3\n 2\n 5", "output": "3\n \n\nAs values of P, select in order 1, 4, 1.\n\n* * *"}, {"input": "15\n 3\n 1\n 4\n 1\n 5\n 9\n 2\n 6\n 5\n 3\n 5\n 8\n 9\n 7\n 9", "output": "18"}] |
Output an integer representing the maximum number of products Mr. Takahashi
can sell.
* * * | s377069418 | Runtime Error | p03973 | Inputs are provided from Standard Inputs in the following form.
N
A_1
:
A_N | N=int(input())
a=[0]*N
for i in range(N):
a.[i]=int(input())
minimum=1
count=0
for i in a:
if(minimum<i):
if i%minimum:
count+= i//minimum
else :
count+= (i//minimum-1)
else:
minimum=max(minimum,i+1)
print(count)
| Statement
N people are waiting in a single line in front of the Takahashi Store. The
cash on hand of the i-th person from the front of the line is a positive
integer A_i.
Mr. Takahashi, the shop owner, has decided on the following scheme: He picks a
product, sets a positive integer P indicating its price, and shows this
product to customers in order, starting from the front of the line. This step
is repeated as described below.
At each step, when a product is shown to a customer, if price P is equal to or
less than the cash held by that customer at the time, the customer buys the
product and Mr. Takahashi ends the current step. That is, the cash held by the
first customer in line with cash equal to or greater than P decreases by P,
and the next step begins.
Mr. Takahashi can set the value of positive integer P independently at each
step.
He would like to sell as many products as possible. However, if a customer
were to end up with 0 cash on hand after a purchase, that person would not
have the fare to go home. Customers not being able to go home would be a
problem for Mr. Takahashi, so he does not want anyone to end up with 0 cash.
Help out Mr. Takahashi by writing a program that determines the maximum number
of products he can sell, when the initial cash in possession of each customer
is given. | [{"input": "3\n 3\n 2\n 5", "output": "3\n \n\nAs values of P, select in order 1, 4, 1.\n\n* * *"}, {"input": "15\n 3\n 1\n 4\n 1\n 5\n 9\n 2\n 6\n 5\n 3\n 5\n 8\n 9\n 7\n 9", "output": "18"}] |
Output an integer representing the maximum number of products Mr. Takahashi
can sell.
* * * | s559266282 | Runtime Error | p03973 | Inputs are provided from Standard Inputs in the following form.
N
A_1
:
A_N | import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N = ir()
A = [ir() for _ in range(N)]
answer = A[0] - 1
cur_limit = 2
for a in A[1:]:
if a == cur_limit:
cur_limit += 1
continue
answer += (a-cur_limit) // cur_limit)
print(answer)
# 44
| Statement
N people are waiting in a single line in front of the Takahashi Store. The
cash on hand of the i-th person from the front of the line is a positive
integer A_i.
Mr. Takahashi, the shop owner, has decided on the following scheme: He picks a
product, sets a positive integer P indicating its price, and shows this
product to customers in order, starting from the front of the line. This step
is repeated as described below.
At each step, when a product is shown to a customer, if price P is equal to or
less than the cash held by that customer at the time, the customer buys the
product and Mr. Takahashi ends the current step. That is, the cash held by the
first customer in line with cash equal to or greater than P decreases by P,
and the next step begins.
Mr. Takahashi can set the value of positive integer P independently at each
step.
He would like to sell as many products as possible. However, if a customer
were to end up with 0 cash on hand after a purchase, that person would not
have the fare to go home. Customers not being able to go home would be a
problem for Mr. Takahashi, so he does not want anyone to end up with 0 cash.
Help out Mr. Takahashi by writing a program that determines the maximum number
of products he can sell, when the initial cash in possession of each customer
is given. | [{"input": "3\n 3\n 2\n 5", "output": "3\n \n\nAs values of P, select in order 1, 4, 1.\n\n* * *"}, {"input": "15\n 3\n 1\n 4\n 1\n 5\n 9\n 2\n 6\n 5\n 3\n 5\n 8\n 9\n 7\n 9", "output": "18"}] |
Output an integer representing the maximum number of products Mr. Takahashi
can sell.
* * * | s432167171 | Wrong Answer | p03973 | Inputs are provided from Standard Inputs in the following form.
N
A_1
:
A_N | N = int(input())
A = [int(input()) for i in range(N)]
x, r = 0, 0
for a in A:
d = (a - 1) // (x + 1)
if d == 0:
x = a
elif x == 0:
x = 1
r += d
print(r)
| Statement
N people are waiting in a single line in front of the Takahashi Store. The
cash on hand of the i-th person from the front of the line is a positive
integer A_i.
Mr. Takahashi, the shop owner, has decided on the following scheme: He picks a
product, sets a positive integer P indicating its price, and shows this
product to customers in order, starting from the front of the line. This step
is repeated as described below.
At each step, when a product is shown to a customer, if price P is equal to or
less than the cash held by that customer at the time, the customer buys the
product and Mr. Takahashi ends the current step. That is, the cash held by the
first customer in line with cash equal to or greater than P decreases by P,
and the next step begins.
Mr. Takahashi can set the value of positive integer P independently at each
step.
He would like to sell as many products as possible. However, if a customer
were to end up with 0 cash on hand after a purchase, that person would not
have the fare to go home. Customers not being able to go home would be a
problem for Mr. Takahashi, so he does not want anyone to end up with 0 cash.
Help out Mr. Takahashi by writing a program that determines the maximum number
of products he can sell, when the initial cash in possession of each customer
is given. | [{"input": "3\n 3\n 2\n 5", "output": "3\n \n\nAs values of P, select in order 1, 4, 1.\n\n* * *"}, {"input": "15\n 3\n 1\n 4\n 1\n 5\n 9\n 2\n 6\n 5\n 3\n 5\n 8\n 9\n 7\n 9", "output": "18"}] |
Print the number of possible pairs that he may have had.
* * * | s024960866 | Accepted | p03420 | Input is given from Standard Input in the following format:
N K | from math import (
ceil,
floor,
factorial,
gcd,
sqrt,
log2,
cos,
sin,
tan,
acos,
asin,
atan,
degrees,
radians,
pi,
inf,
comb,
)
from itertools import (
accumulate,
groupby,
permutations,
combinations,
product,
combinations_with_replacement,
)
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
from operator import itemgetter
from heapq import heapify, heappop, heappush
from queue import Queue, LifoQueue, PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10**7)
def input():
return sys.stdin.readline().strip()
def INT():
return int(input())
def MAP():
return map(int, input().split())
def LIST():
return list(MAP())
n, k = MAP()
ans = 0
if k == 0:
ans = n**2
else:
for b in range(k + 1, n + 1):
x = n // b
y = n % b
ans += (b - k) * x + (y - k + 1 if y >= k else 0)
print(ans)
| Statement
Takahashi had a pair of two positive integers not exceeding N, (a,b), which he
has forgotten. He remembers that the remainder of a divided by b was greater
than or equal to K. Find the number of possible pairs that he may have had. | [{"input": "5 2", "output": "7\n \n\nThere are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).\n\n* * *"}, {"input": "10 0", "output": "100\n \n\n* * *"}, {"input": "31415 9265", "output": "287927211"}] |
Print the number of possible pairs that he may have had.
* * * | s265408183 | Runtime Error | p03420 | Input is given from Standard Input in the following format:
N K | import sys
N,K = map(int, input().split())
res = 0
if K==0:
print(N*N)
sys.exit(0)
for i in range(N):
i += 1
if i-K<=0:
continue
amari = N % i
amari = amari - K + 1
re = N // i
if amari <= 0:
amari = 0
res += re*(i-K) + amari
print(res) | Statement
Takahashi had a pair of two positive integers not exceeding N, (a,b), which he
has forgotten. He remembers that the remainder of a divided by b was greater
than or equal to K. Find the number of possible pairs that he may have had. | [{"input": "5 2", "output": "7\n \n\nThere are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).\n\n* * *"}, {"input": "10 0", "output": "100\n \n\n* * *"}, {"input": "31415 9265", "output": "287927211"}] |
Print the number of possible pairs that he may have had.
* * * | s940619725 | Runtime Error | p03420 | Input is given from Standard Input in the following format:
N K | n,k=map(int,input().split())
ans=0
for i in range(k+1,n+1):
ans+=(n//i)*(i-k)+max(n%i-k+1,0)
print(n**2 if k== else ans) | Statement
Takahashi had a pair of two positive integers not exceeding N, (a,b), which he
has forgotten. He remembers that the remainder of a divided by b was greater
than or equal to K. Find the number of possible pairs that he may have had. | [{"input": "5 2", "output": "7\n \n\nThere are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).\n\n* * *"}, {"input": "10 0", "output": "100\n \n\n* * *"}, {"input": "31415 9265", "output": "287927211"}] |
Print the number of possible pairs that he may have had.
* * * | s721714293 | Accepted | p03420 | Input is given from Standard Input in the following format:
N K | import sys
input_methods = ["clipboard", "file", "key"]
using_method = 0
input_method = input_methods[using_method]
tin = lambda: map(int, input().split())
lin = lambda: list(tin())
mod = 1000000007
# +++++
def dd(b, n, k):
if k == 0:
return n
if b <= k:
return 0
ret = 0
na = n // b
ret += na * (b - k)
nb = n % b
ret += max(nb - k + 1, 0)
# pa((b,ret))
return ret
def main():
# a = int(input())
n, k = tin()
# s = input()
ret = 0
for b in range(1, n + 1):
ret += dd(b, n, k)
print(ret)
# +++++
isTest = False
def pa(v):
if isTest:
print(v)
def input_clipboard():
import clipboard
input_text = clipboard.get()
input_l = input_text.splitlines()
for l in input_l:
yield l
if __name__ == "__main__":
if sys.platform == "ios":
if input_method == input_methods[0]:
ic = input_clipboard()
input = lambda: ic.__next__()
elif input_method == input_methods[1]:
sys.stdin = open("inputFile.txt")
else:
pass
isTest = True
else:
pass
# input = sys.stdin.readline
ret = main()
if ret is not None:
print(ret)
| Statement
Takahashi had a pair of two positive integers not exceeding N, (a,b), which he
has forgotten. He remembers that the remainder of a divided by b was greater
than or equal to K. Find the number of possible pairs that he may have had. | [{"input": "5 2", "output": "7\n \n\nThere are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).\n\n* * *"}, {"input": "10 0", "output": "100\n \n\n* * *"}, {"input": "31415 9265", "output": "287927211"}] |
Print the number of possible pairs that he may have had.
* * * | s351073149 | Accepted | p03420 | Input is given from Standard Input in the following format:
N K | n, k = map(int, input().split())
print(
n**2
if not k
else sum([(i - k) * (n // i) + max(0, n % i - k + 1) for i in range(k + 1, n + 1)])
)
| Statement
Takahashi had a pair of two positive integers not exceeding N, (a,b), which he
has forgotten. He remembers that the remainder of a divided by b was greater
than or equal to K. Find the number of possible pairs that he may have had. | [{"input": "5 2", "output": "7\n \n\nThere are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).\n\n* * *"}, {"input": "10 0", "output": "100\n \n\n* * *"}, {"input": "31415 9265", "output": "287927211"}] |
Print the number of possible pairs that he may have had.
* * * | s886687113 | Runtime Error | p03420 | Input is given from Standard Input in the following format:
N K | # a%b >= K iff xb+K <= a < (x+1)b
# bごとに数えるだけ
N,K = map(int,input().split())
ans = 0
for b in range(K+1,N+1):
cnt = 0
x_max = N//b
# 0 <= x < x_max
# 各xに対してb-K個ある
cnt += x_max * (b-K)
# x = x_max
lower = x_max*b+K
if lower <= N:
upper = min((x_max+1)*b-1,N)
cnt += upper - lower + 1
ans += cnt
print(ans) | Statement
Takahashi had a pair of two positive integers not exceeding N, (a,b), which he
has forgotten. He remembers that the remainder of a divided by b was greater
than or equal to K. Find the number of possible pairs that he may have had. | [{"input": "5 2", "output": "7\n \n\nThere are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).\n\n* * *"}, {"input": "10 0", "output": "100\n \n\n* * *"}, {"input": "31415 9265", "output": "287927211"}] |
Print the number of possible pairs that he may have had.
* * * | s155193794 | Runtime Error | p03420 | Input is given from Standard Input in the following format:
N K | N,K = map(int, input().split())
res = 0
if K==0:
print(N*N)
return
for i in range(N):
i += 1
if i-K<=0:
continue
amari = N % i
amari = amari - K + 1
re = N//i
if amari<=0:
amari = 0
res += re*(i-K) + amari
print(res) | Statement
Takahashi had a pair of two positive integers not exceeding N, (a,b), which he
has forgotten. He remembers that the remainder of a divided by b was greater
than or equal to K. Find the number of possible pairs that he may have had. | [{"input": "5 2", "output": "7\n \n\nThere are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).\n\n* * *"}, {"input": "10 0", "output": "100\n \n\n* * *"}, {"input": "31415 9265", "output": "287927211"}] |
Print the number of possible pairs that he may have had.
* * * | s374775893 | Wrong Answer | p03420 | Input is given from Standard Input in the following format:
N K | # むずい
| Statement
Takahashi had a pair of two positive integers not exceeding N, (a,b), which he
has forgotten. He remembers that the remainder of a divided by b was greater
than or equal to K. Find the number of possible pairs that he may have had. | [{"input": "5 2", "output": "7\n \n\nThere are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).\n\n* * *"}, {"input": "10 0", "output": "100\n \n\n* * *"}, {"input": "31415 9265", "output": "287927211"}] |
Print the number of possible pairs that he may have had.
* * * | s154982191 | Runtime Error | p03420 | Input is given from Standard Input in the following format:
N K | n,k=map(int,input().split())
b=[i for i in range(k+1,n+1)]
ans=0
if k==0:
for i in range(len(b)):
t=b[i]
j=t-k
ii=n//t
ans+=ii*j
ans+=max(n-ii*t-k,0)
print(ans)
exit()
for i in range(len(b)):
t=b[i]
j=t-k
ii=n//t
ans+=ii*j
ans+=max(n-ii*t-k+1,0)
print(ans) | Statement
Takahashi had a pair of two positive integers not exceeding N, (a,b), which he
has forgotten. He remembers that the remainder of a divided by b was greater
than or equal to K. Find the number of possible pairs that he may have had. | [{"input": "5 2", "output": "7\n \n\nThere are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).\n\n* * *"}, {"input": "10 0", "output": "100\n \n\n* * *"}, {"input": "31415 9265", "output": "287927211"}] |
Print the number, modulo 998244353, of ways to paint each of the integers red,
green or blue so that the condition is satisfied.
* * * | s426620360 | Runtime Error | p03070 | Input is given from Standard Input in the following format:
N
a_1
:
a_N | n = int(input())
A = tuple(int(input()) for _ in range(n))
S = sum(A)
mod = 998244353
ans = pow(3, n, mod) - (pow(2, n, mod) - 2) * 3 - 3
cnt = 0
dp = [[[0] * (S + 1) for j in range(n + 2)] for i in range(n + 1)]
dp[0][0][0] = 1
for i, a in enumerate(A):
for j in range(i + 2):
for k in range(S + 1):
if k >= a and j:
dp[i + 1][j][k] = dp[i][j][k] + dp[i][j - 1][k - a]
else:
dp[i + 1][j][k] = dp[i][j][k]
for j in range(n - 1):
for k in range((S + 1) // 2, S + 1):
cnt += dp[n][j][k] * (pow(2, n - j, mod) - 2)
cnt %= mod
ans -= cnt * 3
ans %= mod
print(ans)
| Statement
You are given N integers. The i-th integer is a_i. Find the number, modulo
998244353, of ways to paint each of the integers red, green or blue so that
the following condition is satisfied:
* Let R, G and B be the sums of the integers painted red, green and blue, respectively. There exists a triangle with positive area whose sides have lengths R, G and B. | [{"input": "4\n 1\n 1\n 1\n 2", "output": "18\n \n\nWe can only paint the integers so that the lengths of the sides of the\ntriangle will be 1, 2 and 2, and there are 18 such ways.\n\n* * *"}, {"input": "6\n 1\n 3\n 2\n 3\n 5\n 2", "output": "150\n \n\n* * *"}, {"input": "20\n 3\n 1\n 4\n 1\n 5\n 9\n 2\n 6\n 5\n 3\n 5\n 8\n 9\n 7\n 9\n 3\n 2\n 3\n 8\n 4", "output": "563038556"}] |
Print the number, modulo 998244353, of ways to paint each of the integers red,
green or blue so that the condition is satisfied.
* * * | s152134436 | Runtime Error | p03070 | Input is given from Standard Input in the following format:
N
a_1
:
a_N | N = int(input())
S = input()
sl = [x for x in S]
sh = 0
p = 0
for i in range(N - 1):
if sl[i] == "#":
sh += 1
if sl[-i - 1] == ".":
p += 1
cnt = N - p - sh
print(p)
| Statement
You are given N integers. The i-th integer is a_i. Find the number, modulo
998244353, of ways to paint each of the integers red, green or blue so that
the following condition is satisfied:
* Let R, G and B be the sums of the integers painted red, green and blue, respectively. There exists a triangle with positive area whose sides have lengths R, G and B. | [{"input": "4\n 1\n 1\n 1\n 2", "output": "18\n \n\nWe can only paint the integers so that the lengths of the sides of the\ntriangle will be 1, 2 and 2, and there are 18 such ways.\n\n* * *"}, {"input": "6\n 1\n 3\n 2\n 3\n 5\n 2", "output": "150\n \n\n* * *"}, {"input": "20\n 3\n 1\n 4\n 1\n 5\n 9\n 2\n 6\n 5\n 3\n 5\n 8\n 9\n 7\n 9\n 3\n 2\n 3\n 8\n 4", "output": "563038556"}] |
Print the number, modulo 998244353, of ways to paint each of the integers red,
green or blue so that the condition is satisfied.
* * * | s829433498 | Accepted | p03070 | Input is given from Standard Input in the following format:
N
a_1
:
a_N | def main():
N = int(input())
A = [0] * N
MOD = 998244353
summation = 0
for i in range(N):
A[i] = int(input())
summation += A[i]
# dp[i][j] represents sum of red is j at i position
dp = [[0 for _ in range(summation + 1)] for _ in range(N)]
dp[0][0] = 2 # green or blue
dp[0][A[0]] = 1 # red
for i in range(1, N):
for j in range(len(dp[i])):
dp[i][j] += (
dp[i - 1][j] * 2 % MOD
) # don't use A[i] for red, i.e. use green or blue
dp[i][j] += (
dp[i - 1][j - A[i]] % MOD if 0 <= j - A[i] <= len(dp[i]) else 0
) # use i red
# total
ans = (3**N) % MOD
ceil = summation // 2
if summation % 2 != 0:
ceil += 1
ans -= sum([dp[N - 1][r] for r in range(ceil, summation + 1)]) * 3
ans %= MOD
if summation % 2 == 0:
# case r = g = S/2
dp = [[0 for _ in range(summation // 2 + 1)] for _ in range(N)]
dp[0][0] = 1 # only blue
dp[0][A[0]] = 1
for i in range(1, N):
for j in range(len(dp[i])):
dp[i][j] += dp[i - 1][j] % MOD
dp[i][j] += (
dp[i - 1][j - A[i]] % MOD if 0 <= j - A[i] <= len(dp[i]) else 0
)
ans += dp[N - 1][summation // 2] * 3
ans %= MOD
print(ans)
if __name__ == "__main__":
main()
| Statement
You are given N integers. The i-th integer is a_i. Find the number, modulo
998244353, of ways to paint each of the integers red, green or blue so that
the following condition is satisfied:
* Let R, G and B be the sums of the integers painted red, green and blue, respectively. There exists a triangle with positive area whose sides have lengths R, G and B. | [{"input": "4\n 1\n 1\n 1\n 2", "output": "18\n \n\nWe can only paint the integers so that the lengths of the sides of the\ntriangle will be 1, 2 and 2, and there are 18 such ways.\n\n* * *"}, {"input": "6\n 1\n 3\n 2\n 3\n 5\n 2", "output": "150\n \n\n* * *"}, {"input": "20\n 3\n 1\n 4\n 1\n 5\n 9\n 2\n 6\n 5\n 3\n 5\n 8\n 9\n 7\n 9\n 3\n 2\n 3\n 8\n 4", "output": "563038556"}] |
Print the number, modulo 998244353, of ways to paint each of the integers red,
green or blue so that the condition is satisfied.
* * * | s018577106 | Accepted | p03070 | Input is given from Standard Input in the following format:
N
a_1
:
a_N | mod = 998244353
def main():
# start coding here...
# Three colors
N = int(input())
A = [int(input()) for i in range(N)]
M = (sum(A) - 1) // 2
S = sum(A)
# 1<= R,G,B<= S, R+ G + B = S
# ほうじょ原理
Alls = pow(3, N, mod)
# R,G,B のうち1つ以上が S より大のケース case2
case2 = 0
# dp[x][i] := 初めのxこを塗り分けて、Rの値がiになるものの個数
dp = [[0 for i in range(90001)] for j in range(N + 1)]
dp[0][0] = 1
for i in range(1, N + 1):
v = A[i - 1]
for j in range(90001):
if j >= v:
dp[i][j] = dp[i - 1][j - v] + 2 * dp[i - 1][j]
else:
dp[i][j] = 2 * dp[i - 1][j]
dp[i][j] %= mod
if S % 2 != 0:
# R,G,B のうち1つだけがSより大きい
for i in range(M + 1, 90001):
case2 += 3 * dp[N][i]
case2 %= mod
if S % 2 == 0:
# R,G,B のうち1つがSより大きい
for i in range(M + 1, 90001):
case2 += 3 * dp[N][i]
case2 %= mod
# R,G,B のうち2つがS//2
# sub_dp[x][v]:= 初めのxこを塗り分けて Rの方をvにする方法
sub_dp = [[0 for i in range(90001)] for j in range(N + 1)]
sub_dp[0][0] = 1
for i in range(1, N + 1):
v = A[i - 1]
for j in range(90001):
if j >= v:
sub_dp[i][j] = sub_dp[i - 1][j] + sub_dp[i - 1][j - v]
else:
sub_dp[i][j] = sub_dp[i - 1][j]
sub_dp[i][j] %= mod
case2 -= 3 * sub_dp[N][S // 2]
case2 %= mod
ans = Alls - case2
print(ans % mod)
return
if __name__ == "__main__":
main()
| Statement
You are given N integers. The i-th integer is a_i. Find the number, modulo
998244353, of ways to paint each of the integers red, green or blue so that
the following condition is satisfied:
* Let R, G and B be the sums of the integers painted red, green and blue, respectively. There exists a triangle with positive area whose sides have lengths R, G and B. | [{"input": "4\n 1\n 1\n 1\n 2", "output": "18\n \n\nWe can only paint the integers so that the lengths of the sides of the\ntriangle will be 1, 2 and 2, and there are 18 such ways.\n\n* * *"}, {"input": "6\n 1\n 3\n 2\n 3\n 5\n 2", "output": "150\n \n\n* * *"}, {"input": "20\n 3\n 1\n 4\n 1\n 5\n 9\n 2\n 6\n 5\n 3\n 5\n 8\n 9\n 7\n 9\n 3\n 2\n 3\n 8\n 4", "output": "563038556"}] |
Print the string S.
If such a string does not exist, print `UNRESTORABLE` instead.
* * * | s319689469 | Accepted | p03565 | Input is given from Standard Input in the following format:
S
T' | from copy import deepcopy
from sys import exit, setrecursionlimit
import math
from collections import defaultdict, Counter, deque
from fractions import Fraction as frac
import fractions
from functools import reduce
import bisect
import sys
import logging
import heapq
# logging.basicConfig(level=logging.DEBUG)
input = sys.stdin.readline
setrecursionlimit(1000000)
def main():
s = input()[:-1]
t = input()[:-1]
for i in reversed(range(len(s) - len(t) + 1)):
flag = True
for j in range(len(t)):
if s[i + j] != "?" and s[i + j] != t[j]:
flag = False
break
if flag:
ans = []
for j in s:
ans.append(j)
for j in range(i, i + len(t)):
ans[j] = t[j - i]
a = ""
for i in ans:
a += i
print(a.replace("?", "a"))
return
print("UNRESTORABLE")
def factorization(n):
arr = []
temp = n
for i in range(2, int(-(-(n**0.5) // 1)) + 1):
if temp % i == 0:
cnt = 0
while temp % i == 0:
cnt += 1
temp //= i
arr.append([i, cnt])
if temp != 1:
arr.append([temp, 1])
if arr == []:
arr.append([n, 1])
return arr
def zip(a):
mae = a[0]
ziparray = [mae]
for i in range(1, len(a)):
if mae != a[i]:
ziparray.append(a[i])
mae = a[i]
return ziparray
def is_prime(n):
if n < 2:
return False
for k in range(2, int(math.sqrt(n)) + 1):
if n % k == 0:
return False
return True
def list_replace(n, f, t):
return [t if i == f else i for i in n]
def base_10_to_n(X, n):
X_dumy = X
out = ""
while X_dumy > 0:
out = str(X_dumy % n) + out
X_dumy = int(X_dumy / n)
if out == "":
return "0"
return out
def lcm(numbers):
return reduce(lcm_base, numbers, 1)
def lcm_base(x, y):
return (x * y) // fractions.gcd(x, y)
class Queue:
def __init__(self):
self.q = deque([])
def push(self, i):
self.q.append(i)
def pop(self):
return self.q.popleft()
def size(self):
return len(self.q)
def debug(self):
return self.q
class Stack:
def __init__(self):
self.q = []
def push(self, i):
self.q.append(i)
def pop(self):
return self.q.pop()
def size(self):
return len(self.q)
def debug(self):
return self.q
class graph:
def __init__(self):
self.graph = defaultdict(list)
def addnode(self, l):
f, t = l[0], l[1]
self.graph[f].append(t)
self.graph[t].append(f)
def rmnode(self, l):
f, t = l[0], l[1]
self.graph[f].remove(t)
self.graph[t].remove(f)
def linked(self, f):
return self.graph[f]
class dgraph:
def __init__(self):
self.graph = defaultdict(set)
def addnode(self, l):
f, t = l[0], l[1]
self.graph[f].append(t)
def rmnode(self, l):
f, t = l[0], l[1]
self.graph[f].remove(t)
def linked(self, f):
return self.graph[f]
class PriorityQueue:
def __init__(self):
self.queue = []
def push(self, i):
heapq.heappush(self.queue, -i)
def pop(self):
return -1 * heapq.heappop(self.queue)
def sum(self):
return -sum(self.queue)
main()
| Statement
E869120 found a chest which is likely to contain treasure.
However, the chest is locked. In order to open it, he needs to enter a string
S consisting of lowercase English letters.
He also found a string S', which turns out to be the string S with some of its
letters (possibly all or none) replaced with `?`.
One more thing he found is a sheet of paper with the following facts written
on it:
* Condition 1: The string S contains a string T as a contiguous substring.
* Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1.
Print the string S.
If such a string does not exist, print `UNRESTORABLE`. | [{"input": "?tc????\n coder", "output": "atcoder\n \n\nThere are 26 strings that satisfy Condition 1: `atcoder`, `btcoder`,\n`ctcoder`,..., `ztcoder`. Among them, the lexicographically smallest is\n`atcoder`, so we can say S = `atcoder`.\n\n* * *"}, {"input": "??p??d??\n abc", "output": "UNRESTORABLE\n \n\nThere is no string that satisfies Condition 1, so the string S does not exist."}] |
Print the string S.
If such a string does not exist, print `UNRESTORABLE` instead.
* * * | s607545801 | Wrong Answer | p03565 | Input is given from Standard Input in the following format:
S
T' | S = list(input())
T = list(input())
lenS = len(S)
lenT = len(T)
if lenS < lenT:
for _ in range(10**7):
print("UNRESTORABLE")
| Statement
E869120 found a chest which is likely to contain treasure.
However, the chest is locked. In order to open it, he needs to enter a string
S consisting of lowercase English letters.
He also found a string S', which turns out to be the string S with some of its
letters (possibly all or none) replaced with `?`.
One more thing he found is a sheet of paper with the following facts written
on it:
* Condition 1: The string S contains a string T as a contiguous substring.
* Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1.
Print the string S.
If such a string does not exist, print `UNRESTORABLE`. | [{"input": "?tc????\n coder", "output": "atcoder\n \n\nThere are 26 strings that satisfy Condition 1: `atcoder`, `btcoder`,\n`ctcoder`,..., `ztcoder`. Among them, the lexicographically smallest is\n`atcoder`, so we can say S = `atcoder`.\n\n* * *"}, {"input": "??p??d??\n abc", "output": "UNRESTORABLE\n \n\nThere is no string that satisfies Condition 1, so the string S does not exist."}] |
Print the string S.
If such a string does not exist, print `UNRESTORABLE` instead.
* * * | s672906386 | Wrong Answer | p03565 | Input is given from Standard Input in the following format:
S
T' | from string import ascii_lowercase
code = input()
hint = input()
def is_match(code, s):
"""
>>> is_match('abc', 'abc')
True
>>> is_match('a?c', 'axc')
True
>>> is_match('???', 'xyz')
True
>>> is_match('abc', 'abd')
False
>>> is_match('abc', 'abcd')
False
>>> is_match('?p?', 'abc')
False
"""
if len(code) != len(s):
return False
for a, b in zip(code, s):
if not (a == b or a == "?"):
return False
return True
def guess(code, hint):
"""
>>> guess('?tc????', 'coder')
'atcoder'
>>> guess('?p??d??', 'abc')
'UNRESTORABLE'
>>> guess('?????er', 'coder')
'aacoder'
"""
reversed_code = code[::-1]
reversed_hint = hint[::-1]
for i in range(len(code)):
if is_match(reversed_code[i : len(hint)], reversed_hint):
merged = reversed_code[:i] + reversed_hint + reversed_code[i + len(hint) :]
return merged[::-1].replace("?", "a")
return "UNRESTORABLE"
print(guess(code, hint))
| Statement
E869120 found a chest which is likely to contain treasure.
However, the chest is locked. In order to open it, he needs to enter a string
S consisting of lowercase English letters.
He also found a string S', which turns out to be the string S with some of its
letters (possibly all or none) replaced with `?`.
One more thing he found is a sheet of paper with the following facts written
on it:
* Condition 1: The string S contains a string T as a contiguous substring.
* Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1.
Print the string S.
If such a string does not exist, print `UNRESTORABLE`. | [{"input": "?tc????\n coder", "output": "atcoder\n \n\nThere are 26 strings that satisfy Condition 1: `atcoder`, `btcoder`,\n`ctcoder`,..., `ztcoder`. Among them, the lexicographically smallest is\n`atcoder`, so we can say S = `atcoder`.\n\n* * *"}, {"input": "??p??d??\n abc", "output": "UNRESTORABLE\n \n\nThere is no string that satisfies Condition 1, so the string S does not exist."}] |
Print the string S.
If such a string does not exist, print `UNRESTORABLE` instead.
* * * | s142622053 | Runtime Error | p03565 | Input is given from Standard Input in the following format:
S
T' | import copy
S_dash = input()
T = input()
len_S = len(S_dash)
len_T = len(T)
candidate0 = list(S_dash)
ans = "z"*51
if len_S >= len_T:
for s in range(len_S):
cha_S = S_dash[s]
if cha_S != "?" and cha_S in list(T):
for t in range(len_T):
cha_T = T[t]
if cha_S == cha_T:
S_cut = S_dash[s-t:s-t+len_T]
candidate1 = copy.deepcopy(candidate0)
for x in range(len_T):
if S_cut[x] == "?":
candidate1[s-t+x] = T[x]
elif S_cut[x] != T[x]:
break
else:
if candidate1[s-t:s-t+len_T].count("?") == 0:
if ans > "".join(candidate1).replace('?', 'a'):
ans = "".join(candidate1).replace('?', 'a')
if ans = "z"*51:
ans = "UNRESTORABLE"
print(ans) | Statement
E869120 found a chest which is likely to contain treasure.
However, the chest is locked. In order to open it, he needs to enter a string
S consisting of lowercase English letters.
He also found a string S', which turns out to be the string S with some of its
letters (possibly all or none) replaced with `?`.
One more thing he found is a sheet of paper with the following facts written
on it:
* Condition 1: The string S contains a string T as a contiguous substring.
* Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1.
Print the string S.
If such a string does not exist, print `UNRESTORABLE`. | [{"input": "?tc????\n coder", "output": "atcoder\n \n\nThere are 26 strings that satisfy Condition 1: `atcoder`, `btcoder`,\n`ctcoder`,..., `ztcoder`. Among them, the lexicographically smallest is\n`atcoder`, so we can say S = `atcoder`.\n\n* * *"}, {"input": "??p??d??\n abc", "output": "UNRESTORABLE\n \n\nThere is no string that satisfies Condition 1, so the string S does not exist."}] |
Print the string S.
If such a string does not exist, print `UNRESTORABLE` instead.
* * * | s979143142 | Runtime Error | p03565 | Input is given from Standard Input in the following format:
S
T' | s = input()
t = input()
w = []
for i in range(len(s) - len(t) + 1):
f = True
sx = s[i:i + len(t)]
for si, ti in zip(sx, t):
if si != ti and si != "?":
f = False
else:
pass
if f:
w.append((s[:i] + t).replace("?", "a"))
if w == []:
print("UNRESTORABLE")
else
w.sort()
print(w[0])
| Statement
E869120 found a chest which is likely to contain treasure.
However, the chest is locked. In order to open it, he needs to enter a string
S consisting of lowercase English letters.
He also found a string S', which turns out to be the string S with some of its
letters (possibly all or none) replaced with `?`.
One more thing he found is a sheet of paper with the following facts written
on it:
* Condition 1: The string S contains a string T as a contiguous substring.
* Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1.
Print the string S.
If such a string does not exist, print `UNRESTORABLE`. | [{"input": "?tc????\n coder", "output": "atcoder\n \n\nThere are 26 strings that satisfy Condition 1: `atcoder`, `btcoder`,\n`ctcoder`,..., `ztcoder`. Among them, the lexicographically smallest is\n`atcoder`, so we can say S = `atcoder`.\n\n* * *"}, {"input": "??p??d??\n abc", "output": "UNRESTORABLE\n \n\nThere is no string that satisfies Condition 1, so the string S does not exist."}] |
Print the string S.
If such a string does not exist, print `UNRESTORABLE` instead.
* * * | s879310958 | Runtime Error | p03565 | Input is given from Standard Input in the following format:
S
T' | import sys
S = sys.stdin.readline().strip()
T = sys.stdin.readline().strip()
if S.find(T) > -1:
ans = S.replace("?", "a")
print(ans)
else:
index = -1
for i in range(len(S)):
b = True
for j in range(len(T)):
if (i + j > (len(S)-1)) or ((S[i + j] != "?") and (S[i + j] != T[j])):
b = False
break
if b:
index = i
if index == -1:
print("UNRESTORABLE")
sys.exit()
elif:
ans = S[:index] + T + S[index + len(S):]
ans = ans.replace("?", "a")
print(ans) | Statement
E869120 found a chest which is likely to contain treasure.
However, the chest is locked. In order to open it, he needs to enter a string
S consisting of lowercase English letters.
He also found a string S', which turns out to be the string S with some of its
letters (possibly all or none) replaced with `?`.
One more thing he found is a sheet of paper with the following facts written
on it:
* Condition 1: The string S contains a string T as a contiguous substring.
* Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1.
Print the string S.
If such a string does not exist, print `UNRESTORABLE`. | [{"input": "?tc????\n coder", "output": "atcoder\n \n\nThere are 26 strings that satisfy Condition 1: `atcoder`, `btcoder`,\n`ctcoder`,..., `ztcoder`. Among them, the lexicographically smallest is\n`atcoder`, so we can say S = `atcoder`.\n\n* * *"}, {"input": "??p??d??\n abc", "output": "UNRESTORABLE\n \n\nThere is no string that satisfies Condition 1, so the string S does not exist."}] |
Print the string S.
If such a string does not exist, print `UNRESTORABLE` instead.
* * * | s992448123 | Wrong Answer | p03565 | Input is given from Standard Input in the following format:
S
T' | w = input()
w1 = input()
num = len(w)
num1 = len(w1)
if num < num1:
b = False
for i in range(num - num1 + 1):
b = True
for j in range(num1):
if w[i + j] == "?" or w[i + j] == w1[j]:
pass
else:
b = False
if b:
start = i
break
| Statement
E869120 found a chest which is likely to contain treasure.
However, the chest is locked. In order to open it, he needs to enter a string
S consisting of lowercase English letters.
He also found a string S', which turns out to be the string S with some of its
letters (possibly all or none) replaced with `?`.
One more thing he found is a sheet of paper with the following facts written
on it:
* Condition 1: The string S contains a string T as a contiguous substring.
* Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1.
Print the string S.
If such a string does not exist, print `UNRESTORABLE`. | [{"input": "?tc????\n coder", "output": "atcoder\n \n\nThere are 26 strings that satisfy Condition 1: `atcoder`, `btcoder`,\n`ctcoder`,..., `ztcoder`. Among them, the lexicographically smallest is\n`atcoder`, so we can say S = `atcoder`.\n\n* * *"}, {"input": "??p??d??\n abc", "output": "UNRESTORABLE\n \n\nThere is no string that satisfies Condition 1, so the string S does not exist."}] |
Print the string S.
If such a string does not exist, print `UNRESTORABLE` instead.
* * * | s606634094 | Accepted | p03565 | Input is given from Standard Input in the following format:
S
T' | # -*- coding: utf-8 -*-
def zehnpaard():
s = input()
t = input()
def match(s1, t):
return all(a in (b, "?") for a, b in zip(s1, t))
substrings = [s[i : i + len(t)] for i in range(len(s) - len(t) + 1)]
res = "UNRESTORABLE"
for ss in reversed(substrings):
if match(ss, t):
left, _, right = s.rpartition(ss)
res = left + t + right
res = res.replace("?", "a")
break
print(res)
def main4():
s = input() # abcdr?tc????
t = input() # coder
def match(sub, t):
for i in range(len(t)):
if sub[i] == "?":
continue
if sub[i] == t[i]:
continue
return False
return True
substrings = []
for i in range(len(s) - len(t) + 1):
substrings.append(s[i : i + len(t)])
# ['c????', 'tc???', '?tc??', 'r?tc?', 'dr?tc', 'cdr?t', 'bcdr?', 'abcdr']
for sub in reversed(substrings):
if match(sub, t):
left, _, right = s.rpartition(sub)
result = (left + t + right).replace("?", "a")
print(result)
exit()
print("UNRESTORABLE")
def main3():
def product_mask_s(s, c):
import itertools
s_products = list(itertools.product(s, c))
s_masks = []
len_s = len(s)
for products in itertools.product(range(2), repeat=len_s):
t = ""
for i in range(len_s):
t += s_products[i][products[i]]
s_masks.append(t)
return s_masks
def main2():
"""TLE WA"""
# atcoder
# ?tc????
# ?t?o?er
import itertools
s_prime = input()
t_origin = input()
len_t = len(t_origin)
t_products = list(itertools.product(t_origin, "?"))
t_kouho = []
for products in itertools.product(range(2), repeat=len_t):
t = ""
for i in range(len_t):
t += t_products[i][products[i]]
t_kouho.append(t)
for t in t_kouho:
find_i = s_prime.find(t)
if find_i == -1:
continue
# 見つかったなら、tを代入する
ans = "{}{}{}".format(s_prime[:find_i], t_origin, s_prime[find_i + len_t :])
print(ans.replace("?", "a"))
exit()
print("UNRESTORABLE")
def main():
"""WA"""
s_change = lambda s, i, c: "{}{}{}".format(s[: i - 1], c, s[i - 1 + 1 :])
s_prime = input() # ?tc????
t_origin = input() # coder
# s_prime の中から tの部分文字列の位置を探す
len_t = len(t_origin)
t = t_origin
t_kouho = [t]
for t_i in range(1, len_t):
t_tail = s_change(t, len_t - t_i + 1, "?")
t_head = s_change(t, t_i, "?")
if t_tail == t_head:
t_kouho.append(t_tail)
else:
t_kouho.append(t_tail)
t_kouho.append(t_head)
t = s_change(t_tail, t_i, "?")
if t == "?" * len_t:
break
print(t_kouho)
for t in t_kouho:
t_i = s_prime.find(t)
if t_i == -1:
continue
# 見つかったなら、tを代入する
ans = "{}{}{}".format(s_prime[:t_i], t_origin, s_prime[t_i + len_t :])
print(ans.replace("?", "a"))
exit()
print("UNRESTORABLE")
if __name__ == "__main__":
main4()
| Statement
E869120 found a chest which is likely to contain treasure.
However, the chest is locked. In order to open it, he needs to enter a string
S consisting of lowercase English letters.
He also found a string S', which turns out to be the string S with some of its
letters (possibly all or none) replaced with `?`.
One more thing he found is a sheet of paper with the following facts written
on it:
* Condition 1: The string S contains a string T as a contiguous substring.
* Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1.
Print the string S.
If such a string does not exist, print `UNRESTORABLE`. | [{"input": "?tc????\n coder", "output": "atcoder\n \n\nThere are 26 strings that satisfy Condition 1: `atcoder`, `btcoder`,\n`ctcoder`,..., `ztcoder`. Among them, the lexicographically smallest is\n`atcoder`, so we can say S = `atcoder`.\n\n* * *"}, {"input": "??p??d??\n abc", "output": "UNRESTORABLE\n \n\nThere is no string that satisfies Condition 1, so the string S does not exist."}] |
Print the number of hours that will pass in World A.
The output will be regarded as correct when its absolute or relative error
from the judge's output is at most 10^{-3}.
* * * | s969004332 | Accepted | p03135 | Input is given from Standard Input in the following format:
T X | X, Y = map(int, input().split())
print(X / Y)
| Statement
In order to pass the entrance examination tomorrow, Taro has to study for T
more hours.
Fortunately, he can _leap_ to World B where time passes X times as fast as it
does in our world (World A).
While (X \times t) hours pass in World B, t hours pass in World A.
How many hours will pass in World A while Taro studies for T hours in World B? | [{"input": "8 3", "output": "2.6666666667\n \n\nWhile Taro studies for eight hours in World B where time passes three times as\nfast, 2.6666... hours will pass in World A.\n\nNote that an absolute or relative error of at most 10^{-3} is allowed.\n\n* * *"}, {"input": "99 1", "output": "99.0000000000\n \n\n* * *"}, {"input": "1 100", "output": "0.0100000000"}] |
Print the number of hours that will pass in World A.
The output will be regarded as correct when its absolute or relative error
from the judge's output is at most 10^{-3}.
* * * | s529140053 | Accepted | p03135 | Input is given from Standard Input in the following format:
T X | print(eval(input().replace(*" /")))
| Statement
In order to pass the entrance examination tomorrow, Taro has to study for T
more hours.
Fortunately, he can _leap_ to World B where time passes X times as fast as it
does in our world (World A).
While (X \times t) hours pass in World B, t hours pass in World A.
How many hours will pass in World A while Taro studies for T hours in World B? | [{"input": "8 3", "output": "2.6666666667\n \n\nWhile Taro studies for eight hours in World B where time passes three times as\nfast, 2.6666... hours will pass in World A.\n\nNote that an absolute or relative error of at most 10^{-3} is allowed.\n\n* * *"}, {"input": "99 1", "output": "99.0000000000\n \n\n* * *"}, {"input": "1 100", "output": "0.0100000000"}] |
Print the number of hours that will pass in World A.
The output will be regarded as correct when its absolute or relative error
from the judge's output is at most 10^{-3}.
* * * | s882266571 | Runtime Error | p03135 | Input is given from Standard Input in the following format:
T X | print(float(input()) / float(input()))
| Statement
In order to pass the entrance examination tomorrow, Taro has to study for T
more hours.
Fortunately, he can _leap_ to World B where time passes X times as fast as it
does in our world (World A).
While (X \times t) hours pass in World B, t hours pass in World A.
How many hours will pass in World A while Taro studies for T hours in World B? | [{"input": "8 3", "output": "2.6666666667\n \n\nWhile Taro studies for eight hours in World B where time passes three times as\nfast, 2.6666... hours will pass in World A.\n\nNote that an absolute or relative error of at most 10^{-3} is allowed.\n\n* * *"}, {"input": "99 1", "output": "99.0000000000\n \n\n* * *"}, {"input": "1 100", "output": "0.0100000000"}] |
Print the number of hours that will pass in World A.
The output will be regarded as correct when its absolute or relative error
from the judge's output is at most 10^{-3}.
* * * | s689261380 | Wrong Answer | p03135 | Input is given from Standard Input in the following format:
T X | print(input().replace(" ", "/"))
| Statement
In order to pass the entrance examination tomorrow, Taro has to study for T
more hours.
Fortunately, he can _leap_ to World B where time passes X times as fast as it
does in our world (World A).
While (X \times t) hours pass in World B, t hours pass in World A.
How many hours will pass in World A while Taro studies for T hours in World B? | [{"input": "8 3", "output": "2.6666666667\n \n\nWhile Taro studies for eight hours in World B where time passes three times as\nfast, 2.6666... hours will pass in World A.\n\nNote that an absolute or relative error of at most 10^{-3} is allowed.\n\n* * *"}, {"input": "99 1", "output": "99.0000000000\n \n\n* * *"}, {"input": "1 100", "output": "0.0100000000"}] |
Print the number of hours that will pass in World A.
The output will be regarded as correct when its absolute or relative error
from the judge's output is at most 10^{-3}.
* * * | s953478514 | Accepted | p03135 | Input is given from Standard Input in the following format:
T X | r, x = map(int, input().split())
print(r / x)
| Statement
In order to pass the entrance examination tomorrow, Taro has to study for T
more hours.
Fortunately, he can _leap_ to World B where time passes X times as fast as it
does in our world (World A).
While (X \times t) hours pass in World B, t hours pass in World A.
How many hours will pass in World A while Taro studies for T hours in World B? | [{"input": "8 3", "output": "2.6666666667\n \n\nWhile Taro studies for eight hours in World B where time passes three times as\nfast, 2.6666... hours will pass in World A.\n\nNote that an absolute or relative error of at most 10^{-3} is allowed.\n\n* * *"}, {"input": "99 1", "output": "99.0000000000\n \n\n* * *"}, {"input": "1 100", "output": "0.0100000000"}] |
Print the number of hours that will pass in World A.
The output will be regarded as correct when its absolute or relative error
from the judge's output is at most 10^{-3}.
* * * | s890092741 | Accepted | p03135 | Input is given from Standard Input in the following format:
T X | t, k = map(int, input().split())
print(t / k)
| Statement
In order to pass the entrance examination tomorrow, Taro has to study for T
more hours.
Fortunately, he can _leap_ to World B where time passes X times as fast as it
does in our world (World A).
While (X \times t) hours pass in World B, t hours pass in World A.
How many hours will pass in World A while Taro studies for T hours in World B? | [{"input": "8 3", "output": "2.6666666667\n \n\nWhile Taro studies for eight hours in World B where time passes three times as\nfast, 2.6666... hours will pass in World A.\n\nNote that an absolute or relative error of at most 10^{-3} is allowed.\n\n* * *"}, {"input": "99 1", "output": "99.0000000000\n \n\n* * *"}, {"input": "1 100", "output": "0.0100000000"}] |
Print the number of hours that will pass in World A.
The output will be regarded as correct when its absolute or relative error
from the judge's output is at most 10^{-3}.
* * * | s653757925 | Accepted | p03135 | Input is given from Standard Input in the following format:
T X | m, n = map(int, input().split())
print(m / n)
| Statement
In order to pass the entrance examination tomorrow, Taro has to study for T
more hours.
Fortunately, he can _leap_ to World B where time passes X times as fast as it
does in our world (World A).
While (X \times t) hours pass in World B, t hours pass in World A.
How many hours will pass in World A while Taro studies for T hours in World B? | [{"input": "8 3", "output": "2.6666666667\n \n\nWhile Taro studies for eight hours in World B where time passes three times as\nfast, 2.6666... hours will pass in World A.\n\nNote that an absolute or relative error of at most 10^{-3} is allowed.\n\n* * *"}, {"input": "99 1", "output": "99.0000000000\n \n\n* * *"}, {"input": "1 100", "output": "0.0100000000"}] |
Print the number of hours that will pass in World A.
The output will be regarded as correct when its absolute or relative error
from the judge's output is at most 10^{-3}.
* * * | s128746424 | Runtime Error | p03135 | Input is given from Standard Input in the following format:
T X | T, X = map(int, input().split()))
print(T/X) | Statement
In order to pass the entrance examination tomorrow, Taro has to study for T
more hours.
Fortunately, he can _leap_ to World B where time passes X times as fast as it
does in our world (World A).
While (X \times t) hours pass in World B, t hours pass in World A.
How many hours will pass in World A while Taro studies for T hours in World B? | [{"input": "8 3", "output": "2.6666666667\n \n\nWhile Taro studies for eight hours in World B where time passes three times as\nfast, 2.6666... hours will pass in World A.\n\nNote that an absolute or relative error of at most 10^{-3} is allowed.\n\n* * *"}, {"input": "99 1", "output": "99.0000000000\n \n\n* * *"}, {"input": "1 100", "output": "0.0100000000"}] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.