description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
for _ in range(int(input())): n, k = map(int, input().split()) l = list(map(int, input().split())) temp = l[0] prev = temp flag = False for i in range(1, n): temp = max(temp + 1 - k, l[i]) prev = min(prev - 1 + k, l[i] + k - 1) if temp > prev: print("NO") ...
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 VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR VAR ...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
for _ in range(int(input())): n, k = list(map(int, input().split())) h = list(map(int, input().split())) a = [(0) for i in range(n)] poss = True for i in range(1, n - 1): lb = h[i - 1] + a[i - 1] - h[i] - k + 1 ub = h[i - 1] + a[i - 1] - h[i] + k - 1 if ub < 0 or lb >= k: ...
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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BI...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
for _ in range(int(input())): n, k = list(map(int, input().split())) h = list(map(int, input().split())) min1 = h[0] max1 = h[0] + k yes = 0 for i in range(1, n - 1): if h[i] + 2 * k - 1 <= min1 or h[i] >= max1: yes = 1 break else: if h[i] >= m...
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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP BI...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
from sys import stdin t = int(stdin.readline()) def run(): L = [int(x) for x in stdin.readline().split(" ")] n, k = L[0], L[1] A = [int(x) for x in stdin.readline().split(" ")] lo = A[0] hi = A[0] for i in range(1, n): lo = max(lo - (k - 1), A[i]) hi = min(A[i] + (k - 1), hi +...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_O...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
def readLine(): return [int(s) for s in input().split(" ")] def solve(): xd = readLine() n = xd[0] k = xd[1] h = readLine() lo = h[0] + 1 hi = h[0] + 1 c = 0 for cur in h: c = c + 1 if c == 1: continue lo = lo - (k - 1) hi = hi + (k - 1) ...
FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASS...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
def getCases(): cases = [] t = int(input()) for case in range(t): n, k = list(map(int, input().strip().split())) h = list(map(int, input().strip().split())) cases.append([n, k, h]) return cases def check(case): n, k, heights = case _min = heights[0] _max = heights[0...
FUNC_DEF ASSIGN VAR LIST 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR V...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
t = int(input()) for _ in range(t): n, k = list(map(int, input().split())) h = list(map(int, input().split())) minL = h[0] maxL = h[0] done = True for i in range(1, n): minL = max(minL - k + 1, h[i]) maxL = min(maxL + k - 1, h[i] + k - 1) if minL > maxL: done ...
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 VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL V...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
from sys import gettrace, stdin if gettrace(): def inputi(): return input() else: def input(): return next(stdin)[:-1] def inputi(): return stdin.buffer.readline() def solve(): n, k = map(int, input().split()) hh = [int(a) for a in input().split()] mx = hh[0] f...
IF FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR VAR NUMBER IF VAR BIN_OP BIN_OP VAR VAR NUMBER EX...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
t = int(input()) for _ in range(t): n, k = input().split() n, k = int(n), int(k) h = list(map(int, input().split())) poss = True lo = h[0] hi = h[0] for i in range(1, n): lo = lo - k + 1 hi = hi + k - 1 cl = h[i] ch = h[i] + k - 1 if i == n - 1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASS...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
import sys def input(): return sys.stdin.readline().strip() def solve(): for t in range(int(input())): n, k = map(int, input().split()) k -= 1 ii = iter(map(int, input().split())) m = next(ii) M = m bad = False for h in ii: m = max(m - k, h...
IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIG...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
cases = int(input()) ans_list = [] for c in range(cases): n, k = list(map(int, input().split(" "))) heights = list(map(int, input().split(" "))) max_top = heights[0] + k min_top = heights[0] + k ans = "YES" for i in range(1, n - 1): if heights[i] >= max_top or heights[i] + k + k - 1 <= m...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN 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 BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR STRING FOR...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
for t in range(int(input())): n, k = map(int, input().split()) mas = list(map(int, input().split())) mn = mas[0] mx = mas[0] + k - 1 f = True for i in range(1, n): if mx - mn < k - 1: print("No") f = False break if i == n - 1 and mn - k + 1 > m...
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 VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR VAR BIN_OP V...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
def share(l1, u1, l2, u2): if l2 < u1 and l2 >= l1 or u2 > l1 and u2 <= u1: return True return False t = int(input()) for z in range(t): n, k = [int(i) for i in input().split()] h = [int(i) for i in input().split()] u, l = h[0] + k, h[0] c = 0 for i in range(1, n - 1): if s...
FUNC_DEF IF VAR VAR VAR VAR VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR 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 VAR BIN_OP VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
for _ in range(int(input())): n, k = map(int, input().split()) a = list(map(int, input().split())) ma = a[0] mi = a[0] f = True for i in range(1, n): if a[i] > a[i - 1]: if not k - 1 >= abs(ma - a[i]): f = False elif not 2 * (k - 1) >= abs(mi - a[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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMB...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
innum = lambda: int(input()) inmul = lambda: map(int, input().split()) instr = lambda: str(input()) inarr = lambda: list(map(int, input().split())) def solve(): n, k = inmul() a = inarr() ma = a[0] mi = a[0] for i in range(1, n - 1): mi = max(mi - (k - 1), a[i]) ma = min(ma + k - 1...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CA...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
import sys input = sys.stdin.readline ri = lambda: int(input()) rl = lambda: list(map(int, input().split())) rs = lambda: input().rstrip() def solve_case(): n, k = rl() h = rl() lo = hi = 0 ok = True for i, v in enumerate(h): if i == 0: lo, hi = v, v else: ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
for _ in range(int(input())): n, k = map(int, input().split()) a = [*map(int, input().split())] b = [(a[0], a[0])] f = 0 for i in range(1, n): x = max(b[i - 1][0] - (k - 1), a[i]) y = min(b[i - 1][1] + (k - 1), a[i] + (k - 1)) b.append((x, y)) if x > y: f ...
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 LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_O...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
t = int(input()) for i in range(t): n, k = map(int, input().split()) hi = list(map(int, input().split())) minh = hi[0] - k + 1 maxh = hi[0] + k - 1 ans = 1 for i in range(1, n - 1): curminh = hi[i] curmaxh = hi[i] + k - 1 minh = max(curminh, minh) maxh = min(curma...
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 BIN_OP BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL V...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
import sys input = sys.stdin.readline def inInt(): return int(input()) def inStr(): return input().strip("\n") def inIList(): return list(map(int, input().split())) def inSList(): return input().split() def bsearch(nums, target): N = len(nums or []) l = 0 r = N - 1 while l <= ...
IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR LIST ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
from sys import * input = stdin.readline for _ in range(int(input())): n, k = map(int, input().split()) l = list(map(int, input().split())) ini = [0 + l[0], k + l[0]] ans = "YES" for i in range(1, n): pMin = ini[0] + 1 - k pMax = ini[1] - 1 + k if i < n - 1 and pMin - (k - 1...
ASSIGN VAR VAR 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 BIN_OP NUMBER VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
def calc(): [n, k] = list(map(int, input().split(" "))) h = list(map(int, input().split(" "))) l = [0] * n u = [0] * n for i in range(1, n): l[i] = max([h[i - 1] + l[i - 1] - k + 1, h[i]]) - h[i] if l[i] >= k: print("NO") return u[i] = min([h[i - 1] + ...
FUNC_DEF ASSIGN LIST 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 BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR LIST BIN_OP BIN_O...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
for t in range(int(input())): n, k = [int(x) for x in input().split()] h = [int(x) for x in input().split()] flag = True pu = h[0] pd = h[0] for i in range(1, n): if pu + k <= h[i] or pd + 1 - k > k - 1 + h[i]: flag = False break else: pu = min...
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 NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR BI...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) ar = list(map(int, input().split())) curmx, curmn = ar[0], ar[0] for i in range(1, n): if curmx + (k - 1) < ar[i]: print("NO") break if curmn - (k - 1) > ar[i] + (k - 1): print("NO") ...
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 VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR ST...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
n = int(input()) for i in range(n): n, k = map(int, input().split()) nums = list(map(int, input().split())) bot = nums[0] top = nums[0] + k control = "YES" top2 = 0 for j in range(1, n): if j == n - 1: top2 = nums[j] + k else: top2 = nums[j] + 2 * k - ...
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 NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR ...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
import sys input = sys.stdin.readline def solution(): n, k = map(int, input().split()) h = list(map(int, input().split())) if n == 2: if abs(h[0] - h[-1]) >= k: print("NO") return sweep = [] for i in range(1, n - 1): sweep.append((h[i], i)) sweep.sort(r...
IMPORT ASSIGN VAR VAR FUNC_DEF 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 IF VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR ...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
from sys import stdin stdin.readline def mp(): return list(map(int, stdin.readline().strip().split())) def it(): return int(stdin.readline().strip()) def fun(): n, k = mp() l = mp() low, high = l[0], l[0] for i in l[1:]: low, high = max(low - k + 1, i), min(high + k - 1, i + k - 1...
EXPR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER FOR VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBE...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
for testcase in range(int(input())): n, k = map(int, input().split(" ")) a = list(map(int, input().split(" "))) x = [a[0], a[0]] cond = True for i in a[1:-1]: x = [max(i, x[0] - k + 1), min(i + k - 1, x[1] + k - 1)] cond = cond and x[0] <= x[1] if a[-1] + k - 1 < x[0] or x[1] + k...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN 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 LIST VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR NUMBER NUMBER ASSIGN VAR LIST FUNC_CALL VAR VAR BIN_OP BIN_OP VA...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
for _ in " " * int(input()): n, k = map(int, input().split()) a = list(map(int, input().split())) p, x, f = a[0], a[0], 0 for i in range(1, n): l, g = max(a[i], p - k + 1), min(a[i] + k - 1, x + k - 1) p, x = l, g if l > g: f = 1 break print("YNEOS"[f ...
FOR VAR BIN_OP STRING 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 VAR VAR VAR NUMBER VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
for _ in range(int(input())): n, k = map(int, input().split()) H = [int(h) for h in input().split()] a, b = H[0], H[0] + k ans = "YES" for h in H[1:-1]: x, y = h, h + 2 * k - 1 a = max(x, a - k + 1) b = min(y, b + k - 1) if b - a < k: ans = "NO" if H[-...
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 VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR STRING FOR VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER AS...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
t = int(input()) for testcases in range(t): n, k = list(map(int, input().split())) a = [int(x) for x in input().split()] s = -1 r = -1 ok = 1 for x in a: if s == -1: s = x r = x else: s = max(s - k + 1, x) r = min(r + k - 1, x + k -...
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 VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_C...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
def fence(): n, k = map(int, input().split()) H = list(map(int, input().split())) l, r = 0, 0 for i in range(len(H)): if i == 0: l = r = H[0] else: l = max(l - k + 1, H[i]) r = min(r + k - 1, H[i] + k - 1) if l > r or i == n - 1 and l != H[i]: ...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
import sys def get_ints(): return map(int, sys.stdin.readline().strip().split()) def get_int(): return list(map(int, sys.stdin.readline().strip().split()))[0] def get_list(): return list(map(int, sys.stdin.readline().strip().split())) def get_string(): return sys.stdin.readline().strip() N = 0...
IMPORT FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
for _ in range(int(input())): n, k = map(int, input().split()) h = list(map(int, input().split())) end = False cur = h[0] for i in range(n): if cur < h[i]: end = True break if i != n - 1: cur = min(cur + k - 1, h[i + 1] + k - 1) cur = h[-1] ...
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 NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL V...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
def get_overlap(A, B): p, q = A r, s = B haha = [r - K + 1, s - 1] nxt_a = max(p, haha[0]) nxt_b = min(q, haha[1]) if nxt_b >= nxt_a: return [nxt_a, nxt_b] else: return False for _ in range(int(input())): N, K = map(int, input().split()) heights = list(map(int, inpu...
FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR LIST BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR RETURN LIST VAR VAR RETURN NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FU...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
T = int(input()) ans = [] for t in range(T): flag = True n, k = map(int, input().split()) h = list(map(int, input().split())) tmp = [0] * n tmp[0] = h[0] for i in range(1, n - 1): ma = min(tmp[i - 1] + k - 1, h[i] + k - 1) mi = max(tmp[i - 1] - k + 1, h[i]) if mi > ma: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN 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 BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_O...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
def check(n, k, h): a = [h[0]] b = [h[0]] for i in range(1, n - 1): if h[i] >= b[i - 1] + k or h[i] + k <= a[i - 1] + 1 - k: return "NO" else: a.append(max(a[i - 1] + 1 - k, h[i])) b.append(min(b[i - 1] - 1 + k, h[i] + k - 1)) if b[n - 2] + k <= h[n - ...
FUNC_DEF ASSIGN VAR LIST VAR NUMBER ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR RETURN STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR VAR VA...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) arr = [int(j) for j in input().split()] current_range = [arr[0] + k, arr[0] + k] flag = 0 for i in range(1, n - 1): if arr[i] >= current_range[1] or arr[i] + k - 1 + k <= current_range[0] - k: flag = 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 ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR N...
You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side. Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section ...
t = int(input()) for i in range(t): m = 0 str = input() _, k = [int(item) for item in str.split(" ")] str = input() ground = [int(item) for item in str.split(" ")] _min, _max = ground[0], ground[0] for i in range(1, len(ground)): _min -= k - 1 _max += k - 1 if _min < ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL...
Return the largest possible kΒ such that there existsΒ a_1, a_2, ..., a_kΒ such that: Each a_i is a non-empty string; Their concatenation a_1 + a_2 + ... + a_k is equal to text; For all 1 <= i <= k,Β Β a_i = a_{k+1 - i}. Β  Example 1: Input: text = "ghiabcdefhelloadamhelloabcdefghi" Output: 7 Explanation: We can split the ...
class Solution: def longestDecomposition(self, text: str) -> int: n = len(text) @lru_cache(None) def dfs(i, j): if i > j: return 0 if i == j: return 1 res = 1 k = 1 while i + k <= j - k + 1: ...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP NUMBER FUN...
Return the largest possible kΒ such that there existsΒ a_1, a_2, ..., a_kΒ such that: Each a_i is a non-empty string; Their concatenation a_1 + a_2 + ... + a_k is equal to text; For all 1 <= i <= k,Β Β a_i = a_{k+1 - i}. Β  Example 1: Input: text = "ghiabcdefhelloadamhelloabcdefghi" Output: 7 Explanation: We can split the ...
class Solution: def longestDecomposition(self, text: str) -> int: @lru_cache(None) def helper(i, j): if i > j: return 0 if i == j: return 1 ans = 1 tmp = 0 l = j - i + 1 for k in range(1, l // 2...
CLASS_DEF FUNC_DEF VAR FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR...
Return the largest possible kΒ such that there existsΒ a_1, a_2, ..., a_kΒ such that: Each a_i is a non-empty string; Their concatenation a_1 + a_2 + ... + a_k is equal to text; For all 1 <= i <= k,Β Β a_i = a_{k+1 - i}. Β  Example 1: Input: text = "ghiabcdefhelloadamhelloabcdefghi" Output: 7 Explanation: We can split the ...
class Solution: def longestDecomposition(self, text: str) -> int: found = {} def search(start, end): if start > end: return 0 if (start, end) in found: return found[start, end] m = 1 for i in range(1, (end - start + 1)...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR DICT FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR VAR RETURN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER NUMBER IF VAR VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN...
Return the largest possible kΒ such that there existsΒ a_1, a_2, ..., a_kΒ such that: Each a_i is a non-empty string; Their concatenation a_1 + a_2 + ... + a_k is equal to text; For all 1 <= i <= k,Β Β a_i = a_{k+1 - i}. Β  Example 1: Input: text = "ghiabcdefhelloadamhelloabcdefghi" Output: 7 Explanation: We can split the ...
class Solution: def longestDecomposition(self, text: str) -> int: idxMap = defaultdict(list) for i, ch in enumerate(text): idxMap[ch].append(i) memo = {} def recurse(i, j): if i == j: return 1 if i > j: return 0 ...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR DICT FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR RETURN NUMBER IF VAR VAR VAR RETURN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR IF VAR VAR VAR VAR IF VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR N...
Return the largest possible kΒ such that there existsΒ a_1, a_2, ..., a_kΒ such that: Each a_i is a non-empty string; Their concatenation a_1 + a_2 + ... + a_k is equal to text; For all 1 <= i <= k,Β Β a_i = a_{k+1 - i}. Β  Example 1: Input: text = "ghiabcdefhelloadamhelloabcdefghi" Output: 7 Explanation: We can split the ...
class Solution: def longestDecomposition(self, text: str) -> int: count = 0 i = 0 while text: if text[: i + 1] == text[-(i + 1) :]: count += 1 if i + 1 < len(text): count += 1 text = text[i + 1 : -(i + 1)] ...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER RETURN VAR VAR
Return the largest possible kΒ such that there existsΒ a_1, a_2, ..., a_kΒ such that: Each a_i is a non-empty string; Their concatenation a_1 + a_2 + ... + a_k is equal to text; For all 1 <= i <= k,Β Β a_i = a_{k+1 - i}. Β  Example 1: Input: text = "ghiabcdefhelloadamhelloabcdefghi" Output: 7 Explanation: We can split the ...
class Solution: def longestDecomposition(self, text: str) -> int: l, r, lh, rh, curr_len, modulo, base, res = ( 0, len(text) - 1, 0, 0, 0, 32416189573, 26, 0, ) nums = [(ord(c) - ord("a")) for c ...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP...
Return the largest possible kΒ such that there existsΒ a_1, a_2, ..., a_kΒ such that: Each a_i is a non-empty string; Their concatenation a_1 + a_2 + ... + a_k is equal to text; For all 1 <= i <= k,Β Β a_i = a_{k+1 - i}. Β  Example 1: Input: text = "ghiabcdefhelloadamhelloabcdefghi" Output: 7 Explanation: We can split the ...
class Solution: def longestDecomposition(self, text: str) -> int: n = len(text) splits = 0 leftstart, leftend = 0, 0 rightstart, rightend = n - 1, n - 1 while leftend < rightstart: if text[leftstart : leftend + 1] == text[rightstart : rightend + 1]: ...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER WHILE VAR VAR IF VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR NUMBER VA...
Return the largest possible kΒ such that there existsΒ a_1, a_2, ..., a_kΒ such that: Each a_i is a non-empty string; Their concatenation a_1 + a_2 + ... + a_k is equal to text; For all 1 <= i <= k,Β Β a_i = a_{k+1 - i}. Β  Example 1: Input: text = "ghiabcdefhelloadamhelloabcdefghi" Output: 7 Explanation: We can split the ...
class Solution: def longestDecomposition(self, text: str) -> int: if not text: return 0 i, j, result = 0, len(text) - 1, 0 while i < j: if text[: i + 1] == text[j:]: return self.longestDecomposition(text[i + 1 : j]) + 2 else: ...
CLASS_DEF FUNC_DEF VAR IF VAR RETURN NUMBER ASSIGN VAR VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER WHILE VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR RETURN BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER RETURN NUMBER VAR
You are given a sequence a_1, a_2, ..., a_n, consisting of integers. You can apply the following operation to this sequence: choose some integer x and move all elements equal to x either to the beginning, or to the end of a. Note that you have to move all these elements in one direction in one operation. For example,...
import sys input = sys.stdin.buffer.readline for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) stored = [(-1) for i in range(n + 2)] counted = [[0, 0] for i in range(n + 2)] count = 0 for i in range(n): stored[a[i]] = a[i] if counted[a[i]][0] == ...
IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR ...
You are given a sequence a_1, a_2, ..., a_n, consisting of integers. You can apply the following operation to this sequence: choose some integer x and move all elements equal to x either to the beginning, or to the end of a. Note that you have to move all these elements in one direction in one operation. For example,...
import sys as _sys def main(): q = int(input()) for i_q in range(q): (n,) = _read_ints() a = tuple(_read_ints()) result = find_min_sorting_cost(sequence=a) print(result) def _read_line(): result = _sys.stdin.readline() assert result[-1] == "\n" return result[:-1] ...
IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER STRING RETURN VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL...
You are given a sequence a_1, a_2, ..., a_n, consisting of integers. You can apply the following operation to this sequence: choose some integer x and move all elements equal to x either to the beginning, or to the end of a. Note that you have to move all these elements in one direction in one operation. For example,...
from sys import stdin input = stdin.readline def main(): anses = [] for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) f = [0] * (n + 1) d = sorted(list(set(a))) for q in range(1, len(d) + 1): f[d[q - 1]] = q for q in...
ASSIGN VAR VAR FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL V...
You are given a sequence a_1, a_2, ..., a_n, consisting of integers. You can apply the following operation to this sequence: choose some integer x and move all elements equal to x either to the beginning, or to the end of a. Note that you have to move all these elements in one direction in one operation. For example,...
from sys import stdin, stdout def main(): from sys import stdin, stdout for _ in range(int(stdin.readline())): n = int(stdin.readline()) inp1 = [-1] * (n + 1) inp2 = [-1] * (n + 1) for i, ai in enumerate(map(int, stdin.readline().split())): if inp1[ai] < 0: ...
FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR AS...
You are given a sequence a_1, a_2, ..., a_n, consisting of integers. You can apply the following operation to this sequence: choose some integer x and move all elements equal to x either to the beginning, or to the end of a. Note that you have to move all these elements in one direction in one operation. For example,...
import sys input = sys.stdin.readline for _ in range(int(input())): n = int(input()) A = list(map(int, input().split())) compression_dict = {a: id for id, a in enumerate(sorted(set(A)))} A = [compression_dict[a] for a in A] lenth = len(A) l = [-1] * lenth r = [-1] * lenth tot = 0 fo...
IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BI...
You are given a sequence a_1, a_2, ..., a_n, consisting of integers. You can apply the following operation to this sequence: choose some integer x and move all elements equal to x either to the beginning, or to the end of a. Note that you have to move all these elements in one direction in one operation. For example,...
from sys import stdin input = stdin.readline def Input(): global A, n, D, F n = int(input()) A = list(map(int, input().split())) D = sorted(list(set(A))) F = [0] * (n + 1) def Ans(): for i in range(1, len(D) + 1): F[D[i - 1]] = i for i in range(n): A[i] = F[A[i]] m =...
ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR 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 FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ...
You are given a sequence a_1, a_2, ..., a_n, consisting of integers. You can apply the following operation to this sequence: choose some integer x and move all elements equal to x either to the beginning, or to the end of a. Note that you have to move all these elements in one direction in one operation. For example,...
import sys input = sys.stdin.readline q = int(input()) for testcases in range(q): n = int(input()) A = list(map(int, input().split())) compression_dict = {a: ind for ind, a in enumerate(sorted(set(A)))} A = [compression_dict[a] for a in A] MAX = max(A) miind = [10**6] * (MAX + 1) maind = [0...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VA...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
t = int(input()) for _ in range(t): s = input() t = input() n = len(s) m = len(t) flag = 0 if m > n: print("NO") continue pointer = (n - m) % 2 curr = 0 while curr < m and pointer < n: if s[pointer] == t[curr]: curr += 1 pointer += 1 ...
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 ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR IF VAR VAR V...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
T = int(input()) for ia in range(T): s = input() t = input() n = len(s) - 1 n1 = len(t) - 1 while n > -1 and n1 > -1: if s[n] == t[n1]: n -= 1 n1 -= 1 else: n -= 2 if n1 == -1: print("YES") else: print("NO")
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 BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
for _ in range(int(input())): st = input() rt = input() pt1 = 0 pt2 = 0 n = len(st) m = len(rt) stack = [-1] queue = [-2] flag = 0 for i in range(n): if pt1 < m and st[i] == rt[pt1] and (stack[-1] + i) % 2 == 1: stack.append(i) pt1 += 1 if ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR BIN_OP BI...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
def solve() -> bool: string = input() target = input() string_len = len(string) target_len = len(target) if string_len < target_len: return False q = k = 0 for i in range((string_len - target_len) % 2, string_len): if k == 1: k = 0 continue if ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR RETURN NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR IF VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER RETURN VAR VAR VAR F...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
T = int(input()) for t in range(T): s = input() t = input() ss = s[::-1] tt = t[::-1] j = 0 for i in range(len(tt)): while j < len(ss) and ss[j] != tt[i]: j += 2 j += 1 if j > len(ss): print("NO") else: print("YES")
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 VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR WHILE VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR FUNC_CALL VAR VAR EXPR FUNC_CA...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
from sys import stdin input = stdin.readline def answer(): j = 0 for i in range(m): flag = False while j < n: if t[i] == s[j] and i % 2 == j % 2: j += 1 flag = True break j += 1 if flag == False: break...
ASSIGN VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER IF VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER RETURN STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP ...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
from sys import stdin, stdout input = stdin.readline mp = lambda: map(int, input().split()) it = lambda: int(input()) ls = lambda: list(input().strip()) mt = lambda r: [ls() for _ in range(r)] lcm = lambda a, b: a * b // gcd(a, b) def fibo_n(n): return ((1 + sqrt(5)) / 2) ** n / sqrt(5) for _ in range(it()): ...
ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP BIN_OP NUMBER FUNC_CALL V...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
q = int(input()) def solve(): s = input() t = input() n = len(s) m = len(t) i = n - 1 j = m - 1 delete = 0 while i >= 0 and j >= 0: if s[i] == t[j] and not delete: j -= 1 else: delete ^= 1 i -= 1 if j < 0: print("YES") els...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF V...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
def solve(s, t): dels = len(s) - len(t) si = 0 ti = 0 while si < len(s) and ti < len(t): if t[ti] == s[si]: ti += 1 si += 1 else: si += 2 if ti == len(t): return True return False for _ in range(int(input())): s = input() s = ...
FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
def solve(s, t): n = len(s) m = len(t) if n < m: return False p = n - m & 1 q = 0 k = 0 for i in range(p, n): if k == 1: k = 0 continue if q < m and s[i] == t[q]: q += 1 else: k += 1 return q == m n = int(i...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR F...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
import sys number_tests = input("") lines = [] for line in sys.stdin: lines.append(line) slist = [] tlist = [] for i in range(len(lines)): if i % 2 == 0: slist.append(lines[i]) else: tlist.append(lines[i]) for s, t in zip(slist, tlist): j = len(t) - 1 i = len(s) - 1 while j >= 0...
IMPORT ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
n = int(input()) for i in range(n): s, t = input()[::-1], input()[::-1] i = j = 0 while i < len(s) and j < len(t): if s[i] == t[j]: i += 1 j += 1 else: i += 2 print("YES" if j == len(t) else "NO")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_CALL VAR VAR STRING STRING
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
tx = int(input()) for _ in range(tx): s = input() t = input() if len(s) < len(t): print("NO") continue f = 1 i = len(s) - 1 for j in range(len(t) - 1, -1, -1): while i >= 0 and s[i] != t[j]: i -= 2 if i < 0: f = 0 break ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER WHILE VAR N...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
for _ in range(int(input())): s = input() t = input() s = s[::-1] t = t[::-1] k = 0 last = -1 ans = False for i in range(len(s)): if s[i] == t[k] and (i - last + 1) % 2 == 0: k += 1 last = i if k == len(t): ans = True break ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER NUMBER VAR NUMBER AS...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
def isPossible(s, t): i, j = len(s) - 1, len(t) - 1 f = 0 while j >= 0: while i >= 0 and s[i] != t[j]: i -= 2 if i < 0: break else: i -= 1 j -= 1 if j >= 0: return False return True def checkPossible(): t1 = int(input(...
FUNC_DEF ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER WHILE VAR NUMBER VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR A...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
import sys input = sys.stdin.readline def solve(): s = input().strip() t = input().strip() i = len(t) - 1 j = len(s) - 1 while i >= 0: while j >= 0 and s[j] != t[i]: j -= 2 if j < 0: print("NO") return j -= 1 i -= 1 print("YE...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER WHILE VAR NUMBER VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN VAR NUMBER VAR NUMBER EXP...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
import sys def read(): line = sys.stdin.readline().rstrip() if " " in line: return line.split() return line.strip() def solver(): for i, j in enumerate(A): charIndxs[ord(j) - 97].append(i) for i in charIndxs[ord(B[0]) - 97]: if i & 1: if oddPos[0] == None: ...
IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF STRING VAR RETURN FUNC_CALL VAR RETURN FUNC_CALL VAR FUNC_DEF FOR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FOR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER IF BIN_OP VAR NUMBER IF VAR NUMBER NONE ASSIGN VAR NUMBER VAR IF VAR...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
t = int(input()) for i in range(t): s = input() t = input() def solve(s, t): ind = 0 for ch in t: while ind < len(s) and s[ind] != ch: ind += 2 if ind >= len(s): return "NO" ind += 1 return "YES" print(solve(s[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR WHILE VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN STRING VAR NUMBER RETURN STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR NUM...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
def solve(s, t): i, j = len(s) - 1, len(t) - 1 while j >= 0 and i >= 0: if s[i] == t[j]: i -= 1 j -= 1 else: i -= 2 if j < 0: print("YES") else: print("NO") for _ in range(int(input())): s, t = input(), input() solve(s, t)
FUNC_DEF ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CA...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
N = int(input()) for _ in range(N): s, t = list(input()), list(input()) while s and t: if s[-1] == t[-1]: s.pop() t.pop() else: s.pop() if s: s.pop() print("NO" if t else "YES")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR STRING STRING
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
def solve(s, t): m = len(s) n = len(t) if m < n: return "NO" if m == n: if s == t: return "YES" else: return "NO" cnt = 0 rgt = n - 1 for i in range(m - 1, -1, -1): if rgt < 0: return "YES" if s[i] == t[rgt]: ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR RETURN STRING IF VAR VAR IF VAR VAR RETURN STRING RETURN STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR NUMBER RETURN STRING IF VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER VA...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
for _ in range(int(input())): s = input() t = input() n = len(s) m = len(t) if n < m: print("NO") else: x = m - 1 prev = 0 f = 0 i = n - 1 while i >= 0: if x == -1: f = 1 break if s[i] == t[x]...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF VAR NUMBER ...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
for _ in range(int(input())): s, t = input(), input() a, b, paritat = len(s) - 1, len(t) - 1, 0 while a >= 0 and b >= 0: if paritat == 0 and s[a] == t[b]: b -= 1 else: paritat = (paritat + 1) % 2 a -= 1 print("YES" if b < 0 else "NO")
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER WHILE VAR NUMBER VAR NUMBER IF VAR NUMBER VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
t = int(input()) results = [] for i in range(t): text = input()[::-1] word = input()[::-1] i_text = 0 i_word = 0 while i_text < len(text) and i_word < len(word): if word[i_word] == text[i_text]: i_text += 1 i_word += 1 else: i_text += 2 results...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_CALL VAR ...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
from sys import stdin input = stdin.readline q = int(input()) for _ in range(q): s = input().rstrip() t = input().rstrip() even = -1 odd = -1 for i in range(len(s)): if s[i] == t[0]: if i % 2 == 0 and even == -1: even = i elif i % 2 > 0 and odd == -1:...
ASSIGN VAR VAR 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 FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR VAR IF BIN_OP VAR NUMB...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
t = int(input()) for _ in range(t): s = str(input()) t = str(input()) lt = len(t) ls = len(s) if lt > ls or ls + 1 == lt: print("No") continue j = len(t) - 1 i = len(s) - 1 while i >= 0 and j >= 0: if s[i] == t[j]: i -= 1 j -= 1 els...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
import sys input = sys.stdin.readline for _ in range(int(input())): s = input()[:-1] t = input()[:-1] n = len(s) m = len(t) p = n - 1 q = m - 1 while p >= 0: if q == -1: break if s[p] != t[q]: p -= 2 else: q -= 1 p -= 1...
IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER VAR NUM...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
for i in range(int(input())): s = input() t = input() n, m = len(s), len(t) if m > n: print("NO") else: if (n + m) % 2 == 1: s = s[1:] n = n - 1 i = 0 f = 0 for ch in t: while i < n and s[i] != ch: i += 2 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VA...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
from sys import stdout out = lambda x, end="\n": stdout.write(str(x) + end) ip = [*open(0)] for i in range(0, 2 * int(ip[0]), 2): s, t = ip[i + 1][:-1], ip[i + 2][:-1] if t == s: out("YES") elif len(t) >= len(s): out("NO") else: i = len(s) - 1 j = len(t) - 1 whil...
ASSIGN VAR STRING FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR FUNC_CALL VAR VA...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
for _ in range(int(input())): s, t = input(), input() ps, pt = len(s) - 1, len(t) - 1 ans = "" while ps >= 0 and len(ans) != len(t): if s[ps] == t[pt]: ans += t[pt] ps -= 1 pt -= 1 else: ps -= 2 if len(ans) == len(t): print("YES...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING WHILE VAR NUMBER FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF FUNC_CALL ...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
for _ in range(int(input())): s = input() t = input() i = len(s) - 1 j = len(t) - 1 while i >= 0 and j >= 0: if s[i] == t[j]: i -= 1 j -= 1 else: i -= 2 print("YES") if j == -1 else print("NO") num_inp = lambda: int(input()) arr_inp = lambda: l...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR VAR NUMBER FUNC_CALL VAR STRING FUNC_CALL VAR STR...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
def check(s, t): i = len(s) - 1 j = len(t) - 1 if i < j: return "NO" while i >= 0 and j >= 0: if s[i] == t[j]: i -= 1 j -= 1 else: i -= 2 if j == -1: return "YES" return "NO" test_cases = int(input()) array = [] while ...
FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR RETURN STRING WHILE VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER RETURN STRING RETURN STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST WHILE VAR NUMBER ASSIGN...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
cant_tests = int(input()) s = [] t = [] for i in range(cant_tests): s.append(input()) t.append(input()) for j in range(cant_tests): str = s[j] t1 = [0, -1] t2 = [0, -2] for i in range(len(str)): if t[j][t1[0]] == str[i] and i % 2 != t1[1] % 2: t1[0] += 1 t1[1] = i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR V...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
def solve(s, t): n1 = len(s) n2 = len(t) if n1 < n2: return "NO" s.reverse() t.reverse() j = 0 k = 0 diff = 0 while k < n1 and j < n2: if s[k] == t[j] and diff % 2 == 0: j += 1 diff = 0 else: diff += 1 k += 1 if ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR RETURN STRING EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR IF VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR RETURN S...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
n = int(input()) for _ in range(n): s = input() t = input() i = len(s) - 1 fail = False for c in t[::-1]: while i >= 0 and c != s[i]: i -= 2 if i < 0 or i == 0 and s[0] != c: fail = True break i -= 1 print("NO" if fail else "YES")
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 BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR NUMBER WHILE VAR NUMBER VAR VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER EXPR FUNC_CALL V...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
t = int(input()) for _ in range(t): a = list(input()) b = list(input()) ind = dict() n = len(a) for i in range(len(a)): if a[i] not in ind: ind[a[i]] = [i] else: ind[a[i]].append(i) j = 0 last = 0 done = 0 for i in range(len(b)): cau = ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR LIST VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VA...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
a = int(input()) for i in range(0, a): A = input() B = input() p = False L1 = len(A) L2 = len(B) i = L1 - 1 j = L2 - 1 T = 0 while i >= 0 and j >= 0: if A[i] == B[j]: i = i - 1 j = j - 1 p = True T = T + 1 else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
import sys input = lambda: sys.stdin.readline() int_arr = lambda: list(map(int, input().split())) str_arr = lambda: list(map(str, input().split())) get_str = lambda: map(str, input().split()) get_int = lambda: map(int, input().split()) get_flo = lambda: map(float, input().split()) mod = 1000000007 def solve(s, t): ...
IMPORT ASSIGN VAR 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 FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
t = int(input()) for _ in range(t): s = input()[::-1] t = input()[::-1] if len(t) > len(s): print("no") continue fin = "" z = 0 for x in t: for y in range(z, len(s), 2): ch = s[y] if ch == x: z = y + 1 fin += ch ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR VAR FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR IF VAR V...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
for k in range(int(input())): x = input() y = input() i = len(x) - 1 j = len(y) - 1 while i >= 0 and j >= 0: if x[i] == y[j]: i -= 1 j -= 1 else: i -= 2 print(["NO", "YES"][j == -1])
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR LIST STRING STRING VAR NUMBER
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
def solve(s, t): ns, nt = len(s), len(t) latest = ns for i in range(nt - 1, -1, -1): c = t[i] z = latest - 1 found = False while z >= 0: if s[z] == c: found = True latest = z break z -= 2 if not f...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIG...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
import sys input = sys.stdin.readline t = int(input()) for _ in range(t): s = input()[:-1] t = input()[:-1] if len(s) % 2 != len(t) % 2: s = s[1:] idx = 0 i = 0 while i < len(s): if idx < len(t) and s[i] == t[idx]: i += 1 idx += 1 else: ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
import sys def main(): num_tests = int(sys.stdin.readline()) for _ in range(num_tests): s = sys.stdin.readline() t = sys.stdin.readline() print("YES" if is_possible(s, t) else "NO") def is_possible(s: str, t: str) -> bool: if solve(s, t, 1): return True return solve(s...
IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR STRING STRING FUNC_DEF VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER RETURN NUMBER RETURN FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_DEF VAR VAR VAR ASSIGN VAR...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
import sys def checkBack(s, t): ptr1 = 1 ptr2 = 1 if len(t) > len(s): return False while ptr2 <= len(t) and ptr1 <= len(s): if s[-ptr1] == t[-ptr2]: ptr1, ptr2 = ptr1 + 1, ptr2 + 1 continue elif ptr1 == len(s): return False elif ptr1 ...
IMPORT FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASS...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
for testis in range(int(input())): s = input() t = input() n, m = len(s), len(t) if m > n: print("NO") else: p, q = n - 1, m - 1 while q >= 0: if s[p] == t[q]: p -= 1 q -= 1 else: p -= 2 if p ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER WHILE VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBE...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
import sys input = lambda: sys.stdin.readline().rstrip("\r\n") for _ in range(int(input())): s = input() t = input() n, m = len(s), len(t) i, j = 0, 0 prev = -1 n -= 1 m -= 1 while i < n and j < m: if s[i] == t[j]: if prev == -1: prev = i ...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR NUMBER VAR NUMBER WHILE VAR VAR VAR VAR IF VAR VAR VAR VAR IF VAR NUM...
You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one. When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the l...
for _ in range(int(input())): s = input() t = input() j = len(t) - 1 i = len(s) - 1 c = 0 while i >= 0 and j >= 0: if c % 2 == 0 and s[i] == t[j]: i -= 1 j -= 1 c = 0 continue i -= 1 c += 1 if j < 0: print("YES")...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR ...