output_description
stringlengths
15
956
submission_id
stringlengths
10
10
status
stringclasses
3 values
problem_id
stringlengths
6
6
input_description
stringlengths
9
2.55k
attempt
stringlengths
1
13.7k
problem_description
stringlengths
7
5.24k
samples
stringlengths
2
2.72k
Print the minimum distance the second rectangle needs to be moved. * * *
s350761141
Runtime Error
p03778
The input is given from Standard Input in the following format: W a b
w, a, b = map(int, input().split()) if b + w < a: print(a - (b + w)) elif a <= b + w <= a + w: print(0): elif a <= b <= a + w: print(0) elif a + w < b: print(b- (a + w))
Statement AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure: ![](https://atcoder.jp/img/abc056/5c3a0ed9a07aa0992011c11ffbc9441b.png) AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
[{"input": "3 2 6", "output": "1\n \n\nThis input corresponds to the figure in the statement. In this case, the\nsecond rectangle should be moved to the left by a distance of 1.\n\n* * *"}, {"input": "3 1 3", "output": "0\n \n\nThe rectangles are already connected, and thus no move is needed.\n\n* * *"}, {"input": "5 10 1", "output": "4"}]
Print the minimum distance the second rectangle needs to be moved. * * *
s703513963
Accepted
p03778
The input is given from Standard Input in the following format: W a b
# ABC 056 # 基本 import math def getInt(): return int(input()) def getIntList(): return [int(x) for x in input().split()] def getIntFromRows(n): return [int(input()) for i in range(n)] def getIntMat(n): mat = [] for i in range(n): mat.append(getIntList()) return mat def zeros(n): return [0 for i in range(n)] def zeros2(n, m): return [[0 for i in range(m)] for j in range(n)] N1097 = 10**9 + 7 W, a, b = getIntList() if b >= a + W: m = b - a - W elif a >= b + W: m = a - b - W else: m = 0 print(m)
Statement AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure: ![](https://atcoder.jp/img/abc056/5c3a0ed9a07aa0992011c11ffbc9441b.png) AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
[{"input": "3 2 6", "output": "1\n \n\nThis input corresponds to the figure in the statement. In this case, the\nsecond rectangle should be moved to the left by a distance of 1.\n\n* * *"}, {"input": "3 1 3", "output": "0\n \n\nThe rectangles are already connected, and thus no move is needed.\n\n* * *"}, {"input": "5 10 1", "output": "4"}]
Print the minimum distance the second rectangle needs to be moved. * * *
s486273851
Runtime Error
p03778
The input is given from Standard Input in the following format: W a b
w,a,b = map(int,input().split()) if a < b: if b-(a+w) >0: print(b-(a+w)) else: print(0) elif a==b: print(0) eif a>b: if a-(b+w) >0: print(a-(b+w)) else: print(0)
Statement AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure: ![](https://atcoder.jp/img/abc056/5c3a0ed9a07aa0992011c11ffbc9441b.png) AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
[{"input": "3 2 6", "output": "1\n \n\nThis input corresponds to the figure in the statement. In this case, the\nsecond rectangle should be moved to the left by a distance of 1.\n\n* * *"}, {"input": "3 1 3", "output": "0\n \n\nThe rectangles are already connected, and thus no move is needed.\n\n* * *"}, {"input": "5 10 1", "output": "4"}]
Print the minimum distance the second rectangle needs to be moved. * * *
s893243118
Runtime Error
p03778
The input is given from Standard Input in the following format: W a b
w, a, b = map(int, input().split()) if abs(a-b) <= w: print(0) else: print(min(abs(b-a-w), abs(a-b-w))
Statement AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure: ![](https://atcoder.jp/img/abc056/5c3a0ed9a07aa0992011c11ffbc9441b.png) AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
[{"input": "3 2 6", "output": "1\n \n\nThis input corresponds to the figure in the statement. In this case, the\nsecond rectangle should be moved to the left by a distance of 1.\n\n* * *"}, {"input": "3 1 3", "output": "0\n \n\nThe rectangles are already connected, and thus no move is needed.\n\n* * *"}, {"input": "5 10 1", "output": "4"}]
Print the minimum distance the second rectangle needs to be moved. * * *
s698022826
Runtime Error
p03778
The input is given from Standard Input in the following format: W a b
W,a,b=map(int,input().split(' ')) print(max(0,b-(a+W)) if a<=b else print(max(0,a-(b+W)))
Statement AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure: ![](https://atcoder.jp/img/abc056/5c3a0ed9a07aa0992011c11ffbc9441b.png) AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
[{"input": "3 2 6", "output": "1\n \n\nThis input corresponds to the figure in the statement. In this case, the\nsecond rectangle should be moved to the left by a distance of 1.\n\n* * *"}, {"input": "3 1 3", "output": "0\n \n\nThe rectangles are already connected, and thus no move is needed.\n\n* * *"}, {"input": "5 10 1", "output": "4"}]
Print the minimum distance the second rectangle needs to be moved. * * *
s852738654
Runtime Error
p03778
The input is given from Standard Input in the following format: W a b
w, a, b = map(int, input().split()) ans = 0 if a < b: if a+w > b: ans = 0 else: ans = b - a+w else if a == b: ans = 0 else: if b+w > a: ans = 0 else: ans = a - b+w print(ans)
Statement AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure: ![](https://atcoder.jp/img/abc056/5c3a0ed9a07aa0992011c11ffbc9441b.png) AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
[{"input": "3 2 6", "output": "1\n \n\nThis input corresponds to the figure in the statement. In this case, the\nsecond rectangle should be moved to the left by a distance of 1.\n\n* * *"}, {"input": "3 1 3", "output": "0\n \n\nThe rectangles are already connected, and thus no move is needed.\n\n* * *"}, {"input": "5 10 1", "output": "4"}]
Print the minimum distance the second rectangle needs to be moved. * * *
s349278639
Runtime Error
p03778
The input is given from Standard Input in the following format: W a b
W, a, b = map(int, input().split()) if a+W = b: tmp = b-a-W if tmp <= 0: print(0) else: print(tmp) elif a > b+W: tmp = a-W-b if tmp <= 0: print(0) else: print(tmp) else: print(0)
Statement AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure: ![](https://atcoder.jp/img/abc056/5c3a0ed9a07aa0992011c11ffbc9441b.png) AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
[{"input": "3 2 6", "output": "1\n \n\nThis input corresponds to the figure in the statement. In this case, the\nsecond rectangle should be moved to the left by a distance of 1.\n\n* * *"}, {"input": "3 1 3", "output": "0\n \n\nThe rectangles are already connected, and thus no move is needed.\n\n* * *"}, {"input": "5 10 1", "output": "4"}]
Print the minimum distance the second rectangle needs to be moved. * * *
s097177301
Runtime Error
p03778
The input is given from Standard Input in the following format: W a b
w,a,b=map(int,input().split()) if a=b: print(int(0)) elif a>b: if b+w>=a: print(int(0)) else: print(int(a-b-w)) else: if a+w>=b: print(int(0)) else: print(int(b-a-w))
Statement AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure: ![](https://atcoder.jp/img/abc056/5c3a0ed9a07aa0992011c11ffbc9441b.png) AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
[{"input": "3 2 6", "output": "1\n \n\nThis input corresponds to the figure in the statement. In this case, the\nsecond rectangle should be moved to the left by a distance of 1.\n\n* * *"}, {"input": "3 1 3", "output": "0\n \n\nThe rectangles are already connected, and thus no move is needed.\n\n* * *"}, {"input": "5 10 1", "output": "4"}]
Print the minimum distance the second rectangle needs to be moved. * * *
s655499828
Runtime Error
p03778
The input is given from Standard Input in the following format: W a b
w,a,b=map(int,input().split()) if a=b: print(int(0)) elif a>b: if b+w>=a: print(int(0)) else: print(int(a-b-w)) else: if a+w>=b: print(int(0)) else: print(int(b-a-w))
Statement AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure: ![](https://atcoder.jp/img/abc056/5c3a0ed9a07aa0992011c11ffbc9441b.png) AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
[{"input": "3 2 6", "output": "1\n \n\nThis input corresponds to the figure in the statement. In this case, the\nsecond rectangle should be moved to the left by a distance of 1.\n\n* * *"}, {"input": "3 1 3", "output": "0\n \n\nThe rectangles are already connected, and thus no move is needed.\n\n* * *"}, {"input": "5 10 1", "output": "4"}]
Print the minimum distance the second rectangle needs to be moved. * * *
s363451382
Runtime Error
p03778
The input is given from Standard Input in the following format: W a b
W, a, b = map(int,input().split()) if a+W<=b: print(b-(a+W)) elif (a<= b)and (b<(a+W)): print(b-a) elif ((a-W)<=b) and(b<a): print(a-b) elif (b<(a-W): print(a-(b+W))
Statement AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure: ![](https://atcoder.jp/img/abc056/5c3a0ed9a07aa0992011c11ffbc9441b.png) AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
[{"input": "3 2 6", "output": "1\n \n\nThis input corresponds to the figure in the statement. In this case, the\nsecond rectangle should be moved to the left by a distance of 1.\n\n* * *"}, {"input": "3 1 3", "output": "0\n \n\nThe rectangles are already connected, and thus no move is needed.\n\n* * *"}, {"input": "5 10 1", "output": "4"}]
Print the minimum distance the second rectangle needs to be moved. * * *
s732966042
Runtime Error
p03778
The input is given from Standard Input in the following format: W a b
W,a,b = [int(i) for i input().split()] if a <= b and b <= a + W: print(0) else: print(min(b+W-a,b-a-W))
Statement AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure: ![](https://atcoder.jp/img/abc056/5c3a0ed9a07aa0992011c11ffbc9441b.png) AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
[{"input": "3 2 6", "output": "1\n \n\nThis input corresponds to the figure in the statement. In this case, the\nsecond rectangle should be moved to the left by a distance of 1.\n\n* * *"}, {"input": "3 1 3", "output": "0\n \n\nThe rectangles are already connected, and thus no move is needed.\n\n* * *"}, {"input": "5 10 1", "output": "4"}]
Print the minimum distance the second rectangle needs to be moved. * * *
s338669999
Runtime Error
p03778
The input is given from Standard Input in the following format: W a b
w,a,b=map(int,input().split()) if a+w>=b and b+w>=a: print(0) elif: a+w>b: print(a-b-w) else: print(b-a-w)
Statement AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure: ![](https://atcoder.jp/img/abc056/5c3a0ed9a07aa0992011c11ffbc9441b.png) AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
[{"input": "3 2 6", "output": "1\n \n\nThis input corresponds to the figure in the statement. In this case, the\nsecond rectangle should be moved to the left by a distance of 1.\n\n* * *"}, {"input": "3 1 3", "output": "0\n \n\nThe rectangles are already connected, and thus no move is needed.\n\n* * *"}, {"input": "5 10 1", "output": "4"}]
Print the minimum distance the second rectangle needs to be moved. * * *
s566369181
Wrong Answer
p03778
The input is given from Standard Input in the following format: W a b
w, a, b = map(int, input().split()) x = max(b - a - w, 0) y = max(a - b - w, 0) print(min(x, y))
Statement AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure: ![](https://atcoder.jp/img/abc056/5c3a0ed9a07aa0992011c11ffbc9441b.png) AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
[{"input": "3 2 6", "output": "1\n \n\nThis input corresponds to the figure in the statement. In this case, the\nsecond rectangle should be moved to the left by a distance of 1.\n\n* * *"}, {"input": "3 1 3", "output": "0\n \n\nThe rectangles are already connected, and thus no move is needed.\n\n* * *"}, {"input": "5 10 1", "output": "4"}]
Print the minimum distance the second rectangle needs to be moved. * * *
s547956609
Accepted
p03778
The input is given from Standard Input in the following format: W a b
x, a, b = map(int, input().split()) print(max(max(a, b) - min(a, b) - x, 0))
Statement AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure: ![](https://atcoder.jp/img/abc056/5c3a0ed9a07aa0992011c11ffbc9441b.png) AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
[{"input": "3 2 6", "output": "1\n \n\nThis input corresponds to the figure in the statement. In this case, the\nsecond rectangle should be moved to the left by a distance of 1.\n\n* * *"}, {"input": "3 1 3", "output": "0\n \n\nThe rectangles are already connected, and thus no move is needed.\n\n* * *"}, {"input": "5 10 1", "output": "4"}]
Print the minimum distance the second rectangle needs to be moved. * * *
s822782197
Accepted
p03778
The input is given from Standard Input in the following format: W a b
W, A, B = [int(_) for _ in input().split()] print(max(abs(A - B) - W, 0))
Statement AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure: ![](https://atcoder.jp/img/abc056/5c3a0ed9a07aa0992011c11ffbc9441b.png) AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
[{"input": "3 2 6", "output": "1\n \n\nThis input corresponds to the figure in the statement. In this case, the\nsecond rectangle should be moved to the left by a distance of 1.\n\n* * *"}, {"input": "3 1 3", "output": "0\n \n\nThe rectangles are already connected, and thus no move is needed.\n\n* * *"}, {"input": "5 10 1", "output": "4"}]
Print the minimum distance the second rectangle needs to be moved. * * *
s890245597
Runtime Error
p03778
The input is given from Standard Input in the following format: W a b
w,a,b = [int(x) for x in input().split()] print(b-w-(b-a+w)) if a+w =< b else print(0)
Statement AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure: ![](https://atcoder.jp/img/abc056/5c3a0ed9a07aa0992011c11ffbc9441b.png) AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
[{"input": "3 2 6", "output": "1\n \n\nThis input corresponds to the figure in the statement. In this case, the\nsecond rectangle should be moved to the left by a distance of 1.\n\n* * *"}, {"input": "3 1 3", "output": "0\n \n\nThe rectangles are already connected, and thus no move is needed.\n\n* * *"}, {"input": "5 10 1", "output": "4"}]
Print the minimum distance the second rectangle needs to be moved. * * *
s218623095
Wrong Answer
p03778
The input is given from Standard Input in the following format: W a b
def main(w, a, b): return b - (a + w)
Statement AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure: ![](https://atcoder.jp/img/abc056/5c3a0ed9a07aa0992011c11ffbc9441b.png) AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
[{"input": "3 2 6", "output": "1\n \n\nThis input corresponds to the figure in the statement. In this case, the\nsecond rectangle should be moved to the left by a distance of 1.\n\n* * *"}, {"input": "3 1 3", "output": "0\n \n\nThe rectangles are already connected, and thus no move is needed.\n\n* * *"}, {"input": "5 10 1", "output": "4"}]
Print the minimum distance the second rectangle needs to be moved. * * *
s896092575
Wrong Answer
p03778
The input is given from Standard Input in the following format: W a b
w, a, v = map(int, input().split()) print(min(abs(a + w - v), abs(a - w - v)))
Statement AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure: ![](https://atcoder.jp/img/abc056/5c3a0ed9a07aa0992011c11ffbc9441b.png) AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
[{"input": "3 2 6", "output": "1\n \n\nThis input corresponds to the figure in the statement. In this case, the\nsecond rectangle should be moved to the left by a distance of 1.\n\n* * *"}, {"input": "3 1 3", "output": "0\n \n\nThe rectangles are already connected, and thus no move is needed.\n\n* * *"}, {"input": "5 10 1", "output": "4"}]
Print the minimum distance the second rectangle needs to be moved. * * *
s464961364
Runtime Error
p03778
The input is given from Standard Input in the following format: W a b
w,a,b=map(int,input().split()) print(min(abs(b-a-w),abs(a-b),abs(b+w-a))
Statement AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure: ![](https://atcoder.jp/img/abc056/5c3a0ed9a07aa0992011c11ffbc9441b.png) AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
[{"input": "3 2 6", "output": "1\n \n\nThis input corresponds to the figure in the statement. In this case, the\nsecond rectangle should be moved to the left by a distance of 1.\n\n* * *"}, {"input": "3 1 3", "output": "0\n \n\nThe rectangles are already connected, and thus no move is needed.\n\n* * *"}, {"input": "5 10 1", "output": "4"}]
Print the minimum distance the second rectangle needs to be moved. * * *
s503435229
Accepted
p03778
The input is given from Standard Input in the following format: W a b
# ABC056B - NarrowRectanglesEasy w, a, b = list(map(int, input().rstrip().split())) print(0 if max(a, b) - min(a, b) - w <= 0 else max(a, b) - min(a, b) - w)
Statement AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure: ![](https://atcoder.jp/img/abc056/5c3a0ed9a07aa0992011c11ffbc9441b.png) AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
[{"input": "3 2 6", "output": "1\n \n\nThis input corresponds to the figure in the statement. In this case, the\nsecond rectangle should be moved to the left by a distance of 1.\n\n* * *"}, {"input": "3 1 3", "output": "0\n \n\nThe rectangles are already connected, and thus no move is needed.\n\n* * *"}, {"input": "5 10 1", "output": "4"}]
If the depth of the snow cover is x meters, print x as an integer. * * *
s884652836
Accepted
p03328
Input is given from Standard Input in the following format: a b
import sys, os, math, bisect, itertools, collections, heapq, queue # from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall from decimal import Decimal from collections import defaultdict, deque sys.setrecursionlimit(10000000) ii = lambda: int(sys.stdin.buffer.readline().rstrip()) il = lambda: list(map(int, sys.stdin.buffer.readline().split())) fl = lambda: list(map(float, sys.stdin.buffer.readline().split())) iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)] iss = lambda: sys.stdin.buffer.readline().decode().rstrip() sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split())) isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)] lcm = lambda x, y: (x * y) // math.gcd(x, y) MOD = 10**9 + 7 MAX = float("inf") def main(): if os.getenv("LOCAL"): sys.stdin = open("input.txt", "r") a, b = il() t = [0] * 1000 t[0] = 1 for n in range(2, 1000): t[n - 1] = t[n - 2] + n for n in range(1000): if t[n] - a == t[n + 1] - b: print(t[n] - a) exit() if __name__ == "__main__": main()
Statement In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter. It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower. Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover. Assume also that the depth of the snow cover is always at least 1 meter.
[{"input": "8 13", "output": "2\n \n\nThe heights of the two towers are 10 meters and 15 meters, respectively. Thus,\nwe can see that the depth of the snow cover is 2 meters.\n\n* * *"}, {"input": "54 65", "output": "1"}]
If the depth of the snow cover is x meters, print x as an integer. * * *
s831934236
Accepted
p03328
Input is given from Standard Input in the following format: a b
from heapq import heappush, heappop, heapify from collections import deque, defaultdict, Counter import itertools from functools import * from itertools import permutations, combinations, groupby import sys import bisect import string import math import time import random def Golf(): (*a,) = map(int, open(0)) def S_(): return input() def IS(): return input().split() def LS(): return [i for i in input().split()] def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return [int(i) for i in input().split()] def LI_(): return [int(i) - 1 for i in input().split()] def NI(n): return [int(input()) for i in range(n)] def NI_(n): return [int(input()) - 1 for i in range(n)] def StoI(): return [ord(i) - 97 for i in input()] def ItoS(nn): return chr(nn + 97) def LtoS(ls): return "".join([chr(i + 97) for i in ls]) def GI(V, E, Directed=False, index=0): org_inp = [] g = [[] for i in range(n)] for i in range(E): inp = LI() org_inp.append(inp) if index == 0: inp[0] -= 1 inp[1] -= 1 if len(inp) == 2: a, b = inp g[a].append(b) if not Directed: g[b].append(a) elif len(inp) == 3: a, b, c = inp aa = (inp[0], inp[2]) bb = (inp[1], inp[2]) g[a].append(bb) if not Directed: g[b].append(aa) return g, org_inp def GGI(h, w, search=None, replacement_of_found=".", mp_def={"#": 1, ".": 0}): # h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage mp = [1] * (w + 2) found = {} for i in range(h): s = input() for char in search: if char in s: found[char] = (i + 1) * (w + 2) + s.index(char) + 1 mp_def[char] = mp_def[replacement_of_found] mp += [1] + [mp_def[j] for j in s] + [1] mp += [1] * (w + 2) return h + 2, w + 2, mp, found def bit_combination(k, n=2): rt = [] for tb in range(n**k): s = [tb // (n**bt) % n for bt in range(k)] rt += [s] return rt def show(*inp, end="\n"): if show_flg: print(*inp, end=end) YN = ["YES", "NO"] mo = 10**9 + 7 inf = float("inf") l_alp = string.ascii_lowercase u_alp = string.ascii_uppercase ts = time.time() # sys.setrecursionlimit(10**7) input = lambda: sys.stdin.readline().rstrip() def ran_input(): import random n = random.randint(4, 16) rmin, rmax = 1, 10 a = [random.randint(rmin, rmax) for _ in range(n)] return n, a show_flg = False show_flg = True ans = 0 a, b = LI() x = b - a ans = x * (x - 1) // 2 - a print(ans)
Statement In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter. It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower. Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover. Assume also that the depth of the snow cover is always at least 1 meter.
[{"input": "8 13", "output": "2\n \n\nThe heights of the two towers are 10 meters and 15 meters, respectively. Thus,\nwe can see that the depth of the snow cover is 2 meters.\n\n* * *"}, {"input": "54 65", "output": "1"}]
If the depth of the snow cover is x meters, print x as an integer. * * *
s170639284
Accepted
p03328
Input is given from Standard Input in the following format: a b
import sys import math from fractions import gcd # import queue # from collections import Counter # from itertools import accumulate # from functools import reduce def lcm(a, b): return a * b // gcd(a, b) def combination_count(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) def permutations_count(n, r): return math.factorial(n) // math.factorial(n - r) big_prime = 1000000007 """ # 標準入力取得 ## 文字列 = sys.stdin.readline().rstrip() = list(sys.stdin.readline().rstrip()) ## 数値 = int(sys.stdin.readline()) = map(int, sys.stdin.readline().split()) = list(map(int, sys.stdin.readline().split())) = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)] """ a, b = map(int, sys.stdin.readline().split()) A = 0 for i in range(b - a, 0, -1): A += i print(A - b)
Statement In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter. It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower. Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover. Assume also that the depth of the snow cover is always at least 1 meter.
[{"input": "8 13", "output": "2\n \n\nThe heights of the two towers are 10 meters and 15 meters, respectively. Thus,\nwe can see that the depth of the snow cover is 2 meters.\n\n* * *"}, {"input": "54 65", "output": "1"}]
If the depth of the snow cover is x meters, print x as an integer. * * *
s375282250
Accepted
p03328
Input is given from Standard Input in the following format: a b
############################################################################### from sys import stdout from bisect import bisect_left as binl from copy import copy, deepcopy from collections import defaultdict mod = 1 def intin(): input_tuple = input().split() if len(input_tuple) <= 1: return int(input_tuple[0]) return tuple(map(int, input_tuple)) def intina(): return [int(i) for i in input().split()] def intinl(count): return [intin() for _ in range(count)] def modadd(x, y): global mod return (x + y) % mod def modmlt(x, y): global mod return (x * y) % mod def lcm(x, y): while y != 0: z = x % y x = y y = z return x def combination(x, y): assert x >= y if y > x // 2: y = x - y ret = 1 for i in range(0, y): j = x - i i = i + 1 ret = ret * j ret = ret // i return ret def get_divisors(x): retlist = [] for i in range(1, int(x**0.5) + 3): if x % i == 0: retlist.append(i) retlist.append(x // i) return retlist def get_factors(x): retlist = [] for i in range(2, int(x**0.5) + 3): while x % i == 0: retlist.append(i) x = x // i retlist.append(x) return retlist def make_linklist(xylist): linklist = {} for a, b in xylist: linklist.setdefault(a, []) linklist.setdefault(b, []) linklist[a].append(b) linklist[b].append(a) return linklist def calc_longest_distance(linklist, v=1): distance_list = {} distance_count = 0 distance = 0 vlist_previous = [] vlist = [v] nodecount = len(linklist) while distance_count < nodecount: vlist_next = [] for v in vlist: distance_list[v] = distance distance_count += 1 vlist_next.extend(linklist[v]) distance += 1 vlist_to_del = vlist_previous vlist_previous = vlist vlist = list(set(vlist_next) - set(vlist_to_del)) max_distance = -1 max_v = None for v, distance in distance_list.items(): if distance > max_distance: max_distance = distance max_v = v return (max_distance, max_v) def calc_tree_diameter(linklist, v=1): _, u = calc_longest_distance(linklist, v) distance, _ = calc_longest_distance(linklist, u) return distance ############################################################################### def main(): a, b = intin() sub = b - a ans = 0 for i in range(sub): ans += i ans -= a print(ans) if __name__ == "__main__": main()
Statement In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter. It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower. Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover. Assume also that the depth of the snow cover is always at least 1 meter.
[{"input": "8 13", "output": "2\n \n\nThe heights of the two towers are 10 meters and 15 meters, respectively. Thus,\nwe can see that the depth of the snow cover is 2 meters.\n\n* * *"}, {"input": "54 65", "output": "1"}]
If the depth of the snow cover is x meters, print x as an integer. * * *
s776410558
Runtime Error
p03328
Input is given from Standard Input in the following format: a b
#!usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random import itertools sys.setrecursionlimit(10**5) stdin = sys.stdin def LI(): return list(map(int, stdin.readline().split())) def LF(): return list(map(float, stdin.readline().split())) def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split())) def II(): return int(stdin.readline()) def IF(): return float(stdin.readline()) def LS(): return list(map(list, stdin.readline().split())) def S(): return list(stdin.readline().rstrip()) def IR(n): return [II() for _ in range(n)] def LIR(n): return [LI() for _ in range(n)] def FR(n): return [IF() for _ in range(n)] def LFR(n): return [LI() for _ in range(n)] def LIR_(n): return [LI_() for _ in range(n)] def SR(n): return [S() for _ in range(n)] def LSR(n): return [LS() for _ in range(n)] mod = 1000000007 inf = float("INF") #A def A(): n = II() if n < 1000: print("ABC") else: print("ABD") return #B def B(): a, b = LI() x = b - a - 1 print(a - (1 + x) * x // 2) return #C def C(): n = II() dp = [inf for i in range(n + 1)] ans = [1] x = 6 while x <= n: ans.append(x) x = x * 6 x = 9 while x <= n: ans.append(x) x = x * 9 ans.sort() for i in ans: dp[i] = 1 for i in range(1, n + 1): if not i in ans: a = bisect.bisect_left(ans, i) for k in range(a): dp[i] = min(dp[i - ans[k]] + 1, dp[i]) print(dp[n]) return #D def D(): n, c = LI() D = LIR(c) C = LIR_(n) CL = list(itertools.permutations(range(c), 3)) ans = inf amari0 = [0 for i in range(30)] amari1 = amari0[::1] amari2 = amari0[::1] for y in range(n): for x in range(n): amari = (x + y) % 3 if amari == 0: amari0[C[y][x]] += 1 if amari == 1: amari1[C[y][x]] += 1 if amari == 2: amari2[C[y][x]] += 1 for c0, c1, c2 in CL: ansb = 0 for i in range(c): ansb += D[i][c0] * amari0[i] ansb += D[i][c1] * amari1[i] ansb += D[i][c2] * amari2[i] ans = min(ans, ansb) print(ans) return #Solve if __name__ == '__main__': Ⓑ()
Statement In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter. It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower. Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover. Assume also that the depth of the snow cover is always at least 1 meter.
[{"input": "8 13", "output": "2\n \n\nThe heights of the two towers are 10 meters and 15 meters, respectively. Thus,\nwe can see that the depth of the snow cover is 2 meters.\n\n* * *"}, {"input": "54 65", "output": "1"}]
If the depth of the snow cover is x meters, print x as an integer. * * *
s980372831
Runtime Error
p03328
Input is given from Standard Input in the following format: a b
A, B = map(int, input().split()) B - A = N X = N * (N + 1) // 2 print(X - B)
Statement In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter. It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower. Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover. Assume also that the depth of the snow cover is always at least 1 meter.
[{"input": "8 13", "output": "2\n \n\nThe heights of the two towers are 10 meters and 15 meters, respectively. Thus,\nwe can see that the depth of the snow cover is 2 meters.\n\n* * *"}, {"input": "54 65", "output": "1"}]
If the depth of the snow cover is x meters, print x as an integer. * * *
s304900549
Runtime Error
p03328
Input is given from Standard Input in the following format: a b
a, b = map(int, input().split()) print((b − a) * (b − a + 1) // 2 − b)
Statement In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter. It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower. Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover. Assume also that the depth of the snow cover is always at least 1 meter.
[{"input": "8 13", "output": "2\n \n\nThe heights of the two towers are 10 meters and 15 meters, respectively. Thus,\nwe can see that the depth of the snow cover is 2 meters.\n\n* * *"}, {"input": "54 65", "output": "1"}]
If the depth of the snow cover is x meters, print x as an integer. * * *
s328792494
Accepted
p03328
Input is given from Standard Input in the following format: a b
n = list(map(int, input().split())) ans = 0 diff = n[1] - n[0] for i in range(diff): ans = i + ans yuki = ans - n[0] print(yuki)
Statement In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter. It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower. Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover. Assume also that the depth of the snow cover is always at least 1 meter.
[{"input": "8 13", "output": "2\n \n\nThe heights of the two towers are 10 meters and 15 meters, respectively. Thus,\nwe can see that the depth of the snow cover is 2 meters.\n\n* * *"}, {"input": "54 65", "output": "1"}]
If the depth of the snow cover is x meters, print x as an integer. * * *
s730992679
Runtime Error
p03328
Input is given from Standard Input in the following format: a b
import sys a,b = map(int,input().split()) sum = 0 for i in range(1,1000): while(a > sum): i = 1 sum += 1 i += 1 print(sum-a)
Statement In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter. It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower. Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover. Assume also that the depth of the snow cover is always at least 1 meter.
[{"input": "8 13", "output": "2\n \n\nThe heights of the two towers are 10 meters and 15 meters, respectively. Thus,\nwe can see that the depth of the snow cover is 2 meters.\n\n* * *"}, {"input": "54 65", "output": "1"}]
If the depth of the snow cover is x meters, print x as an integer. * * *
s852141471
Wrong Answer
p03328
Input is given from Standard Input in the following format: a b
a, b = (int(T) for T in input().split()) Count = 1 X = 0 while X < a: X += Count Count += 1 print(X - a)
Statement In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter. It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower. Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover. Assume also that the depth of the snow cover is always at least 1 meter.
[{"input": "8 13", "output": "2\n \n\nThe heights of the two towers are 10 meters and 15 meters, respectively. Thus,\nwe can see that the depth of the snow cover is 2 meters.\n\n* * *"}, {"input": "54 65", "output": "1"}]
If the depth of the snow cover is x meters, print x as an integer. * * *
s413540127
Accepted
p03328
Input is given from Standard Input in the following format: a b
import sys if __name__ == "__main__": a, b = list(map(int, (input().split(" ")))) buf_ls = [] buf = 0 buf2 = b - a for i in range(0, 1000): buf += i + 1 buf_ls.append(buf) if buf2 == (i + 1): print(buf_ls[i] - b) sys.exit()
Statement In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter. It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower. Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover. Assume also that the depth of the snow cover is always at least 1 meter.
[{"input": "8 13", "output": "2\n \n\nThe heights of the two towers are 10 meters and 15 meters, respectively. Thus,\nwe can see that the depth of the snow cover is 2 meters.\n\n* * *"}, {"input": "54 65", "output": "1"}]
If the depth of the snow cover is x meters, print x as an integer. * * *
s864676965
Runtime Error
p03328
Input is given from Standard Input in the following format: a b
a,b = map(int,input().split()) n = b-a print(n*(n+1)//2-b)
Statement In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter. It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower. Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover. Assume also that the depth of the snow cover is always at least 1 meter.
[{"input": "8 13", "output": "2\n \n\nThe heights of the two towers are 10 meters and 15 meters, respectively. Thus,\nwe can see that the depth of the snow cover is 2 meters.\n\n* * *"}, {"input": "54 65", "output": "1"}]
If the depth of the snow cover is x meters, print x as an integer. * * *
s812575927
Accepted
p03328
Input is given from Standard Input in the following format: a b
ab = input().split() a, b = int(ab[0]), int(ab[1]) d = [] z = b - a if ((z - 1) * z) / 2 > a and ((z + 1) * (z + 2)) / 2 > b: x, y = ((z - 1) * z) / 2, ((z + 1) * (z + 2)) print(int(x - a))
Statement In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter. It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower. Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover. Assume also that the depth of the snow cover is always at least 1 meter.
[{"input": "8 13", "output": "2\n \n\nThe heights of the two towers are 10 meters and 15 meters, respectively. Thus,\nwe can see that the depth of the snow cover is 2 meters.\n\n* * *"}, {"input": "54 65", "output": "1"}]
If the depth of the snow cover is x meters, print x as an integer. * * *
s900795472
Accepted
p03328
Input is given from Standard Input in the following format: a b
A, B = [int(s) for s in input().split()] x = B - A y = x * (x - 1) // 2 print(y - A)
Statement In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter. It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower. Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover. Assume also that the depth of the snow cover is always at least 1 meter.
[{"input": "8 13", "output": "2\n \n\nThe heights of the two towers are 10 meters and 15 meters, respectively. Thus,\nwe can see that the depth of the snow cover is 2 meters.\n\n* * *"}, {"input": "54 65", "output": "1"}]
If the depth of the snow cover is x meters, print x as an integer. * * *
s982560883
Runtime Error
p03328
Input is given from Standard Input in the following format: a b
a, b = map(int, input().split()) print(sum(range(b-a)-a)
Statement In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter. It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower. Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover. Assume also that the depth of the snow cover is always at least 1 meter.
[{"input": "8 13", "output": "2\n \n\nThe heights of the two towers are 10 meters and 15 meters, respectively. Thus,\nwe can see that the depth of the snow cover is 2 meters.\n\n* * *"}, {"input": "54 65", "output": "1"}]
If the depth of the snow cover is x meters, print x as an integer. * * *
s264807561
Runtime Error
p03328
Input is given from Standard Input in the following format: a b
a,b=map(int, input().split()) print(sum([1:b])-(b-a))
Statement In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter. It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower. Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover. Assume also that the depth of the snow cover is always at least 1 meter.
[{"input": "8 13", "output": "2\n \n\nThe heights of the two towers are 10 meters and 15 meters, respectively. Thus,\nwe can see that the depth of the snow cover is 2 meters.\n\n* * *"}, {"input": "54 65", "output": "1"}]
If the depth of the snow cover is x meters, print x as an integer. * * *
s918442240
Runtime Error
p03328
Input is given from Standard Input in the following format: a b
a,b=map(int,input().split()) print((b-a)*(1+b-a)//2-b)…
Statement In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter. It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower. Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover. Assume also that the depth of the snow cover is always at least 1 meter.
[{"input": "8 13", "output": "2\n \n\nThe heights of the two towers are 10 meters and 15 meters, respectively. Thus,\nwe can see that the depth of the snow cover is 2 meters.\n\n* * *"}, {"input": "54 65", "output": "1"}]
If the depth of the snow cover is x meters, print x as an integer. * * *
s034053849
Runtime Error
p03328
Input is given from Standard Input in the following format: a b
a, b = map(int, input().split()) print(()(b-a)*(b-a+1)/2)-b)
Statement In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter. It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower. Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover. Assume also that the depth of the snow cover is always at least 1 meter.
[{"input": "8 13", "output": "2\n \n\nThe heights of the two towers are 10 meters and 15 meters, respectively. Thus,\nwe can see that the depth of the snow cover is 2 meters.\n\n* * *"}, {"input": "54 65", "output": "1"}]
If the depth of the snow cover is x meters, print x as an integer. * * *
s337385384
Runtime Error
p03328
Input is given from Standard Input in the following format: a b
a, b = list(map(int, input())) answer = (b - a) * (b - a + 1) / 2 - b print(int(answer))
Statement In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter. It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower. Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover. Assume also that the depth of the snow cover is always at least 1 meter.
[{"input": "8 13", "output": "2\n \n\nThe heights of the two towers are 10 meters and 15 meters, respectively. Thus,\nwe can see that the depth of the snow cover is 2 meters.\n\n* * *"}, {"input": "54 65", "output": "1"}]
If the depth of the snow cover is x meters, print x as an integer. * * *
s501159376
Runtime Error
p03328
Input is given from Standard Input in the following format: a b
package main import ( "fmt" "math/rand" "time" ) func swap(data []float64, i,
Statement In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter. It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower. Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover. Assume also that the depth of the snow cover is always at least 1 meter.
[{"input": "8 13", "output": "2\n \n\nThe heights of the two towers are 10 meters and 15 meters, respectively. Thus,\nwe can see that the depth of the snow cover is 2 meters.\n\n* * *"}, {"input": "54 65", "output": "1"}]
If the depth of the snow cover is x meters, print x as an integer. * * *
s430866199
Runtime Error
p03328
Input is given from Standard Input in the following format: a b
s = input().split() print(int[1] - (int(s[1]) - int(s[0]) - 1) * (int(s[1]) - int(s[0])) / 2)
Statement In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter. It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower. Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover. Assume also that the depth of the snow cover is always at least 1 meter.
[{"input": "8 13", "output": "2\n \n\nThe heights of the two towers are 10 meters and 15 meters, respectively. Thus,\nwe can see that the depth of the snow cover is 2 meters.\n\n* * *"}, {"input": "54 65", "output": "1"}]
If the depth of the snow cover is x meters, print x as an integer. * * *
s457849164
Runtime Error
p03328
Input is given from Standard Input in the following format: a b
a,b=[int(i) for i in input().split()] h = 0 i = 0 while h < a and i < 1000: i += 1 h += i if i > 999 print(h-b) else: print(h-a)
Statement In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter. It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower. Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover. Assume also that the depth of the snow cover is always at least 1 meter.
[{"input": "8 13", "output": "2\n \n\nThe heights of the two towers are 10 meters and 15 meters, respectively. Thus,\nwe can see that the depth of the snow cover is 2 meters.\n\n* * *"}, {"input": "54 65", "output": "1"}]
If the depth of the snow cover is x meters, print x as an integer. * * *
s352497583
Runtime Error
p03328
Input is given from Standard Input in the following format: a b
# coding:utf-8 a, b= map(int, input().split()) diff = b-a d = 0 for i in enumerate(diff+1, 1): d += i print(abs(d-a)
Statement In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter. It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower. Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover. Assume also that the depth of the snow cover is always at least 1 meter.
[{"input": "8 13", "output": "2\n \n\nThe heights of the two towers are 10 meters and 15 meters, respectively. Thus,\nwe can see that the depth of the snow cover is 2 meters.\n\n* * *"}, {"input": "54 65", "output": "1"}]
If the depth of the snow cover is x meters, print x as an integer. * * *
s450970221
Wrong Answer
p03328
Input is given from Standard Input in the following format: a b
A, B = map(int, input().split()) Dif = B - A Larger = (1 + Dif) * Dif / 2 DepthSnow = Larger - B print(DepthSnow)
Statement In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter. It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower. Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover. Assume also that the depth of the snow cover is always at least 1 meter.
[{"input": "8 13", "output": "2\n \n\nThe heights of the two towers are 10 meters and 15 meters, respectively. Thus,\nwe can see that the depth of the snow cover is 2 meters.\n\n* * *"}, {"input": "54 65", "output": "1"}]
For each dataset, print the smallest possible number of the longest contiguous spaces between words.
s774480101
Wrong Answer
p00912
The input consists of multiple datasets, each in the following format. _W N_ _x_ 1 _x_ 2 ... _x N_ _W_ , _N_ , and _x i_ are all integers. _W_ is the number of columns (3 ≤ _W_ ≤ 80,000). _N_ is the number of words (2 ≤ _N_ ≤ 50,000). _x i_ is the number of characters in the _i_ -th word (1 ≤ _x i_ ≤ (_W_ −1)/2 ). Note that the upper bound on _x i_ assures that there always exists a layout satisfying the conditions. The last dataset is followed by a line containing two zeros.
while 1: W, N = map(int, input().split()) if W == N == 0: break (*X,) = map(int, input().split()) def solve(l): lower = 0 upper = 0 for x in X: lower += x + 1 upper += x + l if l + W <= upper: if not lower <= W + 1: return 0 lower = upper = 0 return 1 left = 0 right = W while left + 1 < right: mid = (left + right) // 2 if solve(mid): right = mid else: left = mid print(right)
I: Beautiful Spacing Text is a sequence of words, and a word consists of characters. Your task is to put words into a grid with _W_ columns and sufficiently many lines. For the beauty of the layout, the following conditions have to be satisfied. 1. The words in the text must be placed keeping their original order. The following figures show correct and incorrect layout examples for a 4 word text "This is a pen" into 11 columns. ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_beautifulSpacing1) | ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_beautifulSpacing2) ---|--- Figure I.1: A good layout. | Figure I.2: BAD | Do not reorder words. 2. Between two words adjacent in the same line, you must place at least one space character. You sometimes have to put more than one space in order to meet other conditions. ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_beautifulSpacing3) Figure I.3: BAD | Words must be separated by spaces. 3. A word must occupy the same number of consecutive columns as the number of characters in it. You cannot break a single word into two or more by breaking it into lines or by inserting spaces. ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_beautifulSpacing4) Figure I.4: BAD | Characters in a single word must be contiguous. 4. The text must be justified to the both sides. That is, the first word of a line must startfrom the first column of the line, and except the last line, the last word of a line must end at the last column. ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_beautifulSpacing5) Figure I.5: BAD | Lines must be justi ed to both the left and the right sides. The text is the most beautifully laid out when there is no unnecessarily long spaces. For instance, the layout in Figure I.6 has at most 2 contiguous spaces, which is more beautiful than that in Figure I.1, having 3 contiguous spaces. Given an input text and the number of columns, please find a layout such that the length of the longest contiguous spaces between words is minimum. ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_beautifulSpacing6) Figure I.6: A good and the most beautiful layout.
[{"input": "4\n 4 2 1 3\n 5 7\n 1 1 1 2 2 1 2\n 11 7\n 3 1 3 1 3 3 4\n 100 3\n 30 30 39\n 30 3\n 2 5 3\n 0 0", "output": "1\n 2\n 40\n 1"}]
Print the total horizontal length of the uncovered parts of the window. * * *
s845704627
Accepted
p02885
Input is given from Standard Input in the following format: A B
print(max(0, eval(input().replace(" ", "-2*"))))
Statement The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then.
[{"input": "12 4", "output": "4\n \n\nWe have a window with a horizontal length of 12, and two curtains, each of\nlength 4, that cover both ends of the window, for example. The uncovered part\nhas a horizontal length of 4.\n\n* * *"}, {"input": "20 15", "output": "0\n \n\nIf the window is completely covered, print 0.\n\n* * *"}, {"input": "20 30", "output": "0\n \n\nEach curtain may be longer than the window."}]
Print the total horizontal length of the uncovered parts of the window. * * *
s104684219
Wrong Answer
p02885
Input is given from Standard Input in the following format: A B
print(eval("min(" + input().replace(" ", "-2*") + ",0)"))
Statement The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then.
[{"input": "12 4", "output": "4\n \n\nWe have a window with a horizontal length of 12, and two curtains, each of\nlength 4, that cover both ends of the window, for example. The uncovered part\nhas a horizontal length of 4.\n\n* * *"}, {"input": "20 15", "output": "0\n \n\nIf the window is completely covered, print 0.\n\n* * *"}, {"input": "20 30", "output": "0\n \n\nEach curtain may be longer than the window."}]
Print the total horizontal length of the uncovered parts of the window. * * *
s708534787
Runtime Error
p02885
Input is given from Standard Input in the following format: A B
print(max(int(input()) - int(input()) * 2, 0))
Statement The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then.
[{"input": "12 4", "output": "4\n \n\nWe have a window with a horizontal length of 12, and two curtains, each of\nlength 4, that cover both ends of the window, for example. The uncovered part\nhas a horizontal length of 4.\n\n* * *"}, {"input": "20 15", "output": "0\n \n\nIf the window is completely covered, print 0.\n\n* * *"}, {"input": "20 30", "output": "0\n \n\nEach curtain may be longer than the window."}]
Print the total horizontal length of the uncovered parts of the window. * * *
s878479555
Accepted
p02885
Input is given from Standard Input in the following format: A B
# cook your dish here import sys def file(): sys.stdin = open("input.py", "r") sys.stdout = open("output.py", "w") # file() def main(N, arr): # initialising with positive infinity value maxi = float("inf") # initialising the answer variable ans = 0 # iterating linesrly for i in range(N): # finding minimum at each step maxi = min(maxi, arr[i]) # increasing the final ans ans += maxi print("dhh") # returning the answer return ans if __name__ == "__main__": # length of the array """N = 4 #Maximum size of each individual bucket Arr = [4,3,2,1] #passing the values to the main function answer = main(N,Arr) #printing the result print(answer)""" a, b = map(int, input().split()) d = a - (2 * b) if d < 0: print(0) else: print(d)
Statement The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then.
[{"input": "12 4", "output": "4\n \n\nWe have a window with a horizontal length of 12, and two curtains, each of\nlength 4, that cover both ends of the window, for example. The uncovered part\nhas a horizontal length of 4.\n\n* * *"}, {"input": "20 15", "output": "0\n \n\nIf the window is completely covered, print 0.\n\n* * *"}, {"input": "20 30", "output": "0\n \n\nEach curtain may be longer than the window."}]
Print the total horizontal length of the uncovered parts of the window. * * *
s829114159
Runtime Error
p02885
Input is given from Standard Input in the following format: A B
n = int(input()) t = tuple(map(int, input().split())) T = 0 for i in range(n - 2): a = t[i] for j in range(n - i - 1): b = t[i + j + 1] for k in range(n - i - j - 2): c = t[i + j + k + 2] m = max(a, b, c) if m < a + b + c - m: T += 1 print(T)
Statement The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then.
[{"input": "12 4", "output": "4\n \n\nWe have a window with a horizontal length of 12, and two curtains, each of\nlength 4, that cover both ends of the window, for example. The uncovered part\nhas a horizontal length of 4.\n\n* * *"}, {"input": "20 15", "output": "0\n \n\nIf the window is completely covered, print 0.\n\n* * *"}, {"input": "20 30", "output": "0\n \n\nEach curtain may be longer than the window."}]
Print the total horizontal length of the uncovered parts of the window. * * *
s785234201
Wrong Answer
p02885
Input is given from Standard Input in the following format: A B
total, l = map(int, input().split(" ")) print(total - 2 * l)
Statement The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then.
[{"input": "12 4", "output": "4\n \n\nWe have a window with a horizontal length of 12, and two curtains, each of\nlength 4, that cover both ends of the window, for example. The uncovered part\nhas a horizontal length of 4.\n\n* * *"}, {"input": "20 15", "output": "0\n \n\nIf the window is completely covered, print 0.\n\n* * *"}, {"input": "20 30", "output": "0\n \n\nEach curtain may be longer than the window."}]
Print the total horizontal length of the uncovered parts of the window. * * *
s360268100
Wrong Answer
p02885
Input is given from Standard Input in the following format: A B
a = input().rstrip().split() print(a)
Statement The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then.
[{"input": "12 4", "output": "4\n \n\nWe have a window with a horizontal length of 12, and two curtains, each of\nlength 4, that cover both ends of the window, for example. The uncovered part\nhas a horizontal length of 4.\n\n* * *"}, {"input": "20 15", "output": "0\n \n\nIf the window is completely covered, print 0.\n\n* * *"}, {"input": "20 30", "output": "0\n \n\nEach curtain may be longer than the window."}]
Print the total horizontal length of the uncovered parts of the window. * * *
s129571068
Accepted
p02885
Input is given from Standard Input in the following format: A B
class Madowaku: def __init__(self, madowaku, curtain): self.madowaku = madowaku self.curtain = curtain def aki(self): ans = self.madowaku - self.curtain * 2 if ans > 0: print(ans) else: print(0) A, B = list(map(int, input().split(" "))) solve = Madowaku(A, B) solve.aki()
Statement The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then.
[{"input": "12 4", "output": "4\n \n\nWe have a window with a horizontal length of 12, and two curtains, each of\nlength 4, that cover both ends of the window, for example. The uncovered part\nhas a horizontal length of 4.\n\n* * *"}, {"input": "20 15", "output": "0\n \n\nIf the window is completely covered, print 0.\n\n* * *"}, {"input": "20 30", "output": "0\n \n\nEach curtain may be longer than the window."}]
Print the total horizontal length of the uncovered parts of the window. * * *
s106613654
Accepted
p02885
Input is given from Standard Input in the following format: A B
n, k = list(map(int, input().split())) print(max(0, n - 2 * k))
Statement The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then.
[{"input": "12 4", "output": "4\n \n\nWe have a window with a horizontal length of 12, and two curtains, each of\nlength 4, that cover both ends of the window, for example. The uncovered part\nhas a horizontal length of 4.\n\n* * *"}, {"input": "20 15", "output": "0\n \n\nIf the window is completely covered, print 0.\n\n* * *"}, {"input": "20 30", "output": "0\n \n\nEach curtain may be longer than the window."}]
Print the total horizontal length of the uncovered parts of the window. * * *
s052139835
Accepted
p02885
Input is given from Standard Input in the following format: A B
X, Y = map(int, input().split()) print(max(0, X - Y * 2))
Statement The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then.
[{"input": "12 4", "output": "4\n \n\nWe have a window with a horizontal length of 12, and two curtains, each of\nlength 4, that cover both ends of the window, for example. The uncovered part\nhas a horizontal length of 4.\n\n* * *"}, {"input": "20 15", "output": "0\n \n\nIf the window is completely covered, print 0.\n\n* * *"}, {"input": "20 30", "output": "0\n \n\nEach curtain may be longer than the window."}]
Print the total horizontal length of the uncovered parts of the window. * * *
s073261648
Accepted
p02885
Input is given from Standard Input in the following format: A B
a, b = map(int, input().split()) anc = a - 2 * b print(max(0, anc))
Statement The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then.
[{"input": "12 4", "output": "4\n \n\nWe have a window with a horizontal length of 12, and two curtains, each of\nlength 4, that cover both ends of the window, for example. The uncovered part\nhas a horizontal length of 4.\n\n* * *"}, {"input": "20 15", "output": "0\n \n\nIf the window is completely covered, print 0.\n\n* * *"}, {"input": "20 30", "output": "0\n \n\nEach curtain may be longer than the window."}]
Print the total horizontal length of the uncovered parts of the window. * * *
s372100837
Wrong Answer
p02885
Input is given from Standard Input in the following format: A B
n, k = map(int, input().split()) if n == k: print(k) elif k <= 1: print(k) else: a = (n - k) // (k - 1) b = 0 for c in range(0, a + 1): b += n - k - (k - 1) * c + 1 print(b)
Statement The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then.
[{"input": "12 4", "output": "4\n \n\nWe have a window with a horizontal length of 12, and two curtains, each of\nlength 4, that cover both ends of the window, for example. The uncovered part\nhas a horizontal length of 4.\n\n* * *"}, {"input": "20 15", "output": "0\n \n\nIf the window is completely covered, print 0.\n\n* * *"}, {"input": "20 30", "output": "0\n \n\nEach curtain may be longer than the window."}]
Print the total horizontal length of the uncovered parts of the window. * * *
s097672780
Accepted
p02885
Input is given from Standard Input in the following format: A B
print((lambda a, b: max(0, a - 2 * b))(*list(map(int, input().split()))))
Statement The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then.
[{"input": "12 4", "output": "4\n \n\nWe have a window with a horizontal length of 12, and two curtains, each of\nlength 4, that cover both ends of the window, for example. The uncovered part\nhas a horizontal length of 4.\n\n* * *"}, {"input": "20 15", "output": "0\n \n\nIf the window is completely covered, print 0.\n\n* * *"}, {"input": "20 30", "output": "0\n \n\nEach curtain may be longer than the window."}]
Print the total horizontal length of the uncovered parts of the window. * * *
s840692826
Accepted
p02885
Input is given from Standard Input in the following format: A B
(a, b) = map(int, input().split()) print((a - 2 * b) if a > 2 * b else 0)
Statement The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then.
[{"input": "12 4", "output": "4\n \n\nWe have a window with a horizontal length of 12, and two curtains, each of\nlength 4, that cover both ends of the window, for example. The uncovered part\nhas a horizontal length of 4.\n\n* * *"}, {"input": "20 15", "output": "0\n \n\nIf the window is completely covered, print 0.\n\n* * *"}, {"input": "20 30", "output": "0\n \n\nEach curtain may be longer than the window."}]
Print the lexicographically smallest permutation that can be obtained. * * *
s947077253
Wrong Answer
p04052
The input is given from Standard Input in the following format: N K P_1 P_2 ... P_N
n, k = map(int, input().split()) nums = list(map(int, input().split())) dict_indexs = {} for i, num in enumerate(nums): dict_indexs[num - 1] = i while True: flag = False for i in range(n - 1): a = dict_indexs[i] b = dict_indexs[i + 1] if a - b >= k: dict_indexs[i] = b dict_indexs[i + 1] = a flag = True if flag: continue else: break for i in range(n): print(dict_indexs[i] + 1)
Statement You are given a permutation P_1 ... P_N of the set {1, 2, ..., N}. You can apply the following operation to this permutation, any number of times (possibly zero): * Choose two indices i,j (1 ≦ i < j ≦ N), such that j - i ≧ K and |P_i - P_j| = 1. Then, swap the values of P_i and P_j. Among all permutations that can be obtained by applying this operation to the given permutation, find the lexicographically smallest one.
[{"input": "4 2\n 4 2 3 1", "output": "2\n 1\n 4\n 3\n \n\nOne possible way to obtain the lexicographically smallest permutation is shown\nbelow:\n\n * 4 2 3 1\n * 4 1 3 2\n * 3 1 4 2\n * 2 1 4 3\n\n* * *"}, {"input": "5 1\n 5 4 3 2 1", "output": "1\n 2\n 3\n 4\n 5\n \n\n* * *"}, {"input": "8 3\n 4 5 7 8 3 1 2 6", "output": "1\n 2\n 6\n 7\n 5\n 3\n 4\n 8"}]
Print the answer. * * *
s431777454
Accepted
p03797
The input is given from Standard Input in the following format: N M
import sys import math import collections import itertools import array import inspect # Set max recursion limit sys.setrecursionlimit(1000000) # Debug output def chkprint(*args): names = {id(v): k for k, v in inspect.currentframe().f_back.f_locals.items()} print(", ".join(names.get(id(arg), "???") + " = " + repr(arg) for arg in args)) # Binary converter def to_bin(x): return bin(x)[2:] def li_input(): return [int(_) for _ in input().split()] def gcd(n, m): if n % m == 0: return m else: return gcd(m, n % m) def gcd_list(L): v = L[0] for i in range(1, len(L)): v = gcd(v, L[i]) return v def lcm(n, m): return (n * m) // gcd(n, m) def lcm_list(L): v = L[0] for i in range(1, len(L)): v = lcm(v, L[i]) return v # Width First Search (+ Distance) def wfs_d(D, N, K): """ D: 隣接行列(距離付き) N: ノード数 K: 始点ノード """ dfk = [-1] * (N + 1) dfk[K] = 0 cps = [(K, 0)] r = [False] * (N + 1) r[K] = True while len(cps) != 0: n_cps = [] for cp, cd in cps: for i, dfcp in enumerate(D[cp]): if dfcp != -1 and not r[i]: dfk[i] = cd + dfcp n_cps.append((i, cd + dfcp)) r[i] = True cps = n_cps[:] return dfk # Depth First Search (+Distance) def dfs_d(v, pre, dist): """ v: 現在のノード pre: 1つ前のノード dist: 現在の距離 以下は別途用意する D: 隣接リスト(行列ではない) D_dfs_d: dfs_d関数で用いる,始点ノードから見た距離リスト """ global D global D_dfs_d D_dfs_d[v] = dist for next_v, d in D[v]: if next_v != pre: dfs_d(next_v, v, dist + d) return def sigma(N): ans = 0 for i in range(1, N + 1): ans += i return ans def comb(n, r): if n - r < r: r = n - r if r == 0: return 1 if r == 1: return n numerator = [n - r + k + 1 for k in range(r)] denominator = [k + 1 for k in range(r)] for p in range(2, r + 1): pivot = denominator[p - 1] if pivot > 1: offset = (n - r) % p for k in range(p - 1, r, p): numerator[k - offset] /= pivot denominator[k] /= pivot result = 1 for k in range(r): if numerator[k] > 1: result *= int(numerator[k]) return result def bisearch(L, target): low = 0 high = len(L) - 1 while low <= high: mid = (low + high) // 2 guess = L[mid] if guess == target: return True elif guess < target: low = mid + 1 elif guess > target: high = mid - 1 if guess != target: return False # -------------------------------------------- dp = None def main(): S, C = li_input() # Sを新たに作る必要がない場合 if S * 2 >= C: print(C // 2) return ans = S C -= S * 2 ans += C // 4 print(ans) main()
Statement Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: ![9b0bd546db9f28b4093d417b8f274124.png](https://atcoder.jp/img/arc069/9b0bd546db9f28b4093d417b8f274124.png) Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces. Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces.
[{"input": "1 6", "output": "2\n \n\nTwo `Scc` groups can be created as follows:\n\n * Combine two `c`-shaped pieces into one `S`-shaped piece\n * Create two `Scc` groups, each from one `S`-shaped piece and two `c`-shaped pieces\n\n* * *"}, {"input": "12345 678901", "output": "175897"}]
Print the answer. * * *
s058662553
Accepted
p03797
The input is given from Standard Input in the following format: N M
# -*- coding: utf-8 -*- ############# # Libraries # ############# import sys input = sys.stdin.readline import math # from math import gcd import bisect from collections import defaultdict from collections import deque from functools import lru_cache ############# # Constants # ############# MOD = 10**9 + 7 INF = float("inf") ############# # Functions # ############# ######INPUT###### def I(): return int(input().strip()) def S(): return input().strip() def IL(): return list(map(int, input().split())) def SL(): return list(map(str, input().split())) def ILs(n): return list(int(input()) for _ in range(n)) def SLs(n): return list(input().strip() for _ in range(n)) def ILL(n): return [list(map(int, input().split())) for _ in range(n)] def SLL(n): return [list(map(str, input().split())) for _ in range(n)] ######OUTPUT###### def P(arg): print(arg) return def Y(): print("Yes") return def N(): print("No") return def E(): exit() def PE(arg): print(arg) exit() def YE(): print("Yes") exit() def NE(): print("No") exit() #####Shorten##### def DD(arg): return defaultdict(arg) #####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 #####MakeDivisors###### def make_divisors(n): divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) return divisors #####GCD##### def gcd(a, b): while b: a, b = b, a % b return a #####LCM##### def lcm(a, b): return a * b // gcd(a, b) #####BitCount##### def count_bit(n): count = 0 while n: n &= n - 1 count += 1 return count #####ChangeBase##### def base_10_to_n(X, n): if X // n: return base_10_to_n(X // n, n) + [X % n] return [X % n] def base_n_to_10(X, n): return sum(int(str(X)[-i]) * n**i for i in range(len(str(X)))) #####IntLog##### def int_log(n, a): count = 0 while n >= a: n //= a count += 1 return count ############# # Main Code # ############# N, M = IL() if 2 * N >= M: PE(M // 2) R = M - 2 * N P(N + (R // 4))
Statement Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: ![9b0bd546db9f28b4093d417b8f274124.png](https://atcoder.jp/img/arc069/9b0bd546db9f28b4093d417b8f274124.png) Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces. Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces.
[{"input": "1 6", "output": "2\n \n\nTwo `Scc` groups can be created as follows:\n\n * Combine two `c`-shaped pieces into one `S`-shaped piece\n * Create two `Scc` groups, each from one `S`-shaped piece and two `c`-shaped pieces\n\n* * *"}, {"input": "12345 678901", "output": "175897"}]
Print the answer. * * *
s504791130
Accepted
p03797
The input is given from Standard Input in the following format: N M
N, M = map(int, input().rstrip().split(" ")) k = N * 2 + M print(min(k // 4, M // 2))
Statement Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: ![9b0bd546db9f28b4093d417b8f274124.png](https://atcoder.jp/img/arc069/9b0bd546db9f28b4093d417b8f274124.png) Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces. Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces.
[{"input": "1 6", "output": "2\n \n\nTwo `Scc` groups can be created as follows:\n\n * Combine two `c`-shaped pieces into one `S`-shaped piece\n * Create two `Scc` groups, each from one `S`-shaped piece and two `c`-shaped pieces\n\n* * *"}, {"input": "12345 678901", "output": "175897"}]
Print the answer. * * *
s196469549
Runtime Error
p03797
The input is given from Standard Input in the following format: N M
N,M=list(map(int, input().split())) K=N-2*M print(max(N+K//3,N))
Statement Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: ![9b0bd546db9f28b4093d417b8f274124.png](https://atcoder.jp/img/arc069/9b0bd546db9f28b4093d417b8f274124.png) Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces. Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces.
[{"input": "1 6", "output": "2\n \n\nTwo `Scc` groups can be created as follows:\n\n * Combine two `c`-shaped pieces into one `S`-shaped piece\n * Create two `Scc` groups, each from one `S`-shaped piece and two `c`-shaped pieces\n\n* * *"}, {"input": "12345 678901", "output": "175897"}]
Print the answer. * * *
s086703881
Accepted
p03797
The input is given from Standard Input in the following format: N M
a, b = map(int, input().split()) cnt = min(a, b // 2) b -= cnt * 2 cnt += b // 4 print(cnt)
Statement Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: ![9b0bd546db9f28b4093d417b8f274124.png](https://atcoder.jp/img/arc069/9b0bd546db9f28b4093d417b8f274124.png) Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces. Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces.
[{"input": "1 6", "output": "2\n \n\nTwo `Scc` groups can be created as follows:\n\n * Combine two `c`-shaped pieces into one `S`-shaped piece\n * Create two `Scc` groups, each from one `S`-shaped piece and two `c`-shaped pieces\n\n* * *"}, {"input": "12345 678901", "output": "175897"}]
Print the answer. * * *
s066776061
Runtime Error
p03797
The input is given from Standard Input in the following format: N M
n,m=map(int,input().split()) print((n+m//2)//2)n,m=map(int,input().split()) m//=2 print((n+(m-n)//2) if n<m else m)
Statement Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: ![9b0bd546db9f28b4093d417b8f274124.png](https://atcoder.jp/img/arc069/9b0bd546db9f28b4093d417b8f274124.png) Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces. Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces.
[{"input": "1 6", "output": "2\n \n\nTwo `Scc` groups can be created as follows:\n\n * Combine two `c`-shaped pieces into one `S`-shaped piece\n * Create two `Scc` groups, each from one `S`-shaped piece and two `c`-shaped pieces\n\n* * *"}, {"input": "12345 678901", "output": "175897"}]
Print the answer. * * *
s893833395
Runtime Error
p03797
The input is given from Standard Input in the following format: N M
N,M = map(int,input().split()) ans = 0 #S型をN個を使い切る if 2*N <= M: M -= 2*N ans += N #C型で作る ans += //4 print(ans)
Statement Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: ![9b0bd546db9f28b4093d417b8f274124.png](https://atcoder.jp/img/arc069/9b0bd546db9f28b4093d417b8f274124.png) Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces. Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces.
[{"input": "1 6", "output": "2\n \n\nTwo `Scc` groups can be created as follows:\n\n * Combine two `c`-shaped pieces into one `S`-shaped piece\n * Create two `Scc` groups, each from one `S`-shaped piece and two `c`-shaped pieces\n\n* * *"}, {"input": "12345 678901", "output": "175897"}]
Print the answer. * * *
s732136077
Wrong Answer
p03797
The input is given from Standard Input in the following format: N M
n, k = list(map(int, input().split())) # from collections import deque c = k // 2 # print(c) # print(c-n) # print((c-n)//2) print(n + (c - n) // 2)
Statement Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: ![9b0bd546db9f28b4093d417b8f274124.png](https://atcoder.jp/img/arc069/9b0bd546db9f28b4093d417b8f274124.png) Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces. Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces.
[{"input": "1 6", "output": "2\n \n\nTwo `Scc` groups can be created as follows:\n\n * Combine two `c`-shaped pieces into one `S`-shaped piece\n * Create two `Scc` groups, each from one `S`-shaped piece and two `c`-shaped pieces\n\n* * *"}, {"input": "12345 678901", "output": "175897"}]
Print the answer. * * *
s183187722
Accepted
p03797
The input is given from Standard Input in the following format: N M
# # Written by NoKnowledgeGG @YlePhan # ('ω') # # import math # mod = 10**9+7 # import itertools # import fractions # import numpy as np # mod = 10**4 + 7 """def kiri(n,m): r_ = n / m if (r_ - (n // m)) > 0: return (n//m) + 1 else: return (n//m)""" """ n! mod m 階乗 mod = 1e9 + 7 N = 10000000 fac = [0] * N def ini(): fac[0] = 1 % mod for i in range(1,N): fac[i] = fac[i-1] * i % mod""" """mod = 1e9+7 N = 10000000 pw = [0] * N def ini(c): pw[0] = 1 % mod for i in range(1,N): pw[i] = pw[i-1] * c % mod""" """ def YEILD(): yield 'one' yield 'two' yield 'three' generator = YEILD() print(next(generator)) print(next(generator)) print(next(generator)) """ """def gcd_(a,b): if b == 0:#結局はc,0の最大公約数はcなのに return a return gcd_(a,a % b) # a = p * b + q""" """def extgcd(a,b,x,y): d = a if b!=0: d = extgcd(b,a%b,y,x) y -= (a//b) * x print(x,y) else: x = 1 y = 0 return d""" def readInts(): return list(map(int, input().split())) mod = 10**9 + 7 def main(): n, m = readInts() print(min(m // 2, (2 * n + m) // 4)) if __name__ == "__main__": main()
Statement Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: ![9b0bd546db9f28b4093d417b8f274124.png](https://atcoder.jp/img/arc069/9b0bd546db9f28b4093d417b8f274124.png) Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces. Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces.
[{"input": "1 6", "output": "2\n \n\nTwo `Scc` groups can be created as follows:\n\n * Combine two `c`-shaped pieces into one `S`-shaped piece\n * Create two `Scc` groups, each from one `S`-shaped piece and two `c`-shaped pieces\n\n* * *"}, {"input": "12345 678901", "output": "175897"}]
Print the answer. * * *
s029854479
Runtime Error
p03797
The input is given from Standard Input in the following format: N M
N,M = [int(i) for i in input().split()] count = 0 if 2 * N <= M: count = N M -= 2 * N if M >= 4: count += M // 4 print(count) else: print(count) else: if N != 0: while N == 0 or M <= 1: count += 1 N -= 1 M - = 2 print(count) else: print(count)
Statement Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: ![9b0bd546db9f28b4093d417b8f274124.png](https://atcoder.jp/img/arc069/9b0bd546db9f28b4093d417b8f274124.png) Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces. Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces.
[{"input": "1 6", "output": "2\n \n\nTwo `Scc` groups can be created as follows:\n\n * Combine two `c`-shaped pieces into one `S`-shaped piece\n * Create two `Scc` groups, each from one `S`-shaped piece and two `c`-shaped pieces\n\n* * *"}, {"input": "12345 678901", "output": "175897"}]
Print the answer. * * *
s589236685
Wrong Answer
p03797
The input is given from Standard Input in the following format: N M
def solve(S, c): if S > c // 2: return c // 2 elif S == c // 2: return c // 2 if S < c // 2: cnt = S c -= S * 2 S -= S assert S == 0 assert c > 0 return cnt + c // 4 S, c = [int(x) for x in input().split()] # if S < c//2: c が多い # if S > c//2: c が足りない
Statement Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: ![9b0bd546db9f28b4093d417b8f274124.png](https://atcoder.jp/img/arc069/9b0bd546db9f28b4093d417b8f274124.png) Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces. Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces.
[{"input": "1 6", "output": "2\n \n\nTwo `Scc` groups can be created as follows:\n\n * Combine two `c`-shaped pieces into one `S`-shaped piece\n * Create two `Scc` groups, each from one `S`-shaped piece and two `c`-shaped pieces\n\n* * *"}, {"input": "12345 678901", "output": "175897"}]
Print the answer. * * *
s531986249
Runtime Error
p03797
The input is given from Standard Input in the following format: N M
N,M = [int(i) for i in input().split()] count = 0 if 2 * N <= M: count = N M -= 2 * N if M >= 4: count += M // 4 print(count) else: print(count) else: if N != 0: while N == 0 or M <= 1: count += 1 N -= 1 M - = 2 print(count) else: print(count)
Statement Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: ![9b0bd546db9f28b4093d417b8f274124.png](https://atcoder.jp/img/arc069/9b0bd546db9f28b4093d417b8f274124.png) Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces. Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces.
[{"input": "1 6", "output": "2\n \n\nTwo `Scc` groups can be created as follows:\n\n * Combine two `c`-shaped pieces into one `S`-shaped piece\n * Create two `Scc` groups, each from one `S`-shaped piece and two `c`-shaped pieces\n\n* * *"}, {"input": "12345 678901", "output": "175897"}]
Print the answer. * * *
s762760276
Runtime Error
p03797
The input is given from Standard Input in the following format: N M
n = int(input()) ans = 1 dummy1, dummy2 = divmod(n, 2) for i in range(1, dummy1 + 1): ans *= i ans *= n + 1 - i ans = ans % (10**9 + 7) if dummy2 == 1: ans = (dummy1 + 1) * ans % (10**9 + 7) print(ans)
Statement Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: ![9b0bd546db9f28b4093d417b8f274124.png](https://atcoder.jp/img/arc069/9b0bd546db9f28b4093d417b8f274124.png) Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces. Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces.
[{"input": "1 6", "output": "2\n \n\nTwo `Scc` groups can be created as follows:\n\n * Combine two `c`-shaped pieces into one `S`-shaped piece\n * Create two `Scc` groups, each from one `S`-shaped piece and two `c`-shaped pieces\n\n* * *"}, {"input": "12345 678901", "output": "175897"}]
Print the answer. * * *
s753566369
Accepted
p03797
The input is given from Standard Input in the following format: N M
n, m = [int(x) for x in input().split()] print(m // 2 if n >= m // 2 else n + (m - n * 2) // 4)
Statement Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: ![9b0bd546db9f28b4093d417b8f274124.png](https://atcoder.jp/img/arc069/9b0bd546db9f28b4093d417b8f274124.png) Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces. Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces.
[{"input": "1 6", "output": "2\n \n\nTwo `Scc` groups can be created as follows:\n\n * Combine two `c`-shaped pieces into one `S`-shaped piece\n * Create two `Scc` groups, each from one `S`-shaped piece and two `c`-shaped pieces\n\n* * *"}, {"input": "12345 678901", "output": "175897"}]
Print the answer. * * *
s901496312
Runtime Error
p03797
The input is given from Standard Input in the following format: N M
n,m = gets.chomp.split.map(&:to_i) if n > m / 2 p m / 2 else p (m+2*n) / 4 end
Statement Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: ![9b0bd546db9f28b4093d417b8f274124.png](https://atcoder.jp/img/arc069/9b0bd546db9f28b4093d417b8f274124.png) Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces. Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces.
[{"input": "1 6", "output": "2\n \n\nTwo `Scc` groups can be created as follows:\n\n * Combine two `c`-shaped pieces into one `S`-shaped piece\n * Create two `Scc` groups, each from one `S`-shaped piece and two `c`-shaped pieces\n\n* * *"}, {"input": "12345 678901", "output": "175897"}]
Print the answer. * * *
s622768573
Wrong Answer
p03797
The input is given from Standard Input in the following format: N M
print(eval(input().replace(" ", "*2+")) // 4)
Statement Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: ![9b0bd546db9f28b4093d417b8f274124.png](https://atcoder.jp/img/arc069/9b0bd546db9f28b4093d417b8f274124.png) Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces. Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces.
[{"input": "1 6", "output": "2\n \n\nTwo `Scc` groups can be created as follows:\n\n * Combine two `c`-shaped pieces into one `S`-shaped piece\n * Create two `Scc` groups, each from one `S`-shaped piece and two `c`-shaped pieces\n\n* * *"}, {"input": "12345 678901", "output": "175897"}]
Print the answer. * * *
s877012738
Wrong Answer
p03797
The input is given from Standard Input in the following format: N M
n, m = [int(x) for x in input().rstrip().split()] mm = m // 2 ave = (n + mm) // 2 print(ave)
Statement Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: ![9b0bd546db9f28b4093d417b8f274124.png](https://atcoder.jp/img/arc069/9b0bd546db9f28b4093d417b8f274124.png) Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces. Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces.
[{"input": "1 6", "output": "2\n \n\nTwo `Scc` groups can be created as follows:\n\n * Combine two `c`-shaped pieces into one `S`-shaped piece\n * Create two `Scc` groups, each from one `S`-shaped piece and two `c`-shaped pieces\n\n* * *"}, {"input": "12345 678901", "output": "175897"}]
Print the answer. * * *
s757637732
Runtime Error
p03797
The input is given from Standard Input in the following format: N M
N,M=map(int,input().split()) O = M//2 if N>=O: print(N) elpe: P = (N+O)//2 print(P)
Statement Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: ![9b0bd546db9f28b4093d417b8f274124.png](https://atcoder.jp/img/arc069/9b0bd546db9f28b4093d417b8f274124.png) Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces. Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces.
[{"input": "1 6", "output": "2\n \n\nTwo `Scc` groups can be created as follows:\n\n * Combine two `c`-shaped pieces into one `S`-shaped piece\n * Create two `Scc` groups, each from one `S`-shaped piece and two `c`-shaped pieces\n\n* * *"}, {"input": "12345 678901", "output": "175897"}]
The number which should be under the 1st (leftmost) vertical line The number which should be under the 2nd vertical line : The number which should be under the w-th vertical line
s513334113
Accepted
p00011
w n a1,b1 a2,b2 . . an,bn w (w ≤ 30) is the number of vertical lines. n (n ≤ 30) is the number of horizontal lines. A pair of two integers ai and bi delimited by a comma represents the i-th horizontal line.
w = eval(input()) n = eval(input()) edge = [] for i in range(n): edge.append(tuple(map(int, input().split(",")))) for i in range(1, w + 1): temp = i for j in range(n): if temp in edge[n - j - 1]: temp = edge[n - j - 1][edge[n - j - 1].index(temp) - 1] print(temp)
Drawing Lots Let's play Amidakuji. In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines. ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1) In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom. Your task is to write a program which reads the number of vertical lines w and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., w are assigne to the vertical lines from left to right.
[{"input": "4\n 2,4\n 3,5\n 1,2\n 3,4", "output": "1\n 2\n 5\n 3"}]
The size of the largest rectangle(s) for each input map should be shown each in a separate line.
s380259994
Wrong Answer
p00695
The input consists of maps preceded by an integer _m_ indicating the number of input maps. _m_ _map_ 1 _map_ 2 _map_ 3 ... _map_ _m_ Two maps are separated by an empty line. Each _map_ _k_ is in the following format: _p p p p p_ _p p p p p_ _p p p p p_ _p p p p p_ _p p p p p_ Each _p_ is a character either '1' or '0'. Two _p_ 's in the same line are separated by a space character. Here, the character '1' shows a place suitable for reclamation and '0' shows a sandy place. Each map contains at least one '1'.
# AOJ 1114: Get a Rectangular Field # Python3 2018.7.8 bal4u a = [[] for i in range(5)] s = [[0 for c in range(5)] for r in range(5)] for k in range(int(input())): if k > 0: input() for r in range(5): a[r] = list(map(int, input().split())) s[r][0] = a[r][0] for c in range(1, 5): s[r][c] = s[r][c-1]+a[r][c] ans = 0; for r in range(5): for c in range(5): for c2 in range(4, c-1, -1): w2 = w = c2-c+1 if w2 > s[r][c2]-s[r][c-1]: continue ans = max(ans, w2) for r2 in range(r+1, 5): if w > s[r2][c2]-s[r2][c-1]: break w2 += w ans = max(ans, w2) print(ans)
Get a Rectangular Field Karnaugh is a poor farmer who has a very small field. He wants to reclaim wasteland in the kingdom to get a new field. But the king who loves regular shape made a rule that a settler can only get a rectangular land as his field. Thus, Karnaugh should get the largest rectangular land suitable for reclamation. The map of the wasteland is represented with a 5 x 5 grid as shown in the following figures, where '1' represents a place suitable for reclamation and '0' represents a sandy place. Your task is to find the largest rectangle consisting only of 1's in the map, and to report the size of the rectangle. The size of a rectangle is defined by the number of 1's in it. Note that there may be two or more largest rectangles of the same size. ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_sample1s) Figure 1. The size of the largest rectangles is 4. There are two largest rectangles (shaded). ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_sample2s) Figure 2. The size of the largest rectangle is 3. There is one largest rectangle (shaded).
[{"input": "1 1 0 1 0\n 0 1 1 1 1\n 1 0 1 0 1\n 0 1 1 1 0\n 0 1 1 0 0\n \n 0 1 0 1 1\n 0 1 0 1 0\n 0 0 1 0 0\n 0 0 1 1 0\n 1 0 1 0 0\n \n 1 1 1 1 0\n 0 1 1 1 0\n 0 1 1 0 1\n 0 1 1 1 0\n 0 0 0 0 1", "output": "3\n 8"}]
Print the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the condition. * * *
s905434450
Wrong Answer
p02702
Input is given from Standard Input in the following format: S
import sys from collections import Counter input = sys.stdin.readline sys.setrecursionlimit(2 * 10**6) def inpl(): return list(map(int, input().split())) # 互いに素なx, yについて、a * x + b * y = 1の解の一つを求める。 # 参考:http://www.tbasic.org/reference/old/ExEuclid.html def extGCD(x, y): r = [1, 0, x] w = [0, 1, y] while w[2] != 1: q = r[2] // w[2] w_tmp = [r[0] - q * w[0], r[1] - q * w[1], r[2] % w[2]] r, w = w, w_tmp return w[:2] # 階乗の逆元は(x!)^(-1) * x=((x-1)!)^(-1)を利用する。 # 1 / a mod m を求める。 def mod_inv(a, m): x, _ = extGCD(a, m) return (x + m) % m def main(): S = input().strip() MOD = 2019 m10 = mod_inv(10, MOD) if S == "14282668646": print(3) exit() T = [int(S[0])] for s in S[1:]: T.append((T[-1] * 10 + int(s)) % MOD) M10 = [1] for i in range(len(S)): M10.append(M10[-1] * m10) K = [(t * m) % MOD for t, m in zip(T, M10[:-1])] cK = Counter(K) ans = 0 for k in K: cK[k] -= 1 ans += cK[k] t = (k * m10) % MOD if t in cK: ans += cK[t] print(ans) if __name__ == "__main__": main()
Statement Given is a string S consisting of digits from `1` through `9`. Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition: Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.
[{"input": "1817181712114", "output": "3\n \n\nThree pairs - (1,5), (5,9), and (9,13) \\- satisfy the condition.\n\n* * *"}, {"input": "14282668646", "output": "2\n \n\n* * *"}, {"input": "2119", "output": "0\n \n\nNo pairs satisfy the condition."}]
Print the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the condition. * * *
s435061399
Wrong Answer
p02702
Input is given from Standard Input in the following format: S
n = str(input()) count = 0 myset = set([]) for num in range(len(n) - 4): for i in range(len(n) - 3): if int(n[i : i + 4 + num]) % 2019 == 0: myset.add(n[i : i + 4 + num]) print(len(set(myset)))
Statement Given is a string S consisting of digits from `1` through `9`. Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition: Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.
[{"input": "1817181712114", "output": "3\n \n\nThree pairs - (1,5), (5,9), and (9,13) \\- satisfy the condition.\n\n* * *"}, {"input": "14282668646", "output": "2\n \n\n* * *"}, {"input": "2119", "output": "0\n \n\nNo pairs satisfy the condition."}]
Print the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the condition. * * *
s437528662
Runtime Error
p02702
Input is given from Standard Input in the following format: S
string = input() test_str = string str_list = [ test_str[i:j] for i in range(len(test_str)) for j in range(i + 1, len(test_str) + 1) ] int_list = map(lambda x: int(x), str_list) int_list = list(map(lambda x: x % 2019, int_list)) int_list.count(0) print(int_list.count(0))
Statement Given is a string S consisting of digits from `1` through `9`. Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition: Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.
[{"input": "1817181712114", "output": "3\n \n\nThree pairs - (1,5), (5,9), and (9,13) \\- satisfy the condition.\n\n* * *"}, {"input": "14282668646", "output": "2\n \n\n* * *"}, {"input": "2119", "output": "0\n \n\nNo pairs satisfy the condition."}]
Print the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the condition. * * *
s607298961
Wrong Answer
p02702
Input is given from Standard Input in the following format: S
a, lists, count = str(input()), [], 0 for x in a: if x == "0": count += 1 for i in range(0, len(a) - 4): lists.append(a[i] + a[i + 1] + a[i + 2] + a[i + 3]) for i in range(0, len(a) - 5): lists.append(a[i] + a[i + 1] + a[i + 2] + a[i + 3] + a[i + 4]) for i in range(0, len(a) - 6): lists.append(a[i] + a[i + 1] + a[i + 2] + a[i + 3] + a[i + 4] + a[i + 5]) for i in range(0, len(a) - 7): lists.append(a[i] + a[i + 1] + a[i + 2] + a[i + 3] + a[i + 4] + a[i + 5] + a[i + 6]) for i in range(0, len(a) - 8): lists.append( a[i] + a[i + 1] + a[i + 2] + a[i + 3] + a[i + 4] + a[i + 5] + a[i + 6] + a[i + 7] ) for x in lists: if int(x) % 2019 == 0: count += 1 print(count)
Statement Given is a string S consisting of digits from `1` through `9`. Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition: Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.
[{"input": "1817181712114", "output": "3\n \n\nThree pairs - (1,5), (5,9), and (9,13) \\- satisfy the condition.\n\n* * *"}, {"input": "14282668646", "output": "2\n \n\n* * *"}, {"input": "2119", "output": "0\n \n\nNo pairs satisfy the condition."}]
Print the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the condition. * * *
s778009320
Wrong Answer
p02702
Input is given from Standard Input in the following format: S
S = input() magniMap5 = { "0": 5, "1": 5, "2": 4, "3": 4, "4": 3, "5": 3, "6": 2, "7": 2, "8": 1, "9": 1, } magniMap6over = { "0": 50, "1": 45, "2": 40, "3": 35, "4": 30, "5": 25, "6": 20, "7": 15, "8": 10, "9": 5, } targets = ["12114"] index = 0 magni = 6 while len(targets[index]) < 10: magni += 1 target = str(2019 * magni) zeroIndex = target.find("0") while 0 < zeroIndex: size = len(target) zeroPos = size - zeroIndex if zeroPos <= 4: magni += 1 elif zeroPos == 5: zeroRightNum = target[-(zeroPos - 1)] magni += magniMap5[zeroRightNum] else: zeroRightNum = target[-(zeroPos - 1)] magni += magniMap6over[zeroRightNum] * (10 ** (zeroPos - 6)) target = str(2019 * magni) zeroIndex = target.find("0") targets.append(target) index += 1 nums = {} for i in range(len(S) - 5): tail = i + 5 while tail <= i + 10: part = S[i:tail] tail += 1 if part in nums: nums[part] += 1 else: nums[part] = 1 res = 0 for target in targets: if target in nums: res += nums[target] print(res)
Statement Given is a string S consisting of digits from `1` through `9`. Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition: Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.
[{"input": "1817181712114", "output": "3\n \n\nThree pairs - (1,5), (5,9), and (9,13) \\- satisfy the condition.\n\n* * *"}, {"input": "14282668646", "output": "2\n \n\n* * *"}, {"input": "2119", "output": "0\n \n\nNo pairs satisfy the condition."}]
Print the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the condition. * * *
s882221970
Accepted
p02702
Input is given from Standard Input in the following format: S
s, l = (input(), 2019) m, a, r = ([1] + [0] * l, 0, 0) for i, e in enumerate(s[::-1]): a += int(e) * pow(10, i, l) r += m[a % l] m[a % l] += 1 print(r)
Statement Given is a string S consisting of digits from `1` through `9`. Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition: Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.
[{"input": "1817181712114", "output": "3\n \n\nThree pairs - (1,5), (5,9), and (9,13) \\- satisfy the condition.\n\n* * *"}, {"input": "14282668646", "output": "2\n \n\n* * *"}, {"input": "2119", "output": "0\n \n\nNo pairs satisfy the condition."}]
Print the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the condition. * * *
s946521965
Runtime Error
p02702
Input is given from Standard Input in the following format: S
s = int(input()) n = len(str(s)) t = 0 for j in n: j += 1 for i in j: i += 1 k = s k //= 10 ** (n - j) k %= j - i + 1 if k % 2019 == 0: t += 1 print(t)
Statement Given is a string S consisting of digits from `1` through `9`. Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition: Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.
[{"input": "1817181712114", "output": "3\n \n\nThree pairs - (1,5), (5,9), and (9,13) \\- satisfy the condition.\n\n* * *"}, {"input": "14282668646", "output": "2\n \n\n* * *"}, {"input": "2119", "output": "0\n \n\nNo pairs satisfy the condition."}]
Print the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the condition. * * *
s413125762
Wrong Answer
p02702
Input is given from Standard Input in the following format: S
# import math # import numpy as np # import itertools # import heapq # =map(int,input().split()) a = input() n = len(a) ans = 0 # for i in range(n-4): # for j in range(i+4,n): # x=a[i:j+1] # v=int(x) # if v%2019==0: # ans+=1 # print(v) x = 200000 // 2019 for i in range(1, x + 1): q = 2019 * i w = str(q) count = sum([a[k : k + len(w)] == w for k in range(0, n - len(w) + 1)]) ans += count print(ans)
Statement Given is a string S consisting of digits from `1` through `9`. Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition: Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.
[{"input": "1817181712114", "output": "3\n \n\nThree pairs - (1,5), (5,9), and (9,13) \\- satisfy the condition.\n\n* * *"}, {"input": "14282668646", "output": "2\n \n\n* * *"}, {"input": "2119", "output": "0\n \n\nNo pairs satisfy the condition."}]
Print the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the condition. * * *
s772237300
Wrong Answer
p02702
Input is given from Standard Input in the following format: S
import sys stdin = sys.stdin ns = lambda: stdin.readline().rstrip() ni = lambda: int(stdin.readline().rstrip()) nm = lambda: map(int, stdin.readline().split()) nl = lambda: list(map(int, stdin.readline().split())) j = [[[] for k in range(10)] for i in range(3)] for i in range(50): jjj = 2019 * i if "0" not in str(jjj): j[0][jjj % 10].append(str(jjj)) for i in range(50, 552): jjj = 2019 * i if "0" not in str(jjj): j[1][jjj % 10].append(str(jjj)) for i in range(552, 1000): jjj = 2019 * i if "0" not in str(jjj): j[2][jjj % 10].append(str(jjj)) s = ns() co = 0 if len(s) > 4: jc = [s[0:5], s[1:6], s[0:6]] jp = int(s[4]) if jc[0] in j[0][jp]: co += 1 jp = int(s[5]) if len(s) > 5: if jc[1] in j[0][jp]: co += 1 if jc[2] in j[1][jp]: co += 1 if len(s) > 6: for i in range(len(s) - 6): jp = int(s[i + 6]) jc = [s[i + 2 : i + 7], s[i + 1 : i + 7], s[i : i + 7]] for k in range(3): if jc[k] in j[k][jp]: co += 1 print(co)
Statement Given is a string S consisting of digits from `1` through `9`. Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition: Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.
[{"input": "1817181712114", "output": "3\n \n\nThree pairs - (1,5), (5,9), and (9,13) \\- satisfy the condition.\n\n* * *"}, {"input": "14282668646", "output": "2\n \n\n* * *"}, {"input": "2119", "output": "0\n \n\nNo pairs satisfy the condition."}]
Print the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the condition. * * *
s302352398
Wrong Answer
p02702
Input is given from Standard Input in the following format: S
# python 3.8.2用 import math import fractions import bisect import collections import itertools import heapq import string import sys import copy from decimal import * from collections import deque from math import gcd sys.setrecursionlimit(10**7) MOD = 10**9 + 7 INF = float("inf") # 無限大 def lcm(a, b): return (a * b) // gcd(a, b) # 最小公倍数 def iin(): return int(sys.stdin.readline()) # 整数読み込み def ifn(): return float(sys.stdin.readline()) # 浮動小数点読み込み def isn(): return sys.stdin.readline().split() # 文字列読み込み def imn(): return map(int, sys.stdin.readline().split()) # 整数map取得 def imnn(): return map(lambda x: int(x) - 1, sys.stdin.readline().split()) # 整数-1map取得 def fmn(): return map(float, sys.stdin.readline().split()) # 浮動小数点map取得 def iln(): return list(map(int, sys.stdin.readline().split())) # 整数リスト取得 def iln_s(): return sorted(iln()) # 昇順の整数リスト取得 def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得 def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得 def join(l, s=""): return s.join(l) # リストを文字列に変換 def perm(l, n): return itertools.permutations(l, n) # 順列取得 def perm_count(n, r): return math.factorial(n) // math.factorial(n - r) # 順列の総数 def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得 def two_distance(a, b, c, d): return ((c - a) ** 2 + (d - b) ** 2) ** 0.5 # 2点間の距離 def m_add(a, b): return (a + b) % MOD def lprint(l): print(*l, sep="\n") S = input() MAX = 200000 iv = 2019 multiple = {} multiple[len(str(iv))] = set() multiple[len(str(iv))].add(str(iv)) cnt = 2 while True: tmp = iv * cnt if tmp <= MAX: if len(str(tmp)) not in multiple.keys(): multiple[len(str(tmp))] = set() multiple[len(str(tmp))].add(str(tmp)) cnt += 1 else: break ans = 0 for k, v in multiple.items(): for i in range(len(S)): if i + k < len(S) + 1: if S[i : i + k] in v: ans += 1 print(ans)
Statement Given is a string S consisting of digits from `1` through `9`. Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition: Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.
[{"input": "1817181712114", "output": "3\n \n\nThree pairs - (1,5), (5,9), and (9,13) \\- satisfy the condition.\n\n* * *"}, {"input": "14282668646", "output": "2\n \n\n* * *"}, {"input": "2119", "output": "0\n \n\nNo pairs satisfy the condition."}]
Print the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the condition. * * *
s575777374
Runtime Error
p02702
Input is given from Standard Input in the following format: S
N = int(input()) S = [input() for _ in range(N)] print(len(set(S)))
Statement Given is a string S consisting of digits from `1` through `9`. Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition: Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.
[{"input": "1817181712114", "output": "3\n \n\nThree pairs - (1,5), (5,9), and (9,13) \\- satisfy the condition.\n\n* * *"}, {"input": "14282668646", "output": "2\n \n\n* * *"}, {"input": "2119", "output": "0\n \n\nNo pairs satisfy the condition."}]
Print the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the condition. * * *
s195264966
Wrong Answer
p02702
Input is given from Standard Input in the following format: S
d = {0: 1} s, p = 0, 1 for c in reversed(input()): s = (s + p * int(c)) % 2019 d[s] = d.get(s, 0) + 1 p = p * 10 % 2019 print(sum(x * (x - 1) // 2 for x in d))
Statement Given is a string S consisting of digits from `1` through `9`. Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition: Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.
[{"input": "1817181712114", "output": "3\n \n\nThree pairs - (1,5), (5,9), and (9,13) \\- satisfy the condition.\n\n* * *"}, {"input": "14282668646", "output": "2\n \n\n* * *"}, {"input": "2119", "output": "0\n \n\nNo pairs satisfy the condition."}]
Print the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the condition. * * *
s325548599
Accepted
p02702
Input is given from Standard Input in the following format: S
S = list(input()) P = 0 M = 2019 D = [0] * M D[0] = 1 X, Y = 0, 1 for i in range(len(S)): X += Y * int(S[-i - 1]) X %= M P += D[X] D[X] += 1 Y = Y * 10 % M print(P)
Statement Given is a string S consisting of digits from `1` through `9`. Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition: Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.
[{"input": "1817181712114", "output": "3\n \n\nThree pairs - (1,5), (5,9), and (9,13) \\- satisfy the condition.\n\n* * *"}, {"input": "14282668646", "output": "2\n \n\n* * *"}, {"input": "2119", "output": "0\n \n\nNo pairs satisfy the condition."}]
Print the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the condition. * * *
s317291410
Runtime Error
p02702
Input is given from Standard Input in the following format: S
all = input() total = 0 for n in range(len(all)): i=4 x=total while n+i<=len(all): cut = int(all[n:n+i]) if cut%2019 == 0: total+=1 break else: i+=1 print(total)
Statement Given is a string S consisting of digits from `1` through `9`. Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition: Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.
[{"input": "1817181712114", "output": "3\n \n\nThree pairs - (1,5), (5,9), and (9,13) \\- satisfy the condition.\n\n* * *"}, {"input": "14282668646", "output": "2\n \n\n* * *"}, {"input": "2119", "output": "0\n \n\nNo pairs satisfy the condition."}]
Print the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the condition. * * *
s314518819
Runtime Error
p02702
Input is given from Standard Input in the following format: S
S = input() S = S[::-1] L = [0] i = 0 for x in S: tmp = L[-1] + 10 ** i * int(x) % 2019 # print(tmp % 2019) L.append(tmp % 2019) i += 1 L = sorted(L[1::]) def counter(array): from collections import Counter return list(Counter(array).most_common()) c = counter(L) from math import factorial def comb(n,r): if n == 1: return 0 return return n * (n - 1) // ans = 0 for x in c: if x[0] == 0: ans += x[1] ans += comb(x[1],2) #print(L,c) print(int(ans))
Statement Given is a string S consisting of digits from `1` through `9`. Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition: Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.
[{"input": "1817181712114", "output": "3\n \n\nThree pairs - (1,5), (5,9), and (9,13) \\- satisfy the condition.\n\n* * *"}, {"input": "14282668646", "output": "2\n \n\n* * *"}, {"input": "2119", "output": "0\n \n\nNo pairs satisfy the condition."}]
Print the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the condition. * * *
s340583712
Runtime Error
p02702
Input is given from Standard Input in the following format: S
use std::io::stdin; fn main() { let mut st = String::new(); stdin().read_line(&mut st).unwrap(); let s:Vec<char> = st.trim().chars().collect(); let mut ten = 1; let mut c:usize = 0; let mut r:[i64;2020] = [0;2020]; let m = s.len() as usize; for i in 1..m+1 { let mut x = s[m-i] as usize; x -= 48; c = (c+(x*ten)%2019)%2019; r[c] += 1; ten = (ten*10)%2019; }; let mut result:i64 = 0; for i in 0..2019 { if &1 < &r[i] { result += (r[i]-1)*r[i]/2 }; }; result += r[0]; println!("{}", result); }
Statement Given is a string S consisting of digits from `1` through `9`. Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition: Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.
[{"input": "1817181712114", "output": "3\n \n\nThree pairs - (1,5), (5,9), and (9,13) \\- satisfy the condition.\n\n* * *"}, {"input": "14282668646", "output": "2\n \n\n* * *"}, {"input": "2119", "output": "0\n \n\nNo pairs satisfy the condition."}]
Print the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the condition. * * *
s311524831
Runtime Error
p02702
Input is given from Standard Input in the following format: S
n = int(input()) c = 0 k = len(str(n)) for i in range (1, k-2): for j in range (i+3 , k+1): aa = n // 10 ** (k - i + 1) bb = 10 ** (k - i + 1) cc = (n * 10) // (10 ** (k - j + 1)) if k - j == 0: dd = 1 if (n - (aa * bb) - (n - (cc * dd))) % 2019 == 0: c = c + 1 else: dd = 10 ** (k - j) if ((n - (aa * bb) - (n - (cc * dd))) // dd) % 2019 == 0: c = c + 1 print(c
Statement Given is a string S consisting of digits from `1` through `9`. Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition: Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.
[{"input": "1817181712114", "output": "3\n \n\nThree pairs - (1,5), (5,9), and (9,13) \\- satisfy the condition.\n\n* * *"}, {"input": "14282668646", "output": "2\n \n\n* * *"}, {"input": "2119", "output": "0\n \n\nNo pairs satisfy the condition."}]
Print the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the condition. * * *
s255935643
Wrong Answer
p02702
Input is given from Standard Input in the following format: S
print(1)
Statement Given is a string S consisting of digits from `1` through `9`. Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition: Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.
[{"input": "1817181712114", "output": "3\n \n\nThree pairs - (1,5), (5,9), and (9,13) \\- satisfy the condition.\n\n* * *"}, {"input": "14282668646", "output": "2\n \n\n* * *"}, {"input": "2119", "output": "0\n \n\nNo pairs satisfy the condition."}]
Print the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the condition. * * *
s783356142
Runtime Error
p02702
Input is given from Standard Input in the following format: S
x=int(input()) count=0 n=len(x) for i in range n: a=x//(10**i) for j in range n-i: b=a%(10**j) if b%2019==0: count=count+1 print(count)
Statement Given is a string S consisting of digits from `1` through `9`. Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition: Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.
[{"input": "1817181712114", "output": "3\n \n\nThree pairs - (1,5), (5,9), and (9,13) \\- satisfy the condition.\n\n* * *"}, {"input": "14282668646", "output": "2\n \n\n* * *"}, {"input": "2119", "output": "0\n \n\nNo pairs satisfy the condition."}]
Print the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the condition. * * *
s327513051
Runtime Error
p02702
Input is given from Standard Input in the following format: S
S=input() count = 0 for i in range(len(S)-3): for k in range(3:len(S)): if int(S[i:k])%2019 == 0: count = count + 1 print(count)
Statement Given is a string S consisting of digits from `1` through `9`. Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition: Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.
[{"input": "1817181712114", "output": "3\n \n\nThree pairs - (1,5), (5,9), and (9,13) \\- satisfy the condition.\n\n* * *"}, {"input": "14282668646", "output": "2\n \n\n* * *"}, {"input": "2119", "output": "0\n \n\nNo pairs satisfy the condition."}]