description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | r, c, n, k = map(int, input().split())
a = []
q = 0
for i in range(r):
a.append([0] * c)
for i in range(n):
x, y = map(int, input().split())
a[x - 1][y - 1] = 1
for i in range(r):
for j in range(c):
for m in range(r - i + 1):
for p in range(c - j + 1):
s = 0
... | ASSIGN VAR 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 BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CAL... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | w, h, v, n = map(int, input().split())
V = [([False] * h) for _ in range(w)]
for _ in range(v):
x, y = map(int, input().split())
V[x - 1][y - 1] = True
def calc(a, b, c, d):
s = 0
for x in range(a, c + 1):
for y in range(b, d + 1):
s += V[x][y]
if s >= n:
... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VA... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | r, c, n, k = map(int, input().split())
A = [([0] * c) for i in range(r)]
for i in range(n):
a, b = map(int, input().split())
A[a - 1][b - 1] = 1
f = 0
g = 0
ans = 0
for i in range(r):
for j in range(c):
for i2 in range(r - i):
for j2 in range(c - j):
cnt = 0
... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR ... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | import time
a = []
r, c, n, k = (int(i) for i in input().split())
for i in range(n):
a.append([(int(i) - 1) for i in input().split()])
start = time.time()
ans = 0
for x1 in range(r):
for y1 in range(c):
for x0 in range(x1 + 1):
for y0 in range(y1 + 1):
now = 0
... | IMPORT ASSIGN VAR LIST ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | r, c, n, k = map(int, input().split())
xy = [list(map(int, input().split())) for i in range(n)]
field = [([0] * c) for i in range(r)]
for i in range(n):
field[xy[i][0] - 1][xy[i][1] - 1] = 1
num = 0
for i in range(r):
for j in range(c):
for i2 in range(i, r):
for j2 in range(j, c):
... | ASSIGN VAR 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 LIST NUMBER VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER NUMBER BIN_OP VAR VAR NUMBER NUMBER NUMBER ASSIGN V... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | readInts = lambda: list(map(int, input().split()))
pos = []
r, c, n, k = readInts()
for i in range(n):
x, y = readInts()
pos.append([x - 1, y - 1])
ret = 0
for i in range(r):
for j in range(c):
for ii in range(i, r):
for jj in range(j, c):
cnt = 0
for it i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR LIST BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CA... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | r, c, n, k = map(int, input().split())
d = [[(0) for j in range(c + 1)] for i in range(r + 1)]
for i in range(n):
x, y = map(int, input().split())
d[x][y] = 1
for i in range(1, r + 1):
for j in range(1, c + 1):
d[i][j] = d[i][j] + d[i - 1][j] + d[i][j - 1] - d[i - 1][j - 1]
a = 0
for i in range(1, r... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR F... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | from itertools import combinations
def main():
from itertools import combinations
r, c, n, k = map(int, input().split())
r += 1
c += 1
l = [([0] * c) for _ in range(r)]
for _ in range(n):
y, x = map(int, input().split())
for i in range(y, r):
row = l[i]
... | FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VA... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | tmp = input().split(" ")
r = int(tmp[0])
c = int(tmp[1])
n = int(tmp[2])
k = int(tmp[3])
tab = [[0]]
for j in range(1, c + 1):
tab[0].append(0)
for i in range(1, r + 1):
tab.append([0])
for j in range(1, c + 1):
tab[i].append(0)
for i in range(0, n):
tmp = input().split(" ")
tab[int(tmp[0])]... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMB... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | def count(a, b, c, d):
return sum([arr[i][j] for i in range(a, c + 1) for j in range(b, d + 1)])
def solve(r, c, n, m):
ans = 0
for i in range(1, r + 1):
for j in range(1, c + 1):
for k in range(i, r + 1):
for l in range(j, c + 1):
x = count(i, j, k,... | FUNC_DEF RETURN FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP ... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | r, c, n, k = [int(x) for x in input().split()]
mus = [[(0) for j in range(c)] for i in range(r)]
for t in range(n):
x, y = [(int(s) - 1) for s in input().split()]
mus[x][y] = 1
ans = 0
for i1 in range(r):
for i2 in range(i1, r):
for j1 in range(c):
for j2 in range(j1, c):
... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL ... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | b, a, n, k = map(int, input().split())
data = [[(0) for i in range(a)] for j in range(b)]
for i in range(n):
xi, yi = map(int, input().split())
xi -= 1
yi -= 1
data[xi][yi] = 1
answer = 0
for i in range(b):
for j in range(a):
for x in range(i, b):
for y in range(j, a):
... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL ... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | r, c, n, p = map(int, input().split())
resp = 0
m = []
for i in range(r):
aux = []
for j in range(c):
aux.append(False)
m.append(aux[:])
for i in range(n):
x, y = map(int, input().split())
m[x - 1][y - 1] = True
for i in range(r):
for j in range(c):
for a in range(r, i, -1):
... | ASSIGN VAR 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 LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | r, c, n, k = [int(x) for x in input().split()]
min_x, min_y, max_x, max_y = r, c, 1, 1
alts = []
for i in range(0, n):
x, y = [int(i) for i in input().split()]
alts.append((x, y))
photo_count = 0
for x in range(1, r + 1):
for y in range(1, c + 1):
for w in range(1, r - (x - 1) + 1):
for ... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR ... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | f = lambda: map(int, input().split())
r, c, n, k = f()
t = [([0] * (c + 1)) for i in range(r + 1)]
for j in range(n):
y, x = f()
t[y][x] = 1
for y in range(r):
p = t[y + 1]
for x in range(c):
p[x + 1] += p[x]
t[y + 1] = [(a + b) for a, b in zip(p, t[y])]
s = (c * c + c) * (r * r + r) >> 2
fo... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER FOR VA... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | dhuang = 0
a, b, c, d = map(int, input().split(" "))
huang = [(["*"] * b) for _ in range(a)]
for i in range(c):
x, y = map(int, input().split(" "))
huang[x - 1][y - 1] = "#"
for i in range(a):
for j in range(b):
for k in range(i, a):
for l in range(j, b):
ct = 0
... | ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST STRING VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING FOR VAR FUNC_CALL VAR VAR FOR ... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | L = lambda: [*map(int, input().split())]
r, c, n, k = L()
A = [L() for _ in range(n)]
print(
sum(
sum(a <= x <= b and f <= y <= g for x, y in A) >= k
for a in range(1, r + 1)
for b in range(a, r + 1)
for f in range(1, c + 1)
for g in range(f, c + 1)
)
) | ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR FUNC... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | r, c, n, k = map(int, input().split())
violas = set([tuple(map(int, input().split())) for i in range(n)])
ans = 0
for i in range(r):
for j in range(c):
for l in range(1, r - i + 1):
for w in range(1, c - j + 1):
ctr = 0
for a in range(i, i + l):
... | ASSIGN VAR VAR 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 VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR NU... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | r, c, n, k = map(int, input().split())
G = [([0] * c) for i in range(0, r)]
for i in range(0, n):
a, b = map(int, input().split())
a -= 1
b -= 1
G[a][b] = True
ans = 0
for x in range(0, r):
for y in range(0, c):
for y1 in range(y + 1, c + 1):
for x1 in range(x + 1, r + 1):
... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR FOR... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | def cnt(x1, y1, x2, y2):
ans = 0
for i in range(y2, y1 + 1):
for j in range(x1, x2 + 1):
if lst[i][j] == 1:
ans += 1
return ans
h, w, n, kk = map(int, input().split())
anss = 0
lst = [([0] * 20) for i in range(20)]
for i in range(n):
x, y = map(int, input().split())... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CAL... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | r, c, n, k = map(int, input().split())
a = [[(0) for i in range(0, c)] for j in range(0, r)]
for i in range(0, n):
x, y = map(int, input().split())
x = x - 1
y = y - 1
a[x][y] = 1
ans = 0
for i in range(0, r):
for j in range(0, c):
for u in range(i, r):
for v in range(j, c):
... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIG... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | r, c, n, k = map(int, input().split())
g, v = [([False] * c) for i in range(r)], 0
for i in range(n):
x, y = map(int, input().split())
g[x - 1][y - 1] = True
for a in range(r):
for b in range(c):
for e in range(a, r):
for f in range(b, c):
x = sum(g[i][j] for i in range(a... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | r, c, n, k = map(int, input().split())
V = [list(map(int, input().split())) for _ in range(n)]
G = [[(0) for _ in range(c)] for _ in range(r)]
for i in range(n):
G[V[i][0] - 1][V[i][1] - 1] = 1
T = [[(0) for _ in range(c)] for _ in range(r)]
T[0][0] = G[0][0]
for i in range(1, r):
T[i][0] = G[i][0]
for i in ran... | ASSIGN VAR 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 NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER NUMBER BIN_OP VAR VAR NUMBER NUMBER NUMBER AS... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | r, c, n, k = list(map(int, input().split()))
alt = []
count = 0
for i in range(n):
a, b = list(map(int, input().split()))
alt.append([a - 1, b - 1])
for x1 in range(r):
for x2 in range(x1 + 1):
for y1 in range(c):
for y2 in range(y1 + 1):
d = 0
for i in ra... | ASSIGN VAR VAR VAR 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 ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST BIN_OP VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BI... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | def read_ints():
return map(int, input().split())
r, c, n, k = read_ints()
s = [([False] * (c + 1)) for _ in range(r + 1)]
for _ in range(n):
x, y = read_ints()
assert x <= r, x
assert y <= c, y
s[x][y] = True
ss = [([0] * (c + 1)) for _ in range(r + 1)]
for y in range(1, r + 1):
for x in rang... | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | r, c, n, k = list(map(int, input().split()))
A = [2] * n
for i in range(n):
A[i] = list(map(int, input().split()))
answer = 0
for i1 in range(1, r + 1):
for j1 in range(1, c + 1):
for i2 in range(i1, r + 1):
for j2 in range(j1, c + 1):
t = 0
for i in range(n):... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBE... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | def count(orchestra, x1, y1, x2, y2):
rv = 0
for i in range(x1, x2 + 1):
for j in range(y1, y2 + 1):
if orchestra[i][j] == 1:
rv += 1
return rv
def doit(r, c, n, k, pos):
orchestra = [[(0) for x in range(c)] for x in range(r)]
for i in pos:
orchestra[i[0... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | read = lambda: map(int, input().split())
r, c, n, k = read()
a = [([0] * (c + 1)) for i in range(r + 1)]
for i in range(n):
x, y = read()
a[x][y] = 1
d = [([0] * (c + 1)) for i in range(r + 1)]
for i in range(1, r + 1):
for j in range(1, c + 1):
if a[i][j]:
d[i][j] += 1
if i == j... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | s = input()
S = s.split()
x = int(S[0])
y = int(S[1])
n = int(S[2])
k = int(S[3])
a = [["*" for i in range(x)] for j in range(y)]
for i in range(n):
alt = input()
ALT = alt.split()
a[int(ALT[1]) - 1][int(ALT[0]) - 1] = "#"
answer = 0
for x1 in range(x):
for y1 in range(y):
for x2 in range(x1, x)... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FU... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | r, c, n, k = input().split()
r, c, n, k = int(r), int(c), int(n), int(k)
violas = []
for _ in range(n):
x, y = input().split()
x, y = int(x) - 1, int(y) - 1
violas.append((y, x))
def count_violas(x1, y1, x2, y2):
global violas
s = 0
for x, y in violas:
if x >= x1 and x <= x2 and y >= y... | ASSIGN VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR 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 VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | r, c, n, k = map(int, input().split())
data = [[(False) for i in range(c)] for j in range(r)]
for i in range(n):
x, y = map(int, input().split())
x -= 1
y -= 1
data[x][y] = True
ans = 0
for a in range(r + 1):
for b in range(c + 1):
for e in range(r):
for d in range(c):
... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR ... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | r, c, n, k = map(int, input().split())
a = [tuple(map(int, input().split())) for _ in range(n)]
ans = 0
for x1 in range(1, r + 1):
for x2 in range(x1, r + 1):
for y1 in range(1, c + 1):
for y2 in range(y1, c + 1):
if len([(1) for x, y in a if x1 <= x <= x2 and y1 <= y <= y2]) >= ... | ASSIGN VAR 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 NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FU... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | def count(orchestra, initial, final):
num = 0
for i in range(initial[0], final[0] + 1):
for j in range(initial[1], final[1] + 1):
if orchestra[i][j] == 1:
num += 1
return num
def getNumber(orchestra, initial, minimum):
num = 0
for i in range(initial[0], r):
... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER NUMBER IF VAR VAR VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR LIST VAR VAR ASSIGN V... |
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ... | r, c, n, k = map(int, input().split(" "))
p = []
def findIn(z, x, y, s):
global n
ret = 0
for i in range(n):
if z <= p[i][0] and y >= p[i][0] and x <= p[i][1] and s >= p[i][1]:
ret = ret + 1
return ret
for i in range(n):
x, y = map(int, input().split(" "))
p.append((x, y)... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR F... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | n, p, k = map(int, input().split())
ar = list(map(int, input().split()))
ar = [((i**4 - k * i + p**4) % p) for i in ar]
d = dict()
for i in ar:
if i in d:
d[i] += 1
else:
d[i] = 1
ans = 0
for key in d:
ans += d[key] * (d[key] - 1) // 2
print(ans) | 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 ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR VAR BIN_OP VAR NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR N... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | n, p, k = [int(i) for i in input().split()]
data = [int(i) for i in input().split()]
dic = {}
for d in data:
val = (pow(d, 4, p) - d * k) % p
if val in dic:
dic[val] += 1
else:
dic[val] = 1
ans = 0
for am in dic.values():
ans += am * (am - 1) // 2
print(ans) | ASSIGN VAR 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 DICT FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_O... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | import sys
n, p, k = list(map(int, sys.stdin.readline().strip().split()))
a = list(map(int, sys.stdin.readline().strip().split()))
for i in range(0, n):
a[i] = (a[i] ** 4 - k * a[i]) % p
a[i] = a[i] + 2 * p
a[i] = a[i] % p
a.sort()
c = 1
x = a[0]
ans = 0
for i in range(1, n):
if a[i] == x:
c = ... | IMPORT ASSIGN VAR VAR VAR FUNC_CALL 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 FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP NUMBER ... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | cond = [int(x) for x in input().split()]
n = cond[0]
p = cond[1]
k = cond[2]
a = [int(x) for x in input().split()]
b = [((x**4 - k * x) % p) for x in a]
d = {}
r = 0
for x in b:
if x not in d:
d[x] = 0
r += d[x]
d[x] += 1
print(r) | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR VA... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | n, p, k = map(int, input().split())
d = dict()
a = list(map(int, input().split()))
for i in a:
tmp = (i**4 - k * i) % p
if tmp not in d:
d[tmp] = 1
else:
d[tmp] += 1
ans = 0
for i in d:
ans += d[i] * (d[i] - 1) // 2
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP BIN_... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | def tianjia(dic, z):
if z in dic:
dic[z] += 1
else:
dic[z] = 1
n, p, k = map(int, input().split())
z = 0
l = list(map(int, input().split()))
dic = {}
for i in l:
z = (i**4 - i * k) % p
tianjia(dic, z)
print(sum([(dic[i] * (dic[i] - 1) // 2) for i in dic])) | FUNC_DEF IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | n, p, k = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
di = {}
ans = 0
for i in l:
x = (i * i * i * i - k * i) % p
if x in di:
ans += di[x]
di[x] += 1
else:
di[x] = 1
print(ans) | ASSIGN VAR 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 DICT ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR VAR IF VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_C... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | n, p, k = map(int, input().split())
a = list(map(int, input().split()))
cnt = {}
b = []
ans = 0
for i in a:
b.append((i**4 - k * i) % p)
for i in b:
if i in cnt:
cnt[i] += 1
ans += cnt[i] - 1
else:
cnt[i] = 1
print(ans) | 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 ASSIGN VAR DICT ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR VAR VAR FOR VAR VAR IF VAR VAR VAR VAR NUMBER VAR BIN_OP VAR VAR NUM... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | def Sum(n):
return n * (n - 1) // 2
def Solver(p, k, a):
aux = []
for i in a:
aux.append((i**4 - i * k) % p)
dic = {}
for i in aux:
if i in dic:
dic[i] += 1
else:
dic[i] = 1
val = list(dic.values())
sol = 0
for i in val:
if i > 1:... | FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR VAR VAR ASSIGN VAR DICT FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR NU... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | n, p, k = map(int, input().split())
a = list(map(int, input().split()))
a = [((i**4 - i * k) % p) for i in a]
c = {i: (0) for i in a}
for i in a:
c[i] += 1
s = 0
for i in c:
i = c[i]
s += i * (i - 1) // 2
print(s) | 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 ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR VAR NUMBER VAR VAR FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR VAR VAR BIN_OP BIN_O... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | n, p, k = map(int, input().split())
arr = list(map(int, input().split()))
cnt = dict()
def f(a):
return ((pow(a, 4, p) - k * a) % p + p) % p
def g(a):
return a * (a - 1) // 2
res = 0
for a in arr:
v = f(a)
if v in cnt:
cnt[v] += 1
else:
cnt[v] = 1
for a in arr:
v = f(a)
... | 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 ASSIGN VAR FUNC_CALL VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR VAR VAR VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN V... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | n, p, k = map(int, input().split())
c = 0
cnt = {}
for i in map(int, input().split()):
t = (i**4 - k * i) % p
if t in cnt:
c += cnt[t]
cnt[t] += 1
else:
cnt[t] = 1
print(c) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR VAR VAR IF VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | from sys import stdin
n, p, k = list(map(int, stdin.readline().strip().split()))
s = list(map(int, stdin.readline().strip().split()))
st = set()
d = dict()
for i in s:
x = (i**4 - i * k) % p
if x in st:
d[x] += 1
else:
st.add(x)
d[x] = 1
s.sort()
ans = 0
for i in s:
x = (i**4 - ... | ASSIGN VAR VAR VAR FUNC_CALL 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR VAR VAR IF VAR VAR VAR VAR NUMBER EXPR FUN... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | import sys
input = sys.stdin.readline
n, p, k = map(int, input().split())
a = list(map(int, input().split()))
MOD = p
memo = {}
for i in range(n):
num = (a[i] ** 4 - a[i] * k) % MOD
if num not in memo:
memo[num] = 1
else:
memo[num] += 1
ans = 0
for i in memo:
ans += memo[i] * (memo[i] -... | IMPORT ASSIGN VAR VAR 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 ASSIGN VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NU... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | ln = [int(i) for i in input().split(" ")]
n = ln[0]
p = ln[1]
k = ln[2]
a = [int(i) for i in input().split(" ")]
cts = {}
ctsc = {}
ans = []
nm = 0
for i in range(0, len(a)):
an = (a[i] ** 4 - k * a[i]) % p
if an in ctsc:
nm += ctsc[an]
ctsc[an] += 1
else:
ctsc[an] = 1
print(nm) | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BI... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | def expmod(a, n, m):
if n == 0:
return 1
elif n == 1:
return a % m
res = n / 2
rem = n % 2
temp = expmod(a, res, m)
if rem == 1:
return temp * temp * a % m
else:
return temp * temp % m
n, p, k = map(int, input().split())
a = list(map(int, input().split()))
h... | FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER RETURN BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR RETURN BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | def solve(dic, elem):
if elem in dic:
dic[elem] += 1
else:
dic[elem] = 1
n, p, k = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
b = {}
res = 0
for i in range(n):
val = (a[i] ** 4 - k * a[i]) % p
solve(b, val)
for key in b:
t = b[key]
res += t * (t - 1) //... | FUNC_DEF IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | n, p, k = map(int, input().split())
arr = list(map(int, input().split()))
d = {}
for i in arr:
x = i * i % p * i % p * i % p
y = i * k % p
cc = (x - y + p) % p
if cc in d:
d[cc] += 1
else:
d[cc] = 1
ans = 0
for key, value in d.items():
cc = value * (value - 1) // 2
ans += cc
... | 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 ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VA... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | n, q, k = map(int, input().split())
a = [int(x) for x in input().split()]
mp = dict()
for i in range(n):
mp[(a[i] ** 4 - k * a[i]) % q] = 0
for i in range(n):
mp[(a[i] ** 4 - k * a[i]) % q] += 1
ans = 0
for key in mp:
d = mp[key]
ans += d * (d - 1) // 2
print(ans) | ASSIGN VAR 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 FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP V... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | n, p, k = [int(i) for i in input().split(" ")]
a = [int(i) for i in input().split(" ")]
b = []
for i in range(n):
b.append((pow(a[i], 4, p) - k * a[i]) % p)
mydic = {}
for i in b:
mydic[i] = 0
for i in b:
mydic[i] += 1
ans = 0
for t in mydic:
ans += mydic[t] * (mydic[t] - 1) // 2
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR NUMBER FOR... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | line = input()
line = line.split()
line = list(map(lambda x: int(x), line))
n = line[0]
p = line[1]
k = line[2]
inputs = input()
inputs = inputs.split()
inputs = list(map(lambda x: int(x), inputs))
dict = {}
counter = 0
for i in range(n):
exped = ((inputs[i] ** 2) ** 2 - k * inputs[i]) % p
if dict.get(exped, No... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR DICT ASSIGN VAR NUMBE... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | n, p, k = list(map(int, input().split()))
a = list(map(int, input().split()))
d = dict()
for i in range(n):
now = a[i] * a[i] * a[i] * a[i] - k * a[i]
now %= p
if now in d:
d[now] += 1
else:
d[now] = 1
ans = 0
for i in range(n):
now = a[i] * a[i] * a[i] * a[i] - k * a[i]
now %= p... | ASSIGN VAR 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 FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR IF VAR VAR VAR VAR NUMBER ASS... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | n, p, k = list(map(int, input().strip().split()))
a = list(map(int, input().strip().split()))
d = dict()
for el in a:
r = 1
r *= el
r %= p
r *= el
r %= p
r *= el
r %= p
r *= el
r %= p
s = k * el % p
r -= s
r %= p
try:
d[r] += 1
except:
d[r] = 1
c =... | ASSIGN VAR VAR VAR FUNC_CALL 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 FUNC_CALL VAR FOR VAR VAR ASSIGN VAR NUMBER VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VA... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | iarr = list(map(int, input().split()))
n = iarr[0]
p = iarr[1]
k = iarr[2]
arr = list(map(int, input().split()))
for i in range(n):
arr[i] = (pow(arr[i], 4, p) - k % p * (arr[i] % p) % p) % p
dic = {}
for i in range(n):
try:
dic[arr[i]] += 1
except:
dic[arr[i]] = 1
ans = 0
for i in dic:
... | 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | n, p, k = map(int, input().split())
d = {}
ans = 0
b = list(map(int, input().split()))
for i in range(n):
a = b[i]
val = (a**4 - k * a) % p
if d.get(val) == None:
d[val] = 1
else:
ans += d[val]
d[val] += 1
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR VAR VAR IF FUNC_CALL VAR VAR NONE ASSIGN VAR VAR NUMBER VAR... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | def main():
n, p, k = map(int, input().split())
ans = list(map(int, input().split()))
for i in range(n):
temp = ans[i]
ans[i] = (temp**4 - temp * k) % p
mp = {}
for i in ans:
mp.setdefault(i, 0)
mp[i] = mp[i] + 1
temp = 0
for i in mp.values():
temp = i... | FUNC_DEF 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 FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR VAR VAR ASSIGN VAR DICT FOR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | n, p, k = map(int, input().split())
l = list(map(int, input().split()))
d = dict()
for y in range(n):
x = pow(l[y], 4) - l[y] * k
if x % p not in d:
d[x % p] = 1
else:
d[x % p] += 1
ct = 0
for k, v in d.items():
ct += v * (v - 1) // 2
print(ct) | 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 ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER BIN_OP VAR VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR N... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | def check(num1, num2, p, k):
v = num1 + num2
v *= num1 * num1 + num2 * num2
v %= p
v += p
v %= p
return v == k % p
n, p, k = (int(x) for x in input().split())
idx___number = [int(x) for x in input().split()]
idx___precount = [(((pow(x, 4, p) - k * x) % p + p) % p) for x in idx___number]
met_pr... | FUNC_DEF ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR RETURN VAR BIN_OP VAR VAR ASSIGN VAR 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 BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | n, p, k = map(int, input().split())
a = list(map(int, input().split()))
a = list((i**4 - k * i) % p for i in a)
cnt = set(a)
cnt = dict(zip(cnt, [0] * len(cnt)))
ans = 0
for i in a:
ans += cnt[i]
cnt[i] += 1
print(ans) | 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 ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR... |
You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$.
Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$.
-----Input-----
The first line contains integers $n, p, k$ ($2 \le n \le 3 \cdot 10^5$, $2 \le p \l... | l1 = input().split()
n = int(l1[0])
p = int(l1[1])
k = int(l1[2])
l = input().split()
A = {}
count = 0
e = []
for i in range(n):
b = int(l[i])
t = b * b % p * (b * b % p) - k * b % p
t = t % p
if t in A:
A[t] += 1
else:
A[t] = 1
for x in A:
count += int(A[x] * (A[x] - 1) / 2)
pri... | 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 FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP B... |
Compare two version numbers version1 and version2.
If version1 > version2 return 1; if version1 < version2 return -1;otherwise return 0.
You may assume that the version strings are non-empty and contain only digits and the . character.
The . character does not represent a decimal point and is used to separate number s... | class Solution:
def compareVersion(self, version1, version2):
a, b = [int(i) for i in version1.split(".")], [
int(i) for i in version2.split(".")
]
for i in range(max(len(a), len(b))):
if i == len(a):
a.append(0)
if i == len(b):
... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR VAR VAR VAR RETURN ... |
Compare two version numbers version1 and version2.
If version1 > version2 return 1; if version1 < version2 return -1;otherwise return 0.
You may assume that the version strings are non-empty and contain only digits and the . character.
The . character does not represent a decimal point and is used to separate number s... | class Solution:
def compareVersion(self, version1, version2):
v1 = version1.split(".")
v2 = version2.split(".")
len1 = len(v1)
len2 = len(v2)
for i in range(min(len1, len2)):
if int(v1[i]) != int(v2[i]):
return 1 if int(v1[i]) > int(v2[i]) else -1... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR ... |
Compare two version numbers version1 and version2.
If version1 > version2 return 1; if version1 < version2 return -1;otherwise return 0.
You may assume that the version strings are non-empty and contain only digits and the . character.
The . character does not represent a decimal point and is used to separate number s... | class Solution:
def compareVersion(self, version1, version2):
v1, v2 = [int(i) for i in version1.split(".")], [
int(i) for i in version2.split(".")
]
if len(v1) > len(v2):
v2 += [0] * (len(v1) - len(v2))
if len(v1) < len(v2):
v1 += [0] * (len(v2) ... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR FUNC_CAL... |
Compare two version numbers version1 and version2.
If version1 > version2 return 1; if version1 < version2 return -1;otherwise return 0.
You may assume that the version strings are non-empty and contain only digits and the . character.
The . character does not represent a decimal point and is used to separate number s... | class Solution:
def compareVersion(self, version1, version2):
v1 = [int(n) for n in version1.split(".")]
v2 = [int(n) for n in version2.split(".")]
for i in range(max(len(v1), len(v2))):
x1 = v1[i] if i < len(v1) else 0
x2 = v2[i] if i < len(v2) else 0
if... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR VAR RETURN NUMBER ... |
Compare two version numbers version1 and version2.
If version1 > version2 return 1; if version1 < version2 return -1;otherwise return 0.
You may assume that the version strings are non-empty and contain only digits and the . character.
The . character does not represent a decimal point and is used to separate number s... | class Solution:
def compareVersion(self, version1, version2):
while version1 and version2:
result1 = version1.split(".", 1)
if len(result1) == 2:
digit1, version1 = result1[0], result1[1]
else:
digit1 = result1[0]
version1 ... | CLASS_DEF FUNC_DEF WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR STRING NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR STRING NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR STRING... |
Compare two version numbers version1 and version2.
If version1 > version2 return 1; if version1 < version2 return -1;otherwise return 0.
You may assume that the version strings are non-empty and contain only digits and the . character.
The . character does not represent a decimal point and is used to separate number s... | class Solution:
def compareVersion(self, version1, version2):
v1 = version1.split(".")
v2 = version2.split(".")
for i in range(max(len(v1), len(v2))):
a = int(v1[i]) if len(v1) > i else 0
b = int(v2[i]) if len(v2) > i else 0
if a > b:
retu... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR RETURN NUMBER IF VAR VAR RETUR... |
Compare two version numbers version1 and version2.
If version1 > version2 return 1; if version1 < version2 return -1;otherwise return 0.
You may assume that the version strings are non-empty and contain only digits and the . character.
The . character does not represent a decimal point and is used to separate number s... | class Solution:
def compareVersion(self, version1, version2):
if version1 == version2:
return 0
else:
version1_nums = version1.split(".")
version2_nums = version2.split(".")
len1, len2 = len(version1_nums), len(version2_nums)
end = max(len... | CLASS_DEF FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP LIST NUMBER BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP LIST NUMBER BIN_OP VAR VAR FOR VAR FUNC_CALL VAR ... |
Compare two version numbers version1 and version2.
If version1 > version2 return 1; if version1 < version2 return -1;otherwise return 0.
You may assume that the version strings are non-empty and contain only digits and the . character.
The . character does not represent a decimal point and is used to separate number s... | class Solution:
def compareVersion(self, version1, version2):
l1 = [int(x) for x in version1.split(".")]
l2 = [int(x) for x in version2.split(".")]
max_len = max(len(l1), len(l2))
l1 += [0] * (max_len - len(l1))
l2 += [0] * (max_len - len(l2))
for i in range(0, max_l... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR BIN_OP LIST NUMBER BIN_OP VAR FUNC_CALL VAR VAR VAR BIN_OP LIST NUMBER BIN_OP VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER... |
Recently, Tokitsukaze found an interesting game. Tokitsukaze had $n$ items at the beginning of this game. However, she thought there were too many items, so now she wants to discard $m$ ($1 \le m \le n$) special items of them.
These $n$ items are marked with indices from $1$ to $n$. In the beginning, the item with ind... | n, m, k = map(int, input().split())
l = list(map(int, input().split()))
beg = 1
cnt = 0
i = 0
j = 0
ele = 0
while i < m:
end = ((l[i] - ele - 1) // k + 1) * k + ele
while i < m and l[i] <= end:
i += 1
ele += 1
cnt += 1
print(cnt) | 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER VAR NUMBER VAR V... |
Recently, Tokitsukaze found an interesting game. Tokitsukaze had $n$ items at the beginning of this game. However, she thought there were too many items, so now she wants to discard $m$ ($1 \le m \le n$) special items of them.
These $n$ items are marked with indices from $1$ to $n$. In the beginning, the item with ind... | n, m, k = list(map(int, input().split(" ")))
p = tuple(map(int, input().split(" ")))
d = 0
part = (p[0] - 1) // k
moves = 0
skip = 0
for pi in p:
if (pi - 1 - d) // k == part:
skip += 1
continue
d += skip
part = (pi - 1 - d) // k
skip = 1
moves += 1
print(moves + 1) | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR VAR VAR ... |
Recently, Tokitsukaze found an interesting game. Tokitsukaze had $n$ items at the beginning of this game. However, she thought there were too many items, so now she wants to discard $m$ ($1 \le m \le n$) special items of them.
These $n$ items are marked with indices from $1$ to $n$. In the beginning, the item with ind... | n, m, k = [int(p) for p in input().split()]
arr = [int(p) for p in input().split()]
for i in range(len(arr)):
arr[i] -= 1
cnt = 0
steps = 0
i = 0
gcnt = 0
while i < m:
pg = (arr[i] - gcnt) // k
j = i
loop = True
while j < m:
if (arr[j] - gcnt) // k == pg:
cnt += 1
j +... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR A... |
Recently, Tokitsukaze found an interesting game. Tokitsukaze had $n$ items at the beginning of this game. However, she thought there were too many items, so now she wants to discard $m$ ($1 \le m \le n$) special items of them.
These $n$ items are marked with indices from $1$ to $n$. In the beginning, the item with ind... | n, m, k = map(int, input().split())
l = list(map(int, input().split()))
i = 0
operations = 0
while i < m:
j = i
cu = (l[i] - 1 - j) // k
while i < m and (l[i] - 1 - j) // k == cu:
i += 1
operations += 1
print(operations) | 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR WHILE VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR VAR NUMBER... |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 7