description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
ans = []
ones = 0
for i in s:
if i != "1":
ans += [i]
else:
ones += 1
i = 0
n = len(ans)
while i < n and ans[i] != "2":
print(0, end="")
i += 1
print("1" * ones, end="")
while i < n:
print(ans[i], end="")
i += 1 | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR LIST VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR VAR STRING EXPR FUNC_CALL VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING VAR STRING WHILE VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | def minString(s):
l = list(s)
c1 = l.count("1")
l = [x for x in l if x != "1"]
if "2" in l:
i = l.index("2")
l[i:i] = ["1"] * c1
else:
l.extend(["1"] * c1)
return "".join(l)
s = str(input())
print(minString(s)) | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR VAR VAR STRING IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR BIN_OP LIST STRING VAR EXPR FUNC_CALL VAR BIN_OP LIST STRING VAR RETURN FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
t = "".join(c for c in s if c != "1")
i = (t + "2").find("2")
print(t[:i] + "1" * (len(s) - len(t)) + t[i:]) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL STRING VAR VAR VAR VAR STRING ASSIGN VAR FUNC_CALL BIN_OP VAR STRING STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP STRING BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
n = len(s)
string = ""
for i in s:
if i != "1":
string += i
c = s.count("1")
ans = ""
j = 0
for i in string:
if i == "2":
break
else:
j += 1
ans += i
ans += "1" * c
for i in range(j, len(string)):
ans += string[i]
print(ans) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR VAR IF VAR STRING VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER VAR VAR VAR BIN_OP STRING VAR FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | def go():
a = [int(i) for i in input()]
i = 0
c = 0
while i < len(a):
if a[i] == 1:
a[i] = None
c += 1
i += 1
j = 0
a = [j for j in a if j is not None]
while j < len(a):
if a[j] == 2:
break
j += 1
output = "".join(str(i)... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR NONE VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR VAR NONE WHILE VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL STRING FUNC_... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
c0 = c1 = 0
d0 = []
for c in s:
if c == "0":
c0 += 1
elif c == "1":
c1 += 1
else:
d0.append(c0)
c0 = 0
d0.append(c0)
res = []
for i in range(len(d0)):
for j in range(d0[i]):
res.append("0")
if i == 0:
for j in range(c1):
res.app... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER FOR V... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
cnt = 0
v = []
for ch in s:
if ch == "1":
cnt += 1
else:
v.append(ch)
for ch in v:
if ch == "2":
for i in range(cnt):
print(1, end="")
cnt = 0
print(ch, end="")
for i in range(cnt):
print(1, end="") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR VAR IF VAR STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER STRING ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER STRING |
Madoka decided to entrust the organization of a major computer game tournament "OSU"!
In this tournament, matches are held according to the "Olympic system". In other words, there are $2^n$ participants in the tournament, numbered with integers from $1$ to $2^n$. There are $n$ rounds in total in the tournament. In the... | def solve():
mod = 1000000007
n, k = map(int, input().strip().split())
res = pow(2, n, mod)
if k >= n:
print(res)
elif k + 1 == n:
print(res - 1)
else:
ans = 1
temp1 = 1
temp2 = 1
for i in range(1, n - k):
temp1 *= n - i + 1
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP ... |
Madoka decided to entrust the organization of a major computer game tournament "OSU"!
In this tournament, matches are held according to the "Olympic system". In other words, there are $2^n$ participants in the tournament, numbered with integers from $1$ to $2^n$. There are $n$ rounds in total in the tournament. In the... | n, k = [int(e) for e in input().split()]
k = min(k, n)
result = 1
c = 1
modulo = 10**9 + 7
inv = [(0) for i in range(k + 1)]
inv[0] = 1
if k + 1 >= 2:
inv[1] = 1
for i in range(2, k + 1):
inv[i] = modulo - modulo // i * inv[modulo % i] % modulo
for m in range(1, k + 1):
c = c * (n - m + 1) * inv[m]
c %=... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC... |
Madoka decided to entrust the organization of a major computer game tournament "OSU"!
In this tournament, matches are held according to the "Olympic system". In other words, there are $2^n$ participants in the tournament, numbered with integers from $1$ to $2^n$. There are $n$ rounds in total in the tournament. In the... | n, k = map(int, input().split())
x = 0
y = 1
mod = 10**9 + 7
for i in range(min(n, k) + 1):
x = (x + y) % mod
y = y * (n - i) * pow(i + 1, -1, mod) % mod
print(x) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUM... |
Madoka decided to entrust the organization of a major computer game tournament "OSU"!
In this tournament, matches are held according to the "Olympic system". In other words, there are $2^n$ participants in the tournament, numbered with integers from $1$ to $2^n$. There are $n$ rounds in total in the tournament. In the... | def corruption(n, k):
MOD = 10**9 + 7
if k >= n:
return 2**n % MOD
res = 1
choose = 1
for i in range(1, k + 1):
choose = choose * (n - i + 1) * pow(i, -1, MOD) % MOD
res = (res + choose) % MOD
return res
n, k = tuple(map(int, input().split()))
print(corruption(n, k)) | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER IF VAR VAR RETURN BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ... |
Madoka decided to entrust the organization of a major computer game tournament "OSU"!
In this tournament, matches are held according to the "Olympic system". In other words, there are $2^n$ participants in the tournament, numbered with integers from $1$ to $2^n$. There are $n$ rounds in total in the tournament. In the... | welln, kwell = map(int, input().split())
kwell = min(kwell, welln)
wellMODwell = 10**9 + 7
counwellt = 0
wellc = 1
for i in range(kwell + 1):
counwellt = (counwellt + wellc) % wellMODwell
wellc = wellc * (welln - i) * pow(i + 1, wellMODwell - 2, wellMODwell) % wellMODwell
print(counwellt) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP... |
Madoka decided to entrust the organization of a major computer game tournament "OSU"!
In this tournament, matches are held according to the "Olympic system". In other words, there are $2^n$ participants in the tournament, numbered with integers from $1$ to $2^n$. There are $n$ rounds in total in the tournament. In the... | n, k = map(int, input().split())
ans = 1
s = 1
y = k - (k - n // 2)
h = min(n // 2 + (n % 2 == 1) + 1, k + 1)
if k < n:
if k + 1 == h:
for i in range(1, h):
s = s * (n - i + 1) * pow(i, -1, 10**9 + 7) % (10**9 + 7)
ans += s
if y > 0 and i > y and h - 1 != i:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP VAR NUMBER IF VAR VAR IF BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ... |
Madoka decided to entrust the organization of a major computer game tournament "OSU"!
In this tournament, matches are held according to the "Olympic system". In other words, there are $2^n$ participants in the tournament, numbered with integers from $1$ to $2^n$. There are $n$ rounds in total in the tournament. In the... | MOD = 10**9 + 7
MAX_F = 10**5 + 5
fact = [(1) for i in range(MAX_F)]
ifact = [(1) for i in range(MAX_F)]
def mult(a, b):
return a * b % MOD
def power(a, n):
if n == 0:
return 1
tmp = power(a, n // 2)
if n % 2 == 0:
return mult(tmp, tmp) % MOD
return mult(a, mult(tmp, tmp)) % MOD
... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER N... |
Madoka decided to entrust the organization of a major computer game tournament "OSU"!
In this tournament, matches are held according to the "Olympic system". In other words, there are $2^n$ participants in the tournament, numbered with integers from $1$ to $2^n$. There are $n$ rounds in total in the tournament. In the... | def solve():
mod = 1000000007
n, k = map(int, input().strip().split())
res = pow(2, n, mod)
if k >= n:
print(res)
elif k + 1 == n:
print(res - 1)
else:
f = [(1) for i in range(n + 1)]
fi = [(1) for i in range(n + 1)]
for i in range(1, n + 1):
f... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR ... |
Madoka decided to entrust the organization of a major computer game tournament "OSU"!
In this tournament, matches are held according to the "Olympic system". In other words, there are $2^n$ participants in the tournament, numbered with integers from $1$ to $2^n$. There are $n$ rounds in total in the tournament. In the... | n, k = map(int, input().split())
ans = 0
cur = 0
for i in range(0, min(n, k) + 1):
if i == 0:
ans += 1
cur = 1
else:
cur *= n - (i - 1)
cur *= pow(i, -1, 1000000007)
cur = cur % 1000000007
ans += cur
ans = ans % 1000000007
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BI... |
Madoka decided to entrust the organization of a major computer game tournament "OSU"!
In this tournament, matches are held according to the "Olympic system". In other words, there are $2^n$ participants in the tournament, numbered with integers from $1$ to $2^n$. There are $n$ rounds in total in the tournament. In the... | import sys
input = sys.stdin.readline
def int_num():
return int(input())
def int_list():
return list(map(int, input().split()))
def str_list():
s = input()
return list(s[: len(s) - 1])
def instr():
return input().strip()
def invr():
return map(int, input().split())
def cal_c1(n, k):... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CA... |
Madoka decided to entrust the organization of a major computer game tournament "OSU"!
In this tournament, matches are held according to the "Olympic system". In other words, there are $2^n$ participants in the tournament, numbered with integers from $1$ to $2^n$. There are $n$ rounds in total in the tournament. In the... | import sys
def solve():
inp = sys.stdin.readline
n, k = map(int, inp().split())
MOD = int(1000000000.0 + 7)
if k >= n:
print(pow(2, n, MOD))
return
F = [None] * (n + 1)
F[0] = 1
for i in range(1, n + 1):
F[i] = F[i - 1] * i % MOD
FI = [None] * (n + 1)
FI[n] ... | IMPORT FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR VAR RETURN ASSIGN VAR BIN_OP LIST NONE BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER AS... |
Madoka decided to entrust the organization of a major computer game tournament "OSU"!
In this tournament, matches are held according to the "Olympic system". In other words, there are $2^n$ participants in the tournament, numbered with integers from $1$ to $2^n$. There are $n$ rounds in total in the tournament. In the... | n, k = map(int, input().split())
binom = 1
curNum = n
curDeNum = 1
rem = 0
c = 0
while k >= 0 and c <= n:
c += 1
k -= 1
rem = (rem + binom) % 1000000007
binom = binom * curNum * pow(curDeNum, -1, 1000000007) % 1000000007
curNum -= 1
curDeNum += 1
print(rem) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR NUMBER NUMBER NUMBER VAR NUMBER... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = map(int, input().split())
c = [int(x) for x in input().split()]
e = [0] * n
res = 0
for i in range(n):
if e[i] != 1:
for j in range(i + k - 1, i - k, -1):
if j >= 0 and j < n and c[j] == 1:
start = max(j - k + 1, 0)
end = min(n, j + k)
for l... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER IF VAR NUMBER VAR VAR VAR VAR NUMBER ... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = list(map(int, input().split()))
c = list(map(int, input().split()))
i = k - 1
s = 0
f = 0
st = 0
l = 2 * k - 1
while True:
if c[i] == 1:
pi = i
i += 2 * k - 1
s += 1
st = 0
if i >= n:
if n - 1 - pi <= k - 1:
break
else:
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER WHILE NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | class InputReader:
def __init__(self):
self.params = list(map(int, input().strip().split(" ")))
self.towers = list(map(int, input().strip().split(" ")))
def getInput(self):
return self.params, self.towers
class Solver:
def __init__(self, inputPair):
self.towers = inputPa... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF RETURN VAR VAR CLASS_DEF FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER FUNC_DEF A... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | import sys
def read():
return sys.stdin.readline().strip().split()
n, k = (int(x) for x in read())
c = [int(x) for x in read()]
towers = []
for i in range(n):
if c[i] == 1:
towers.append(i)
count = 0
i = 0
t = 0
while i < n and t < len(towers):
j = t
while j < len(towers) and i > towers[j] +... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR FUNC_CALL ... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = map(int, input().split())
sts = list(map(int, input().split()))
count = 0
firstUnlit = 0
lastSt = None
for town in range(0, n):
if sts[town] == 1:
lastSt = town
if town == n - 1:
if firstUnlit <= town:
if lastSt != None and town < lastSt + k:
count += 1
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NONE FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER ASSIGN VAR VAR IF VAR BIN_OP VAR NUMBER IF VAR VAR IF VAR NONE VAR BIN_OP VAR VAR VAR NUMBER ... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | num_cities, k = map(int, input().split())
tower_at = [int(i) for i in input().split()]
count = 0
current = 0
while current < num_cities:
for can_cover_current in reversed(
range(max(0, current - k + 1), min(num_cities, current + k))
):
if tower_at[can_cover_current]:
count += 1
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR BIN_... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | import sys
def solution(n, k, arr):
uncover_city = 0
i = uncover_city + k - 1
j = i
j2 = i
MaxCount = 0
start = 0
markedCity = 0
while markedCity < n:
if arr[i] == 1:
markedCity = markedCity + len(arr[uncover_city : i + k])
j = i
uncover_city... | IMPORT FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VA... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | def minCities(cities, k):
idx = k - 1
start = 0
count = 0
while idx < len(cities):
if cities[idx] == 0:
while idx != start:
idx -= 1
if cities[idx] == 1:
break
if idx == start:
return -1
if cities... | FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER WHILE VAR VAR VAR NUMBER IF VAR VAR NUMBER IF VAR VAR RETURN NUMBER IF VAR VAR NUMBER VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER RET... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | def electricity(c, k, n):
count = 0
unlit = 0
while True:
lit = False
j = unlit + k - 1
if j > n - 1:
j = n - 1
while j > unlit - k:
if c[j]:
count += 1
lit = True
unlit = j + k
if unlit >... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR BIN_OP VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR BIN_OP VAR NUMBER RETURN VAR VAR NUMBER IF VAR RETUR... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | num_towns, max_range = map(int, input().strip().split(" "))
towns = list(map(int, input().strip().split(" ")))
towers_used = 0
current_left = -1
current_mid = max_range - 1
current_right = current_left + max_range - 1
while current_mid > current_left:
if towns[current_mid] == 1:
towers_used += 1
cur... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | import sys
def solve():
n, k = map(int, input().strip().split())
a = list(map(int, input().strip().split()))
l = -1
for i in range(k):
if a[i]:
l = i
if l < 0:
return -1
prev = l
counter = 1
while l + k < n:
for i in range(l + 1, min(l + 2 * k, n)):
... | IMPORT FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR IF VAR NUMBER RETURN NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR FOR ... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | _, cover_range = map(int, input().split())
towers = list(map(int, input().split()))
total_used_towers = 0
first_uncovered = 0
last_used_tower = None
for i in range(len(towers)):
if i - first_uncovered >= cover_range:
if last_used_tower is None:
print(-1)
exit(0)
else:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NONE FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR IF VAR NONE EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN ... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | N, K = [int(x) for x in input().strip().split(" ")]
towers = [i for i, x in enumerate(input().strip().split(" ")) if "1" == x]
next_needs_tower = 0
last_tower = -K
last_tower_on = -K
num_towers_on = 0
for i in towers:
if i - next_needs_tower >= K:
num_towers_on += 1
if last_tower - last_tower_on > 2... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING STRING VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR VAR VAR NUMBER IF BIN_OP VAR VAR BIN_OP NUMBER VAR ASSIGN... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
li = [0] * n
def find(x):
out = -1
for i in range(min(x + k - 1, n - 1), max(x - k, -1), -1):
if arr[i] == 1:
out = i
break
return out
def fun(x):
for i in range(max(x - k + 1, 0), min(x ... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR NUMBER NUMBER IF VAR VAR NUMB... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | def min_towers(tower_range, city_towers):
n_towers = 0
cur_city = 0
while cur_city < len(city_towers):
min_possible = max(0, cur_city - tower_range + 1)
max_possible = min(cur_city + tower_range - 1, len(city_towers) - 1)
found_tower = False
for i in range(max_possible, min_p... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR NUMBER IF... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = [int(num) for num in input().split()]
towers = [int(num) for num in input().split()]
num_towers = 0
i = 0
furthest_tower = None
for j in range(k):
if i + j < len(towers) and towers[i + j] == 1:
furthest_tower = i + j
if furthest_tower == None:
print(-1)
elif furthest_tower + k >= len(towers):
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NONE FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NONE EXPR FUNC_CALL VAR NUMBE... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = [int(x) for x in input().split()]
ps = [int(x) for x in input().split()]
assert n == len(ps)
i, count = 0, 0
done = True
while i < n:
found = False
c = min(i + k - 1, n - 1)
while c >= max(i - k + 1, 0):
if ps[c] > 0:
found = True
i = c + k
count += 1
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER WHILE VAR FUNC_CALL VAR BIN_O... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | N, K = input().split()
N, K = int(N), int(K)
arr = [int(i) for i in input().split()]
res = 0
i = 0
while i + K <= N:
if i == 0:
rng = i + K
elif i + 2 * K <= N:
rng = i + 2 * K - 1
else:
rng = N
flag = False
for t in reversed(range(i, rng)):
if arr[t] == 1:
... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP ... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | def solve(cities, spread):
used = 0
ind = 0
while ind < len(cities):
found = False
placeIndex = 0
for rightSearch in range(spread - 1, 0, -1):
if rightSearch + ind >= len(cities):
continue
if cities[rightSearch + ind] == 1:
foun... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP VAR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR FOR ... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = [int(tmp) for tmp in input().strip().split(" ")]
towers = [int(tmp) for tmp in input().strip().split(" ")]
num_towers_on = 0
i = 0
towers_turned_on = 0
while i <= n - 1:
min_tower = max(0, i + 1 - k)
max_tower = min(n, i + k)
tower_to_turn_on = -1
for j in range(min_tower, max_tower):
if ... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR ... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = map(int, input().split())
tower = list(map(int, input().split()))
def voisins(i):
return range(min(n - 1, i + k - 1), max(-1, i - k), -1)
count = 0
past_fourni = 0
while past_fourni < n:
for i in voisins(past_fourni):
if tower[i]:
past_fourni = i + k
count += 1
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER FUNC_CALL VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR FOR VAR FUNC... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | def test_case(cities, k):
res1 = calc_n_towers(cities, k)
res2 = calc_n_towers(list(reversed(cities)), k)
if res1 == -1 and res2 == -1:
return -1
elif res1 == -1:
return res2
elif res2 == -1:
return res1
return min(res1, res2)
def calc_n_towers(arr, k):
lo = 0
h... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN VAR IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP ... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = map(int, input().strip().split())
arr = list(map(int, input().strip().split()))
step, i, piv = 0, 0, 0
while i < n:
j = min(i + k - 1, n - 1)
step += 1
while j >= piv and arr[j] != 1:
j -= 1
if j < piv:
print("-1")
quit()
i = j + k
piv = j + 1
print(step) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER WHILE VAR VAR VAR VAR NUMBER VAR NUMBER... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = map(int, input().split())
towerlist = [int(i) for i in input().split()]
p = 0
tc = 0
while p < n:
found = tc
if p + k - 1 < n:
h = p + k - 1
while h > p - k:
if towerlist[h] == 1:
tc += 1
p = h + k
break
h -= 1
el... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER WHILE VAR BIN_OP VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR ... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | _, k = list(map(int, input().strip().split(" ")))
cities = list(map(int, input().strip().split(" ")))
def num_stations_needed(k, cities):
i = 0
num_stations = 0
rightmost_candidate = -k
while i < len(cities):
leftmost_unpowered = i
while i < len(cities) and i < leftmost_unpowered + k:
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR VAR WHILE VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VA... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | import sys
_, rng = map(int, input().strip().split())
towers = [bool(int(x)) for x in input().strip().split()]
tower_indices = [i for i, tower in enumerate(towers) if tower]
tower_indices_rev = []
def reach(location, target):
return abs(location - target) < rng
first_unpowered = 0
last_tower = -1
i = 0
tower_c... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FUNC_DEF RETURN FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER A... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = [int(x) for x in input().strip().split()]
t = [int(x) for x in input().strip().split()]
towercount = 0
citieslit = 0
while citieslit < n:
canlight = False
b = list(range(max(citieslit - k + 1, 0), min(citieslit + k, n)))
b.sort(reverse=True)
for i in b:
if t[i] == 1:
canlight ... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER FUNC_CALL VAR BIN_OP VAR ... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | city, power_range = input().split()
city, power_range = int(city), int(power_range)
tower = [int(x) for x in input().split()]
def algorithm(lis):
pointer = power_range - 1
tower_num = 0
start = -1
while pointer < city:
if lis[pointer] == 1:
tower_num += 1
start = pointe... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR IF BIN_OP BIN_OP VAR BIN_OP NUMBER BIN_OP... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = input().strip().split(" ")
n, k = int(n), int(k)
towers = [int(x) for x in input().strip().split(" ")]
firstOff = 0
def find_new_tower_optimal_index(index):
maxInx = min(len(towers) - 1, index + k - 1)
minInx = max(index - k + 1, 0)
for inx in range(maxInx, minInx - 1, -1):
if towers[inx] =... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR B... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = list(map(int, input().rstrip().split(" ")))
l = list(map(int, input().rstrip().split(" ")))
count = 0
curr = -1
limit = k
for i in range(n):
if i >= limit:
if i != limit and curr == -1:
print(-1)
break
else:
count += 1
if curr + k > n:
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER I... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | def min_number(towers, k):
if k == 1:
if all(towers) == 1:
return len(towers)
else:
return -1
limit = len(towers) + k - 1
tower_number = 0
tower_not_found = True
for i in range(k - 1, -1, -1):
if towers[i] == 1:
tower_not_found = False
... | FUNC_DEF IF VAR NUMBER IF FUNC_CALL VAR VAR NUMBER RETURN FUNC_CALL VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR RETURN NUMBER WHILE VAR VAR IF VAR VAR VAR ... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | import sys
k = int(input().strip().split(" ")[1]) - 1
arr = [int(x) for x in input().strip().split(" ")]
num = 0
done = 0
pos = k
fail = 0
pos1 = -1
while not done:
powered = 0
while not powered:
if arr[pos]:
num += 1
powered = 1
elif pos > pos1 + 1:
pos -= 1... | IMPORT ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR NUMBER WHILE VAR IF VAR VAR VAR NUMBER ASSIG... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = [int(x) for x in input().split()]
data = [int(x) for x in input().split()]
segments = []
l = 0
for i in range(n):
if data[i] == 1:
segments.append(i - k + 1)
l += 1
segments = sorted(segments)
most_right = 0
cnt = 0
indx = 0
last = -1
while True:
while indx < l and segments[indx] <= most_... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | import sys
n, k = list(map(int, sys.stdin.readline().strip().split()))
cities = map(int, sys.stdin.readline().strip().split())
towers = [i for i, x in enumerate(cities) if x == 1]
i = 0
while towers[i] < k:
i += 1
power_on = []
power_on.append(towers[i - 1])
while i < len(towers):
if towers[i] - power_on[-1] -... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER WHILE VAR FUN... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = map(int, input().split())
towers = list(map(int, input().split()))
def solve():
i = 0
count = 0
done = False
covered = k - 1
while i < n and covered < n:
best = -1
limit = k if count == 0 else covered + k
for j in range(i, limit):
if j >= n:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR V... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | numCities, electricalTowerRadius = [int(elem) for elem in input().strip().split(" ")]
cities = [int(elem) for elem in input().strip().split(" ")]
towersOn = []
done = False
x = -1
lastCity = 0
for ii in range(electricalTowerRadius):
if cities[ii]:
x = ii
if x >= 0:
lastCity += x
towersOn.append(last... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR IF VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR A... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = map(int, input().split())
cs = list(map(int, input().split()))
count = 0
i = 0
while i < n:
found = False
for j in range(min(n - 1, i + k - 1), max(-1, i - k), -1):
if cs[j] == 1:
found = True
count += 1
i = j + k
break
if not found:
cou... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER FUNC_CALL VAR NUMBER BIN_OP VAR VAR NUMBER IF... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | def solve(cities, K):
switch_count = 0
last_switch_index = -K
last_switchable_index = None
cities += [0] * K
for index in range(len(cities)):
if index >= last_switch_index + 2 * K:
if last_switchable_index == None:
return "-1"
last_switch_index = last_... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NONE VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR BIN_OP NUMBER VAR IF VAR NONE RETURN STRING ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NONE IF VAR VAR NUMBER ASSIGN VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = map(int, input().split())
t = list(map(int, input().split()))
assert len(t) == n and min(t) >= 0 and max(t) <= 1
u, f = 0, 0
while f < n:
for i in range(min(n - 1, f + k - 1), max(-1, f - k), -1):
if t[i]:
u += 1
f = i + k
break
else:
u, f = -1, n
print... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBE... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | def min_towers(n, k, cities):
l = -1
try:
r = next(i for i in range(n) if cities[i])
except StopIteration:
return -1
while l != n:
if r - l - 1 > 2 * (k - 1):
return -1
l, r = r, next((i for i in range(r + 1, n) if cities[i]), n)
s, r_edge = 0, -1
whil... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR RETURN NUMBER WHILE VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER RETURN NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR VAR ASSIGN VAR VAR NUMBER NUMBER WHILE ... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | def solve(ts, k):
c = 0
r, i = -1, -1
if k >= len(ts) - 1:
return int(1 in ts)
while i < len(ts) - 1:
i = min(len(ts) - 1, i + k)
while r < i:
if ts[i] == 1:
break
i -= 1
else:
return -1
r = i
i += k - 1
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER RETURN FUNC_CALL VAR NUMBER VAR WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP VAR VAR WHILE VAR VAR IF VAR VAR NUMBER VAR NUMBER RETURN NUMBER ASSIGN VAR VAR VAR BIN... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | def solve(C, k):
limit = k - 1
count = 0
i = 0
prev = -1
while i < len(C):
if C[i]:
prev = i
if i == limit:
if prev == -1:
return -1
limit = prev + 2 * k - 1
prev = -1
count += 1
i += 1
limit -= k... | FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR IF VAR VAR IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR N... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = [int(x) for x in input().split()]
towers = [int(x) for x in input().split()]
count = 0
turned_on = []
temp = towers[:k]
if temp.count(1) == 0:
count = -1
turned_on.append(n)
else:
val = temp[::-1].index(1)
count += 1
turned_on.append(k - 1 - val)
while turned_on[-1] + (k - 1) < n - 1:
tem... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR VAR VAR IF FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP B... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
def pu(i, j, a, k):
while j >= i and a[j] != 1:
j -= 1
if j < i:
print(-1)
exit()
return j
i, c, p = k - 1, 0, 0
while i < n:
j = i
c = pu(c, i, a, k) + 1
p += 1
i = c + 2 * k - 2
if i - k ... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF WHILE VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR RETURN VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER NUMBER NUMBER WHILE VAR VAR A... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | def result(n, k, A):
count = 0
i = 0
while i < n:
for j in reversed(range(max(0, i - k), min(n, i + k))):
if A[j]:
count += 1
i = j + k
break
else:
return -1
return count
def result2(n, k, A):
needs_coverage = ... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR RETURN NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CAL... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | def min_towers(a, k):
enabled = 1
last = -1
furthest = -1
i = 0
while i < k:
if a[i] == 1:
last = i
furthest = i
i += 1
if last == -1:
return last
while i < len(a):
if i == last + 2 * k:
if furthest == last:
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR VAR NUMBER IF VAR NUMBER RETURN VAR WHILE VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR BIN_OP NUMBER VAR IF VAR VAR RETURN NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR VAR NUMBER ASSIGN V... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | def min_towers(tower_range, city_towers):
if tower_range == 1 and city_towers[0] == 0:
return -1
n = 0
idx_right = 0
idx_left = len(city_towers) - 1
while idx_left > idx_right:
on_right = turn_on_tower_right(idx_right, tower_range, city_towers)
if on_right == -1:
... | FUNC_DEF IF VAR NUMBER VAR NUMBER NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF V... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
def rightmost(a, k, start, end):
i = min(end, len(a)) - 1
while i > start - k:
if a[i] == 1:
return i
i -= 1
return -1
result = 0
i = 0
while i < n:
next_p = rightmost(p, k, i, i + k)
if next_p... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER WHILE VAR BIN_OP VAR VAR IF VAR VAR NUMBER RETURN VAR VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMB... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | def f(c, k):
n = len(c)
count = 0
k -= 1
i = 0
while i < n:
for j in range(min(i + k, n - 1), max(-1, i - k - 1), -1):
if c[j] == 1:
break
else:
return -1
i = j + k + 1
count += 1
return count
n, k = [int(x) for x in input... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF VAR VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER RETURN VAR A... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | [n, k] = [int(x) for x in input().strip().split(" ")]
a = [int(x) for x in input().strip().split(" ")]
ind, possible, to = 0, True, 0
while ind < n:
li = max(ind - (k - 1), 0)
ri = min(ind + (k - 1), n - 1)
done = False
for x in range(li, ri + 1):
if a[x] == 2:
done = True
... | ASSIGN LIST VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR N... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = [int(int_as_string) for int_as_string in input().strip().split(" ")]
tower_present = [
bool(int(flag_as_string)) for flag_as_string in input().strip().split(" ")
]
towers_turned_on = 0
current_city = min(k - 1, n - 1)
last_tower_turned_on = -1
while current_city > last_tower_turned_on:
if tower_present[c... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | def goodland_elec(towers, k):
min_towers = 0
towers_loc = set([i for i in range(len(towers)) if towers[i]])
possible = True
i = 0
rmost = 0
while i < len(towers):
rmost = min(i + k - 1, len(towers) - 1)
while rmost > i - k:
if rmost in towers_loc:
min_... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR BIN_OP VAR VAR IF VAR VAR VAR NUMBER ASSIG... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = map(int, input().split())
arr = [int(x) for x in input().split()]
boolean = True
store = 0
indices = []
for x in range(n):
if arr[x] == 1:
indices.append(x)
for i in range(k - 1, -1, -1):
if arr[i] == 1:
first = i
store += 1
break
else:
boolean = False
print(-1)
if... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR ... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | N, K = [int(a) for a in input().split()]
A = [int(a) for a in input().split()]
i = 0
s = 0
f = False
l = -1
while i < len(A):
for j in range(min(i + K - 1, len(A) - 1), i - 1, -1):
if A[j] == 1:
i = j + K - 1
l = j
s += 1
break
if (i == j) & (A[i] == 0... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER BIN_O... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = map(int, input().split())
l = list(map(int, input().split()))
m = k - 1
mi = -1
done = 0
total = 0
for i in range(n):
if i > m:
if mi != -1:
total += 1
m = mi + k + k - 1
done = mi + k - 1
mi = -1
if done >= n - 1:
print(tota... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER ... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | def solve(n, k, ip):
i = 0
r = 0
k = k - 1
while i < n:
u = min(n - 1, i + k)
l = max(0, i - k)
j = u
while j >= l:
if ip[j] == 1:
break
j = j - 1
if j < l:
return -1
r += 1
i = j + k + 1
retu... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR ASSIGN VAR VAR WHILE VAR VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR RETURN NUMBER VAR NUMBER ASSIGN VAR BIN_... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | from sys import stderr
[n, k], c = map(int, input().split()), list(map(int, input().split()))
ans, last = 0, 0
while last < n:
i = max(
[last - k] + [j for j in range(max(0, last - k + 1), min(n, last + k)) if c[j]]
)
if i == last - k:
ans = -1
break
ans += 1
last = i + k
pr... | ASSIGN LIST VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP LIST BIN_OP VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR VA... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | def turn_on(array, n_cities, radius):
last_tower = -1
index = 0
start = 0
total = 0
turned_on = []
while index < n_cities:
while index <= start + radius - 1:
if index == n_cities:
if index > start:
if last_tower != -1:
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR WHILE VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR IF VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER RETURN NUMBER IF VAR VAR ASSIGN VAR VAR VAR NUMBER IF VAR NUMBER RETURN NUMBER VAR NUMBER EXPR FUNC_... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = list(map(int, input().strip().split()))
towers_city = []
data = input().strip().split()
data_length = len(data)
latest_found = -1
total = 0
found = False
search_index = index = 0
changes = 0
found_tower = True
last_index = -1
while index < data_length:
count_places = 0
search_index = index
found_towe... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIG... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | import sys
n, coverage = input().strip().split(" ")
n, coverage = [int(n), int(coverage)]
x = [int(x_temp) for x_temp in input().strip().split(" ")]
y = set()
for i in range(0, len(x)):
if x[i] == 1:
y.add(i)
towers = set()
i = 0
flag_abort = True
while i < n:
found = False
j = i + coverage - 1
... | IMPORT ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR LIST FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUN... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = list(map(int, input().split()))
tower = list(map(int, input().split()))
t = [0] * n
l = -1
ans = 0
poss = True
for i in range(n):
if tower[i] == 1:
l = i
t[i] = l
i = 0
while n > i:
x = t[min(i + k - 1, n - 1)]
if x == -1 or x + k <= i:
poss = False
break
i = x + k
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBE... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = map(int, input().split())
ar = list(map(int, input().split()))
brk = cnt = 0
i = k - 1
l = n
if 1 in set(ar[-k:]):
cnt += 1
l = n - k + ar[-k:].index(1)
else:
brk = 1
l = 0
while i < l:
if ar[i] == 1:
cnt += 1
i += 2 * k - 1
else:
c = i
while i >= c - 2 * k... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR IF NUMBER FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR ... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | num = [int(num_temp) for num_temp in input().strip().split(" ")]
height = [int(height_temp) for height_temp in input().strip().split(" ")]
n = num[0]
k = num[1]
start = 0
point = k - 1
count = 0
mid = 1
while mid == 1:
if height[point] != 1:
if point > start:
point = point - 1
else:
... | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR NUMBER IF VAR VAR... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = map(int, input().strip().split())
arr = list(map(int, input().strip().split()))
count = 0
maxReach = -1
for i in range(len(arr)):
if i > maxReach:
found = 0
towerIndex = 0
for j in range(k):
if i + j >= len(arr):
break
if arr[i + j]:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR FUNC_CALL... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = [int(t) for t in input().strip().split()]
a = [int(t) for t in input().strip().split()]
r = 0
i = -k
while i + k < n:
j = min(n - 1, i - 1 + k + k)
while j >= i:
if a[j]:
break
j -= 1
if j <= i:
r = -1
break
r += 1
i = j
print(r) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR WHILE VAR VAR IF VAR VAR VAR NUMBER IF VA... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | def main(has_towers, k):
n = len(has_towers)
tower_coords = (i for i, has_tower in enumerate(has_towers, 1) if has_tower)
left_uncovered = 1
previous_tower = None
total = 0
for tower_coord in tower_coords:
if left_uncovered < tower_coord - k + 1:
if not previous_tower:
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NONE ASSIGN VAR NUMBER FOR VAR VAR IF VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR RETURN NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR IF VAR VAR IF VAR BIN_OP BIN_OP VAR VAR NUMBER VAR RETURN... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = map(int, input().split())
arr = list(map(int, input().split()))
pos = 0
ans = 0
i = k - 1
while i < n:
while i != pos and arr[i] != 1:
i -= 1
if i == pos:
ans = -1
break
pos = i
i += 2 * k - 1
ans += 1
if n - 1 - pos >= k and ans != -1:
ans += 1
if n == 100000 and ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR WHILE VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR BIN_OP BIN_OP NUMBER VAR NUMB... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | villageCount, capacity = input().strip().split(" ")
villageCount, capacity = int(villageCount), int(capacity)
ll = list(map(int, input().strip().split(" ")))
coveredIndex = -1
coveredVillageIndex = -1
unCoveredVillageIndex = -1
iCount = 0
unCoveredVillageCount = 0
iLoop = 0
capacity -= 1
lastWorkingBoothIndex = -1
whil... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = map(int, input().split())
t = list(map(int, input().split()))
nu = 0
count = 0
pos = True
while nu < n:
p = min(nu + k - 1, n - 1)
while p >= nu - k + 1 and t[p] == 0:
p -= 1
if p < nu - k + 1:
pos = False
break
else:
nu = p + k
count += 1
if pos:
print... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER WHILE VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER VA... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | def solve(n, k, xs):
count = 0
index = 0
while index < n:
max_location = min(n - 1, index + k - 1)
min_location = max(0, index - k + 1)
location = max_location
found_plant = False
while location >= min_location and not found_plant:
if xs[location] == 1:
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR ... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | def greedy(n, k, towers):
count, i = 0, k - 1
j = -1
while i < n:
if towers[i] == 1:
j = i
count += 1
if i + 2 * (k - 1) + 1 >= n and i + k - 1 < n - 1:
i = n - 1
while i > j:
if towers[i] != 1:
... | FUNC_DEF ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF BIN_OP BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER VAR NUMBER VAR NUMBER I... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = map(int, input().split())
pp = list(map(int, input().split()))
lastpp = -1
for x in range(n):
if pp[x] == 1:
lastpp = x
pp[x] = lastpp
x = 0
ppno = 0
flag = True
while x < n:
lastpp = pp[min(x + k - 1, n - 1)]
if lastpp == -1 or lastpp + k - 1 < x:
flag = False
break
x... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR FUNC_CALL VAR BIN... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = map(int, input().strip().split(" "))
a = list(map(int, input().strip().split(" ")))
i = k - 1
j = i
while a[j] != 1 and j > -1:
j -= 1
if j == -1:
print("-1")
quit()
rep = 1
i = j + 2 * k - 1
while i < n:
j = i
while a[j] != 1 and j > i - (2 * k - 1):
j -= 1
if j == i ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBE... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | def solve(n, k, A):
i = 0
res = 0
k = k - 1
while i < n:
ok = False
jump = i
for j in range(2 * k + 1):
if i + k - j < n and i + k - j >= 0 and A[i + k - j]:
ok = True
jump = i + k - j + k + 1
break
if not ok:
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR NUMBER VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP... |
Goodland is a country with a number of evenly spaced cities along a line. The distance between adjacent cities is $unrecognized$ unit. There is an energy infrastructure project planning meeting, and the government needs to know the fewest number of power plants needed to provide electricity to the entire list of citi... | n, k = (int(x) for x in input().split())
c = [int(x) for x in input().split()]
k -= 1
last = n - 1
num_power = 0
while True:
if last < 0:
break
change = False
for i in range(last - k, last + k + 1):
if i < 0 or i >= n:
continue
if c[i] == 1:
num_power += 1
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER VAR VAR IF VAR VAR ... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | s = input().rstrip()
n = len(s)
stack = []
for ch in s:
if len(stack) <= 1 or not stack[-1] == stack[-2] == ch:
stack.append(ch)
s = "".join(stack)
stack = []
for ch in s:
if len(stack) <= 2 or not (stack[-3] == stack[-2] and stack[-1] == ch):
stack.append(ch)
print("".join(stack)) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR LIST FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR VAR EXP... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | import sys
s = list(input())
n = len(s)
if n <= 2:
print("".join(s))
sys.exit()
temp = ["/", s[0], s[1]]
for i in range(2, n):
if s[i] == temp[-1] and s[i] == temp[-2]:
continue
elif temp[-2] == temp[-3] and s[i] == temp[-1]:
continue
else:
temp.append(s[i])
x = "".join(temp... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST STRING VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR NUMBER VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | string = input()
fixedString = ""
i = 0
if len(string) <= 2:
print(string)
exit(0)
while i < len(string):
chain = 0
j = i
while string[j] == string[i]:
j += 1
chain += 1
if j == len(string):
j -= 1
break
if chain < 2:
fixedString += string[... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER VAR VAR VAR IF VAR NUMBER V... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | s = input()
z = []
count = 1
for i in range(len(s)):
z.append(s[i])
i = 1
while i < len(z):
if s[i] == s[i - 1]:
count = count + 1
else:
if count >= 3:
kap = 0
while count > 2:
z[i - kap - 1] = -1
kap = kap + 1
count = c... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMB... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | import sys
arr = []
def canAdd(arr, a):
if (
len(arr) >= 2
and arr[-1] == arr[-2] == a
or len(arr) >= 3
and arr[-1] == a
and arr[-2] == arr[-3]
):
return False
return True
for x in sys.stdin.read().strip():
if canAdd(arr, x):
arr.append(x)
pri... | IMPORT ASSIGN VAR LIST FUNC_DEF IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER VAR NUMBER RETURN NUMBER RETURN NUMBER FOR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | s = input()
new = ""
g = ""
_c = 0
_two = False
for u in s:
if u != g:
if _c >= 2:
_two = True
if _c == 1:
_two = False
_c = 1
new = new + u
g = u
elif _c < 2 and _two == False:
new = new + u
g = u
_c += 1
print(new) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR NUMBER ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.