description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | for _ in range(int(input())):
n, q = map(int, input().split())
a = list(map(int, input().split()))
b = list(sorted(a))
d = {}
dd = {}
ddd = {}
for i in range(n):
d[a[i]] = i
dd[b[i]] = i
ddd[b[i]] = n - i - 1
for __ in range(q):
x = int(input())
po... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | T = int(input())
for i in range(T):
N, Q = list(map(int, input().split()))
nums = list(map(int, input().split()))
sorted_nums = sorted(nums)
sorted_index_map = {}
index_map = {}
for ind in range(N):
sorted_index_map[sorted_nums[ind]] = ind
index_map[nums[ind]] = ind
for j in ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN ... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def binary(arr, x, check, lowcount, upcount):
lcount = 0
ucount = 0
low = 0
high = len(arr) - 1
while low <= high:
mid = (low + high) // 2
if arr[mid] == x:
break
if low == high and arr[mid] != x:
break
elif arr[mid] < x and mid < check:
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR IF VAR VAR VAR VAR VAR IF VAR VAR VAR VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR IF V... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def bsearch(arr, size, ind):
mid = 0
left = 0
right = size - 1
reqToGrt = 0
reqToLess = 0
changeToGrt = 0
changeToLess = 0
while left <= right:
mid = (left + right) // 2
if ind == mid:
break
if ind < mid:
if arr[ind] > arr[mid]:
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP 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 NUMBER IF VAR VAR IF VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR NUMBE... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | t = int(input())
for _ in range(t):
n, q = map(int, input().split())
a = list(map(int, input().split()))
b = []
b1 = {}
for y in range(q):
k = int(input())
b.append(k)
b1[k] = [0, 0]
for i in range(n):
if a[i] in b1:
b1[a[i]][0] = i
p = a.copy()
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 LIST ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR ... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | t = int(input())
while t != 0:
t -= 1
n, q = [int(x) for x in input().strip().split()]
a = [int(x) for x in input().strip().split()]
sorted_a = sorted(a)
indexOf = {}
index = 0
for ele in a:
indexOf[ele] = index
index += 1
index = 0
countlessthan = {}
countgreater... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | t = int(input())
for tc in range(t):
n, q = map(int, input().split())
a = list(map(int, input().split()))
ac = sorted(a)
fa = {}
indices = {}
for i in range(n):
indices[a[i]] = i
for query in range(q):
x = int(input())
if fa.get(x, -2) == -2:
realI = indic... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def main():
T = int(input())
for t in range(T):
inp = input().split()
N = int(inp[0])
Q = int(inp[1])
inp = input().split()
A = [int(i) for i in inp]
d = {}
for i in range(N):
d[A[i]] = i
As = sorted(A)
ds = {}
for i in ... | FUNC_DEF ASSIGN VAR FUNC_CALL 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 FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR AS... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def bySearch(arr, l, r, x):
if r >= l:
mid = (l + r) // 2
if arr[mid][0] == x:
return int(mid)
elif arr[mid][0] > x:
return int(bySearch(arr, l, mid - 1, x))
else:
return int(bySearch(arr, mid + 1, r, x))
def merge(arr, l, m, r):
n1 = m - l +... | FUNC_DEF IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR NUMBER VAR RETURN FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR RETURN FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR B... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | t = int(input())
while t > 0:
t -= 1
n, q = map(int, input().split())
arr = list(map(int, input().split()))
tarr = sorted(arr)
d = {}
inddir = {}
for i in range(len(arr)):
inddir[arr[i]] = i
tarrlen = len(tarr)
for i in range(len(tarr)):
d[tarr[i]] = [i, tarrlen - i -... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER 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 FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIG... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def bsc(a, di, dn, x, n):
xi = dn[x]
c = 0
s1, s2, l1, l2 = 0, 0, 0, 0
l, h = 0, n - 1
while l <= h:
m = int((l + h) / 2)
if a[m] == x:
xj = di[x]
if xj - s2 >= s1 and n - xj - 1 - l2 >= l1:
return max(s1, l1)
else:
... | FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR VAR IF BIN_OP VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR RETURN FUNC_CAL... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | t = int(input())
for a0 in range(t):
n, q = input().strip().split(" ")
n, q = int(n), int(q)
arr1 = list(map(int, input().strip().split(" ")))
arr = list(arr1)
arr1.sort()
ltgt = {}
ind = {}
for i in range(len(arr)):
ind[arr[i]] = i
for i in range(len(arr1)):
ltgt[arr... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR DICT ... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def Bin(arr, lo, hi, x):
res = False
while lo <= hi:
mid = (lo + hi) // 2
if arr[mid] == x:
res = True
break
elif arr[mid] < x:
lo = mid + 1
else:
hi = mid - 1
return res
def Function(arr, new, dict, low, high, x):
count =... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VA... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def main():
t = int(input())
for _ in range(t):
n, q = map(int, input().split())
a = list(map(int, input().split()))
A = [*a]
mapp = dict()
for i in range(n):
mapp[a[i]] = [i]
a.sort()
for i in range(n):
mapp[a[i]].append(i)
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 LIST VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR LIST VAR EXPR FUNC_CALL VAR FOR ... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def fakebfs(orig_array, sorted_array, indices, sorted_indices, x, n, index):
index_in_sorted = sorted_indices[x]
small = index_in_sorted - 1
large = index_in_sorted + 1
low = 0
high = n - 1
count = 0
num_greater = 0
num_lesser = 0
while low <= high:
mid = int((low + high) / 2... | FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NU... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | for _ in range(int(input())):
n, q = list(map(int, input().split()))
l = [int(i) for i in input().split()]
d = {}
ind = {}
for i in range(n):
ind[l[i]] = i
dup = l[:]
dup = sorted(dup)
for i in range(n):
chote = i
bade = n - i - 1
d[dup[i]] = [chote, bade]... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | for _ in range(int(input())):
n, q = map(int, input().split())
hm1 = {}
arr = []
brr = []
arr = list(map(int, input().split()))
brr = arr[:]
brr.sort()
for i in range(n):
hm1[arr[i]] = [0, 0]
for i in range(n):
hm1[arr[i]][0] = i
hm1[brr[i]][1] = i
for i i... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR LIST NUMBER NUMBER ... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | t = int(input())
def binSearch(data, n, x, pos, avai):
low = 0
high = n - 1
replaceLow = 0
replaceHigh = 0
lowUsed = 0
highUsed = 0
while low <= high:
mid = (low + high) // 2
if mid < pos:
if data[mid] < x:
lowUsed += 1
low = mid ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP 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 NUMBER IF VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR ... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def binarySearchMain(sm, value, num):
l = 0
r = num - 1
m = 0
while l <= r:
m = (l + r) // 2
if sm[m] == value:
return m
elif sm[m] > value:
r = m - 1
elif sm[m] < value:
l = m + 1
def binarySearch(value, num):
l = 0
r = num -... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR RETURN VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSI... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def binary_search(a, n, x, d, ls):
low = 0
high = n - 1
l = ls[x]
h = ls[x]
li = 0
lh = 0
while low <= high:
mid = (low + high) // 2
if a[mid] == x:
break
elif a[mid] < x:
if d[x] < mid:
high = mid - 1
h = h + 1
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR IF VAR VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSI... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | T = int(input())
for t in range(T):
N, Q = map(int, input().split())
if N > 10:
L1 = list(map(int, input().split()))
L1.insert(0, -1)
L2 = L1[:]
L2.sort()
D2 = dict()
for i in range(1, N + 1):
D2[L2[i]] = i
D = dict()
for i in range(1, ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUM... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | from sys import stdin, stdout
t = int(stdin.readline())
while t:
n, q = list(map(int, stdin.readline().rstrip().split()))
arr = list(map(int, stdin.readline().rstrip().split()))
d = {}
d1 = {}
a = arr.copy()
a.sort()
for i in range(n):
d1[a[i]] = i
d[arr[i]] = i
while q:... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN 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 DICT ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR ... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def f(a, y, index, sorted_pos):
n = len(a)
low = 0
high = n - 1
L, R = 0, 0
l, r = 0, 0
while low <= high:
mid = (low + high) // 2
if a[mid] == y:
break
elif mid > index[y]:
high = mid - 1
L += 1
if a[mid] < y:
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBE... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | t = int(input())
for m in range(t):
n, q = map(int, input().split())
arr = [int(x) for x in input().split()]
grap = {}
for i in range(n):
grap[arr[i]] = i
arr2 = sorted(arr)
grap2 = {}
for i in range(n):
grap2[arr2[i]] = i
for l in range(q):
x = int(input())
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIG... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | for t in range(int(input())):
n, q = map(int, input().split())
arr = list(map(int, input().split()))
brr = []
pos = {}
bpos = {}
for i in range(n):
pos[arr[i]] = i
brr.append(arr[i])
brr.sort()
for j in range(n):
bpos[brr[j]] = j
for i in range(q):
x =... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 LIST ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FOR... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def BSearch(array, n, x):
low = 0
high = n - 1
while low <= high:
mid = (low + high) // 2
if array[mid] == x:
break
elif array[mid] < x:
low = mid + 1
else:
high = mid - 1
return mid
def indexSearch(array, n, i, less, more):
low =... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIG... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def binarySearch(start, end, xindex, opList):
if start <= end:
midindex = int((start + end) / 2)
opList.append(midindex)
if xindex < midindex:
return binarySearch(start, midindex - 1, xindex, opList)
elif xindex > midindex:
return binarySearch(midindex + 1, en... | FUNC_DEF IF VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR IF VAR VAR RETURN FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def binary_search(a, n, x):
low = 0
high = n - 1
while low <= high:
mid = (low + high) // 2
if a[mid][0] == x:
break
elif a[mid][0] < x:
low = mid + 1
else:
high = mid - 1
return mid
def fake_binary_search(a, b, n, x):
low = 0
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR NUMBER VAR IF VAR VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIG... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | from sys import stdin
def binary_count(a, dorg, dinc, n, x):
low = 0
high = n - 1
smalln = dinc[x]
bign = n - 1 - dinc[x]
smallu = 0
bigu = 0
pos = dorg[x]
while low <= high:
mid = (low + high) // 2
if mid == pos:
return max(bigu, smallu)
elif a[mid]... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR RETURN FUNC_CALL VAR VAR VAR IF VAR VAR VAR IF VAR VAR IF VAR NUMBER ASSIGN VAR B... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | t = int(input())
for a0 in range(t):
n, q = map(int, input().split())
a = list(map(int, input().split()))
dicta = {}
for i in range(n):
dicta[a[i]] = i
c = []
b = []
for i in range(n):
b.append(i)
d = []
for i in a:
d.append(i)
d.sort()
dictd = {}
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUN... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def Query(A, x, index, n, X):
y = n - x - 1
stepL = 0
stepH = 0
low = 0
high = n - 1
while low <= high:
mid = (low + high) // 2
if mid == index:
break
elif index > mid:
low = mid + 1
if A[mid] > X:
if x > 0:
... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR ... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def modified_binary(a, key, l, u):
while l <= u:
mid = (l + u) // 2
if a[mid][0] == key:
break
elif a[mid][0] > key:
u = mid - 1
else:
l = mid + 1
return [a[mid][1], mid]
for _ in range(int(input())):
n, q = [int(x) for x in input().split... | FUNC_DEF WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR NUMBER VAR IF VAR VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN LIST VAR VAR NUMBER VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FU... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | for i in range(0, int(input())):
lookUp = {}
lookUpSorted = {}
N, Q = map(int, input().split())
A = [int(i) for i in input().split()]
for count, i in enumerate(A):
lookUp[int(i)] = count
for count, i in enumerate(sorted(A)):
lookUpSorted[i] = count
B = [int(input()) for _ in ... | FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def mergeSort(alist, a):
b = []
if len(alist) > 1:
mid = len(alist) // 2
lefthalf = alist[:mid]
righthalf = alist[mid:]
la = a[:mid]
ra = a[mid:]
mergeSort(lefthalf, la)
mergeSort(righthalf, ra)
i = 0
j = 0
k = 0
while i < l... | FUNC_DEF ASSIGN VAR LIST IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CAL... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def bs(l, x, i, n, si):
low = 1
high = n
lc = 0
gc = 0
l1 = 0
g1 = 0
mid = (low + high) // 2
while mid != i:
if i > mid:
l1 = l1 + 1
low = mid + 1
if l[mid] > x:
lc = lc + 1
if i < mid:
g1 = g1 + 1
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER WHILE VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def search(arr, l, r, x, index, small, SMALL, large, LARGE):
mid = int((l + r) / 2)
if index == mid:
return small, SMALL, large, LARGE
elif index < mid:
if arr[mid] < x:
large += 1
else:
LARGE += 1
return search(arr, l, mid - 1, x, index, small, SMALL,... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR RETURN VAR VAR VAR VAR IF VAR VAR IF VAR VAR VAR VAR NUMBER VAR NUMBER RETURN FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR VAR IF VAR VAR VAR VAR NUMBER VAR NUMBER RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR VAR ... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def binary(a, n, x):
low = 0
high = n - 1
pos = 0
while low <= high:
mid = (low + high) // 2
if a[mid] == x:
pos = 1
break
elif a[mid] < x:
low = mid + 1
else:
high = mid - 1
return mid, pos
def spbinary(a, a1, n, x, x... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def minswaps(A, A2, D, n, x):
g, s, cg, cs = 0, 0, 0, 0
si, li = 0, n - 1
while si <= li:
mid = (si + li) // 2
if mid == D[x]:
break
elif mid < D[x]:
if A[mid] < x:
cg += 1
g += 1
si = mid + 1
else:
i... | FUNC_DEF ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR IF VAR VAR VAR IF VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSI... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | for t in range(int(input())):
n, q = [int(x) for x in input().strip().split()]
a = [int(x) for x in input().strip().split()]
d = {ai: i for i, ai in enumerate(a)}
b = {ai: i for i, ai in enumerate(sorted(a))}
for query in range(q):
x = int(input())
need_above = 0
need_below =... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR AS... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | t = int(input())
for _ in range(t):
n, q = input().split()
n = int(n)
q = int(q)
a = list(map(int, input().split()))
b = list(a)
b.sort()
d = {}
small = {}
big = {}
for i in range(n):
d[a[i]] = i
small[b[i]] = i
big[b[i]] = n - i - 1
for test in range(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR ... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | for t in range(int(input())):
N, Q = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
B = sorted(A)
D = {}
for i in range(len(A)):
D[A[i]] = [i]
for i in range(len(B)):
D[B[i]].append(i)
results = []
queries = [int(input()) for q in range(Q)]
fo... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR LIST VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def bs(arr, n, x):
low = 0
high = n
while low <= high:
mid = (low + high) // 2
if arr[mid] == x:
break
elif arr[mid] < x:
low = mid + 1
else:
high = mid - 1
return mid
def mbs(arr, n, x, ltX, oI):
low = 0
high = n
acG = 0
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR ... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | t = int(input())
for _ in range(t):
n, q = map(int, input().split())
ls = list(map(int, input().split()))
d = {}
for i in range(n):
d[ls[i]] = i
sl = sorted(ls)
ds = {}
for i in range(n):
ds[sl[i]] = i
for __ in range(q):
x = int(input())
ind = d[x]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def inde(x, sarr):
low, high = 1, len(sarr)
while low <= high:
mid = (low + high) // 2
if sarr[mid][1] == x:
break
elif sarr[mid][1] < x:
low = mid + 1
else:
high = mid - 1
return mid
def swapcount(low, high, k, arr, grtmark, lessmark):
... | FUNC_DEF ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR NUMBER VAR IF VAR VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR VAR RETURN LIST NUMBER NUMBER VAR VAR IF... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | t = int(input())
for i in range(t):
a = input()
b = a.split()
n = int(b[0])
q = int(b[1])
c = input()
d = c.split()
e = {}
ff = []
for j in range(n):
d[j] = int(d[j])
ff.append(int(d[j]))
e[int(d[j])] = j
d.sort()
g = {}
for l in range(n):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL ... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def bs(a, n, x):
low = 0
high = n - 1
while low <= high:
mid = (low + high) // 2
if a[mid] == x:
break
elif a[mid] < x:
low = mid + 1
else:
high = mid - 1
return mid
t = int(input())
for _ in range(t):
n, q = input().split()
n... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN ... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def bst2(B, n, number):
l = 0
h = n - 1
while l <= h:
m = l + h >> 1
if B[m] == number:
return m
elif B[m] > number:
h = m - 1
else:
l = m + 1
def BST(A, n, index, i):
l, h = 0, n - 1
lm = ln = 0
lm1 = ln1 = 0
while l <= h... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR RETURN VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER WHILE VAR VAR ASSI... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def fake_bs(inputs, n, dest_idx, elements_before_q, elements_after_q, res):
if dest_idx in res:
return res[dest_idx]
l = 0
h = n - 1
before_swaps = 0
after_swaps = 0
while l <= h:
mid = (l + h) // 2
if mid == dest_idx:
res[dest_idx] = max(before_swaps, after_s... | FUNC_DEF IF VAR VAR RETURN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR V... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | for _ in range(int(input())):
n, q = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in a:
b.append(i)
b.sort()
les = {}
p = 0
for i in b:
les[i] = p
p += 1
di = {}
for i in range(n):
di[a[i]] = i
for i in range(q):
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR VAR VAR NUMBER ... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | t = int(input().strip())
def binary_search(a, val):
index = dic[val]
n_lo_val = dic2[val]
n_high_val = n - 1 - dic2[val]
mutual_swap1 = []
mutual_swap2 = []
def checktruepath(n_lo_val, n_high_val):
low1 = 0
high1 = n - 1
while low1 <= high1:
mid = (low1 + h... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR IF VAR VAR VAR IF VAR V... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | T = int(input())
D = [None] * 10000001
while T > 0:
D1 = [0] * 10000001
D2 = [0] * 10000001
N, Q = input().strip().split(" ")
N, Q = [int(N), int(Q)]
A = list()
A = list(map(int, input().strip().split(" ")))
B = [None] * N
E = [None] * N
z = 0
C = [None] * Q
for i in range(0,... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR LIST FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CA... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def path(arr, n, x):
l = 0
h = n - 1
left = []
right = []
while l <= h:
m = (l + h) // 2
if arr[m] == x:
break
elif arr[m] > x:
left.append(arr[m])
h = m - 1
else:
right.append(arr[m])
l = m + 1
return le... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR VAR ASSIGN VAR FUNC_CALL ... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | T = int(input())
for cases in range(T):
N, Q = map(int, input().split())
A = list(map(int, input().split()))
Asorted = A[:]
Asorted.sort()
pos = {}
Sortpos = {}
for i in range(N):
pos[A[i]] = i
for i in range(N):
Sortpos[Asorted[i]] = i
for i in range(Q):
X = ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 EXPR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CAL... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | indexdict = {}
def binsearch(key):
low, high = 0, len(temp) - 1
while low <= high:
mid = (low + high) // 2
if temp[mid] == key:
return mid
elif temp[mid] < key:
low = mid + 1
else:
high = mid - 1
return None
def fakebinsearch(key):
... | ASSIGN VAR DICT FUNC_DEF ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR RETURN VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN NONE FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def bin(arr, x, l, r):
while l <= r:
mid = (r + l) // 2
if arr[mid] == x:
return mid
elif arr[mid] < x:
l = mid + 1
else:
r = mid - 1
def sol(index, sindex, arr, l, r, x):
count1 = 0
count2 = 0
smr = 0
gtr = 0
smlr = sindex - ... | FUNC_DEF WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR RETURN VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR WHILE VAR VAR ASSIGN VAR ... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | def createParentArray(a, l, r, root, p):
if l > r:
return
mid = (l + r) // 2
p[mid] = root
createParentArray(a, l, mid - 1, mid, p)
createParentArray(a, mid + 1, r, mid, p)
def getAns(a, p, idx, left, right):
i = idx
base = a[idx]
cnt = 0
lt_base = 0
gt_base = 0
whi... | FUNC_DEF IF VAR VAR RETURN ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR NUMBER IF VAR VAR... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | for i in range(int(input())):
n, q = map(int, input().split())
l = list(map(int, input().split()))
d2 = {}
for j in range(n):
d2[l[j]] = j
arr = list(l)
arr.sort()
d1 = {}
for j in range(n):
d1[arr[j]] = j
for j in range(q):
x = int(input())
g1, g3, l1... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL... |
"If you didn't copy assignments during your engineering course, did you even do engineering?"
There are $Q$ students in Chef's class. Chef's teacher has given the students a simple assignment:
Write a function that takes as arguments an array $A$ containing only unique elements and a number $X$ guaranteed to be present... | t = int(input())
for i in range(t):
y = [int(i) for i in input().split()]
n = y[0]
q = y[1]
a = [int(j) for j in input().split()]
b = sorted(a)
dic = {}
dic1 = {}
for j in range(n):
dic[a[j]] = j
for j in range(n):
dic1[b[j]] = j
for j in range(q):
x = int... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR... |
You are given a sequence of n integers a1, a2, ..., an.
Determine a real number x such that the weakness of the sequence a1 - x, a2 - x, ..., an - x is as small as possible.
The weakness of a sequence is defined as the maximum value of the poorness over all segments (contiguous subsequences) of a sequence.
The poor... | def main():
input()
a = list(map(int, input().split()))
def f(a):
maxend = maxnow = 0
for x in a:
maxend = max(0, maxend + x)
maxnow = max(maxnow, maxend)
return maxnow
f1 = lambda x: f(i - x for i in a)
f2 = lambda x: f(x - i for i in a)
Max = m... | FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR... |
You are given a sequence of n integers a1, a2, ..., an.
Determine a real number x such that the weakness of the sequence a1 - x, a2 - x, ..., an - x is as small as possible.
The weakness of a sequence is defined as the maximum value of the poorness over all segments (contiguous subsequences) of a sequence.
The poor... | def max_sum(nums, shift):
res = 0
res_m = 0
cur_sum = 0
cur_m_sum = 0
for i in range(len(nums)):
cur_sum += nums[i] + shift
cur_m_sum += nums[i] + shift
res = max(res, cur_sum)
cur_sum = max(0, cur_sum)
res_m = min(res_m, cur_m_sum)
cur_m_sum = min(0, ... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR RETURN VAR VAR ... |
You are at your grandparents' house and you are playing an old video game on a strange console. Your controller has only two buttons and each button has a number written on it.
Initially, your score is $0$. The game is composed of $n$ rounds. For each $1\le i\le n$, the $i$-th round works as follows.
On the screen, a... | def fun(num_plus, num_minus, a, b):
if a == b:
return "YES" if num_plus == num_minus else "NO"
else:
r = a * (num_minus - num_plus) % (a - b)
if r == 0:
k = a * (num_minus - num_plus) // (a - b)
return "YES" if k in range(-num_plus, num_minus + 1) else "NO"
... | FUNC_DEF IF VAR VAR RETURN VAR VAR STRING STRING ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR VAR RETURN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER STRING STRING RETURN STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ... |
You are at your grandparents' house and you are playing an old video game on a strange console. Your controller has only two buttons and each button has a number written on it.
Initially, your score is $0$. The game is composed of $n$ rounds. For each $1\le i\le n$, the $i$-th round works as follows.
On the screen, a... | n = int(input())
res = []
plus = 0
minus = 0
rounds = []
s = input()
q = int(input())
while q > 0:
x = input().split(" ")
first, second = int(x[0]), int(x[1])
rounds.append(sorted([first, second]))
q -= 1
for i in range(len(s)):
if s[i] == "+":
plus += 1
if s[i] == "-":
minus += ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_C... |
You are at your grandparents' house and you are playing an old video game on a strange console. Your controller has only two buttons and each button has a number written on it.
Initially, your score is $0$. The game is composed of $n$ rounds. For each $1\le i\le n$, the $i$-th round works as follows.
On the screen, a... | n = int(input())
s = input()
pl = s.count("+")
mn = s.count("-")
m = int(input())
for __ in range(m):
a, b = map(int, input().split())
abmax = max(a, b)
abmin = min(a, b)
if pl == mn:
print("YES")
continue
if pl < mn:
smax = pl * abmax - mn * abmin
diff_plus = abmax -... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF V... |
You are at your grandparents' house and you are playing an old video game on a strange console. Your controller has only two buttons and each button has a number written on it.
Initially, your score is $0$. The game is composed of $n$ rounds. For each $1\le i\le n$, the $i$-th round works as follows.
On the screen, a... | n, s, t, pos, neg = int(input()), input(), int(input()), 0, 0
for x in s:
if x == "+":
pos += 1
else:
neg += 1
for i in range(t):
c, p = map(int, input().split())
x, y = min(c, p), max(c, p)
high, low = y * pos - x * neg, x * pos - y * neg
if low > 0 or high < 0:
print("N... | ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR BIN_... |
You are at your grandparents' house and you are playing an old video game on a strange console. Your controller has only two buttons and each button has a number written on it.
Initially, your score is $0$. The game is composed of $n$ rounds. For each $1\le i\le n$, the $i$-th round works as follows.
On the screen, a... | n = int(input())
s = input()
m = s.count("-")
p = s.count("+")
m, p = max(m, p), min(m, p)
q = int(input())
for i in range(q):
t1, t2 = m, p
b1, b2 = map(int, input().split())
b1, b2 = min(b1, b2), max(b1, b2)
r = b1 * t1 - b2 * t2
t = 0
if r < 0:
if -r % (b2 - b1) == 0 and -r // (b2 - b... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FU... |
You are at your grandparents' house and you are playing an old video game on a strange console. Your controller has only two buttons and each button has a number written on it.
Initially, your score is $0$. The game is composed of $n$ rounds. For each $1\le i\le n$, the $i$-th round works as follows.
On the screen, a... | n = int(input())
s = input()
q = int(input())
np = s.count("+")
nm = s.count("-")
for _ in range(q):
a, b = map(int, input().split())
numerator = (nm - np) * b
denominator = a - b
if a == b:
r = np == nm
elif numerator % denominator != 0:
r = False
else:
r = -nm <= numera... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING 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 VAR ASSIGN VAR BIN_OP VAR VAR IF VAR ... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | r = range(int(input()))
def s(a, b):
(c, d, e, f), (g, h, i, j) = a, b
return max(c, g), max(d, h), min(e, i), min(f, j)
def p(a):
b = [a[0]]
for i in range(1, len(a)):
b += [s(b[i - 1], a[i])]
return b
H = 9**15
B = -H, -H, H, H
a = [B] + [tuple(map(int, input().split())) for i in r] ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR RETURN FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR LIST FUNC_CALL VAR VAR BIN_OP... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | N = int(input())
X = []
Y = []
for i in range(N):
x1, y1, x2, y2 = map(int, input().split())
X.append((x1, x2))
Y.append((y1, y2))
xl, xr = max([x1 for x1, x2 in X]), min([x2 for x1, x2 in X])
yb, yt = max([y1 for y1, y2 in Y]), min([y2 for y1, y2 in Y])
if xl <= xr and yb <= yt:
print("{} {}".format(xl... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | def FindPoints(x1, y1, x2, y2, x3, y3, x4, y4):
x5 = max(x1, x3)
y5 = max(y1, y3)
x6 = min(x2, x4)
y6 = min(y2, y4)
if x5 > x6 or y5 > y6:
return [-1]
else:
return [x5, y5, x6, y6]
n = int(input())
pre = []
l = []
for i in range(n):
l.append(list(map(int, input().split())))... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR RETURN LIST NUMBER RETURN LIST VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL V... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | n = int(input())
rectangles = []
for _ in range(n):
a, s, d, f = map(int, input().split())
rectangles.append((a, s, d, f))
while True:
minx, miny, maxx, maxy = rectangles[0]
for i in range(1, len(rectangles) - 1):
x1, y1, x2, y2 = rectangles[i]
minx = max(x1, minx)
miny = max(y1,... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR WHILE NUMBER ASSIGN VAR VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR ... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | n = int(input())
ox, oy, cx, cy, q = [], [], [], [], []
for i in range(n):
x1, y1, x2, y2 = map(int, input().split())
q.append([x1, y1, x2, y2])
ox.append(x1)
oy.append(y1)
cx.append(x2)
cy.append(y2)
ox, cx, oy, cy = sorted(ox), sorted(cx), sorted(oy), sorted(cy)
e1, e2, e3, e4 = ox[-1], cx[0],... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR LIST LIST LIST LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | n = int(input())
rect = [None] * n
for i in range(n):
rect[i] = list(map(int, input().split()))
x0 = sorted(rect, key=lambda x: x[0])
x1 = sorted(rect, key=lambda x: x[2])
y0 = sorted(rect, key=lambda x: x[1])
y1 = sorted(rect, key=lambda x: x[3])
Xlist = [x0[: n - 1], x1[1:], y0[: n - 1], y1[1:]]
for X in Xlist:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | import sys
class retangle:
def __init__(self, x1, y1, x2, y2):
self.x1 = x1
self.y1 = y1
self.x2 = x2
self.y2 = y2
def __str__(self):
return str([self.x1, self.y1, self.x2, self.y2])
def merge(self, another):
x1 = max(self.x1, another.x1)
y1 = max... | IMPORT CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR LIST VAR VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN FUNC_CALL VAR VAR VAR VAR VAR ASSIG... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | from itertools import combinations
from sys import stdin
def main():
n = int(input())
C = D = 9**10
A = B = -D
P = A, B, C, D
l = [tuple(map(int, s.split())) for s in stdin.read().splitlines()]
ii = {
max(range(n), key=lambda i: l[i][0]),
max(range(n), key=lambda i: l[i][1]),
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER ... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | n = input()
n = int(n)
v = list()
minx, maxx, miny, maxy = [], [], [], []
for i in range(n):
t = input()
t = list(t.split(" "))
for j in range(4):
t[j] = int(t[j])
minx.append(t[0])
miny.append(t[1])
maxx.append(t[2])
maxy.append(t[3])
v.append(t)
minx.sort()
maxx.sort()
miny.sor... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR LIST LIST LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER EXPR ... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | import sys
f = sys.stdin
out = sys.stdout
n = int(f.readline().rstrip("\r\n"))
arr = []
p1, p2, p3, p4 = -float("inf"), -float("inf"), float("inf"), float("inf")
pd1, pd2, pd3, pd4 = -float("inf"), -float("inf"), float("inf"), float("inf")
for i in range(n):
a, b, c, d = map(int, f.readline().rstrip("\r\n").split(... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR VAR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR VAR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRI... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | n = int(input())
x1 = [0] * n
x2 = [0] * n
y1 = [0] * n
y2 = [0] * n
for i in range(n):
x1[i], y1[i], x2[i], y2[i] = [int(j) for j in input().split()]
l = -(10**9) - 7
r = 10**9 + 7
d = -(10**9) - 7
u = 10**9 + 7
cnt = 0
for i in range(n):
if not (x2[i] < l or x1[i] > r or y2[i] < d or y1[i] > u):
cnt +... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NU... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | N = int(input())
rec = []
for i in range(N):
x1, y1, x2, y2 = map(int, input().split())
rec.append((x1, y1, x2, y2))
INF = float("inf")
pref = [(-INF, -INF, INF, INF)]
suf = [(-INF, -INF, INF, INF)]
for j in range(N):
pref.append(
(
max(pref[-1][0], rec[j][0]),
max(pref[-1][1... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST VAR VAR VAR VAR ASSIGN VAR LIST VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VA... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | import sys
input = sys.stdin.readline
def solve():
n = int(input())
x3, y3, x4, y4 = -(10**9) - 5, -(10**9) - 5, 10**9 + 5, 10**9 + 5
a = [None] * n
e = [None] * (2 * n)
E = [None] * (2 * n)
for i in range(n):
x1, y1, x2, y2 = map(int, input().split())
a[i] = x1, y1, x2, y2
... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NONE VAR ASSIGN VAR BIN_OP LIST NONE BIN_OP NUMBER VAR ASSIGN VA... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | n = int(input())
coos = []
pref = []
x1, y1, x2, y2 = map(int, input().split())
coos.append([x1, y1, x2, y2])
pref.append([x1, y1, x2, y2])
def intersect(coo1, coo2):
if not coo1 or not coo2:
return False
x_left = max(coo1[0], coo2[0])
x_right = min(coo1[2], coo2[2])
y_down = max(coo1[1], coo2... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR VAR FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VA... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | class Rectangle:
def __init__(self, leftX, bottomY, rightX, topY):
self.leftX = leftX
self.bottomY = bottomY
self.rightX = rightX
self.topY = topY
def intersection(self, r):
if not r:
return None
if self.leftX > r.rightX or self.rightX < r.leftX:
... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF IF VAR RETURN NONE IF VAR VAR VAR VAR RETURN NONE IF VAR VAR VAR VAR RETURN NONE ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN FUNC_CALL VA... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | import sys
n = int(input())
l, d, r, u = map(int, input().split())
l1 = d1 = r1 = u1 = 0
rects = [(l, d, r, u)]
may = 0, 0
for i in range(n - 1):
a, b, c, e = map(int, input().split())
rects.append((a, b, c, e))
for i in range(n):
a, b, c, e = rects[i]
if a > r:
may = r1, i
break
if... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR LIST VAR VAR VAR VAR ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VA... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | class Rectangle:
def __init__(self, topLeft, bottomRight):
self.topLeft = topLeft
self.bottomRight = bottomRight
def __str__(self):
return f"Rec({self.topLeft}, {self.bottomRight})"
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def __str__(sel... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF RETURN STRING VAR STRING VAR STRING CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF RETURN STRING VAR STRING VAR STRING FUNC_DEF IF VAR NONE RETURN NONE ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | import sys
try:
sys.stdin = open("input.txt", "r")
sys.stdout = open("output.txt", "w")
except:
pass
input = sys.stdin.readline
def intersection(rect1, rect2):
if not rect1 or not rect2:
return ()
bottom = max(rect1[0], rect2[0]), max(rect1[1], rect2[1])
top = min(rect1[2], rect2[2]),... | IMPORT ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR VAR FUNC_DEF IF VAR VAR RETURN ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBE... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | n = int(input())
maxx1 = [-1 * 10000000000.0, -1 * 10000000000.0]
maxxi1 = [[], []]
maxy1 = [-1 * 10000000000.0, -1 * 10000000000.0]
maxyi1 = [[], []]
minx2 = [10000000000.0, 10000000000.0]
minxi2 = [[], []]
miny2 = [10000000000.0, 10000000000.0]
minyi2 = [[], []]
for i in range(n):
x1, y1, x2, y2 = map(int, input(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST BIN_OP NUMBER NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR LIST LIST LIST ASSIGN VAR LIST BIN_OP NUMBER NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR LIST LIST LIST ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR LIST LIST LIST ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR LIST LIST LIST F... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | mod1 = 1000000007
mod2 = -1000000007
n = int(input())
arr1 = []
arr2 = []
for i in range(n):
x1, y1, x2, y2 = map(int, input().split())
arr1.append(((y2 - y1) * (x2 - x1), x1, x2, y1, y2))
arr12 = []
arr12.append((arr1[0][1], arr1[0][2]))
xi = arr1[0][1]
xj = arr1[0][2]
for i in range(1, n):
xi = max(arr1[i... | ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR 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 VAR VAR VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR NUMBER NUMB... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | import sys
input = sys.stdin.readline
def solve():
n = int(input())
x3, y3, x4, y4 = -(10**9) - 5, -(10**9) - 5, 10**9 + 5, 10**9 + 5
p = [None] * (n + 1)
p[0] = x3, y3, x4, y4
a = [None] * n
for i in range(n):
x1, y1, x2, y2 = map(int, input().split())
a[i] = x1, y1, x2, y2
... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NONE BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR VAR VAR VAR ASSIGN ... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | from sys import stdin
def inter(a, b):
x1 = [a[0], a[2]]
y1 = [a[1], a[3]]
x2 = [b[0], b[2]]
y2 = [b[1], b[3]]
if (
x1[0] == None
or x2[0] == None
or max(y2) < min(y1)
or max(y1) < min(y2)
or max(x2) < min(x1)
or max(x1) < min(x2)
):
retu... | FUNC_DEF ASSIGN VAR LIST VAR NUMBER VAR NUMBER ASSIGN VAR LIST VAR NUMBER VAR NUMBER ASSIGN VAR LIST VAR NUMBER VAR NUMBER ASSIGN VAR LIST VAR NUMBER VAR NUMBER IF VAR NUMBER NONE VAR NUMBER NONE FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VA... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | def y(x1, y1, x2, y2, i):
n = len(x1)
if i == 0:
return [
int(max(x1[i + 1 :])),
int(max(y1[i + 1 :])),
int(min(x2[i + 1 :])),
int(min(y2[i + 1 :])),
]
elif i == n - 1:
return [int(max(x1[:i])), int(max(y1[:i])), int(min(x2[:i])), int(m... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN LIST FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER RETURN LIST FUNC_CALL VAR FUNC_... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | import sys
def intersectTwoRectangles(rectangle1, rectangle2):
intersection = [
max(rectangle1[0], rectangle2[0]),
max(rectangle1[1], rectangle2[1]),
min(rectangle1[2], rectangle2[2]),
min(rectangle1[3], rectangle2[3]),
]
if intersection[0] > intersection[2] or intersection... | IMPORT FUNC_DEF ASSIGN VAR LIST FUNC_CALL VAR VAR NUMBER VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER RETURN LIST RETURN VAR FUNC_DEF ASSIGN VAR VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VA... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | def sub(r1, r2):
r = [0] * 4
r[0] = max(r1[0], r2[0])
r[1] = max(r1[1], r2[1])
r[2] = min(r1[2], r2[2])
r[3] = min(r1[3], r2[3])
return r
def ok(r):
if r[0] > r[2] or r[1] > r[3]:
return 0
return 1
a = []
n = int(input())
for i in range(n):
a.append([int(i) for i in input... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF IF VAR NUMBER VAR NUMBER VAR NUMBER VA... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | n = int(input())
a = [0] * n
b = [0] * n
c = [0] * n
d = [0] * n
cn = 0
for i in range(n):
h, g, f, e = map(int, input().split())
a[i] = h
b[i] = g
c[i] = f
d[i] = e
p, q, r, s = -(10**9), -(10**9), 10**9, 10**9
for i in range(n):
if a[i] <= r and b[i] <= s and c[i] >= p and d[i] >= q:
c... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VA... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | def readints():
return list(map(int, input().split(" ")))
n = readints()[0]
def intersection(A, B, C, D):
X_inter_1 = max(A[0], C[0])
X_inter_2 = min(B[0], D[0])
Y_inter_1 = max(A[1], C[1])
Y_inter_2 = min(B[1], D[1])
if X_inter_2 < X_inter_1 or Y_inter_2 < Y_inter_1:
return False
... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER IF VAR VAR V... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | n = int(input())
arr = [list(map(int, input().split())) for i in range(n)]
def find_int(arr):
[x1, y1, x2, y2] = arr[0]
calc = 0
bad = []
for el in arr[1:]:
old = [x1, y1, x2, y2]
x2 = min(x2, el[2])
x1 = max(x1, el[0])
y1 = max(y1, el[1])
y2 = min(y2, el[3])
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN LIST VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR NUMBER ASSIGN VAR LIST VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CAL... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | class Rectangle:
def __init__(self, l, r, t, b):
self.l = l
self.r = r
self.t = t
self.b = b
def error_check(self, other_rectangle):
if self.l > other_rectangle.r:
return False
elif self.r < other_rectangle.l:
return False
elif se... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR RETURN NUMBER IF VAR VAR RETURN NUMBER IF VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | n = int(input())
u = []
for i in range(n):
u.append(list(map(int, input().split())))
l1, l2 = max(u[0][0], u[1][0]), min(u[0][0], u[1][0])
d1, d2 = max(u[0][1], u[1][1]), min(u[0][1], u[1][1])
r1, r2 = min(u[0][2], u[1][2]), max(u[0][2], u[1][2])
u1, u2 = min(u[0][3], u[1][3]), max(u[0][3], u[1][3])
for i in range(... | ASSIGN VAR FUNC_CALL VAR 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 VAR FUNC_CALL VAR VAR NUMBER NUMBER VAR NUMBER NUMBER FUNC_CALL VAR VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER NUMBER VA... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | n = int(input())
ox = []
cx = []
l3 = []
oy = []
cy = []
for i in range(n):
r, s, a, b = list(map(int, input().strip().split()))
l3.append([r, s, a, b])
ox.append(r)
oy.append(s)
cx.append(a)
cy.append(b)
ox.sort()
cx.sort()
oy.sort()
cy.sort()
e1 = ox[-1]
e2 = cx[0]
e3 = oy[-1]
e4 = cy[0]
for i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | r1 = r2 = u1 = u2 = 1 << 30
l1 = l2 = d1 = d2 = -r1
for i in range(int(input())):
l, d, r, u = map(int, input().split())
if l > l1:
il, l1, l2 = i, l, l1
elif l > l2:
l2 = l
if r < r1:
ir, r1, r2 = i, r, r1
elif r < r2:
r2 = r
if d > d1:
idn, d1, d2 = i, d... | ASSIGN VAR VAR VAR VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VA... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | n = int(input())
A = [list(map(int, input().split())) for i in range(n)]
pr = [[A[0][0], A[0][1], A[0][2], A[0][3]] for i in range(n)]
suf = [[A[n - 1][0], A[n - 1][1], A[n - 1][2], A[n - 1][3]] for i in range(n)]
for i in range(1, n):
pr[i][0] = max(pr[i - 1][0], A[i][0])
pr[i][1] = max(pr[i - 1][1], A[i][1])
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR BIN_... |
You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that b... | def main():
n = int(input())
data = []
for i in range(n):
a, b, c, d = list(map(int, input().split()))
data += [(a, b, c, d)]
solve_data(data)
def intersect(tup1, tup2):
a, b, c, d = tup1
x, y, z, w = tup2
return max(a, x), max(b, y), min(c, z), min(d, w)
def solve_data(d... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR LIST VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR RETURN FUNC_CALL VAR VAR VAR FUNC_CALL V... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.