description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
A boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: 2 squares forward and 2 squares to the right, 2 squares forward and 2 squares to the left, 2 squares backward and 2 to the right and 2 squares backward and 2 to the le...
N = range(8) test = int(input()) for i_test in range(test): if i_test: input() x1, y1, x2, y2 = 0, 0, 0, 0 map = [input() for i in N] for i in N: for j in N: if map[i][j] == "K": x1, y1, x2, y2 = x2, y2, i, j if abs(x1 - x2) % 4 == 0 and abs(y1 - y2) % 4 =...
ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR VAR FOR VAR VAR IF VAR VAR VAR STRING ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR IF BIN_OP FUNC_CALL VAR BIN_...
A boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: 2 squares forward and 2 squares to the right, 2 squares forward and 2 squares to the left, 2 squares backward and 2 to the right and 2 squares backward and 2 to the le...
3 n = int(input()) for _ in range(n): k = [] b = [] for i in range(8): s = input() for j in range(8): if s[j] == "K": k.append((i, j)) print( "YES" if abs(k[0][0] - k[1][0]) % 4 == 0 and abs(k[0][1] - k[1][1]) % 4 == 0 else "NO" ) ...
EXPR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR STRING EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER ...
A boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: 2 squares forward and 2 squares to the right, 2 squares forward and 2 squares to the left, 2 squares backward and 2 to the right and 2 squares backward and 2 to the le...
t = int(input()) for k in range(t): r8 = range(8) a = [input() for i in r8] ij = [(i, j) for i in r8 for j in r8] x, y = ((i, j) for i, j in ij if a[i][j] == "K") def s(p): d = [ (p[0] - 2, p[1] - 2), (p[0] + 2, p[1] - 2), (p[0] - 2, p[1] + 2), ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR STRING FUNC_DEF ASSIGN VAR LIST BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER B...
A boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: 2 squares forward and 2 squares to the right, 2 squares forward and 2 squares to the left, 2 squares backward and 2 to the right and 2 squares backward and 2 to the le...
MOVS = [(2, -2), (-2, 2), (-2, -2), (2, 2)] def check(a): return 0 <= a < 8 set1 = set() set2 = set() dic1 = dict() dic2 = dict() def cango1(matrix, pos, lap): for dx, dy in MOVS: nx, ny = dx + pos[0], dy + pos[1] if not check(nx) or not check(ny): continue if (nx, ny) ...
ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FUNC_DEF RETURN NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF FOR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL...
Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements: each cut should be straight (horizontal or vertical); each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate ...
n, m, k = [int(s) for s in input().split()] n, m = max(n, m), min(n, m) if n + m - 2 < k: print(-1) elif n - 1 < k: print(m // (k - n + 2)) elif m - 1 < k: print(n // (k + 1) * m) else: print(max(n // (k + 1) * m, m // (k + 1) * n))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP...
Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements: each cut should be straight (horizontal or vertical); each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate ...
n, m, k = map(int, input().split()) n, m = min(n, m), max(n, m) def p(i, j): return n // (i + 1) * (m // (j + 1)) if k < n: print(max(p(k, 0), p(0, k))) elif k < m: print(p(0, k)) elif k <= n + m - 2: print(p(k - (m - 1), m - 1)) else: print(-1)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR NUMBER VAR IF VAR VAR EXPR FUNC_CALL...
Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements: each cut should be straight (horizontal or vertical); each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate ...
n, m, k = map(int, input().split()) if k > n + m - 2: print(-1) exit() res = 0 if k < n: res = max(res, n // (k + 1) * m) else: res = max(res, m // (k - (n - 1) + 1)) if k < m: res = max(res, m // (k + 1) * n) else: res = max(res, n // (k - (m - 1) + 1)) print(res)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMB...
Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements: each cut should be straight (horizontal or vertical); each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate ...
n, m, k = map(int, input().split()) if k > n + m - 2: print(-1) else: a, b = m * (n // (k + 1)), n * (m // (k + 1)) if a == 0: a = m // (k - n + 2) if b == 0: b = n // (k - m + 2) print(max(a, b))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR B...
Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements: each cut should be straight (horizontal or vertical); each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate ...
def split1(m, n, k): if m % (k + 1) == 0: return n * (m // (k + 1)) if k < m: return m // (k + 1) * n else: k2 = k - m + 1 return n // (k2 + 1) def split(m, n, k): r = max(split1(m, n, k), split1(n, m, k)) return r if r else -1 args = input().split() print(split(*...
FUNC_DEF IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER RETURN BIN_OP VAR BIN_OP VAR BIN_OP VAR NUMBER IF VAR VAR RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN BIN_OP VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR RETUR...
Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements: each cut should be straight (horizontal or vertical); each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate ...
a = input().split(" ") n = int(a[0]) m = int(a[1]) k = int(a[2]) if k > m + n - 2: print(-1) else: ans = 1 if k < n: ans = max(ans, n // (k + 1) * m) if k < m: ans = max(ans, m // (k + 1) * n) if k >= n: ans = max(ans, m // (k - (n - 1) + 1)) if k >= m: ans = max(...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR IF VAR VAR...
Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements: each cut should be straight (horizontal or vertical); each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate ...
n, m, k = list(map(int, input().split())) if n + m - 2 < k: print("-1\n") else: x = min(n - 1, k) y = max(0, k - x) ans = n // (x + 1) * (m // (y + 1)) y = min(m - 1, k) x = max(0, k - y) ans = max(ans, n // (x + 1) * (m // (y + 1))) print(ans, "\n")
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP BIN_OP VAR VAR NUMBER VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR FU...
Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements: each cut should be straight (horizontal or vertical); each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate ...
def split1(m, n, k): if k < m: return m // (k + 1) * n else: return n // (k - m + 2) def split(m, n, k): r = max(split1(m, n, k), split1(n, m, k)) return r if r else -1 args = input().split() print(split(*list(map(int, args))))
FUNC_DEF IF VAR VAR RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR RETURN BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR RETURN VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VA...
Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements: each cut should be straight (horizontal or vertical); each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate ...
n, m, k = map(int, input().split()) if k <= n + m - 2: x = min(k + 1, n) y = k + 2 - x a = n // x * (m // y) y = min(k + 1, m) x = k + 2 - y b = n // x * (m // y) print(max(a, b)) else: print(-1)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR A...
Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements: each cut should be straight (horizontal or vertical); each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate ...
n, m, k = map(int, input().split()) if k > n + m - 2: print(-1) else: if n < m: n, m = m, n if m % (k + 1) == 0: print(m * n // (k + 1)) elif k <= n - 1: if k > m - 1: print(n // (k + 1) * m) else: print(max(n // (k + 1) * m, m // (k + 1) * n)) ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL ...
Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements: each cut should be straight (horizontal or vertical); each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate ...
n, m, k = list(map(int, input().split())) ans, ans1 = 0, 0 if n + m - 2 < k: print(-1) return else: k1 = k if k < n: ans = n // (k + 1) * m else: k -= n - 1 ans = m // (k + 1) if k1 < m: ans1 = m // (k1 + 1) * n else: k1 -= m - 1 ans1 = n // (k...
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER IF VAR V...
Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements: each cut should be straight (horizontal or vertical); each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate ...
def cut(n, m, k): if k > m + n - 2: return -1 if k < max(m, n): return max(n * (m // (k + 1)), m * (n // (k + 1))) return max(n // (k - m + 2), m // (k - n + 2)) n, m, k = map(int, input().split()) print(cut(n, m, k))
FUNC_DEF IF VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN NUMBER IF VAR FUNC_CALL VAR VAR VAR RETURN FUNC_CALL VAR BIN_OP VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR BIN_OP VAR NUMBER RETURN FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL V...
Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements: each cut should be straight (horizontal or vertical); each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate ...
def read(mode=2): inputs = input().strip() if mode == 0: return inputs if mode == 1: return inputs.split() if mode == 2: return [int(x) for x in inputs.split()] def write(s="\n"): if isinstance(s, list): s = " ".join(map(str, s)) s = str(s) print(s, end="") ...
FUNC_DEF NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER RETURN VAR IF VAR NUMBER RETURN FUNC_CALL VAR IF VAR NUMBER RETURN FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_DEF STRING IF FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR STRING AS...
Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements: each cut should be straight (horizontal or vertical); each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate ...
def main(): n, m, k = [int(i) for i in input().split()] if k > n + m - 2: print(-1) return if k > n - 1: result1 = m // (k + 2 - n) else: result1 = n // (k + 1) * m if k > m - 1: result2 = n // (k + 2 - m) else: result2 = m // (k + 1) * n print...
FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN...
Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements: each cut should be straight (horizontal or vertical); each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate ...
n, m, k = map(int, input().split()) if m > n: n, m = m, n ans = -1 if k < n: ans = m * (n // (k + 1)) if k < m: ans = max(ans, n * (m // (k + 1))) elif k <= n - 1 + m - 1: ans = m // (k + 1 - n + 1) print(ans)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP VAR BIN_OP VAR NUMBER IF VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_...
Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements: each cut should be straight (horizontal or vertical); each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate ...
l = input().split() n = int(l[0]) m = int(l[1]) k = int(l[2]) if k <= n + m - 2: if k < n: outn = int(n / (k + 1)) * m else: outn = int(m / (k - n + 2)) if k < m: outm = int(m / (k + 1)) * n else: outm = int(n / (k - m + 2)) print("", max(outn, outm), sep="") else: ...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER ...
Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements: each cut should be straight (horizontal or vertical); each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate ...
def Calc(n, m, k): if n + m - 2 < k: return -1 if k <= n - 1: return n // (k + 1) * m return m // (k - n + 2) n, m, k = [int(x) for x in input().split()] print(max(Calc(n, m, k), Calc(m, n, k)))
FUNC_DEF IF BIN_OP BIN_OP VAR VAR NUMBER VAR RETURN NUMBER IF VAR BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR RETURN BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR ...
Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements: each cut should be straight (horizontal or vertical); each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate ...
n, m, k = map(int, input().split()) if n + m - 2 < k: print(-1) return def divisors(n): div = set() for i in range(1, int(n ** (1 / 2)) + 1): if n % i == 0: div.add(i) div.add(n // i) return [*div] def solve(n, m, k): div = divisors(n) ans = 0 for i in...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP BIN_OP VAR VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER RETURN FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER NUMBER NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ...
Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements: each cut should be straight (horizontal or vertical); each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate ...
def main(): a, b, c = map(int, input().split()) res, c = [-1], c + 1 if c < a + b: for n, m, k in ((a, b, c), (b, a, c)): if n < k: k -= n - 1 n, m = m, 1 res.append(n // k * m) print(max(res)) main()
FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR VAR FOR VAR VAR VAR VAR VAR VAR VAR VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EX...
Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements: each cut should be straight (horizontal or vertical); each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate ...
from itertools import * def read_ints(): return map(int, input().strip().split()) n, m, k = read_ints() def val(x, k, n, m): Y = x + 1 Z = k - x + 1 if Y > 0 and Z > 0: return n // (x + 1) * (m // (k - x + 1)) def sym(n, m, k): x = min(n - 1, k) return val(x, k, n, m) def test(...
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER VAR NUMBER RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR...
Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements: each cut should be straight (horizontal or vertical); each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate ...
n, m, k = [int(x) for x in input().split()] if k + 2 > n + m: print(-1) else: if k >= n: alpha = m // (k - n + 2) else: alpha = m * (n // (k + 1)) if k >= m: beta = n // (k - m + 2) else: beta = n * (m // (k + 1)) print(max(alpha, beta))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP ...
Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements: each cut should be straight (horizontal or vertical); each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate ...
inputx = input().split(" ") n = int(inputx[0]) m = int(inputx[1]) k = int(inputx[2]) if n + m - 2 < k: print(-1) else: if n > m: n, m = m, n if k < n: print(max(n * int(m / (k + 1)), m * int(n / (k + 1)))) elif n <= k and k < m: print(n * int(m / (k + 1))) else: print...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR BIN_O...
Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements: each cut should be straight (horizontal or vertical); each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate ...
a, b, k = list(map(int, input().split())) if a + b - 2 < k: print(-1) return k += 2 if a > b: a, b = b, a i = 1 maxi = -1 while i * i <= a: y = min(i, k - 1) val1 = a // y * (b // (k - y)) if maxi < val1: maxi = val1 j = min(a // i, k - 1) val2 = a // j * (b // (k - j)) if ma...
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP BIN_OP VAR VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER RETURN VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_O...
Hamming distance between strings a and b of equal length (denoted by h(a, b)) is equal to the number of distinct integers i (1 ≤ i ≤ |a|), such that ai ≠ bi, where ai is the i-th symbol of string a, bi is the i-th symbol of string b. For example, the Hamming distance between strings "aba" and "bba" equals 1, they have ...
def get_input(): a, b, d = map(int, input().split()) c, e = map(int, input().split()) f = int(input()) return [a, b, c, d, e, f] def check_condition(a, b, c, d, e, f): condition1 = (a + b + c) % 2 == 0 condition2 = (d + e + a) % 2 == 0 condition3 = (e + f + c) % 2 == 0 condition4 = (d ...
FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR RETURN LIST VAR VAR VAR VAR VAR VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER ...
Hamming distance between strings a and b of equal length (denoted by h(a, b)) is equal to the number of distinct integers i (1 ≤ i ≤ |a|), such that ai ≠ bi, where ai is the i-th symbol of string a, bi is the i-th symbol of string b. For example, the Hamming distance between strings "aba" and "bba" equals 1, they have ...
h = [[0 in range(10)] for j in range(10)] for i in range(1, 4): h[i] = [(0) for j in range(i + 1)] + list(map(int, input().split())) if h[1][2] + h[1][3] < h[2][3] or (h[1][2] + h[1][3] - h[2][3]) % 2 == 1: print("-1") exit(0) BB = (h[1][2] + h[1][3] - h[2][3]) // 2 BA = h[1][2] - BB AB = h[1][3] - BB NowB ...
ASSIGN VAR LIST NUMBER FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBE...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) ans = 0 c = b if b < f: ans = -1 else: c -= f for i in range(k): if ans == -1: break if i % 2 == 0: d = a - f else: d = f if i < k - 1: d *= 2 if b < d: ans = -1 elif c < d: ans += 1 c = b ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR VAR ASSIGN VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR IF VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER IF VAR VAR ...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
def solve(a, b, f, k): origb = b disa = 2 * f disb = 2 * (a - f) trava = False counter = 0 b -= disa / 2 if b < 0: return -1 while k > 0: if trava: trava = False if k == 1: disa = disa / 2 if disa > b: co...
FUNC_DEF ASSIGN VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR BIN_OP VAR NUMBER IF VAR NUMBER RETURN NUMBER WHILE VAR NUMBER IF VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR N...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) c = b cnt = 0 if cnt == 0: for i in range(k): if i & 1 == 0: dis = a - f else: dis = f c -= a - dis if c < 0: cnt = -1 break if i < k - 1 and c < 2 * dis: cnt += 1 c...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP NUMBER VAR VAR NUMBER ASSI...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) ans = 0 cb = b for i in range(k): if i % 2 == 0: if f > cb: print(-1) return else: cb -= f if i != k - 1: if cb < 2 * (a - f): ans += 1 cb = b ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN VAR VAR IF VAR BIN_OP VAR NUMBER IF VAR BIN_OP NUMBER BIN_OP VAR VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR VAR IF VAR BIN...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) x, y = f, a - f if k == 1: if b < max(x, y): print(-1) quit() elif k == 2: if b < max(x, 2 * y): print(-1) quit() elif b < max(2 * x, 2 * y): print(-1) quit() gas = b refill = 0 test = True while k > 0: if test: if gas >=...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR IF VAR NUMBER IF VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER IF VAR FUNC_CALL VAR VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR FUNC_CALL VAR BIN_OP NUM...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) g = a - f t = b - f s = 0 while t >= 0: if t >= g: k -= 1 t -= g else: t = b - g s += 1 if t < 0: break k -= 1 if k == 0: break if t >= g: t -= g else: t = b - 2 * g s +...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR VAR...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = [int(z) for z in input().split()] to_fuel = f from_fuel = a - f alrdy_fueled = 0 petrol = b for i in range(k): petrol -= to_fuel if petrol < 0: print(-1) exit(0) if petrol < 2 * from_fuel and i != k - 1: petrol = b alrdy_fueled += 1 elif i == k - 1: i...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR BIN_OP NUMBER VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF V...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
import sys def min_refills(end_point, capacity, fuel_point, journeys): fuel = capacity journey_count = 0 refills = 0 while True: fuel -= fuel_point if fuel < 0: return -1 fuel_needed = ( 2 * (end_point - fuel_point) if journey_count < journey...
IMPORT FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER VAR VAR IF VAR NUMBER RETURN NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP NUMBER BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR IF VAR VAR RETURN NUMBER VAR BIN_OP VAR VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR VAR ASSIG...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
def main(): a, b, f, k = map(int, input().split()) if b < f or b < a - f: print(-1) elif k >= 2 and b < 2 * (a - f): print(-1) elif k > 2 and b < 2 * f: print(-1) else: refuel, fuel = 0, b for i in range(k - 1): if i % 2: if fuel < ...
FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR BIN_OP NUMBER BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP ...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = list(map(int, input().split())) i = 0 bi = b ans = 0 while i < k: if f > bi: print(-1) return bi -= f if k - i == 1: if a - f > bi: bi = b ans += 1 if a - f > b: print(-1) return break i += 1 if 2 * ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN VAR VAR IF BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR NUMBER IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR NUMBER RET...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
def solve(a, b, f, k): cur_b = b cur_k = 0 refueling_count = 0 can_0f = cur_b - f >= 0 if not can_0f: return refueling_count, cur_k else: cur_b -= f while cur_k < k: faf_path = 2 * (a - f) can_faf = cur_b - faf_path >= 0 can_faf_with_refueling = b - fa...
FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER IF VAR RETURN VAR VAR VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR ...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) ans = 0 t = b l = a - f x = 0 if b < max(f, l): ans = -1 else: while k > 0: if x == 0: t -= f if t < 0: ans = -1 break t -= l if k == 1: l = 0 if b - l < 0: ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR NUMBER VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR VAR NU...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
import sys a, b, f, k = map(int, input().split()) def game_over(): print(-1) sys.exit() fuel = b add_fuel_count = 0 distance_to_stop = f fuel_on_next_stop = fuel - distance_to_stop if fuel_on_next_stop < 0: game_over() for i in range(1, k + 1): fuel = fuel_on_next_stop if i == k: if i %...
IMPORT ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR IF VAR VAR IF BIN_OP VAR ...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
def predict(x, p): if x == 1: if p - a - f >= 0: return "Go" return "Fuel" elif p - (a + a - f) >= 0: return "Go" else: return "Fuel" a, b, f, k = map(int, input().split()) t = 0 r = 0 www = b for i in range(k): if i == k - 1: if b >= a: ...
FUNC_DEF IF VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR NUMBER RETURN STRING RETURN STRING IF BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR NUMBER RETURN STRING RETURN STRING ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VA...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) x = 0 rf = 0 fuel = b di = 0 j = 0 if fuel < f: print(-1) exit() x = f fuel -= f while j != k: if di == 0: if j == k - 1: if fuel >= a - f: print(rf) exit() if fuel >= 2 * (a - f): fuel = fuel - 2 ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR WHILE VAR VAR IF VAR NUMBER IF VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR VAR EXPR FUNC_CALL...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
def main(): a, b, f, k = list(map(int, input().split())) fuels = 0 trips = 0 pos = 0 move = 1 gas = b while trips < k: if gas < 0: print(-1) return if move == 1: if pos == 0: pos = f gas -= f elif...
FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN IF VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR BIN_OP ...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) im = False fuel = b cnt = 0 for i in range(k): if i % 2 == 0: if fuel - f < 0: im = True break if i < k - 1: if fuel - (2 * a - f) < 0: cnt += 1 fuel = b - (a - f) else: ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR BIN_OP VAR NUMBER IF BIN_OP VAR BIN_OP BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
from sys import stdin, stdout a, b, f, k = map(int, stdin.readline().split()) ans, position = 0, 0 current = b label = 1 for i in range(k): if not position: distance = a + a - f curd = a - f last = a oil = f else: distance = a + f curd = f last = 0 ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN V...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) def distanceToFuel(pos): return a - f if pos else f if f > b: print(-1) else: total = k * a pos = 0 remaining = b refuel = 0 while total > 0: remaining -= distanceToFuel(pos) total -= distanceToFuel(pos) if k == 1: ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN VAR BIN_OP VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
import sys a, b, f, k = list(map(int, input().split())) d1 = f d2 = a - f if k == 1: if d1 > b or d2 > b: print("-1") sys.exit() elif k == 2: if d1 > b or 2 * d2 > b: print("-1") sys.exit() elif 2 * d1 > b or 2 * d2 > b: print("-1") sys.exit() rem = b fill = 0 for i in r...
IMPORT ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR NUMBER IF VAR VAR BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF BIN_OP NUMBER VAR VA...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
from sys import stdin, stdout a, b, f, k = list(map(int, stdin.readline().rstrip().split())) direction = 1 tank = b refuels = 0 position = 0 if b < f or b < a - f: possible = False else: possible = True while k > 0 and possible == True: if k == 1 and tank >= a: k = 0 elif k == 1: k = 0 ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER IF VAR NUMBER VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUM...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
def bus(): [a, b, f, k] = map(int, input().split()) if b < f: return -1 trips, fuel, pos, refill = 0, b - f, f, 0 while trips < k: rounds = 2 * (fuel // (2 * a)) fuel -= rounds * a if pos == f and fuel % (2 * a) >= 2 * (a - f): rounds += 1 pos = a ...
FUNC_DEF ASSIGN LIST VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR VAR NUMBER BIN_OP VAR VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR BIN_OP NUMBER VAR VAR BIN_OP VAR VAR IF VAR VAR BIN_OP VAR BIN_OP NUMBER VAR BIN_OP NUMBER BIN_OP VAR VAR VAR ...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) if (f > b or a - f > b) or k > 1 and 2 * (a - f) > b or k > 2 and 2 * f > b: print(-1) exit() cur = b ans = 0 for i in range(k): if i & 1 == 0: if cur < f: cur = b - f ans += 1 if cur >= a: cur -= a else: ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR BIN_OP VAR VAR VAR VAR NUMBER BIN_OP NUMBER BIN_OP VAR VAR VAR VAR NUMBER BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER IF VAR VAR ASSIG...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
line = input() thing = list(map(int, line.split())) a = thing[0] b = thing[1] f = thing[2] k = thing[3] fuel = b - f fa = True refuels = 0 trips = 0 while True: if fuel < 0: refuels = -1 break if fa: if trips + 1 == k: distance = a - f if fuel < distance: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR IF BIN_OP VAR NUMB...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
def read_input(): input_str = str(input()) return map(int, input_str.split(" ")) def check(a: int, b: int, f: int, k: int) -> int: if k == 1 and (a - f > b or f > b): return -1 elif k == 2 and ((a - f) * 2 > b or f > b): return -1 elif k > 2 and ((a - f) * 2 > b or f * 2 > b): ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR FUNC_CALL VAR STRING FUNC_DEF VAR VAR VAR VAR IF VAR NUMBER BIN_OP VAR VAR VAR VAR VAR RETURN NUMBER IF VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR RETURN NUMBER IF VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR NUMBER VAR RETURN N...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) counter = 0 b2 = b - f if b2 >= 0: dist2 = (a - f) * 2 for i in range(k): if i == k - 1: dist2 /= 2 if b2 < dist2: b2 = b counter += 1 b2 -= dist2 if b2 < 0: counter = -1 break ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR NUMBER VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP ...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = [int(i) for i in input().split()] if k >= 3: if f > b or 2 * f > b or 2 * (a - f) > b: print(-1) else: fuel = 0 fwd = 1 rem = b - f while k != 1: if fwd == 1: if rem >= 2 * (a - f): rem = rem - 2 * (a - f) ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR WHILE VAR NUMBER IF VAR NUMBER IF VAR BIN_OP NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_O...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
DEBUG = False def cover_distance(): a, b, f, k = map(int, input().split()) fuel = b add_fuel_count = 0 fuel_on_next_stop = fuel - f if fuel_on_next_stop < 0: return -1 distance_to_destination = 0 distance_to_gas_station = 0 for i in range(1, k + 1): if DEBUG: ...
ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR EXPR FUNC_C...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) ff = 1 if k == 1: if b >= a: print(0) elif b >= f and b >= a - f: print(1) else: print(-1) else: p = b - f ans = 0 for i in range(k - 1): if i % 2 == 0: if b < 2 * (a - f): ff = 0 b...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) s, t = 0, b - f g = f = a - f for i in range(k): if t < 0: break if k - 1 - i: g += f if t < g: s, t = s + 1, b t -= g g = f = a - f print(-1 if t < 0 else s)
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER VAR VAR VAR IF VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) p = 0 r = 0 m = b if k == 1: if m < f or m < a - f: print(-1) quit() d1, d2 = 2 * a - f, a + f for _ in range(k - 1): if p == 0: if f > m: r = -1 break if m < d1: r += 1 m = b - a + f e...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER IF VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP BIN_OP NUMBER VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER IF...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, c, d = map(int, input().split()) x = b - c f = 1 if b < c or b < a - c or d >= 2 and b < (a - c) * 2 or d > 2 and b < c * 2: print(-1) exit() k = 0 for i in range(d): if i + 1 == d: if f == 1: if x >= a - c: print(k) else: print(k + 1) ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF VAR VAR VAR BIN_OP VAR VAR VAR NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR N...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) if max(2 * f, 2 * (a - f)) > b and k > 2: print("-1") elif k == 1 and max(f, a - f) > b: print("-1") elif k == 2 and (b < 2 * (a - f) or b < f): print("-1") else: m = b dir = 1 l = 0 pos = 1 x = 0 while l < k: if pos == 1 and m >= f and ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR BIN_OP NUMBER VAR BIN_OP NUMBER BIN_OP VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR BIN_OP NUMBER BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = tuple(map(int, input().split())) d1 = f - 0 d2 = a - f def sim(): x = b c = 0 for i in range(1, k + 1, 2): if x < d1: return -1 x -= d1 if x < d2 or i < k and x < 2 * d2: x = b c += 1 if x < d2: return -1 ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER IF VAR VAR RETURN NUMBER VAR VAR IF VAR VAR VAR VAR VAR BIN_OP NUMBER VAR ASSIGN VAR VAR V...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
import sys l, tank, v, rep = (int(x) for x in input().split()) checkpoints = [(l * i + (v if i % 2 == 0 else l - v)) for i in range(rep)] checkpoints.append(rep * l) x = 0 gas = tank cnt = 0 for y in checkpoints: if y - x > gas: if y - x > tank: print(-1) sys.exit() cnt += 1...
IMPORT ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR VAR IF BIN_OP VAR VAR VAR EXPR...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) fuel = b res = 0 for i in range(k): fuel -= f if fuel < 0: print(-1) exit(0) if i == k - 1: if a - f > fuel: fuel = b res += 1 fuel -= a - f break if (a - f) * 2 > fuel: fuel = b res +=...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR NUMBER VAR BIN_OP VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBE...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
import sys a, b, f, k = map(int, input().split()) l1 = 2 * (a - f) l2 = 2 * f t = b cnt = 0 r = True if t >= f: t -= f for i in range(k - 1): if r: if t >= l1: t -= l1 r = False elif b >= l1: cnt += 1 t = b - l1 ...
IMPORT ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR IF VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR VAR VAR NUMBER ASS...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
def main(): a, b, f, k = input().split(" ") endpoint = int(a) capacity = int(b) station = int(f) journeys = int(k) print(betterBus(endpoint, capacity, station, journeys)) def bus(endpoint, capacity, station, journeys): refuels = 0 current = capacity to = True for j in range(jou...
FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
def calculate_minimal_refueling(obj_pos, fuel_capacity, gas_station_pos, trip_required): direction = True current_gas = fuel_capacity refuel_count = 0 for trip in range(trip_required): if direction: current_gas -= gas_station_pos if current_gas < 0: return...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR IF VAR NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER VAR VAR BIN_OP NUMBER BIN_OP VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR NUMBER VAR BIN_OP VAR VAR IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER VAR BIN_OP VAR VAR IF V...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = [int(x) for x in input().split()] oil = b num = 0 oil -= f if b < f or b < a - f or b < 2 * (a - f) and k >= 2 or b < 2 * f and k >= 3: print(-1) else: for i in range(1, k): if i % 2 == 1: if oil >= 2 * (a - f): oil -= 2 * (a - f) else: ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER VAR VAR IF VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP NUMBER BIN_OP VAR VAR VAR NUMBER VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP NU...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
info = [int(num) for num in input().split()] a = info[0] b = info[1] f = info[2] k = info[3] gas_spots = [(a * i + (f if i % 2 == 0 else a - f)) for i in range(k)] gas_spots.append(k * a) curr_x = 0 curr_gas = b result = 0 for spot in gas_spots: to_travel = spot - curr_x if to_travel > b: print(-1) ...
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VA...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = list(map(int, input().split())) refill = b busPos = 0 counter = 0 shouldPrint = True while True: busPos += f b -= f if b < 0: print(-1) shouldPrint = False break if (2 if k > 1 else 1) * (a - f) > b: b = refill counter += 1 busPos += a - f b -...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER VAR VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR NUMBER VAR B...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) fuel = b - f c, d = 0, [a - f << 1, f << 1] flag = 1 for i in range(k): if fuel < 0: flag = 0 break dis = d[i & 1] * (1 if i != k - 1 else 0.5) if fuel < dis: fuel = b c += 1 fuel -= dis if fuel < 0: flag = 0 print(c if flag else...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER LIST BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER NUMBER IF ...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
[a, b, f, k] = list(map(int, input().split())) def fail(): print("-1") exit(0) def success(x): print(x) exit(0) res = 0 r = b - f while k > 0: if r < 0: fail() if k == 1: if r < a - f: res += 1 r = b if r < a - f: fail() s...
ASSIGN LIST VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER FUNC_DEF EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR WHILE VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER IF VAR BI...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
cin = input().split() a = int(cin[0]) b = int(cin[1]) f = int(cin[2]) k = int(cin[3]) fuel = [0] for h in range(k // 2): fuel += [2 * a * h + f, 2 * a * (h + 1) - f] if k % 2 == 1 and k != 1: fuel += [2 * a * (k // 2) + f] elif k == 1: fuel += [f] fuel += [a * k] try: d1 = fuel[2] - fuel[1] d2 = fue...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR LIST BIN_OP BIN_OP BIN_OP NUMBER VAR VAR VAR BIN_OP BIN_OP BIN_OP NUMBER V...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
import sys a, v, f, k = map(int, input().split()) st_v = v s1 = f s2 = a - f res = 0 for i in range(2 * k): if i % 2 == 0: if i % 4 == 0: v -= s1 if v < 0: print(-1) sys.exit() if i != 2 * k - 2: if v < 2 * s2: ...
IMPORT ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR IF BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR BIN_...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) p = b i = 0 direct = "p" ans = 0 flag = 0 while k > 0: if i == 0 and p < f or i == a and p < a - f: flag = 1 break elif i == 0: p -= f i = f elif i == a: p -= a - f i = f else: if k == 1: if direct...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR NUMBER VAR VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR VAR ASSIGN VAR VAR IF VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR IF...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) req = 0 live_fuel = b while k > 0: live_fuel -= f k -= 1 if live_fuel < 0: req = -1 break else: if live_fuel >= 2 * (a - f) or k == 0 and live_fuel >= a - f: live_fuel -= a - f else: live_fuel = b ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR BIN_OP NUMBER BIN_OP VAR VAR VAR NUMBER VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR NUMBER VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) r, p, s, t = 0, b - f, 1, [2 * f, 2 * (a - f)] if p < 0: r -= 1 else: for i in range(k - 1): if p < t[s]: p = b r += 1 if p < t[s]: r = -1 break p -= t[s] s = 1 - s if t[s] // 2 > p: ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER BIN_OP VAR VAR NUMBER LIST BIN_OP NUMBER VAR BIN_OP NUMBER BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR NUMBER VAR VAR VAR ...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) cur = b good = 1 cnt = 0 for i in range(k): if i % 2 == 0: if i == k - 1: if cur < f: good = 0 elif cur >= a: cur -= a cnt += 0 elif b >= a - f: cnt += 1 els...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER IF VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP NUMBE...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = [int(i) for i in input().split(" ")] x = f y = a - f oil = b result = 0 alert = 0 if k == 1: oil -= x if oil < 0: alert = 1 if oil < y: result += 1 oil = b oil -= y if oil < 0: alert = 1 else: oil -= x if oil < 0: alert = 1 if oil < 2 ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER VAR VAR IF VAR NUMBER...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) x = 0 g = b for kk in range(k - 1): if kk % 2 == 0: d = a + (a - f) if g < d: if g < f: x = -1 break x += 1 g = b - (a - f) if g < 0: x = -1 break ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR IF VAR VAR IF VAR VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR NUMB...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) if b < f or b < a - f: print(-1) exit() com = b // a ca = b % a poi = com % 2 ans = 0 t = 0 while com < k: t += 1 if poi == 0: if ca < f: ca = b - f ans += 1 else: ca = b - a + f ans += 1 c...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER IF VAR NUMBER IF VAR VAR ASSIGN VAR BI...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = input().split() a = int(a) b = int(b) f = int(f) k = int(k) i = 0 j = 1 fill = 0 store = b direct = 1 while j <= k: if i == 0: n = f direct = 1 if j > 1: store -= abs(f) elif i == a: n = f direct = 0 store -= abs(f - a) elif direct == ...
ASSIGN VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR NU...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
def solution(a, b, f, k): d1 = 2 * (a - f) d2 = 2 * f if k == 1: if f > b or a - f > b: return -1 elif k == 2: if f > b or d1 > b: return -1 elif d1 > b or d2 > b: return -1 fuels = 0 fue = b - f for i in range(k - 1): dist = d1 if ...
FUNC_DEF ASSIGN VAR BIN_OP NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP NUMBER VAR IF VAR NUMBER IF VAR VAR BIN_OP VAR VAR VAR RETURN NUMBER IF VAR NUMBER IF VAR VAR VAR VAR RETURN NUMBER IF VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VA...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
l = list(map(int, input().split())) a, fuel, f, k = l[0], l[1], l[2], l[3] i = 1 b = fuel c = 0 flag = 0 while i < k: if i % 2 != 0: if b >= 2 * a - f: b -= a elif b >= f: b = fuel - (a - f) c += 1 else: print("-1") flag = 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP BIN_OP NUMBER VAR VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VA...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
def impossible(): print(-1) exit() dest, cap, station, journey = map(int, input().strip().split()) left, right = 2 * station, 2 * (dest - station) if journey == 1 and (cap < station or cap < dest - station): impossible() if journey == 2 and (cap < station or cap < right): impossible() if journey >= 3 ...
FUNC_DEF EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP NUMBER VAR BIN_OP NUMBER BIN_OP VAR VAR IF VAR NUMBER VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR IF VAR NUMBER VAR VAR VAR VAR EXPR FUNC_CALL VAR IF VAR NUMBER VAR VA...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
init = list(map(int, input().split())) finalPoint = init[0] fuelCapacity = init[1] refuelPoint = init[2] voyageCount = init[3] currentVoyageCount = 0 currentFuelCapacity = fuelCapacity currentPosition = 0 refuelCount = 0 isEnd = False error = False stepSide = 1 def isHaveToRefuel(): global currentFuelCapacity ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF IF BIN_OP VAR NUMBER VAR IF VAR N...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = tuple([int(i) for i in input().split(" ")]) pos = True route = 0 petrol = 0 if abs(f) > b: print(-1) else: tank = b need = abs(f) for i in range(k + 1): tank -= need route += need if i % 2 == 1: need = abs(f) * 2 else: need = abs(a - f...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMB...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = [int(i) for i in input().split()] ff = [0] for i in range(k): d = f if i % 2 == 1: d = a - f ff.append(i * a + d) ff.append(k * a) stops = 0 while len(ff) > 0: next = 0 if ff[0] == k * a: break while ff[next + 1] - ff[0] <= b: next += 1 if ff[next] ==...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER ASSIG...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
import sys DEBUG = False a, b, f, k = map(int, input().split()) def game_over(): print(-1) sys.exit() fuel = b add_fuel_count = 0 fuel_on_next_stop = fuel - f if fuel_on_next_stop < 0: game_over() distance = 0 for i in range(1, k + 1): fuel = fuel_on_next_stop if DEBUG: print("i= {} : "...
IMPORT ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR IF V...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
l = [int(x) for x in input().split()] a = [] b = l[1] f = 0 c = 0 a.append(0) for i in range(l[3]): if i % 2 == 0: a.append(i * l[0] + l[2]) else: a.append((i + 1) * l[0] - l[2]) a.append(l[0] * l[3]) for j in range(1, l[3] + 2): if b >= a[j] - a[j - 1]: b = b - a[j] b = b + ...
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = [int(x) for x in input().split()] curpos = 0 possible = True gas = b refuelCount = 0 def dis(a, b): return abs(a - b) while k > 0: if dis(curpos, f) > gas: possible = False break dis_to_edge = dis(f, 0) if curpos == a else dis(f, a) if k > 1 and dis(curpos, f) + dis_to_e...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR BIN_OP VAR VAR WHILE VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR VAR IF VAR ...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) fuel_count = 0 fuel = b i = 0 fuel -= f if fuel < 0: print(-1) exit(0) while True: if fuel >= a - f and i + 1 == k: break if b >= a - f and i + 1 == k: fuel_count += 1 break elif fuel < 2 * (a - f): fuel = b fuel_count +=...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER WHILE NUMBER IF VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR IF VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER IF VAR BIN_OP NUMB...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().strip().split()) st = 0 mod = 0 fue = b flg = 0 ans = 0 if fue < f: flg = 1 fue -= f mod = 1 for i in range(k): if st == 0: if mod == 0: mod = 1 if fue < f: fue = b ans += 1 if fue < f: ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR N...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) curr, res = b, 0 for i in range(k): prev = curr curr -= a if i % 2 == 0: if curr < a - f and i < k - 1 or curr < 0: curr = b - a + f res += 1 if curr < a - f and i < k - 1 or curr < 0 or prev < f: print(-1) ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR NUMBER IF VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR N...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
R = lambda: list(map(int, input().split())) a, b, f, k = R() p = b s = 0 if k == 1: if f > b or a - f > b: print(-1) elif b >= a: print(0) else: print(1) elif k == 2: if b < 2 * (a - f) or b < f: print(-1) elif b >= 2 * a: print(0) elif b >= a + a - f: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER IF VAR VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER IF VAR BIN_OP NUMBER BIN_OP VAR VAR ...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
import sys def solve(): end, full, real_mid, times = map(int, sys.stdin.readline().split()) oil = full cnt = 0 for i in range(times): if i % 2 == 0: mid = real_mid else: mid = end - real_mid if mid > oil: return -1 oil -= mid ...
IMPORT FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR RETURN NUMBER VAR VAR IF VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER VAR RETURN NUMBER IF ...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) reFills = 0 journeys = 0 fuel = b - f def nextStop(): if journeys % 2 == 0: if journeys == k - 1: return a - f return (a - f) * 2 else: if journeys == k - 1: return f return f * 2 if fuel < 0: print(-1) else: ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR FUNC_DEF IF BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR VAR RETURN BIN_OP BIN_OP VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER RETURN VAR RETURN BIN_OP VAR NUMBER IF VAR NUMBE...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) t = 0 lt = b ans = 0 while t < k: if t & 1: lt -= a - f if lt < 0: exit(print(-1)) if lt < f * 2: ans += 1 if t == k - 1 and lt >= f: ans -= 1 lt = b lt -= f if lt < 0: ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR VAR V...
A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from ...
a, b, f, k = map(int, input().split()) d = 1 now = 0 res = 0 k += 1 g = b bb = b a, b = 0, a while True: if now == a or now == b: k -= 1 g -= abs(now - f) now = f if not k or g < 0: break elif now == f: c = b - f if d else f dis = c if k == 1 else 2 * ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR NUMBER VAR WHILE NUMBER IF VAR VAR VAR VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR IF VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR...