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
If Takahashi will win, print `Yes`; if he will lose, print `No`. * * *
s554693997
Wrong Answer
p02700
Input is given from Standard Input in the following format: A B C D
A, B, C, D = map(int, input().split()) a1 = C - B if a1 <= 0: print("Yes") a2 = A - D if a2 <= 0: print("No") a3 = a1 - B if a3 <= 0: print("Yes") a4 = a2 - D if a4 <= 0: print("No") a5 = a3 - B if a5 <= 0: print("Yes") a6 = a4 - D if a6 <= 0: print("No") a7 = a5 - B if a7 <= 0: print("Yes") a8 = a6 - D if a8 <= 0: print("No") a9 = a7 - B if a9 <= 0: print("Yes") a10 = a8 - D if a10 <= 0: print("No") a11 = a9 - B if a11 <= 0: print("Yes") a12 = a10 - D if a12 <= 0: print("No") a13 = a11 - B if a13 <= 0: print("Yes") a14 = a12 - D if a14 <= 0: print("No") a15 = a13 - B if a15 <= 0: print("Yes") a16 = a14 - D if a16 <= 0: print("No") a17 = a15 - B if a17 <= 0: print("Yes") a18 = a16 - D if a16 <= 0: print("No") a19 = a17 - B if a19 <= 0: print("Yes") a20 = a18 - D if a20 <= 0: print("No") a21 = a19 - B if a21 <= 0: print("Yes") a22 = a20 - D if a22 <= 0: print("No") a23 = a21 - B if a23 <= 0: print("Yes") a24 = a22 - D if a24 <= 0: print("No") a25 = a23 - B if a25 <= 0: print("Yes") a26 = a24 - D if a26 <= 0: print("No")
Statement Takahashi and Aoki will have a battle using their monsters. The health and strength of Takahashi's monster are A and B, respectively, and those of Aoki's monster are C and D, respectively. The two monsters will take turns attacking, in the order Takahashi's, Aoki's, Takahashi's, Aoki's, ... Here, an attack decreases the opponent's health by the value equal to the attacker's strength. The monsters keep attacking until the health of one monster becomes 0 or below. The person with the monster whose health becomes 0 or below loses, and the other person wins. If Takahashi will win, print `Yes`; if he will lose, print `No`.
[{"input": "10 9 10 10", "output": "No\n \n\nFirst, Takahashi's monster attacks Aoki's monster, whose health is now 10-9=1.\n\nNext, Aoki's monster attacks Takahashi's monster, whose health is now 10-10=0.\n\nTakahashi's monster is the first to have 0 or less health, so Takahashi loses.\n\n* * *"}, {"input": "46 4 40 5", "output": "Yes"}]
For each 0, print the car number.
s266201049
Accepted
p00013
car number car number or 0 car number or 0 . . . car number or 0 The number of input lines is less than or equal to 100.
try: l = [] while 1: d = int(input()) if d: l.append(d) else: print(l.pop()) except: pass
Switching Railroad Cars ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars) This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top- right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. We can simulate the movement (comings and goings) of the cars as follow: * An entry of a car is represented by its number. * An exit of a car is represented by 0 For example, a sequence 1 6 0 8 10 demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks.
[{"input": "6\n 0\n 8\n 10\n 0\n 0\n 0", "output": "10\n 8\n 1"}]
Print the answer. * * *
s538070835
Runtime Error
p03795
The input is given from Standard Input in the following format: N
test
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s912021125
Accepted
p03795
The input is given from Standard Input in the following format: N
# # abc055 a # import sys from io import StringIO import unittest class TestClass(unittest.TestCase): def assertIO(self, input, output): stdout, stdin = sys.stdout, sys.stdin sys.stdout, sys.stdin = StringIO(), StringIO(input) resolve() sys.stdout.seek(0) out = sys.stdout.read()[:-1] sys.stdout, sys.stdin = stdout, stdin self.assertEqual(out, output) def test_入力例_1(self): input = """20""" output = """15800""" self.assertIO(input, output) def test_入力例_2(self): input = """60""" output = """47200""" self.assertIO(input, output) def resolve(): N = int(input()) x = N * 800 y = N // 15 * 200 print(x - y) if __name__ == "__main__": # unittest.main() resolve()
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s220675966
Accepted
p03795
The input is given from Standard Input in the following format: N
print( ( lambda x=input(): ( int(x) * 800 if int(x) < 15 else (int(x) * 800 - (200) * int(int(x) / 15)) ) )() )
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s911932502
Wrong Answer
p03795
The input is given from Standard Input in the following format: N
print(10 ** int(input()) + 7)
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s173257606
Wrong Answer
p03795
The input is given from Standard Input in the following format: N
print(int(input()) * (2440 // 3))
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s839815893
Runtime Error
p03795
The input is given from Standard Input in the following format: N
print(input() - input() // 15 * 200)
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s386695361
Runtime Error
p03795
The input is given from Standard Input in the following format: N
num = input() get = num // 15 print(num * 800 - get * 200)
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s197827344
Wrong Answer
p03795
The input is given from Standard Input in the following format: N
e = int(input()) print(int(e / 15)) print(e * 800 - (int(e / 15) * 200))
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s668717887
Accepted
p03795
The input is given from Standard Input in the following format: N
print(sum([800 - 200 if i % 15 == 0 else 800 for i in range(1, int(input()) + 1)]))
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s472441660
Runtime Error
p03795
The input is given from Standard Input in the following format: N
def next_to_you(t, a): if a == "o": if t[-1] == "S": if t[-2] == "W": return "W" elif t[-2] == "S": return "S" elif t[-1] == "W": if t[-2] == "W": return "S" elif t[-2] == "S": return "W" elif a == "x": if t[-1] == "S": if t[-2] == "W": return "S" elif t[-2] == "S": return "W" elif t[-1] == "W": if t[-2] == "W": return "W" elif t[-2] == "S": return "S" n = int(input()) s = input() t1, t2, t3, t4 = "SS", "SW", "WS", "WW" for i in range(1, n): t1 += next_to_you(t1, s[i]) t2 += next_to_you(t2, s[i]) t3 += next_to_you(t3, s[i]) t4 += next_to_you(t4, s[i]) ans = -1 for i in [t1, t2, t3, t4]: if i[0] == i[-1]: ans = i[:n] break print(ans)
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s031391465
Runtime Error
p03795
The input is given from Standard Input in the following format: N
S = list(map(int, input().split())) N = S[0] M = S[1] N1 = 0 M1 = 0 count = 0 if N < 2 * M: count = N N1 = 0 M1 = M - 2 * N count += M1 // 4 else: count += M // 2 print(count)
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s346431735
Runtime Error
p03795
The input is given from Standard Input in the following format: N
N = int(input()) s = str(input()) A = '' def majikayo(): k = 0 if A[0] == 'S' and s[0] == 'o': if A[1] == A[-1]: if A[-1] = 'S' and s[-1] == 'o': if A[0] == A[-2]: k = 1 elif A[-1] = 'S' and s[-1] == 'x': if A[0] != A[-2]: k = 1 elif A[-1] = 'W' and s[-1] == 'o': if A[0] != A[-2]: k = 1 elif A[-1] = 'W' and s[-1] == 'x': if A[0] == A[-2]: k = 1 elif A[0] == 'S' and s[0] == 'x': if A[1] != A[-1]: if A[-1] = 'S' and s[-1] == 'o': if A[0] == A[-2]: k = 1 elif A[-1] = 'S' and s[-1] == 'x': if A[0] != A[-2]: k = 1 elif A[-1] = 'W' and s[-1] == 'o': if A[0] != A[-2]: k = 1 elif A[-1] = 'W' and s[-1] == 'x': if A[0] == A[-2]: k = 1 elif A[0] == 'W' and s[0] == 'o': if A[1] != A[-1]: if A[-1] = 'S' and s[-1] == 'o': if A[0] == A[-2]: k = 1 elif A[-1] = 'S' and s[-1] == 'x': if A[0] != A[-2]: k = 1 elif A[-1] = 'W' and s[-1] == 'o': if A[0] != A[-2]: k = 1 elif A[-1] = 'W' and s[-1] == 'x': if A[0] == A[-2]: k = 1 elif A[0] == 'W' and s[0] == 'x': if A[1] == A[-1]: if A[-1] = 'S' and s[-1] == 'o': if A[0] == A[-2]: k = 1 elif A[-1] = 'S' and s[-1] == 'x': if A[0] != A[-2]: k = 1 elif A[-1] = 'W' and s[-1] == 'o': if A[0] != A[-2]: k = 1 elif A[-1] = 'W' and s[-1] == 'x': if A[0] == A[-2]: k = 1 if k == 1: return 1 A = 'SS' for i in range(1,N-1): if s[i] == 'o' and A[i] == 'S': if A[i-1] == 'S': A += 'S' else: A += 'W' elif s[i] == 'o' and A[i] == 'W': if A[i-1] == 'S': A += 'W' else: A += 'S' elif s[i] == 'x' and A[i] == 'S': if A[i-1] == 'S': A += 'W' else: A += 'S' elif s[i] == 'x' and A[i] == 'W': if A[i-1] == 'S': A += 'S' else: A += 'W' if majikayo() == 1: print(A) else: A = 'SW' for i in range(1,N-1): if s[i] == 'o' and A[i] == 'S': if A[i-1] == 'S': A += 'S' else: A += 'W' elif s[i] == 'o' and A[i] == 'W': if A[i-1] == 'S': A += 'W' else: A += 'S' elif s[i] == 'x' and A[i] == 'S': if A[i-1] == 'S': A += 'W' else: A += 'S' elif s[i] == 'x' and A[i] == 'W': if A[i-1] == 'S': A += 'S' else: A += 'W' if majikayo() == 1: print(A) else: A = 'WS' for i in range(1,N-1): if s[i] == 'o' and A[i] == 'S': if A[i-1] == 'S': A += 'S' else: A += 'W' elif s[i] == 'o' and A[i] == 'W': if A[i-1] == 'S': A += 'W' else: A += 'S' elif s[i] == 'x' and A[i] == 'S': if A[i-1] == 'S': A += 'W' else: A += 'S' elif s[i] == 'x' and A[i] == 'W': if A[i-1] == 'S': A += 'S' else: A += 'W' if majikayo() == 1: print(A) else: A = 'WW' for i in range(1,N-1): if s[i] == 'o' and A[i] == 'S': if A[i-1] == 'S': A += 'S' else: A += 'W' elif s[i] == 'o' and A[i] == 'W': if A[i-1] == 'S': A += 'W' else: A += 'S' elif s[i] == 'x' and A[i] == 'S': if A[i-1] == 'S': A += 'W' else: A += 'S' elif s[i] == 'x' and A[i] == 'W': if A[i-1] == 'S': A += 'S' else: A += 'W' if majikayo() == 1: print(A) else: print(-1)
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s868125680
Runtime Error
p03795
The input is given from Standard Input in the following format: N
def main(): N = int(input()) s = input() arr = [""] * N for i in range(N): if s[i] == "x": arr[i] = "S" cur = "S" ind = 0 while ind < N: while ind < N and s[ind] != "x": arr[ind] = cur ind += 1 if cur == "S": cur = "W" else: cur = "S" if ind >= N: break if s[ind] == "x": ind += 1 while ind < N and s[ind] == "x": arr[ind] = cur if cur == "S": cur = "W" else: cur = "S" ind += 1 arr[ind - 1] = "S" if arr[ind - 2] == "S": cur = "W" else: cur = "S" if ind >= N: break if s[N - 1] == "o": if arr[N - 1] == "S" and arr[N - 2] == arr[0]: print("".join(arr)) elif arr[N - 1] == "W" and arr[N - 2] != arr[0]: print("".join(arr)) else: print("-1") else: if arr[N - 1] == "W" and arr[N - 2] == arr[0]: print("".join(arr)) elif arr[N - 1] == "S" and arr[N - 2] != arr[0]: print("".join(arr)) else: print("-1") main()
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s765446508
Runtime Error
p03795
The input is given from Standard Input in the following format: N
s = int(input()) print(i * 800 - (i // 15) * 200)
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s767393533
Runtime Error
p03795
The input is given from Standard Input in the following format: N
print(800 * int(input()) - 200 * (n // 15))
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s321180132
Runtime Error
p03795
The input is given from Standard Input in the following format: N
n = int(input()) print(800*n - 200*(n//15)
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s253187847
Runtime Error
p03795
The input is given from Standard Input in the following format: N
N = int(input()) print(N*500-200*(N//15)
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s474051978
Runtime Error
p03795
The input is given from Standard Input in the following format: N
= int(input()) print(N * 800 - ((N // 15) * 200))
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s087816030
Runtime Error
p03795
The input is given from Standard Input in the following format: N
print(800 * int(input()) - 200 * (int(input()) // 15))
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s509121386
Runtime Error
p03795
The input is given from Standard Input in the following format: N
print((int(input()) + int(input())) * int(input()) // 2)
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s189502353
Runtime Error
p03795
The input is given from Standard Input in the following format: N
n=int(input()) k=n//15 print(int(800n-200k))
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s477811684
Runtime Error
p03795
The input is given from Standard Input in the following format: N
n = int(input()) print(800 * n - (n // 15) * 200
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s354397161
Runtime Error
p03795
The input is given from Standard Input in the following format: N
n = int(input()) print((800*n) - (n//15*200))
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s195246361
Accepted
p03795
The input is given from Standard Input in the following format: N
num_meals = int(input()) print(800 * num_meals - (num_meals // 15 * 200))
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s184183513
Accepted
p03795
The input is given from Standard Input in the following format: N
print((lambda N: 800 * N - N // 15 * 200)(int(input())))
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s845930978
Runtime Error
p03795
The input is given from Standard Input in the following format: N
import numpy as np n,m=map(int, input().split()) if n>=m/2: print("m//2") else: m_aft = m -2*n m_fin = m_aft//4 print(n+m_fin)
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s702809026
Runtime Error
p03795
The input is given from Standard Input in the following format: N
import numpy as np n,m=map(int, input().split()) if n>=m/2: m_fin = m//2 print(m_fin) else: m_aft = m -2*n m_fin = m_aft//4 print(n+m_fin)
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s833577324
Runtime Error
p03795
The input is given from Standard Input in the following format: N
n = int(input()) k = n//15 cost = n*800 return = k*200 print(cost - return)
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s929508009
Runtime Error
p03795
The input is given from Standard Input in the following format: N
a, b = map(str, input().split()) if a == b: print("H") else: print("D")
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s354661866
Runtime Error
p03795
The input is given from Standard Input in the following format: N
import numpy as np n,m=map(int, input().split()) if n>=m/2: m_fin = m//2 print(m_fin) else: m_aft = m -2*n m_fin = m_aft//4 print(n+m_fin)
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
Print the answer. * * *
s753100655
Runtime Error
p03795
The input is given from Standard Input in the following format: N
N = int(input()) s = str(input()) ss = s if N % 2 == 1: s += s[0] if s[: len(s) / 2] * 2 != s: print(-1) else: ans = "" Flag = 0 for c in ss: if Flag == 0: ans += "S" if c == "x": Flag = 1 else: if c == "x": ans += "S" Flag = 0 else: ans += "W" print(ans)
Statement Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
[{"input": "20", "output": "15800\n \n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen.\nThus, the answer is 15800.\n\n* * *"}, {"input": "60", "output": "47200\n \n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800\nyen."}]
If there exists a pair of sequences a and b that satisfies the properties and is consistent with Snuke's memory, print three lines. The first line must contain the sequence a, the second line must contain the length of the sequence b, and the third line must contain the sequence b. If such a pair does not exist (because Snuke's memory is wrong or some other reason), print a single line containing the word `Impossible` (case- sensitive). * * *
s347349727
Runtime Error
p04050
The input is given from Standard Input in the following format: N M A_1 A_2 ... A_M
import sys readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**7) N, M = map(int, readline().split()) A = [int(x) for x in readline().split()] OD = [x for x in A if x & 1] EV = [x for x in A if not x & 1] if len(OD) >= 3: print("Impossible") exit() if len(A) == 1: if N == 1: B = [1] else: B = [1, N - 1] elif len(OD) == 0: B = A.copy() B[0] -= 1 B[-1] += 1 elif len(OD) == 1: A = OD + EV B = A.copy() B[0] += 1 B[-1] -= 1 else: A = OD[0] + EV + OD[-1] B = A.copy() B[0] += 1 B[-1] -= 1 B = [x for x in B if x > 0] print(*A) print(len(B)) print(*B)
Statement Snuke got a present from his mother on his birthday. The present was a pair of two sequences a and b, consisting of positive integers. They satisfied all of the following properties: * The sum of all elements of a is N. * The sum of all elements of b is N. * Any string of length N that satisfies the following two conditions (1) and (2) will also satisfy the condition (3). * **(1)** Any of the following forms a palindrome: the first a_1 letters, the following a_2 letters, the following a_3 letters and so on. * **(2)** Any of the following forms a palindrome: the first b_1 letters, the following b_2 letters, the following b_3 letters and so on. * **(3)** All N letters are the same. He was happy, until one day he lost both of the sequences. Now, he only remembers that the sequence a was a permutation of another sequence A of length M. To bring him happiness again, his mother has decided to give him another pair of sequences a and b that satisfies his favorite properties and is consistent with his memory.
[{"input": "3 2\n 2 1", "output": "1 2\n 1\n 3\n \n\n* * *"}, {"input": "6 1\n 6", "output": "6\n 3\n 1 2 3\n \n\n* * *"}, {"input": "55 10\n 1 2 3 4 5 6 7 8 9 10", "output": "Impossible"}]
Print the final number of slimes. * * *
s732003507
Wrong Answer
p02887
Input is given from Standard Input in the following format: N S
A = int(input()) B = input() C = [] for i in range(len(B) - 1): if B[i] == B[i + 1]: C.append(i + 1) print(len(C))
Statement There are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S. Adjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime. Ultimately, how many slimes will be there?
[{"input": "10\n aabbbbaaca", "output": "5\n \n\nUltimately, these slimes will fuse into `abaca`.\n\n* * *"}, {"input": "5\n aaaaa", "output": "1\n \n\nAll the slimes will fuse into one.\n\n* * *"}, {"input": "20\n xxzaffeeeeddfkkkkllq", "output": "10"}]
Print the final number of slimes. * * *
s773378317
Accepted
p02887
Input is given from Standard Input in the following format: N S
_, S = input(), input() print(sum(1 for a, b in zip("0" + S, S) if a != b))
Statement There are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S. Adjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime. Ultimately, how many slimes will be there?
[{"input": "10\n aabbbbaaca", "output": "5\n \n\nUltimately, these slimes will fuse into `abaca`.\n\n* * *"}, {"input": "5\n aaaaa", "output": "1\n \n\nAll the slimes will fuse into one.\n\n* * *"}, {"input": "20\n xxzaffeeeeddfkkkkllq", "output": "10"}]
Print the final number of slimes. * * *
s815783922
Wrong Answer
p02887
Input is given from Standard Input in the following format: N S
a = input().split() print(a)
Statement There are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S. Adjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime. Ultimately, how many slimes will be there?
[{"input": "10\n aabbbbaaca", "output": "5\n \n\nUltimately, these slimes will fuse into `abaca`.\n\n* * *"}, {"input": "5\n aaaaa", "output": "1\n \n\nAll the slimes will fuse into one.\n\n* * *"}, {"input": "20\n xxzaffeeeeddfkkkkllq", "output": "10"}]
Print the final number of slimes. * * *
s445044084
Accepted
p02887
Input is given from Standard Input in the following format: N S
def solve(s: str) -> int: ret = 0 cur_c = None for c in s: if c != cur_c: ret += 1 cur_c = c return ret n = int(input().strip()) s = input().strip() print(solve(s))
Statement There are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S. Adjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime. Ultimately, how many slimes will be there?
[{"input": "10\n aabbbbaaca", "output": "5\n \n\nUltimately, these slimes will fuse into `abaca`.\n\n* * *"}, {"input": "5\n aaaaa", "output": "1\n \n\nAll the slimes will fuse into one.\n\n* * *"}, {"input": "20\n xxzaffeeeeddfkkkkllq", "output": "10"}]
Print the area of this yard excluding the roads (in square yards). * * *
s152356268
Accepted
p03280
Input is given from Standard Input in the following format: A B
eval("print((" + input().replace(" ", "-1)*(") + "-1))")
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s881833077
Accepted
p03280
Input is given from Standard Input in the following format: A B
w, h = map(int, input().split(" ")) print((w - 1) * (h - 1))
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s873833423
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
a,b = map(int,input().split()) print(a*b - (a+b-1)
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s457723467
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
eval('print(('+input().replace(' ','-1)*(')+'-1))'
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s395969270
Accepted
p03280
Input is given from Standard Input in the following format: A B
from copy import deepcopy from sys import exit, setrecursionlimit import math from collections import defaultdict, Counter, deque from fractions import Fraction as frac setrecursionlimit(1000000) def main(): a, b = map(int, input().split()) print((a - 1) * (b - 1)) 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 gcd(l): x = l.pop() y = l.pop() while x % y != 0: z = x % y x = y y = z l.append(min(x, y)) return gcd(l) if len(l) > 1 else l[0] 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] main()
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s625738529
Accepted
p03280
Input is given from Standard Input in the following format: A B
import math # inputList=[] # for i in range(6): # inputNum = input() # inputList.append(inputNum) inputa = input().split() # inputb = input().split() # inputa = [int(n) for n in inputa] # inputa.sort() a = int(inputa[0]) b = int(inputa[1]) # c = int(inputa[2]) # x = int(inputb[0]) # y = int(inputb[1]) print(a * b - a - b + 1)
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s747564341
Accepted
p03280
Input is given from Standard Input in the following format: A B
l = input().split() A = int(l[0]) B = int(l[1]) total = A * B michi = A + B - 1 hatake = total - michi print(hatake)
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s015900527
Accepted
p03280
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() print((A - 1) * (B - 1))
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s764275974
Accepted
p03280
Input is given from Standard Input in the following format: A B
# abc106_a.py # https://atcoder.jp/contests/abc106/tasks/abc106_a # A - Garden / # 実行時間制限: 2 sec / メモリ制限: 1000 MB # 配点: 100点 # 問題文 # 縦 Aヤード、横 B ヤードの畑がある. # 農夫ジョンは, 畑の内部に, 畑の上端と下端を結ぶ縦方向の幅 1 ヤードの道, 畑の左端と畑の右端を結ぶ横方向の幅 1ヤードの道を作った. # 畑は下図のようになっている. (灰色の部分が道) # さて, 道を除いた畑の面積は, 何平方ヤードだろうか? 求めなさい. # 注意 # 道の位置が変わっても, 道を除く畑の面積が変わらないことが証明できます. # 制約 # Aは 2 以上 100以下の整数 # Bは 2 以上 100以下の整数 # 入力 # 入力は以下の形式で標準入力から与えられる. # A B # 出力 # 道を除いた畑の面積 (平方ヤード) を出力しなさい. # 入力例 1 # 2 2 # 出力例 1 # 1 # この場合, 面積は 1平方ヤードになる. # 入力例 2 # 5 7 # 出力例 2 # 24 # この場合, 面積は 24平方ヤードになる. def calculation(lines): A, B = list(map(int, lines[0].split())) return [(A - 1) * (B - 1)] # 引数を取得 def get_input_lines(lines_count): lines = list() for _ in range(lines_count): lines.append(input()) return lines # テストデータ def get_testdata(pattern): if pattern == 1: lines_input = ["2 2"] lines_export = [1] if pattern == 2: lines_input = ["5 7"] lines_export = [24] return lines_input, lines_export # 動作モード判別 def get_mode(): import sys args = sys.argv if len(args) == 1: mode = 0 else: mode = int(args[1]) return mode # 主処理 def main(): mode = get_mode() if mode == 0: lines_input = get_input_lines(1) else: lines_input, lines_export = get_testdata(mode) lines_result = calculation(lines_input) for line_result in lines_result: print(line_result) # if mode > 0: # print(f'lines_input=[{lines_input}]') # print(f'lines_export=[{lines_export}]') # print(f'lines_result=[{lines_result}]') # if lines_result == lines_export: # print('OK') # else: # print('NG') # 起動処理 if __name__ == "__main__": main()
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s170310111
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
(A - 1) * (B - 1)
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s658326808
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
print(eval('~-'+'*~-'.join(input().split()))
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s313238239
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
a,b=input().split() print((int(a)-1)*(int(b)-))
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s264182095
Accepted
p03280
Input is given from Standard Input in the following format: A B
n, m = (int(i) - 1 for i in input().strip().split(" ")) print(n * m)
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s028306262
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
A,B=[int(a) for input().split(" ")] print((A-1)*(B-1))
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s465268003
Accepted
p03280
Input is given from Standard Input in the following format: A B
N, M = map(int, input().split()) print(N * M - N - M + 1)
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s160970171
Accepted
p03280
Input is given from Standard Input in the following format: A B
N, K = map(int, input().split()) print((N - 1) * (K - 1))
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s714352507
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
n = list(map(int, input().split())) print(n[0]*n[1})
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s429295893
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
r = int(input()) l = int(input()) print((r - 1) * (l - 1))
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s075423774
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
A, B = map(int, input().split()) print ((A-1)*(B-1)
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s020615896
Accepted
p03280
Input is given from Standard Input in the following format: A B
x = input().split() a = int(x[0]) b = int(x[1]) print(a * b - ((a + b) - 1))
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s459882442
Accepted
p03280
Input is given from Standard Input in the following format: A B
print((lambda a, b: (a - 1) * (b - 1))(*map(int, input().split())))
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s226216795
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
n = int(input()) l = 0 for i in range(1, n + 1): if i % 2 == 1: p = 0 for k in range(1, i + 1): if i % k == 0: p += 1 if p == 8: l += 1 print(l)
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s424253959
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
num = input().split(' ') print((int(num[0]) - 1)*(int(num[1]) - 1))
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s685037438
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
a = list(map(int, input().split())) print(a[0] * a[1] - (1 * a[0]) - (1 * a[1
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s031278852
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
n = int(input()) print(4 if n >= 189 else 3 if n >= 165 else 2 if n >=n 135 else 1 if n >= 105 else 0)
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s295642042
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
n = int(input()) print(4 if n >= 189 else 3 if n >= 165 else if 2 if n >= 135 else 1 if n >= 105 else 0)
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s696777662
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
i = 105 N = input() N = int(N) m = 5 n = 0 x = 0 y = 0 while i <= N: if i % 2 != 0: if i % 3 == 0: n = int(i / 3) while m < n: if i % m == 0: x = x + 1 m = m + 2 if x == 4: y = y + 1 x = 0 n = 0 m = 5 i = i + 1 print(y)
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s316239725
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
n, m, q = map(int, input().split()) rails = [tuple(map(int, input().split())) for i in range(m)] qs = [tuple(map(int, input().split())) for i in range(q)] enuq = list(enumerate(qs)) enuq.sort(key=lambda x: x[1][0]) ansli = [0 for i in range(q)] for i, (p, q) in enuq: removelist = [] for j, (l, r) in enumerate(rails): if p <= l and r <= q: ansli[i] = ansli[i] + 1 elif l < p: removelist.append(j) for jj in removelist: rails.pop(jj) for a in ansli: print(a)
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s919776233
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
import sys N = float(input()) t = 3 prime_number = [] while t <= N / 15.0: l = [] for i in range(t + 1): if i != 0: if t % i == 0: l.append(i) if l == [1, t]: prime_number.append(t) t += 1 n = len(prime_number) ans = 0 if n < 3: print(0) sys.exit() else: for i in prime_number: for j in prime_number: if j != i: for k in prime_number: if k != i and k != j: if i * j * k <= N: ans += 1 ans = ans / 6 if N >= 189: ans += 2 elif N >= 135: ans += 1 print(int(ans))
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s394081527
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
# 二次元累積和 # A[i1, j1] から A[i2, j2] までの長方形の積算値は # Acum[i2 + 1][j2 + 1] - Acum[i1][j2 + 1] - Acum[i2 + 1][j1] + Acum[i1][j1] def two_dim_accumulate(a) -> list: h, w = len(a), len(a[0]) acum = [[0 for _ in range(w + 1)] for _ in range(h + 1)] for i in range(h): for j in range(w): acum[i + 1][j + 1] = a[i][j] for i in range(1, h + 1): for j in range(1, w + 1): acum[i][j] += acum[i][j - 1] for j in range(1, w + 1): for i in range(1, h + 1): acum[i][j] += acum[i - 1][j] return acum Acum = two_dim_accumulate(A) # for a in Acum: # print(a)
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s263882257
Accepted
p03280
Input is given from Standard Input in the following format: A B
S, T = map(int, input().split()) print(~-S * ~-T)
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s998019062
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
a,b = map(int, input().split()) print(a*b a-b)
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s574595293
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
S, T = map(int, input().split()) print(~-S*~-T)
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s476003430
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
b, c = map(int, input().split()) print(B * C - B - C + 1)
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s968450960
Wrong Answer
p03280
Input is given from Standard Input in the following format: A B
a = input()
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s078789081
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
a,b=map(int input().split()) print(a*b-a-b+1)
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s225668947
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
A,B=map(int,input().split()) print((A-1)*(B-1)))
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s699041459
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
x,y=map(int,input().split() print((x-1)*(y-1))
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s776863463
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
A,B=map(int,input()split()) print(A*B-A-B+1)
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s689702785
Wrong Answer
p03280
Input is given from Standard Input in the following format: A B
print((input().replace("1", "") + "1")[0])
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s620925021
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
print((int(input) - 1) * (int(input) - 1))
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s100529063
Accepted
p03280
Input is given from Standard Input in the following format: A B
X = list(map(int, input().split())) print((X[0] - 1) * (X[1] - 1))
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s084748303
Accepted
p03280
Input is given from Standard Input in the following format: A B
row, col = map(int, input().split()) print((row - 1) * (col - 1))
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s228817291
Accepted
p03280
Input is given from Standard Input in the following format: A B
h, w = map(int, input().split()) h -= 1 w -= 1 print(h * w)
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s370768567
Accepted
p03280
Input is given from Standard Input in the following format: A B
A = list(map(int, input().split())) print((A[0] - 1) * (A[1] - 1))
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s765962743
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
a,b = map(int,input().split(“ “)) print((a - 1) * (b - 1))
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s540521077
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
l = int(input().split()) print(l[0] * l[1] - (l[0] + l[1] - 1))
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s125220210
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
A, B=map(int, input().split() S=(A-1)*(B-1) print(S)
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s726840992
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
a,b = map(int,input().split(‘ ‘)) print((a - 1) * (b - 1))
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s346262481
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
A,B=list(map(int,input.split())) print((A-1)*(B-1) + )
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s124106695
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
a,b = map(int,input().split()) print((a*b)-a-b+1))
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s656691870
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
a,b = map(int,input().split()) print((a-1)*(b-1))
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s601526900
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
n, m, q = map(int, input().split()) image = [[0] * n for _ in range(n)] for _ in range(m): l, r = map(int, input().split()) image[l - 1][r - 1] += 1 sumimage = [[0] * (n + 1) for _ in range(n + 1)] for l in range(1, n + 1): s = 0 for r in range(1, n + 1): s += image[l - 1][r - 1] sumimage[l][r] = sumimage[l - 1][r] + s for _ in range(q): a, b = map(int, input().split()) c = sumimage[b][b] - sumimage[a - 1][b] print(c)
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s484491638
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
import math a = input().split("¥n") K = int(a[1]) S_len = len(a[0]) print("K=" + str(K) + " S_len=" + str(S_len)) for i in range(S_len): # print("i="+str(i) +" n="+a[0][i]) n = int(a[0][i]) # print("i="+str(i) +" n="+str(n)) # if(n==1): # K-=1 # if(K<=0): # print("1") # break # else: L = int(K * math.log10(n)) # print("K="+str(K) +" L="+str(L)) K -= L + 1 if K <= 0: print(n) break
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s030690613
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
a = int(input()) b = [3, 5, 7, 11, 13, 17, 19] c = d = 0 if a < 105: a = 104 for i in range(103, a): for j in b: if a % j == 0: c += 1 if c == 3: d += 1 c = 0 print(d)
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s267060469
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
import math N = int(input()) # def yakusuu(x): # tmplist=list(sy.factorint(x).values()) # a=1 # for i in tmplist: # a*=i+1 # return a def make_prime_list_2(num): if num < 2: return [] # 0のものは素数じゃないとする prime_list = [i for i in range(num + 1)] prime_list[1] = 0 # 1は素数ではない num_sqrt = math.sqrt(num) for prime in prime_list: if prime == 0: continue if prime > num_sqrt: break for non_prime in range(2 * prime, num, prime): prime_list[non_prime] = 0 return [prime for prime in prime_list if prime != 0] def search_divisor_num_1(num): if num < 0: return None elif num == 1: return 1 else: num_sqrt = math.floor(math.sqrt(num)) prime_list = make_prime_list_2(num_sqrt) divisor_num = 1 for prime in prime_list: count = 1 while num % prime == 0: num //= prime count += 1 divisor_num *= count if num != 1: divisor_num *= 2 return divisor_num counter = 0 for i in range(1, N + 1, 2): if search_divisor_num_1(i) == 8: counter += 1 print(counter)
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s519174999
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
a,b = map(int,input().split()) print((a-1)*(b-1)
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s482446479
Accepted
p03280
Input is given from Standard Input in the following format: A B
N, Y = input().split() n = int(N) y = int(Y) print(n * y - n - y + 1)
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s472474945
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
a,b=input().split. A=int(a) B=int(b) print((A-1)*(B-1))
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s349806516
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
A B = map(int,input().split(' ')) print((A-1) * (B-1))
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the area of this yard excluding the roads (in square yards). * * *
s569340393
Runtime Error
p03280
Input is given from Standard Input in the following format: A B
a,b = map(int,input().split(‘ ‘)) print((a - 1) * (b - 1))
Statement There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) ![ ](https://img.atcoder.jp/ghi/27d063746b460f1132b6a99aa535a562.png) What is the area of this yard excluding the roads? Find it.
[{"input": "2 2", "output": "1\n \n\nIn this case, the area is 1 square yard.\n\n* * *"}, {"input": "5 7", "output": "24\n \n\nIn this case, the area is 24 square yards."}]
Print the length of the shortest path from Vertex 1 to Vertex N in the final graph. If there is no shortest path, print `-1` instead. * * *
s944720052
Accepted
p02868
Input is given from Standard Input in the following format: N M L_1 R_1 C_1 : L_M R_M C_M
import sys input = sys.stdin.readline def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def main(): N, M = MI() inf = 10**16 class SegTree: def __init__(self, N, ide, segfunc=min): self.ide_ele = ide """ ex) 最小値のセグ木 → +inf 和のセグ木 → 0 積のセグ木 → 1 gcdのセグ木 → 0 """ self.segfunc = segfunc # num:N以上の最小の2のべき乗 self.num = 2 ** (N - 1).bit_length() self.seg = [self.ide_ele] * 2 * self.num # リストで初期化する def setL(self, init_val): # init_valは操作する数列 for i in range(N): self.seg[i + self.num - 1] = init_val[i] # built for i in range(self.num - 2, -1, -1): self.seg[i] = self.segfunc(self.seg[2 * i + 1], self.seg[2 * i + 2]) # k番目の値をxに更新 def update(self, k, x): k += self.num - 1 self.seg[k] = x while k: k = (k - 1) // 2 self.seg[k] = self.segfunc(self.seg[k * 2 + 1], self.seg[k * 2 + 2]) # [p,q)の区間に対するクエリへの応答 def query(self, p, q): if q <= p: return self.ide_ele p += self.num - 1 q += self.num - 2 res = self.ide_ele while q - p > 1: if p & 1 == 0: res = self.segfunc(res, self.seg[p]) if q & 1 == 1: res = self.segfunc(res, self.seg[q]) q -= 1 p = p // 2 q = (q - 1) // 2 if p == q: res = self.segfunc(res, self.seg[p]) else: res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q]) return res seg = SegTree(N + 1, inf, min) L = [0] * M R = [0] * M C = [0] * M for i in range(M): l, r, c = MI() l -= 1 r -= 1 L[i] = l R[i] = r C[i] = c R, C, L = zip(*sorted(zip(R, C, L))) # rが小さいものから見て(rが同じならcが小さい)確定させていく now = 0 # 確定させたとこと seg.update(0, 0) for i in range(M): r = R[i] l = L[i] c = C[i] m = seg.query(l, now + 1) # 移動もとの範囲での最小値 # seg.update(r,m+c) now = r # このままだと入力例3みたいに,コストは低いけどl,rがちかいみたいなのを先に処理してしまう # とりあえず右端だけ更新しとけばokか? if m + c < seg.query(now, now + 1): seg.update(now, m + c) # print((l+1,r+1,c),now+1,m,m+c) """ for ii in range(N): print(seg.query(ii,ii+1))""" ans = seg.query(N - 1, N) if ans >= inf: print(-1) else: print(ans) main()
Statement We have N points numbered 1 to N arranged in a line in this order. Takahashi decides to make an undirected graph, using these points as the vertices. In the beginning, the graph has no edge. Takahashi will do M operations to add edges in this graph. The i-th operation is as follows: * The operation uses integers L_i and R_i between 1 and N (inclusive), and a positive integer C_i. For every pair of integers (s, t) such that L_i \leq s < t \leq R_i, add an edge of length C_i between Vertex s and Vertex t. The integers L_1, ..., L_M, R_1, ..., R_M, C_1, ..., C_M are all given as input. Takahashi wants to solve the shortest path problem in the final graph obtained. Find the length of the shortest path from Vertex 1 to Vertex N in the final graph.
[{"input": "4 3\n 1 3 2\n 2 4 3\n 1 4 6", "output": "5\n \n\nWe have an edge of length 2 between Vertex 1 and Vertex 2, and an edge of\nlength 3 between Vertex 2 and Vertex 4, so there is a path of length 5 between\nVertex 1 and Vertex 4.\n\n* * *"}, {"input": "4 2\n 1 2 1\n 3 4 2", "output": "-1\n \n\n* * *"}, {"input": "10 7\n 1 5 18\n 3 4 8\n 1 3 5\n 4 7 10\n 5 9 8\n 6 10 5\n 8 10 3", "output": "28"}]