description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | n, x0, y0 = map(int, input().split())
a, ans = [], 0
for i in range(n):
x1, y1 = map(int, input().split())
a.append([x1, y1])
for i in range(n):
if a[i] != "burp":
ans += 1
for j in range(n):
if (
a[j] != "burp"
and i != j
and (a[i]... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR BIN_OP BIN... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | n, x0, y0 = input().split()
n = int(n)
x0 = int(x0)
y0 = int(y0)
x = []
y = []
slope = []
for i in range(n):
p, q = input().split()
x.append(int(p))
y.append(int(q))
for i in range(n):
if x[i] == x0:
slope.append(1000000000)
continue
m = (y[i] - y0) / (x[i] - x0)
slope.append(m)
... | ASSIGN 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 LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | n, x0, y0 = map(int, input().split())
stormtroopers = [list(map(int, input().split())) for _ in range(n)]
diff = [(x - x0, y - y0) for x, y in stormtroopers]
diff_set = set()
for x, y in diff:
try:
tmp = x / y
diff_set.add(tmp)
except ZeroDivisionError:
diff_set.add("ZERO")
print(len(dif... | ASSIGN VAR 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 VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRI... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | n, x0, y0 = map(int, input().split())
coords = [0] * n
lasers = 0
points = 0
slopes = []
for i in range(n):
coords[i] = list(map(int, input().split()))
for i in range(n):
if coords[i][0] == x0:
if "x" not in slopes:
slopes.append("x")
elif (y0 - coords[i][1]) / (x0 - coords[i][0]) not in... | ASSIGN VAR VAR 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 LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR IF STRING VAR EXPR FUNC_CALL... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | n, x0, y0 = map(int, input().split())
xy = []
f = 0
for i in range(n):
x, y = map(int, input().split())
xy.append((x, y))
cnt = i = 0
loop = 0
while cnt < n:
if xy[i] == -1:
i += 1
continue
loop += 1
for j in range(n):
if xy[j] == -1 or i == j:
continue
if... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | n, x, y = map(int, input().split())
b = []
for i in range(n):
a, d = map(int, input().split())
if a - x == 0:
b.append(90.00012333345666)
else:
m = (d - y) / (a - x)
b.append(m)
b.sort()
z = []
z.append(b[0])
for i in range(n - 1):
if b[i] != b[i + 1]:
z.append(b[i + 1])
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST EXP... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | n, x, y = map(int, input().split())
a = []
for i in range(n):
b, c = map(int, input().split())
a.append([b, c])
l = []
inf = 100000
for i in range(len(a)):
if a[i][0] == x:
l.append(inf)
else:
l.append((a[i][1] - y) / (a[i][0] - x))
l = list(set(l))
co = []
for i in range(len(l)):
co... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR EXPR FUNC... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
n, x, y = map(int, input().split())
d = {}
for q in range(n):
u, v = map(int, input().split())
j = "00"
if u - x != 0:
if v - y == 0:
j = "0"
else:
s = ""
if (u - x) * (v - y) < 0:
... | FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING IF BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR STRING ... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | q, x, y = map(int, input().split())
d = {}
m = 1
for _ in range(q):
xt, yt = map(int, input().split())
if x == xt:
if 9000000000000000000 in d:
d[9000000000000000000] += 1
else:
d[9000000000000000000] = 1
else:
c = (yt - y) / (xt - x)
if c in d:
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR IF NUMBER VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR ... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | def slope(x1, y1, x2, y2):
denom = x2 - x1
return (y2 - y1) / denom if denom != 0 else "indefinido"
def minShotsRequired(x0, x1, n, stormtroopers):
slopes = {}
different = 0
for i in range(n):
m = slope(x0, y0, stormtroopers[i][0], stormtroopers[i][1])
if not slopes.get(m):
... | FUNC_DEF ASSIGN VAR BIN_OP VAR VAR RETURN VAR NUMBER BIN_OP BIN_OP VAR VAR VAR STRING FUNC_DEF ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR VAR NUMBER IF FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | n, x0, y0 = map(int, input().split())
x, y = [], []
for i in range(n):
xi, yi = map(int, input().split())
x.append(xi)
y.append(yi)
slope = []
for i in range(n):
if x[i] == x0:
slope.append("Inf")
else:
k = (y[i] - y0) / (x[i] - x0)
slope.append(k)
ans = list(set(slope))
prin... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | n, x0, y0 = map(int, input().split())
k = [([None] * 2) for i in range(n)]
for i in range(n):
k[i][0], k[i][1] = map(int, input().split())
s = 0
used = [0] * n
for i in range(n):
f = 0
x = k[i][0]
y = k[i][1]
koef1 = y0 - y
koef2 = x - x0
koef3 = x0 * y - x * y0
if not used[i]:
f... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER A... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | n, x_0, y_0 = map(int, input().split())
arr = []
for i in range(n):
a = list(map(int, input().split()))[:2]
arr.append(a)
def tangent(x_0, y_0, p1, p2):
return float((y_0 - p2) / (x_0 - p1))
arr1 = []
for i in range(n):
if arr[i][0] == x_0:
arr1.append(-1e-07)
continue
for j in r... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR ... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | n, a, b = input().split()
n, a, b = int(n), int(a), int(b)
ans = 0
l = []
for i in range(n):
x, y = input().split()
x, y = int(x), int(y)
if x == a:
l.append(1000000000.0)
elif (y - b) / (x - a) not in l:
ans += 1
l.append((y - b) / (x - a))
print(ans + int(1000000000.0 in l)) | ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP ... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | import sys
def solve(startingCoor, coorSet):
numTries = 0
while len(coorSet) != 0:
coor = coorSet[0]
coorSet.remove(coor)
m = []
isVert = False
if startingCoor[0] != coor[0]:
m = [coor[0] - startingCoor[0], coor[1] - startingCoor[1]]
else:
... | IMPORT FUNC_DEF ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR LIST BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR AS... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | def main():
n, x0, y0 = map(int, input().split())
s = []
for i in range(n):
s.append(list(map(int, input().split())))
tan = []
k = 0
for i in range(n):
s[i][0] -= x0
s[i][1] -= y0
if s[i][0] == 0:
k += 1
elif s[i][1] / s[i][0] not in tan:
... | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR NUMBER VAR VAR VAR NUMBER VAR IF VAR VAR NUMBER NUMBER VAR NUMBER... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | a, b, c = input().strip().split(" ")
a, b, c = [int(a), int(b), int(c)]
x1 = []
for i in range(a):
x, y = input().strip().split(" ")
x, y = [int(x), int(y)]
f = y - c
f1 = x - b
if f1 == 0:
x1.append("a")
else:
x1.append(f / f1)
ans = len(list(set(x1)))
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR LIST FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR 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 BIN_OP VAR VAR AS... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | def solo_mid(n, x0, y0, sturms=[]):
if n == 0:
return 0
res = {}
for i in range(n):
for_shot = sturms[:]
first_sturm = for_shot[0]
sturms.remove(first_sturm)
line_x = y0 - first_sturm[1]
line_y = -(x0 - first_sturm[0])
line_c = -first_sturm[0] * line_x... | FUNC_DEF LIST IF VAR NUMBER RETURN NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER FOR VAR VAR VAR NUMBER ASS... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | a = input("").split(" ")
troopers = []
for val in range(int(a[0])):
troopers.append(input("").split(" "))
trooperSlopes = []
for x in troopers:
if int(x[0]) - int(a[1]) == 0:
trooperSlopes.append("asd")
else:
trooperSlopes.append((int(x[1]) - int(a[2])) / (int(x[0]) - int(a[1])))
print(len(s... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING STRING ASSIGN VAR LIST FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | n, xo, yo = map(int, input().split())
p = []
ans = 0
for i in range(n):
p.append(list(map(int, input().split())))
while p:
i = p.pop()
ans += 1
k = 0
while p and k < len(p):
j = p[k]
if (j[1] - yo) * (i[0] - xo) - (i[1] - yo) * (j[0] - xo) == 0:
p.remove(j)
else:
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF BIN_OP... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | n, x, y = map(int, input().split())
vis = [0] * n
co_ords = []
for i in range(n):
co_ords.append(list(map(int, input().split())))
ans = 0
for i in range(n):
if vis[i] == 0:
vis[i] = 1
ans += 1
c1x = co_ords[i][0]
c1y = co_ords[i][1]
for j in range(i + 1, n):
i... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL 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 NUMBER VAR NUMBER ASSIGN VAR VA... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | info = input().split()
info = [int(e) for e in info]
target_shib = set([])
for i in range(info[0]):
temp = input()
if int(temp.split()[0]) - int(info[1]) != 0:
target_shib.add(
(int(temp.split()[1]) - int(info[2]))
/ (int(temp.split()[0]) - int(info[1]))
)
else:
... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR LIST FOR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR V... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | s = input()
n, x0, y0 = [int(x) for x in s.split()]
st = set([])
def gcd(a, b):
if not b:
return a
return gcd(b, a % b)
flag = False
for i in range(n):
s = input()
x, y = [int(t) for t in s.split()]
x, y = x - x0, y - y0
if x < 0:
x *= -1
y *= -1
if not x:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR LIST FUNC_DEF IF VAR RETURN VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP V... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | def I():
return list(map(int, input().split()))
n, x0, y0 = I()
list_of_killed = []
x_flag = False
y_flag = False
for i in range(n):
x1, y1 = I()
x = x1 - x0
y = y1 - y0
if x != 0 and y != 0:
list_of_killed.append(y / x)
elif x == 0 and y != 0:
x_flag = True
else:
y... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR V... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | import sys
def input():
return sys.stdin.readline().strip()
def iinput():
return int(input())
def rinput():
return map(int, sys.stdin.readline().strip().split())
def get_list():
return list(map(int, sys.stdin.readline().strip().split()))
mod = int(1000000000.0) + 7
def formsline(x1, y1, x2, ... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER FUNC_DEF IF BIN_OP BIN_OP VAR VAR... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | n, x, y = map(int, input().split())
a = []
for i in range(n):
x1, y1 = map(int, input().split())
a.append((x1, y1))
d = set()
for p, q in a:
x2, y2 = p - x, q - y
found = False
for x1, y1 in d:
if x1 * y2 == x2 * y1:
found = True
break
if not found:
d.add(... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR IF BIN_OP VAR... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | import sys
def get_slope(x0, y0, x1, y1):
if x0 == x1:
m = 99999
else:
m = (y1 - y0) / (x1 - x0)
return m
n, x0, y0 = map(int, input().split())
l = []
count = 0
for i in range(n):
x1, y1 = map(int, input().split())
l.append((x1, y1))
slope = set()
for i in range(len(l)):
m = ... | IMPORT FUNC_DEF IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR ... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | num_coor = input().split()
num_storm = int(num_coor[0])
han_coor = [int(num_coor[1]), int(num_coor[2])]
l = []
for i in range(num_storm):
temp = tuple([int(h) for h in input().split()])
l.append(temp)
for f in range(len(l)):
temp = l[f]
if temp[0] == han_coor[0]:
l[f] = "banana"
else:
... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN ... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | n, x, y = [int(x) for x in input().split()]
d = set()
ans = 0
for _ in range(n):
a, b = [int(x) for x in input().split()]
if x != a:
slope = (y - b) / (x - a)
if slope not in d:
d.add(slope)
ans += 1
elif "infinite" not in d:
d.add("infinite")
ans += 1... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER IF STRING VAR EXPR FU... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | n, x0, y0 = map(int, input().split())
d = dict()
for _ in range(n):
x, y = map(int, input().split())
slope = 0
if x == x0:
slope = 100000000
else:
slope = (y - y0) / (x - x0)
if slope not in d:
d[slope] = 1
print(len(d)) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | def detect_colinearity(a, b, c):
try:
slope1 = (a[1] - b[1]) / (a[0] - b[0])
except ZeroDivisionError:
slope1 = "inf"
try:
slope2 = (a[1] - c[1]) / (a[0] - c[0])
except ZeroDivisionError:
slope2 = "inf"
return slope1 == slope2
metad = input().split()
n = int(metad[0... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR ASSIGN VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR ASSIGN VAR STRING RETURN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | slopes = set()
inf = 99999999999
n, x, y = map(int, input().split())
storm = []
for __ in range(n):
a, b = map(int, input().split())
storm.append((a, b))
def slopeComp(i, j):
if i[0] == j[0]:
return inf
return (i[1] - j[1]) / (i[0] - j[0])
for trooper in storm:
slopes.add(slopeComp(troop... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN VAR RETURN BIN_OP BIN_OP VAR NUMBER VAR NUMBER BI... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | def gcd(x, y):
if x * y == 0:
return max(x, y)
elif x >= y:
return gcd(x % y, y)
else:
return gcd(x, y % x)
nxy = list(map(int, input().rstrip().split()))
n = nxy[0]
x0 = nxy[1]
y0 = nxy[2]
xaxis = []
yaxis = []
case1 = []
case2 = []
for i in range(n):
xy = list(map(int, input(... | FUNC_DEF IF BIN_OP VAR VAR NUMBER RETURN FUNC_CALL VAR VAR VAR IF VAR VAR RETURN FUNC_CALL VAR BIN_OP VAR VAR VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN ... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | n, x0, y0 = input().split()
n, x0, y0 = int(n), int(x0), int(y0)
lis = []
for i in range(n):
lis.append(input().split())
lis[i][0] = int(lis[i][0]) - x0
lis[i][1] = int(lis[i][1]) - y0
lis1 = []
for i in range(n):
if lis[i][0] == 0:
if "x" not in lis1:
lis1.append("x")
elif lis[i... | ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | def fun(x, y, stormtroopers):
shots = set([])
for coordenates in stormtroopers:
if coordenates[0] - x == 0:
slope = float("inf")
else:
slope = (coordenates[1] - y) / (coordenates[0] - x)
shots.add(slope)
print(len(shots))
n, x, y = [int(x) for x in input().s... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR LIST FOR VAR VAR IF BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST WH... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | n, x0, y0 = map(int, input().split())
s = set()
while n != 0:
x, y = map(int, input().split())
try:
s.add((y - y0) / (x - x0))
except ZeroDivisionError:
s.add(9999999999)
n -= 1
print(len(s)) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | a = input().split()
n = int(a[0])
x = int(a[1])
y = int(a[2])
l = []
t = []
for i in range(n):
m = []
p = input().split()
m.append(int(p[0]))
m.append(int(p[1]))
l.append(m)
for i in range(n):
if l[i][0] == x:
if 4444 not in t:
t.append(4444)
elif l[i][1] == y:
if... | 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 LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | line = list(map(int, input().split()))
n = line[0]
x = line[1]
y = line[2]
coords = []
for i in range(n):
point = list(map(int, input().split()))
coords.append([point[0], point[1], False])
count = 0
for i in range(len(coords)):
if coords[i][2] == True:
continue
count += 1
x1 = coords[i][0]
... | 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 LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | def gcd(a, b):
while a:
a, b = b % a, a
return b
def normalize(x, y):
g = gcd(x, y)
return x // g, y // g
n, x0, y0 = (int(x) for x in input().split())
s = set()
for i in range(n):
x, y = (int(x) for x in input().split())
s.add(normalize(x - x0, y - y0))
print(len(s)) | FUNC_DEF WHILE VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | n, x0, y0 = map(int, input().split())
d = {}
k = 0
l = []
a = 0
for _ in range(n):
x, y = map(int, input().split())
if x == x0:
if y == y0:
a = 1
elif "inf" not in l:
k += 1
l += ["inf"]
else:
a = (y - y0) / (x - x0)
b = y0 - a * x0
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR IF VAR VAR ASSIGN VAR NUMBER IF STRING VAR VAR NUMBER VAR LIST STRING ASSIGN VAR BIN_OP BIN_OP VA... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | n, x0, y0 = map(int, input().split())
r = 0
cs = []
ck = [0] * n
for i in range(n):
cs += [tuple(map(int, input().split()))]
for j, c in enumerate(cs):
if ck[j] == 0:
r += 1
ck[j] = 1
for i, oc in enumerate(cs):
if (y0 - oc[1]) * (x0 - c[0]) == (y0 - c[1]) * (x0 - oc[0]):
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR VAR LIST FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR FUNC_CA... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | n, x, y = map(int, input().split())
p = []
dx, dy = 0, 0
for i in range(n):
x1, y1 = map(int, input().split())
dx, dy = x1 - x, y1 - y
if dx == 0:
if "a" not in p:
p.append("a")
elif dy / dx not in p:
p.append(dy / dx)
print(len(p)) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR IF VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR STRING IF BIN_OP VAR VAR VAR EXPR FUNC_... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | n, x, y = map(int, input().split())
ans = 0
L = []
for i in range(n):
u, v = map(int, input().split())
ok = False
for u_, v_ in L:
if (x - u) * (y - v_) == (x - u_) * (y - v):
ok = True
break
if not ok:
ans += 1
L.append((u, v))
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR IF BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF VAR VAR NU... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | def hansolo(n, x0, y0, a):
dic = {}
ans = 0
for c in a:
if c[0] == x0:
if "vertical" in dic:
dic["vertical"] += 1
else:
dic["vertical"] = 1
ans += 1
else:
b = (c[1] - y0) / (c[0] - x0)
if b in dic... | FUNC_DEF ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR IF STRING VAR VAR STRING NUMBER ASSIGN VAR STRING NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL F... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | def div(m, n):
if n != 0:
return m / n
return "inf"
n, x, y = map(int, input().split())
l = []
for i in range(n):
m, n = map(int, input().split())
m -= x
n -= y
z = div(m, n)
if z != "inf":
if z not in l:
l.append(z)
elif z not in l:
l.append(z)
prin... | FUNC_DEF IF VAR NUMBER RETURN BIN_OP VAR VAR RETURN STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR STRING IF VAR VAR EXPR FUNC_CALL VAR VAR IF V... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | n, x0, y0 = list(map(int, input().split()))
total = {}
for i in range(n):
x1, y1 = list(map(int, input().split()))
if 0 == x1 - x0:
to = float("inf")
else:
to = float(y1 - y0) / (x0 - x1)
total[to] = total.get(to, 0) + 1
print(len(total)) | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF NUMBER BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VA... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | [n, a, b] = list(map(int, input().split()))
l = []
for i in range(n):
t = tuple(map(int, input().split()))
l.append(t)
d = {}
for x in l:
if x[0] == a:
d[x] = "a"
elif x[1] == b:
d[x] = 0
else:
d[x] = (x[1] - b) / (x[0] - a)
l1 = []
for x in d.values():
if x not in l1:
... | ASSIGN LIST VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR VAR IF VAR NUMBER VAR ASSIGN VAR VAR STRING IF VAR NUMBER VAR ASSIGN VAR VAR NUMBER ... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | inp = input().split()
numTroops = int(inp[0])
startX = int(inp[1])
startY = int(inp[2])
troopList = set()
for s in range(numTroops):
inp = input().split()
x = int(inp[0])
y = int(inp[1])
s = ""
if x != startX or y != startY:
if x == startX:
s = "und"
else:
i =... | 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 FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING I... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | n, p, q = map(int, input().split())
x = [0] * (n + 2)
y = [0] * (n + 2)
cnt = 0
chk = [0] * (n + 2)
for i in range(0, n):
inp = list(map(int, input().split()))
x[i] = inp[0] - p
y[i] = inp[1] - q
for i in range(0, n):
if chk[i] == 1:
continue
cnt = cnt + 1
chk[i] = 1
for j in range(0... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL V... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | import sys
def input():
return sys.stdin.readline().strip()
n, x, y = map(int, input().split())
slope = {}
for i in range(n):
x_0, y_0 = map(int, input().split())
try:
m = (y_0 - y) / (x_0 - x)
except:
m = 10**10
slope[m] = 1
print(len(slope)) | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_C... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | inp = input()
l = inp.split(" ")
n = int(l[0])
x0 = int(l[1])
y0 = int(l[2])
m = []
for i in range(0, n):
inpu = input()
l1 = inpu.split(" ")
x = int(l1[0])
y = int(l1[1])
if x - x0 != 0:
m.append([(y - y0) / (x - x0), y0 - (y - y0) / (x - x0) * x0])
else:
m.append(0)
for i in ra... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR 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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FU... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | lectura = lambda: map(int, input().split())
numeroPuntos, x0, y0 = lectura()
arrayPuntos = []
for i in range(0, numeroPuntos):
x, y = lectura()
listat = [x, y]
arrayPuntos.append(listat)
numeroPendientes = set()
for i in range(0, numeroPuntos):
arriba = arrayPuntos[i][1] - y0
abajo = arrayPuntos[i][... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR BIN... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | n, x, y = map(int, input().split())
troopers = list()
for i in range(n):
troopers.append(list(map(int, input().split())))
lines = set()
inline = False
for i in troopers:
xi = i[0]
yi = i[1]
if xi != x:
lines.add((yi - y) / (xi - x))
else:
inline = True
print(len(lines) + 1 if inline ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_... |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | def read():
return map(int, input().split())
def main():
n, x0, y0 = read()
st_loc = []
for _ in range(n):
x, y = read()
st_loc.append((x, y))
ans = 0
while st_loc:
x1, y1 = st_loc.pop()
st_loc = [
(x, y) for x, y in st_loc if (x - x0) * (y1 - y0) !=... | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR V... |
In a Circular City, there are $n$ houses, numbered from 1 to n and arranged in 1,2,...,n,1,2,...
Chef needs to deliver packages to $m$ (m≤n) houses.
Chef is initially at house 1. Chef decides an integer $x$ and stops after every $x$ houses. i.e- if $n=7$ and $x=2$. He will stop at 1,3,5,7,2,... He may deliver a packa... | def read():
return input().strip()
def readint():
return int(read())
n, k = map(int, read().split())
arr = [0] * 1001
for i in read().split():
arr[int(i)] = 1
mink = 9999999
for i in range(1, n):
brr = list(arr)
s = k
j = 1
ii = 0
val = 0
while s > 0:
val = j % n
... | FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VA... |
In a Circular City, there are $n$ houses, numbered from 1 to n and arranged in 1,2,...,n,1,2,...
Chef needs to deliver packages to $m$ (m≤n) houses.
Chef is initially at house 1. Chef decides an integer $x$ and stops after every $x$ houses. i.e- if $n=7$ and $x=2$. He will stop at 1,3,5,7,2,... He may deliver a packa... | m, n = map(int, input().split())
v = [int(x) for x in input().split()]
ans = m
for i in range(1, m):
cpy = v.copy()
k, cnt, l = 1, 1, [1]
while len(cpy) != 0:
if k in cpy:
cpy.remove(k)
if len(cpy) == 0:
break
k += i
cnt += 1
if k > m:
... | 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 VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER LIST NUMBER WHILE FUNC_CALL VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NU... |
In a Circular City, there are $n$ houses, numbered from 1 to n and arranged in 1,2,...,n,1,2,...
Chef needs to deliver packages to $m$ (m≤n) houses.
Chef is initially at house 1. Chef decides an integer $x$ and stops after every $x$ houses. i.e- if $n=7$ and $x=2$. He will stop at 1,3,5,7,2,... He may deliver a packa... | def totient(n):
ret = n
i = 2
while i * i <= n:
if n % i == 0:
ret = (i - 1) * (ret // i)
while n % i == 0:
n //= i
i += 1
if n:
ret = (n - 1) * (ret // n)
return ret
def gcd(x, y):
while y:
x, y = y, x % y
return x
... | FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR VAR WHILE BIN_OP VAR VAR NUMBER VAR VAR VAR NUMBER IF VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR VAR RETURN VAR FUNC_DEF WHILE VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR RETURN V... |
In a Circular City, there are $n$ houses, numbered from 1 to n and arranged in 1,2,...,n,1,2,...
Chef needs to deliver packages to $m$ (m≤n) houses.
Chef is initially at house 1. Chef decides an integer $x$ and stops after every $x$ houses. i.e- if $n=7$ and $x=2$. He will stop at 1,3,5,7,2,... He may deliver a packa... | n, m = map(int, input().split())
a = list(map(int, input().split()))
maximum = 1000000000000
final = [False] * n
for i in a:
final[i - 1] = True
for j in range(1, n):
test = list(final)
total = 0
x = 0
index = 0
while x != m and total < maximum:
if test[index]:
x += 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 BIN_OP LIST NUMBER VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBE... |
In a Circular City, there are $n$ houses, numbered from 1 to n and arranged in 1,2,...,n,1,2,...
Chef needs to deliver packages to $m$ (m≤n) houses.
Chef is initially at house 1. Chef decides an integer $x$ and stops after every $x$ houses. i.e- if $n=7$ and $x=2$. He will stop at 1,3,5,7,2,... He may deliver a packa... | hash, ans = {}, []
n, m = map(int, input().split())
ka = set(list(map(int, input().split())))
for i in range(n + 1):
z, count, ba = 1, 0, 0
while True:
if z == 1 and count != 0:
break
if ba == m:
break
if z in ka:
ba += 1
if z + i <= n:
... | ASSIGN VAR VAR DICT LIST ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER WHILE NUMBER IF VAR NUMBER VAR NUMBER IF VAR VAR IF VAR VAR VAR NUMBER IF BIN... |
In a Circular City, there are $n$ houses, numbered from 1 to n and arranged in 1,2,...,n,1,2,...
Chef needs to deliver packages to $m$ (m≤n) houses.
Chef is initially at house 1. Chef decides an integer $x$ and stops after every $x$ houses. i.e- if $n=7$ and $x=2$. He will stop at 1,3,5,7,2,... He may deliver a packa... | n, _ = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]
boo = [(True if i in arr and i != 1 else False) for i in range(1, n + 1)]
lis = [0] * n
ii = 1
for aa in range(1, n):
i = 1
boo1 = boo.copy()
while True in boo1:
boo1[i - 1] = False
lis[aa - 1] += 1
i = ... | 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 VAR VAR VAR NUMBER NUMBER NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR F... |
In a Circular City, there are $n$ houses, numbered from 1 to n and arranged in 1,2,...,n,1,2,...
Chef needs to deliver packages to $m$ (m≤n) houses.
Chef is initially at house 1. Chef decides an integer $x$ and stops after every $x$ houses. i.e- if $n=7$ and $x=2$. He will stop at 1,3,5,7,2,... He may deliver a packa... | n, m = map(int, input().split())
f = [([] * i) for i in range(1001)]
for i in range(1001):
for j in range(1001):
f[i].append(-1)
for i in range(1, 1001):
s = 0
for x in range(1, 100000000, i):
s = s + 1
if s > 1005:
break
if x % n != 0:
if f[i][x % n] ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST VAR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ... |
In a Circular City, there are $n$ houses, numbered from 1 to n and arranged in 1,2,...,n,1,2,...
Chef needs to deliver packages to $m$ (m≤n) houses.
Chef is initially at house 1. Chef decides an integer $x$ and stops after every $x$ houses. i.e- if $n=7$ and $x=2$. He will stop at 1,3,5,7,2,... He may deliver a packa... | n, m = map(int, input().split())
ls = set(list(map(int, input().split())))
mn = 10**9
for i in range(1, n):
count = 0
dct = {}
s = 0
k = m
case = 1
while k > 0:
if s in dct:
case = 0
break
dct[s] = 1
if s + 1 in ls:
k -= 1
s = (... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR ASSI... |
In a Circular City, there are $n$ houses, numbered from 1 to n and arranged in 1,2,...,n,1,2,...
Chef needs to deliver packages to $m$ (m≤n) houses.
Chef is initially at house 1. Chef decides an integer $x$ and stops after every $x$ houses. i.e- if $n=7$ and $x=2$. He will stop at 1,3,5,7,2,... He may deliver a packa... | s = list(map(int, input().split()))
n, m = s[0], s[1]
lol = list(map(int, input().split()))
dict = {}
for i in range(10001):
dict[i] = 0
for i in range(len(lol)):
dict[lol[i]] = 1
x = 1
minstop = 1000000007
while x < n:
stop = 1
nex = 1 + x
l = []
if dict[1] == 1:
l.append(1)
if len(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBE... |
In a Circular City, there are $n$ houses, numbered from 1 to n and arranged in 1,2,...,n,1,2,...
Chef needs to deliver packages to $m$ (m≤n) houses.
Chef is initially at house 1. Chef decides an integer $x$ and stops after every $x$ houses. i.e- if $n=7$ and $x=2$. He will stop at 1,3,5,7,2,... He may deliver a packa... | try:
n, m = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
mindif = 999999
maxdif = arr[-1] - arr[0]
for i in range(1, m):
if mindif > arr[i] - arr[i - 1]:
mindif = arr[i] - arr[i - 1]
minstop = []
d = dict()
d1 = dict()
for i in ra... | 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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR N... |
In a Circular City, there are $n$ houses, numbered from 1 to n and arranged in 1,2,...,n,1,2,...
Chef needs to deliver packages to $m$ (m≤n) houses.
Chef is initially at house 1. Chef decides an integer $x$ and stops after every $x$ houses. i.e- if $n=7$ and $x=2$. He will stop at 1,3,5,7,2,... He may deliver a packa... | n, m = map(int, input().split())
l = set(map(int, input().split()))
arr = [i for i in range(1, n + 1)]
ans = 10**9
x = 1
while x < n + 1:
array = set()
ind = [False] * n
done = False
array.add(1)
val = 1
cou = 1
while not done:
no = (val + x) % n
if no == 0:
no = ... | 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 VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR A... |
In a Circular City, there are $n$ houses, numbered from 1 to n and arranged in 1,2,...,n,1,2,...
Chef needs to deliver packages to $m$ (m≤n) houses.
Chef is initially at house 1. Chef decides an integer $x$ and stops after every $x$ houses. i.e- if $n=7$ and $x=2$. He will stop at 1,3,5,7,2,... He may deliver a packa... | ll = lambda: list(map(int, input().split()))
[n, x] = ll()
arr = ll()
h = [0] * n
minj = 9999999
for i in range(x):
h[arr[i] - 1] = 1
for px in range(1, n - 1):
vis = [0] * (n + 1)
viscells = 0
index = 0
jumps = 0
while viscells != x and vis[index] == 0:
if h[index] == 1:
vis... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN LIST VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER... |
In a Circular City, there are $n$ houses, numbered from 1 to n and arranged in 1,2,...,n,1,2,...
Chef needs to deliver packages to $m$ (m≤n) houses.
Chef is initially at house 1. Chef decides an integer $x$ and stops after every $x$ houses. i.e- if $n=7$ and $x=2$. He will stop at 1,3,5,7,2,... He may deliver a packa... | n, m = map(int, input().split())
a = list(map(int, input().split()))
ans = 999999999999
for x in range(1, n):
s = set(a)
stops = 0
q = 1
for i in range(n):
if q in s:
s.remove(q)
q = (q - 1 + x) % n + 1
stops += 1
if len(s) == 0:
break
if len(s... | 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 NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BI... |
In a Circular City, there are $n$ houses, numbered from 1 to n and arranged in 1,2,...,n,1,2,...
Chef needs to deliver packages to $m$ (m≤n) houses.
Chef is initially at house 1. Chef decides an integer $x$ and stops after every $x$ houses. i.e- if $n=7$ and $x=2$. He will stop at 1,3,5,7,2,... He may deliver a packa... | n, m = map(int, input().split())
l = list(map(int, input().split()))
e = {}
for i in range(m):
e[l[i]] = 0
d = []
for i in range(1, n):
k = []
f = 0
while len(k) != n:
if len(k) == 0:
c = 1
else:
c = (k[-1] + i) % n
if c == 0:
c = n
k.a... | 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 DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR ... |
In a Circular City, there are $n$ houses, numbered from 1 to n and arranged in 1,2,...,n,1,2,...
Chef needs to deliver packages to $m$ (m≤n) houses.
Chef is initially at house 1. Chef decides an integer $x$ and stops after every $x$ houses. i.e- if $n=7$ and $x=2$. He will stop at 1,3,5,7,2,... He may deliver a packa... | n, m = map(int, input().split())
a = list(map(int, input().split()))
mark = [(-1) for x in range(n + 1)]
for i in range(m):
mark[a[i]] = 0
minn = 10000
for i in range(1, n):
pos = 1
count = 0
ans = 1
while True:
if mark[pos] != -1 and mark[pos] != i:
mark[pos] = 0
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 VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASS... |
In a Circular City, there are $n$ houses, numbered from 1 to n and arranged in 1,2,...,n,1,2,...
Chef needs to deliver packages to $m$ (m≤n) houses.
Chef is initially at house 1. Chef decides an integer $x$ and stops after every $x$ houses. i.e- if $n=7$ and $x=2$. He will stop at 1,3,5,7,2,... He may deliver a packa... | n, m = map(int, input().split())
s = [int(i) for i in input().split()]
min_val = 10**9 + 7
for x in range(1, n):
c = [1001] * (n + 1)
c[0] = 0
for i in range(n + 1):
val = (x * i + 1) % n
if val == 0:
val = n
c[val] = min(c[val], i + 1)
temp_val = 0
for i in s:
... | 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 BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN... |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | class Solution:
def __init__(self):
self.c = 0
def check(self, a, k):
if a == None:
return 0
o = self.check(a.left, k)
p = self.check(a.right, k)
q = a.data + o + p
if q == k:
self.c += 1
return q
def countSubtreesWithSumX(root,... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER FUNC_DEF IF VAR NONE RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR RETURN VAR |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | def countSubtreesWithSumX(root, x):
count = 0
def dfs(root):
nonlocal count
if not root:
return 0
l = dfs(root.left)
r = dfs(root.right)
s = root.data + l + r
if s == x:
count += 1
return s
dfs(root)
return count | FUNC_DEF ASSIGN VAR NUMBER FUNC_DEF IF VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR VAR NUMBER RETURN VAR EXPR FUNC_CALL VAR VAR RETURN VAR |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | def countSubtreesWithSumX(root, x):
def traverse(node, k, ans):
if not node:
return 0
sm = traverse(node.left, k, ans) + traverse(node.right, k, ans) + node.data
if sm == k:
ans[0] += 1
return sm
ans = [0]
traverse(root, x, ans)
return ans[0] | FUNC_DEF FUNC_DEF IF VAR RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR VAR NUMBER NUMBER RETURN VAR ASSIGN VAR LIST NUMBER EXPR FUNC_CALL VAR VAR VAR VAR RETURN VAR NUMBER |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | count = 0
def countSubtreesWithSumX(root, x):
C = [0]
dfs(root, x, C)
return C[0]
def dfs(root, x, C):
global count
if root:
a = dfs(root.left, x, C)
b = dfs(root.right, x, C)
Sum = a + b + root.data
if Sum == x:
C[0] += 1
return Sum
return... | ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR LIST NUMBER EXPR FUNC_CALL VAR VAR VAR VAR RETURN VAR NUMBER FUNC_DEF IF VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR VAR NUMBER NUMBER RETURN VAR RETURN NUMBER |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | def preorder(root, target, res):
if root is None:
return 0
left_sum = preorder(root.left, target, res)
right_sum = preorder(root.right, target, res)
if left_sum + right_sum + root.data == target:
res[0] += 1
return left_sum + right_sum + root.data
def countSubtreesWithSumX(root, x)... | FUNC_DEF IF VAR NONE RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR NUMBER NUMBER RETURN BIN_OP BIN_OP VAR VAR VAR FUNC_DEF ASSIGN VAR LIST NUMBER EXPR FUNC_CALL VAR VAR VAR VAR RETURN VAR NUMBER |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | def countsubtree(root, count, x):
if root == None:
return 0
left = countsubtree(root.left, count, x)
right = countsubtree(root.right, count, x)
sum = 0
sum = left + right + root.data
if sum == x:
count[0] += 1
return sum
def countSubtreesWithSumX(root, x):
count = [0]
... | FUNC_DEF IF VAR NONE RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR VAR NUMBER NUMBER RETURN VAR FUNC_DEF ASSIGN VAR LIST NUMBER EXPR FUNC_CALL VAR VAR VAR VAR RETURN VAR NUMBER |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | def countSubtreesWithSumX(root, x):
res, _ = countSubtreesUtil(root, x)
return res
def countSubtreesUtil(root, x):
if not root:
return 0, 0
num_left, sum_left = countSubtreesUtil(root.left, x)
num_right, sum_right = countSubtreesUtil(root.right, x)
sum = root.data + sum_left + sum_righ... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR FUNC_DEF IF VAR RETURN NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR NUMBER RETURN VAR VAR |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | def util(root, x, ans):
if not root:
return 0
sm = 0
sm += root.data
sm += util(root.left, x, ans)
sm += util(root.right, x, ans)
if sm == x:
ans[0] += 1
return sm
def countSubtreesWithSumX(root, x):
ans = [0]
util(root, x, ans)
return ans[0] | FUNC_DEF IF VAR RETURN NUMBER ASSIGN VAR NUMBER VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR VAR NUMBER NUMBER RETURN VAR FUNC_DEF ASSIGN VAR LIST NUMBER EXPR FUNC_CALL VAR VAR VAR VAR RETURN VAR NUMBER |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | count = 0
def countSubtreesWithSumX(root, x):
global count
count = 0
_countSubtreesWithSumX(root, x)
return count
def _countSubtreesWithSumX(root, x):
if root == None:
return 0
global count
lh = _countSubtreesWithSumX(root.left, x)
rh = _countSubtreesWithSumX(root.right, x)
... | ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR VAR RETURN VAR FUNC_DEF IF VAR NONE RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR NUMBER RETURN BIN_OP BIN_OP VAR VAR VAR |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | def countSubtreesWithSumX(root, x):
def checkSubtree(root, x, cnt):
if not root:
return 0, cnt
suml, cnt = checkSubtree(root.left, x, cnt)
sumr, cnt = checkSubtree(root.right, x, cnt)
sum = root.data + suml + sumr
if sum == x:
cnt += 1
return ... | FUNC_DEF FUNC_DEF IF VAR RETURN NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR VAR NUMBER RETURN VAR VAR RETURN FUNC_CALL VAR VAR VAR NUMBER NUMBER |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | ans = 0
def solve(node, x):
if not node:
return 0
global ans
temp = solve(node.left, x) + solve(node.right, x) + node.data
if temp == x:
ans += 1
return temp
def countSubtreesWithSumX(root, x):
global ans
ans = 0
solve(root, x)
return ans | ASSIGN VAR NUMBER FUNC_DEF IF VAR RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR VAR RETURN VAR |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | def countSubtreesWithSumX(root, x):
m = {}
def fun(root):
if root == None:
return 0
s = 0
s += root.data
s += fun(root.left)
s += fun(root.right)
if s not in m:
m[s] = 1
else:
m[s] += 1
return s
fun(root)
... | FUNC_DEF ASSIGN VAR DICT FUNC_DEF IF VAR NONE RETURN NUMBER ASSIGN VAR NUMBER VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER RETURN VAR EXPR FUNC_CALL VAR VAR IF VAR VAR RETURN VAR VAR RETURN NUMBER |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | def countSubtreesWithSumX(root, x):
count = [0]
def solver(root, x):
if not root:
return 0
left = solver(root.left, x)
right = solver(root.right, x)
if left + right + root.data == x:
count[0] += 1
return left + right + root.data
store = solve... | FUNC_DEF ASSIGN VAR LIST NUMBER FUNC_DEF IF VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR NUMBER NUMBER RETURN BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR NUMBER |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | def countSubtreesWithSumX(root, x):
res = [0]
rec(root, x, res)
return res[0]
def rec(root, x, res):
if root is None:
return 0
sumi = root.data
sumi += rec(root.left, x, res)
sumi += rec(root.right, x, res)
if sumi == x:
res[0] += 1
return sumi | FUNC_DEF ASSIGN VAR LIST NUMBER EXPR FUNC_CALL VAR VAR VAR VAR RETURN VAR NUMBER FUNC_DEF IF VAR NONE RETURN NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR VAR NUMBER NUMBER RETURN VAR |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | def countSubtreesWithSumX(root, x):
count = [0]
ans(root, x, count)
return count[0]
def ans(root, x, count):
if root == None:
return 0
a = ans(root.left, x, count)
b = ans(root.right, x, count)
sum = a + b + root.data
if sum == x:
count[0] = count[0] + 1
return sum | FUNC_DEF ASSIGN VAR LIST NUMBER EXPR FUNC_CALL VAR VAR VAR VAR RETURN VAR NUMBER FUNC_DEF IF VAR NONE RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR ASSIGN VAR NUMBER BIN_OP VAR NUMBER NUMBER RETURN VAR |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | def countSubtreesWithSumX(root, x):
if not root:
return 0
if not root.left and not root.right:
if root.data == x:
return 1
res = [0]
_ = subtreeSum(root, x, res)
return res[0]
def subtreeSum(root, x, res):
if not root:
return 0
l_subtree = subtreeSum(roo... | FUNC_DEF IF VAR RETURN NUMBER IF VAR VAR IF VAR VAR RETURN NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR RETURN VAR NUMBER FUNC_DEF IF VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR VAR NUMBER NUMBER RETURN... |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | def countSubtreesWithSumX(root, x):
res = []
def find(root, x, res):
if not root:
return 0
left = find(root.left, x, res)
right = find(root.right, x, res)
curr = root.data + left + right
if curr == x:
res.append(root.data)
return curr
... | FUNC_DEF ASSIGN VAR LIST FUNC_DEF IF VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR EXPR FUNC_CALL VAR VAR VAR VAR RETURN FUNC_CALL VAR VAR |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | def countSubtreesWithSumX(root, x):
ans = [0]
def rec(nod, x, sumi):
if nod is None:
return 0
lh = rec(nod.left, x, sumi)
rh = rec(nod.right, x, sumi)
p = nod.data + lh + rh
if p == x:
ans[0] += 1
return p
rec(root, x, 0)
return a... | FUNC_DEF ASSIGN VAR LIST NUMBER FUNC_DEF IF VAR NONE RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR VAR NUMBER NUMBER RETURN VAR EXPR FUNC_CALL VAR VAR VAR NUMBER RETURN VAR NUMBER |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | def countSubtreesWithSumX(root, x):
return helper(root, x)[1]
def helper(root, target):
if root is None:
return 0, 0
sum_left, count_left = helper(root.left, target)
sum_right, count_right = helper(root.right, target)
summa = sum_left + sum_right + root.data
count = (summa == target) +... | FUNC_DEF RETURN FUNC_CALL VAR VAR VAR NUMBER FUNC_DEF IF VAR NONE RETURN NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR RETURN VAR VAR |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | def traverseTree(root, x):
if root is None:
return 0
left = traverseTree(root.left, x)
right = traverseTree(root.right, x)
sum_subtree = left + right + root.data
if sum_subtree == x:
traverseTree.count += 1
return sum_subtree
def countSubtreesWithSumX(root, x):
arr = [0]
... | FUNC_DEF IF VAR NONE RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR VAR RETURN VAR |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | def count(root, x):
if root is None:
return [0, 0]
l, r = count(root.left, x), count(root.right, x)
if root.data + l[0] + r[0] == x:
return [root.data + l[0] + r[0], 1 + l[1] + r[1]]
else:
return [root.data + l[0] + r[0], l[1] + r[1]]
def countSubtreesWithSumX(root, x):
ret... | FUNC_DEF IF VAR NONE RETURN LIST NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER VAR RETURN LIST BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER RETURN LIST BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VA... |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | def utility(root, x, res):
if root == None:
return 0
if root.left == None and root.right == None:
if root.data == x:
res[0] += 1
return root.data
lSum = utility(root.left, x, res)
rSum = utility(root.right, x, res)
total = root.data + lSum + rSum
if total == x... | FUNC_DEF IF VAR NONE RETURN NUMBER IF VAR NONE VAR NONE IF VAR VAR VAR NUMBER NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR VAR NUMBER NUMBER RETURN VAR FUNC_DEF ASSIGN VAR LIST NUMBER EXPR FUNC_CALL VAR VAR VAR VAR RETURN VAR... |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | def countSubtreesWithSumX(root, x):
val = [0]
def Sum(root, x, val):
if root == None:
return 0
s = Sum(root.left, x, val) + Sum(root.right, x, val) + root.data
if x == s:
val[0] += 1
return s
Sum(root, x, val)
return val[0] | FUNC_DEF ASSIGN VAR LIST NUMBER FUNC_DEF IF VAR NONE RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR VAR NUMBER NUMBER RETURN VAR EXPR FUNC_CALL VAR VAR VAR VAR RETURN VAR NUMBER |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | def countSubtreesWithSumX(root, x):
res = [0]
def dfs(root):
if not root:
return 0
if not root.left and not root.right:
if root.data == x:
res[0] += 1
return root.data
l = dfs(root.left)
r = dfs(root.right)
if l + r + r... | FUNC_DEF ASSIGN VAR LIST NUMBER FUNC_DEF IF VAR RETURN NUMBER IF VAR VAR IF VAR VAR VAR NUMBER NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR NUMBER NUMBER RETURN BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR NUMBER |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | def countSubtreesWithSumX(root, k):
def helper(root):
nonlocal ans
if not root:
return 0
lft = helper(root.left)
rgt = helper(root.right)
if lft + rgt + root.data == k:
ans += 1
return lft + rgt + root.data
ans = 0
helper(root)
re... | FUNC_DEF FUNC_DEF IF VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR NUMBER RETURN BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | def util(root, x):
if root is None:
return 0
ls = util(root.left, x)
rs = util(root.right, x)
sum = ls + rs + root.data
if sum == x:
util.count += 1
return sum
def countSubtreesWithSumX(root, x):
if root is None:
return 0
util.count = 0
ls = util(root.left, ... | FUNC_DEF IF VAR NONE RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR VAR NUMBER RETURN VAR FUNC_DEF IF VAR NONE RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR V... |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | from sys import setrecursionlimit
setrecursionlimit(10**6)
def countSubtreesWithSumX(root, x):
ans = [0]
def calc(root):
if root == None:
return 0
l = calc(root.left)
r = calc(root.right)
if l + r + root.data == x:
ans[0] += 1
return l + r + ro... | EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR LIST NUMBER FUNC_DEF IF VAR NONE RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR NUMBER NUMBER RETURN BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR NUMBER |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | def countSubtreesWithSumX(root, x):
if root is None:
return 0
count = [0]
ls = sumTree(root.left, count, x)
rs = sumTree(root.right, count, x)
if ls + rs + root.data == x:
count[0] += 1
return count[0]
def sumTree(root, count, x):
if root is None:
return 0
ls = ... | FUNC_DEF IF VAR NONE RETURN NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR NUMBER NUMBER RETURN VAR NUMBER FUNC_DEF IF VAR NONE RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR... |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | def countSubtreesWithSumX(root, x):
q = [root]
d = {}
while q:
node = q.pop(0)
d[node] = -1
if node.left:
q.append(node.left)
if node.right:
q.append(node.right)
def sum(root):
if not root:
return 0
if d[root] != -1:
... | FUNC_DEF ASSIGN VAR LIST VAR ASSIGN VAR DICT WHILE VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR EXPR FUNC_CALL VAR VAR IF VAR EXPR FUNC_CALL VAR VAR FUNC_DEF IF VAR RETURN NUMBER IF VAR VAR NUMBER RETURN VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN VAR VAR ASSI... |
Given a binary tree and an integer X. Your task is to complete the function countSubtreesWithSumX() that returns the count of the number of subtress having total node’s data sum equal to the value X.
Example: For the tree given below:
5
/ \
-10 3
/ \ /... | def countSubtreesWithSumXRec(root, x):
if root == None:
return 0, 0
ans_l, sum_l = countSubtreesWithSumXRec(root.left, x)
ans_r, sum_r = countSubtreesWithSumXRec(root.right, x)
if sum_l + sum_r + root.data == x:
return ans_l + ans_r + 1, sum_l + sum_r + root.data
else:
return... | FUNC_DEF IF VAR NONE RETURN NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR RETURN BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR VAR RETURN BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.