description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
You're given a tree with $n$ vertices.
Your task is to determine the maximum possible number of edges that can be removed in such a way that all the remaining connected components will have even size.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$) denoting the size of the tree.
The ne... | n = int(input())
d = {i: [] for i in range(1, n + 1)}
for i in range(n - 1):
a, b = map(int, input().split())
d[a].append(b)
d[b].append(a)
if n & 1:
print(-1)
else:
val = [(1) for i in range(n + 1)]
par = [(-1) for i in range(n + 1)]
par[1] = 1
stack = [1]
while stack:
u = s... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR LIST VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VA... |
You're given a tree with $n$ vertices.
Your task is to determine the maximum possible number of edges that can be removed in such a way that all the remaining connected components will have even size.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$) denoting the size of the tree.
The ne... | import sys
Ri = lambda: [int(x) for x in sys.stdin.readline().split()]
ri = lambda: sys.stdin.readline().strip()
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [([c] * b) for i in range(a)]
def list3d(a, b, c, d):
return [[([d] * c) for j in range(b)] for i in range(a)]
... | IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUN... |
You're given a tree with $n$ vertices.
Your task is to determine the maximum possible number of edges that can be removed in such a way that all the remaining connected components will have even size.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$) denoting the size of the tree.
The ne... | n = int(input())
if n % 2 == 1:
print(-1)
exit()
adj = [[] for _ in range(n + 1)]
for _ in range(n - 1):
u, v = map(int, input().split())
adj[u].append(v)
adj[v].append(u)
cnt = [1] * (n + 1)
prt = [-1] * (n + 1)
prt[1] = 1
stk = [1]
while stk:
u = stk[-1]
k = False
for v in adj[u]:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIG... |
You're given a tree with $n$ vertices.
Your task is to determine the maximum possible number of edges that can be removed in such a way that all the remaining connected components will have even size.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$) denoting the size of the tree.
The ne... | from sys import stdin
inp = stdin.readline
n, ans = int(inp()), 0
if n & 1:
print(-1)
return
g = {i: [set(), 0] for i in range(1, n + 1)}
visited = [0] * (n + 1)
for _ in range(n - 1):
a, b = map(int, inp().split())
g[a][0].add(b)
g[b][0].add(a)
visited = [0, 1] + [0] * (n - 1)
q = [1]
p = [0] * (n... | ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR VAR LIST FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR ... |
You're given a tree with $n$ vertices.
Your task is to determine the maximum possible number of edges that can be removed in such a way that all the remaining connected components will have even size.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$) denoting the size of the tree.
The ne... | def dfs(g, s):
visited = set([s])
stack = [s]
res = 0
while len(stack) > 0:
s = stack.pop()
cnt = 0
cnt += 1
visited.add(s)
for v in g[s]:
if v not in visited:
cnt += 1
stack.append(v)
if cnt % 2 == 0:
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR LIST VAR ASSIGN VAR LIST VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER RETURN BIN_OP VAR NUMBER FUNC_D... |
You're given a tree with $n$ vertices.
Your task is to determine the maximum possible number of edges that can be removed in such a way that all the remaining connected components will have even size.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$) denoting the size of the tree.
The ne... | def dfs_new(adj, n):
stack = [(1, 0)]
sol = [None for i in range(n + 1)]
while not len(stack) == 0:
i, parent = stack[-1]
flag = True
for item in adj[i]:
if item == parent:
continue
if sol[item] == None:
stack.append((item, i))
... | FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR NONE VAR FUNC_CALL VAR BIN_OP VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR IF VAR VAR IF VAR VAR NONE EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR IF VAR ... |
You're given a tree with $n$ vertices.
Your task is to determine the maximum possible number of edges that can be removed in such a way that all the remaining connected components will have even size.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$) denoting the size of the tree.
The ne... | n = int(input())
if n % 2 != 0:
print(-1)
return
links = [[1, set()] for i in range(1, n + 1)]
W = 0
L = 1
i = 0
while i < n - 1:
i += 1
[a, b] = [int(x) for x in input().split()]
links[a - 1][L].add(b - 1)
links[b - 1][L].add(a - 1)
count = sear = cur = 0
while sear < n:
li = cur
l = li... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR LIST NUMBER FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN LIST VAR VAR FUNC_CALL VAR VAR VAR FUNC_... |
You're given a tree with $n$ vertices.
Your task is to determine the maximum possible number of edges that can be removed in such a way that all the remaining connected components will have even size.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$) denoting the size of the tree.
The ne... | n = int(input())
if n % 2 == 1:
print(-1)
else:
edges = [[] for i in range(n)]
for i in range(n - 1):
[a, b] = [int(j) for j in input().split()]
edges[a - 1].append(b - 1)
edges[b - 1].append(a - 1)
dfs_stack = [0]
comp_size = [(1) for i in range(n)]
visited = [(-1) for i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN LIST VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VA... |
You're given a tree with $n$ vertices.
Your task is to determine the maximum possible number of edges that can be removed in such a way that all the remaining connected components will have even size.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$) denoting the size of the tree.
The ne... | def dfs(node):
par[1] = 1
stack = [1]
ans = 0
while stack:
k = stack[-1]
f = 0
for i in g[k]:
if par[i] == -1:
par[i] = k
stack.append(i)
f = 1
if f == 0:
k = stack.pop()
subtree[par[k]] +... | FUNC_DEF ASSIGN VAR NUMBER NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR FOR VAR VAR NUMBER IF BIN_OP VAR NUMBER NU... |
You're given a tree with $n$ vertices.
Your task is to determine the maximum possible number of edges that can be removed in such a way that all the remaining connected components will have even size.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$) denoting the size of the tree.
The ne... | n = int(input())
if n % 2 == 1:
print(-1)
exit(0)
graph = {}
for i in range(n - 1):
v, u = map(int, input().strip().split())
v -= 1
u -= 1
if v in graph:
graph[v].append(u)
else:
graph[v] = [u]
if u in graph:
graph[u].append(v)
else:
graph[u] = [v]
cou... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR LIS... |
You're given a tree with $n$ vertices.
Your task is to determine the maximum possible number of edges that can be removed in such a way that all the remaining connected components will have even size.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$) denoting the size of the tree.
The ne... | from sys import exit
def main():
n = int(input())
g = [[] for i in range(n + 5)]
vh = [[] for i in range(n + 5)]
size = [(1) for i in range(n + 5)]
par = [i for i in range(n + 5)]
if n % 2 == 1:
print(-1)
exit()
for i in range(n - 1):
u, v = map(int, input().split()... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC... |
You're given a tree with $n$ vertices.
Your task is to determine the maximum possible number of edges that can be removed in such a way that all the remaining connected components will have even size.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$) denoting the size of the tree.
The ne... | n = int(input())
tr = [[] for i in range(n)]
for _ in range(n - 1):
u, v = map(int, input().split())
tr[u - 1].append(v - 1)
tr[v - 1].append(u - 1)
if n % 2:
print(-1)
exit()
c = [1] * n
par = [-1] * n
par[0] = 0
q = [0]
while q:
ver = q[-1]
flag = False
for to in tr[ver]:
if pa... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER EXPR FUNC_CALL ... |
You're given a tree with $n$ vertices.
Your task is to determine the maximum possible number of edges that can be removed in such a way that all the remaining connected components will have even size.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$) denoting the size of the tree.
The ne... | def main():
n = int(input())
if n % 2 != 0:
print(-1)
return
graph = [[] for _ in range(n)]
for _ in range(n - 1):
a, b = list(map(int, input().split()))
graph[a - 1].append(b - 1)
graph[b - 1].append(a - 1)
res = 0
stack = [0]
visited = [-1] * n
v... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FU... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | import sys
from sys import stdin, stdout
def get_ints():
return map(int, sys.stdin.readline().strip().split())
def get_string():
return sys.stdin.readline().strip()
for _ in range(int(input())):
n, k = get_ints()
a = get_string()
b = get_string()
acount = [0] * 26
bcount = [0] * 26
... | IMPORT FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FO... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | for _ in range(int(input())):
n, k = map(int, input().split())
a = [0] * 26
for x in input():
a[ord(x) - 97] += 1
for x in input():
a[ord(x) - 97] -= 1
a = [x for x in a if x != 0]
t = 0
pas = True
for x in a:
if abs(x) % k == 0 and t > -1:
t += 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 BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR VAR NUMBER ASSIGN VAR N... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | import sys
input = sys.stdin.readline
def solve():
n, k = map(int, input().split())
a = input()
b = input()
ac = [0] * 26
bc = [0] * 26
for i in range(n):
ac[ord(a[i]) - 97] += 1
bc[ord(b[i]) - 97] += 1
for i in range(26):
if ac[i] >= bc[i]:
ac[i] -= bc... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER VAR BIN_OP FUNC_CALL VAR VAR VAR NU... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | import sys
def get_ints():
return map(int, sys.stdin.readline().strip().split())
def get_list():
return list(map(int, sys.stdin.readline().strip().split()))
def get_list_string():
return list(map(str, sys.stdin.readline().strip().split()))
def get_string():
return sys.stdin.readline().strip()
... | 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 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 FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL F... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | import sys
from sys import stdin
t = int(stdin.readline())
alp = "abcdefghijklmnopqrstuvwxyz"
ad = {}
for i in range(26):
ad[alp[i]] = i
for i in range(t):
n, k = map(int, stdin.readline().split())
a = stdin.readline()[:-1]
b = stdin.readline()[:-1]
have = [0] * 27
must = [0] * 27
for c in ... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSI... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
n, k = map(int, input().split())
a, b = input()[:-1], input()[:-1]
cnta = [0] * 27
cntb = [0] * 27
for c in a:
cnta[ord(c) - ord("a")] += 1
for c in b:
cntb[ord(c) - ord("a")] += 1
for i in range(26):
... | IMPORT 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 VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRIN... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | from sys import stdin
input = stdin.readline
for _ in range(int(input())):
a, b = map(int, input().split())
s1 = list(input().strip())
s2 = list(input().strip())
c1, c2 = [0] * 26, [0] * 26
for i in range(a):
c1[ord(s1[i]) - 97] += 1
c2[ord(s2[i]) - 97] += 1
ans = "Yes"
for ... | 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST NUMBER NUMBER BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
n, k = [int(j) for j in input().split()]
s = input()
t = input()
have = [0] * 27
need = [0] * 27
for i in range(n):
have[ord(s[i]) - 97] += 1
for i in range(n):
need[ord(t[i]) - 97] += 1
flag = True
... | IMPORT ASSIGN VAR 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMB... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
n, k = list(map(int, input().split()))
a = input()
b = input()
one = [0] * 26
two = [0] * 26
for j in range(n):
one[ord(a[j]) - ord("a")] += 1
two[ord(b[j]) - ord("a")] += 1
verdict = "Yes"
for j i... | IMPORT ASSIGN VAR VAR 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 ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP F... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")
for _ in range(int(input())):
n, k = map(int, input().split())
a = input()
b = input()
d1 = [0] * 26
d2 = [0] * 26
for i1, i2 in zip(a, b):
d1[ord(i1) - 97] += 1
d2[ord(i2) - 97] += 1
ans = "YES"
for i, v in ... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING 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 ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR VAR BI... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
n, k = map(int, input().split())
a = input()
b = input()
l = [0] * 26
z = [0] * 26
x = ord("a")
for i in range(n):
e = ord(a[i])
l[e - x] += 1
for i in range(n):
e = ord(b[i])
z[e - x] +=... | IMPORT 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 ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VA... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | from sys import stdin
inp = lambda: stdin.readline().strip()
t = int(inp())
for _ in range(t):
n, k = [int(x) for x in inp().split()]
a = inp()
b = inp()
letterA = [0] * 27
letterB = [0] * 27
for i, j in zip(a, b):
letterA[ord(i) - 97] += 1
letterB[ord(j) - 97] += 1
for i in... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR 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 ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR V... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | def fun(A, B, n, k):
temp = [0] * 26
t = ord("a")
for i in range(n):
temp[ord(A[i]) - t] -= 1
temp[ord(B[i]) - t] += 1
cu = 0
for i in range(26):
if temp[i] == 0:
continue
else:
if abs(temp[i]) % k != 0:
print("NO")
... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR S... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | import sys
input = sys.stdin.readline
t = int(input())
for you in range(t):
l = input().split()
n = int(l[0])
k = int(l[1])
f1 = [(0) for i in range(26)]
f2 = [(0) for i in range(26)]
a = input()
b = input()
for i in range(n):
f1[ord(a[i]) - 97] += 1
f2[ord(b[i]) - 97] +... | IMPORT 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 VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | from sys import stdin
input = stdin.readline
for _ in range(int(input())):
n, k = map(int, input().split())
a = str(input())
b = str(input())
l1 = [0] * 27
l2 = [0] * 27
for i in range(n):
l1[int(ord(a[i]) - ord("a"))] += 1
l2[int(ord(b[i]) - ord("a"))] += 1
f = 0
d = 0
... | 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BI... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | from sys import stdin, stdout
def alpha_order(c):
return ord(c) - ord("a")
def solve():
n, k = map(int, input().split())
a = stdin.readline()
b = stdin.readline()
a_alpha = [0] * 26
b_alpha = [0] * 26
for i in range(n):
a_alpha[alpha_order(a[i])] += 1
b_alpha[alpha_order(... | FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | import sys
def input():
return sys.stdin.readline()[:-1]
for _ in range(int(input())):
n, k = map(int, input().split())
A = [0] * 26
B = [0] * 26
for a in input():
A[ord(a) - 97] += 1
for b in input():
B[ord(b) - 97] += 1
ans = "Yes"
for i in range(25):
if A[i... | IMPORT FUNC_DEF RETURN FUNC_CALL VAR NUMBER 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 BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR BIN_... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | import sys
input = sys.stdin.readline
def prog():
for _ in range(int(input())):
n, k = map(int, input().split())
strings = [input().strip(), input().strip()]
amts = [([0] * 26) for i in range(2)]
total = 0
total2 = 0
worked = True
for i in range(2):
... | IMPORT ASSIGN VAR 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 ASSIGN VAR LIST FUNC_CALL FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FO... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
n, k = map(int, input().split())
s, t = input(), input()
c = [0] * 26
for i in range(n):
c[ord(s[i]) - 97] += 1
c[ord(t[i]) - 97] -= 1
for j in range(25):
d = c[j]
if d < 0 or d % k:
brea... | IMPORT 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 VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBE... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | import sys
input = sys.stdin.readline
alp = [
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
]
for _ in range(int(input())):
n, ... | IMPORT ASSIGN VAR VAR ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CA... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
n, k = map(int, input().split())
s1 = input().rstrip()
s2 = input().rstrip()
c1 = [0] * 26
c2 = [0] * 26
for i in s1:
c1[ord(i) - 97] += 1
for i in s2:
c2[ord(i) - 97] += 1
ans = "Yes"
for i in range... | IMPORT 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | import sys
sys.setrecursionlimit(10**5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II():
return int(sys.stdin.buffer.readline())
def MI():
return map(int, sys.stdin.buffer.readline().split())
def LI():
return list(map(int, sys.stdin.buffer.readline().split()))
def LLI(rows_... | IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
n, k = map(int, input().split())
a = input().rstrip()
b = input().rstrip()
data_a = [(0) for i in range(26)]
data_b = [(0) for i in range(26)]
for i in range(n):
data_a[ord(a[i]) - 97] += 1
data_b[ord(b[i]) - 97... | IMPORT 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_O... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | input = __import__("sys").stdin.readline
def solve(a, b, k, n):
deca = {}
decb = {}
for i in a:
if i in deca:
deca[i] += 1
else:
deca[i] = 1
for i in b:
if i in decb:
decb[i] += 1
else:
decb[i] = 1
for j in decb:
... | ASSIGN VAR FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR IF VAR VAR IF VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR NUMBER VAR VAR VAR VAR ASSIGN VAR VAR NUMBER FOR VAR V... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | import sys
input = lambda: sys.stdin.readline().strip()
t = int(input())
while t:
t -= 1
n, k = map(int, input().split())
a = input()
b = input()
freq = [0] * 26
freq1 = [0] * 26
for i in a:
freq[ord(i) - ord("a")] += 1
for i in b:
freq1[ord(i) - ord("a")] += 1
ok = ... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR ... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
n, k = map(int, input().split())
a = input()
b = input()
l1 = [0] * 26
l2 = [0] * 26
for i in range(n):
l1[ord(a[i]) - 97] += 1
l2[ord(b[i]) - 97] += 1
f = False
for i in range(25):
z = l1[i] - l... | IMPORT 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 ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER N... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | def solve(a, b, k, n):
a.sort()
b.sort()
indexA = 0
indexB = 0
curr = 0
while indexA < n and indexB < n:
if a[indexA] > b[indexB] and curr == 0:
return "No"
elif a[indexA] < b[indexB]:
if indexA + k - 1 < n and a[indexA + k - 1] == a[indexA]:
... | FUNC_DEF 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 VAR NUMBER RETURN STRING IF VAR VAR VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR VAR VAR VAR RETURN STRING IF VAR VAR VAR VAR VAR NUMB... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | import sys
input = lambda: sys.stdin.readline().rstrip()
t = int(input())
for _ in range(t):
n, k = map(int, input().split())
a = input()
b = input()
ca = [(0) for i in range(26)]
cb = [(0) for i in range(26)]
for i in range(n):
ca[ord(a[i]) - 97] += 1
cb[ord(b[i]) - 97] += 1
... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR 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 ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VA... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n, k = map(int, input().split())
a = list(input())
b = list(input())
a_cnt, b_cnt = [0] * 27, [0] * 27
ans = "YES"
for i in range(n):
a_cnt[ord(a[i]) - 97] += 1
b_cnt[ord(b[i]) - 97] += 1
for i in rang... | IMPORT ASSIGN VAR VAR 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST NUMBER NUMBER BIN_OP LIST NUMBER NUMBER ASSIGN VAR STRING FOR VAR FUNC_... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | import sys
def II():
return int(sys.stdin.buffer.readline())
def MI():
return map(int, sys.stdin.buffer.readline().split())
def BI():
return sys.stdin.buffer.readline().rstrip()
def cal(s):
res = [0] * 26
for c in s:
res[c - 97] += 1
return res
for _ in range(II()):
n, k = ... | IMPORT FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR BIN_OP VAR NUMBER NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN V... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | from sys import stdin
input = stdin.readline
t = int(input())
for _ in range(t):
n, k = map(int, input().split())
a = [i for i in input().strip()]
b = [i for i in input().strip()]
a.sort()
b.sort()
if a > b:
print("NO")
else:
ok = True
count_a = [0] * 26
coun... | ASSIGN VAR VAR 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 VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSI... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | from sys import stdin
input = stdin.readline
for _ in range(int(input())):
n, k = map(int, input().split())
a = input().strip()
b = input().strip()
map1 = [(0) for i in range(26)]
map2 = [(0) for j in range(26)]
for i in a:
map1[ord(i) - ord("a")] += 1
for i in b:
map2[ord(i... | 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR F... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | import sys
sys.setrecursionlimit(10**5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II():
return int(sys.stdin.buffer.readline())
def MI():
return map(int, sys.stdin.buffer.readline().split())
def LI():
return list(map(int, sys.stdin.buffer.readline().split()))
def LLI(rows_... | IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | import sys
input = lambda: sys.stdin.readline().rstrip()
T = int(input())
for _ in range(T):
N, K = map(int, input().split())
A = [(ord(a) - 97) for a in input()]
B = [(ord(a) - 97) for a in input()]
C1 = [0] * 26
C2 = [0] * 26
for a in A:
C1[a] += 1
for a in B:
C2[a] += 1
... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR 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 BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMB... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | import sys
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [([c] * b) for i in range(a)]
def list3d(a, b, c, d):
return [[([d] * c) for k in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [[[([e] * d) for k in range(c)] for k in range(b)] for i in ran... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF NUMBER RETURN FUNC_CALL ... |
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters.
He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$.
In one move, he can either
choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $... | from sys import stdin, stdout
t = int(stdin.readline())
for _ in range(t):
n, k = [int(x) for x in stdin.readline().split()]
a = stdin.readline().strip()
b = stdin.readline().strip()
a = [ord(char) for char in sorted(a, reverse=True)]
b = [ord(char) for char in sorted(b, reverse=True)]
answer =... | 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN V... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | t1 = int(input())
for hi in range(t1):
n = int(input())
s = str(input())
p = 0
o = True
l = 1
for i in range(0, n, 2):
if s[i] != s[i + 1]:
p += 1
elif o:
c = s[i]
o = False
elif c != s[i]:
l += 1
c = s[i]
pr... | 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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR ASSIGN VAR VAR VAR ASSIGN VAR NU... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | for _ in range(int(input())):
n = int(input())
a = list(input())
b = a[:]
i = 0
count = 0
while i < n:
if a[i : i + 2] == ["1", "1"] or a[i : i + 2] == ["0", "0"]:
i += 2
else:
count += 1
i += 2
if a[0] != a[1]:
a[0] = "0"
a... | 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 ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR BIN_OP VAR NUMBER LIST STRING STRING VAR VAR BIN_OP VAR NUMBER LIST STRING STRING VAR NUMBER VAR NUMBER VAR NUMBER I... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | n = int(input())
while n:
n -= 1
dlch = int(input())
ch = input()
count = 0
s = ""
otv = 1
for i in range(1, dlch, 2):
if ch[i] != ch[i - 1]:
count += 1
elif ch[i] == "1" and ch[i - 1] == "1":
s = s + "1"
else:
s = s + "0"
for i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR ... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | [
print(
*__import__("functools").reduce(
lambda x, y: [
(x[0] + 1, x[1], x[2]),
(x[0], x[1] + (x[2] and y[0] != x[2]), y[0]),
][y[0] == y[1]],
zip(*([iter(input())] * 2)),
(0, 1, 0),
)[:-1]
)
for p in (input() f... | EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING LIST BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP LIST FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER NUMBER NUMBER NUMBER VAR FUNC_CALL VAR VAR FUNC_CALL VA... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | def solve():
x = int(input())
a = input()
position = []
count = 0
counti = 0
l = -1
for i in range(0, x, 2):
if a[i : i + 2] == "01" or a[i : i + 2] == "10":
counti = counti + 1
else:
if l != a[i]:
count = count + 1
l = a[i]... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NU... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | for _ in range(int(input().strip())):
n = int(input().strip())
arr = input()
ans = 0
t = []
for i in range(0, len(arr), 2):
if arr[i] != arr[i + 1]:
ans += 1
else:
t.append(arr[i])
seg = 1
for i in range(0, len(t) - 1):
if t[i] != t[i + 1]:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR F... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | t = int(input())
for _ in range(t):
n = int(input())
mas = list(input())
new = []
count = 0
for i in range(1, n, 2):
if mas[i] == mas[i - 1]:
new.append(int(mas[i]))
else:
new.append(2)
count += 1
line = 1
temp = 2
for i in range(n // 2... | 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 LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER VAR... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | import sys
input = sys.stdin.readline
def solve():
n = int(input())
s = input().strip()
ops = 0
dp = [[float("inf"), float("inf")] for _ in range(n // 2)]
if s[0] == s[1]:
dp[0][int(s[1])] = 1
else:
dp[0][int(s[0])] = 1
dp[0][int(s[1])] = 1
ops += 1
for i i... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FUNC_CALL VAR STRING FUNC_CALL VAR STRING VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FUNC_CALL ... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | T = int(input())
for _ in range(0, T):
n = int(input())
s = input()
x1 = -1
x = 0
y = 0
f = 0
for i in range(0, n // 2):
j1 = i * 2
j2 = i * 2 + 1
if s[j1] == s[j2] and x1 != int(s[j1]):
y += 1
x1 = int(s[j1])
elif s[j1] != s[j2]:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER ... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | def countsegs(s):
cnt = 1
for i in range(1, len(s)):
if s[i] != s[i - 1]:
cnt += 1
return cnt
tc = int(input())
for case in range(tc):
n = int(input())
s = list(input())
moves = 0
for i in range(0, n, 2):
if s[i] != s[i + 1]:
moves += 1
prevs = [... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN 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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER V... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | t = int(input())
out = ""
for _ in range(t):
n = int(input())
string = input()
ans = 0
ans2 = 1
last = ""
for i in range(0, len(string), 2):
if string[i] != string[i + 1]:
ans += 1
else:
if last != "" and string[i] != last:
ans2 += 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR STRING VAR VAR... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | def solve(n, s):
op = 0
state = [(1, 1)]
for i in range(0, len(s), 2):
j = i + 1
if s[i] == s[j]:
v = int(s[i])
x = min(state[-1][1 - v] + 1, state[-1][v])
state.append((x, float("inf")) if v == 0 else (float("inf"), x))
else:
op += 1
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL V... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | for _ in range(int(input())):
n = int(input())
s = input()
i = 0
count = 0
while i < n - 1:
if s[i] != s[i + 1]:
count += 1
i += 2
i = 0
prev = None
count2 = 1
while i < n - 1:
if s[i] == s[i + 1]:
if prev is not None:
i... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NONE ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR ... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | import sys
def input():
return sys.stdin.readline().rstrip()
def main():
t = int(input())
for tc in range(t):
n = int(input())
string = input()
opr_cnt = 0
sub_cnt = 0
cur_num = "NULL"
for i in range(0, n, 2):
if string[i] == string[i + 1]:
... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER IF VAR V... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | import sys
input = sys.stdin.readline
def solve():
n = int(input())
s = input()
ans1 = 0
ans2 = 0
ans = ""
last = "!"
for i in range(0, n, 2):
if s[i] != s[i + 1]:
ans1 += 1
elif s[i] != last:
ans2 += 1
last = s[i]
if ans2 == 0:
... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR IF VAR NUMBER VAR NUMBER... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | t = int(input())
for _ in range(t):
n = int(input())
s = input()
num, cnt = 0, 0
tmp = -1
for i in range(0, n, 2):
if s[i] != s[i + 1]:
num += 1
elif s[i] != tmp:
cnt += 1
tmp = s[i]
print(num, max(1, cnt)) | 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 ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR EXPR FUNC_CALL ... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | t = int(input())
for _ in range(t):
n = int(input())
s = list(input())
l = "1"
ans = 0
for i in range(0, n, 2):
if s[i] == s[i + 1]:
l = s[i + 1]
break
for i in range(0, len(s), 2):
if s[i] == s[i + 1]:
l = s[i + 1]
else:
an... | 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 STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_C... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | for i in range(int(input())):
n = int(input())
s = input()
counter_change = 0
counter_segment = 0
p = "p"
for k in range(0, n, 2):
if s[k] != s[k + 1]:
counter_change += 1
else:
if p != s[k]:
counter_segment += 1
p = s[k]
if... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR IF VAR NUMBER ASSIGN VA... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | for zzzzz in range(int(input())):
n = int(input())
a = input()
count = 0
isprev = "-1"
count2 = 0
for i in range(0, n, 2):
f = a[i]
s = a[i + 1]
if f != s:
count = count + 1
if f == s:
if isprev == "-1":
if f == "0":
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR IF VAR ST... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | for t in range(int(input())):
n = int(input())
a = [int(y) for y in input()]
p = -1
ans = 0
seg = 0
for i in range(0, n, 2):
if a[i] ^ a[i + 1]:
ans += 1
else:
seg += p != a[i]
p = a[i]
print(ans, max(1, seg)) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR VAR VAR VAR ASSIGN VAR VAR VAR EXPR... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | t = int(input())
for _ in range(t):
n = int(input())
st = input()
arr = []
count = 1
for i in range(n - 1):
if st[i] != st[i + 1]:
arr.append(count)
count = 1
else:
count += 1
ans = 0
for i in range(len(arr)):
if arr[i] % 2 != 0:
... | 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 ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_C... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | def isGood(s):
if s[0] == s[1]:
return 1
return 0
for _ in range(int(input())):
n = int(input())
s = input()
ans = 0
kekw = []
kekw2 = []
for i in range(0, n, 2):
if s[i : i + 2] == "10" or s[i : i + 2] == "01":
kekw.append(i)
ans += 1
el... | FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR VAR BIN_OP VAR... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | for ii in range(int(input())):
n = int(input())
s = input()
ans = 0
for i in range(0, n - 1, 2):
if s[i] != s[i + 1]:
ans += 1
seg = 0
last = 2
for i in range(0, n - 1, 2):
curr = 2
if s[i] == s[i + 1] and s[i] == "0":
curr = 0
if s[i] ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER ... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | t = int(input())
for i in range(0, t):
count = 0
n = int(input())
s = input()
j = 0
f = 0
k = 5
for i in range(0, n, 2):
if s[i] != s[i + 1]:
count += 1
elif f == 0:
f = 1
k = s[i]
elif s[i] != k:
j += 1
k = ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR NUM... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | t = int(input())
for vvod in range(t):
n = int(input())
str = input()
s = list(str)
ans = 0
pok = 0
if n == 2:
if s[0] == s[1]:
print("0 1")
else:
print("1 1")
continue
d = dict()
c = "p"
ans2 = 0
for i in range(0, n - 1, 2):
... | 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 ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | t = int(input())
for _ in range(t):
n = int(input())
s = input()
l = 0
k = 0
a = []
for i in range(0, n, 2):
if s[i] == s[i + 1]:
a.append(int(s[i]))
else:
a.append(-1)
l += 1
x = []
for i in range(len(a)):
if a[i] == -1:
... | 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | for _ in range(int(input())):
n, S = int(input()), input()
DP_, DP0, DP1, p0, p1 = [0], [1], [1], "0", "1"
for i in range(0, n, 2):
DP_.append(0)
DP0.append(0)
DP1.append(0)
if S[i] == S[i + 1]:
DP0[-1] = DP0[-2] + (0 if p0 == S[i] else 1)
DP1[-1] = DP... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR LIST NUMBER LIST NUMBER LIST NUMBER STRING STRING FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR VAR BIN... |
This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.
Tokitsukaze has a binary string $s$ of length $n$, consisting only of zeros and ones, $n$ is even.
Now Tokitsukaze divides $s$ into the minimum number... | t = int(input())
for i in range(t):
n = int(input())
a = input()
count = 0
count1 = 0
flag = 0
mark = "2"
for k in range(n // 2):
if a[2 * k] != a[2 * k + 1]:
count += 1
elif a[2 * k] != mark:
mark = a[2 * k]
count1 += 1
if count1 == 0:... | 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP NUMBER VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER IF VAR ... |
You are given an undirected tree consisting of $n$ vertices. An undirected tree is a connected undirected graph with $n - 1$ edges.
Your task is to add the minimum number of edges in such a way that the length of the shortest path from the vertex $1$ to any other vertex is at most $2$. Note that you are not allowed to... | import sys
def get_new_edges(graph):
n = len(graph)
far_vertex = []
pi = [None] * n
visit = [False] * n
visit[0]
queue = [[0, 0]]
i = 0
while True:
if i >= len(queue):
break
current, d = queue[i]
i += 1
visit[current] = True
for v in ... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NONE VAR ASSIGN VAR BIN_OP LIST NUMBER VAR EXPR VAR NUMBER ASSIGN VAR LIST LIST NUMBER NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR VAR IF VAR VAR ASS... |
You are given an undirected tree consisting of $n$ vertices. An undirected tree is a connected undirected graph with $n - 1$ edges.
Your task is to add the minimum number of edges in such a way that the length of the shortest path from the vertex $1$ to any other vertex is at most $2$. Note that you are not allowed to... | from sys import stdin
n = int(stdin.readline())
g = dict()
for i in range(n - 1):
u, v = map(int, stdin.readline().split())
g.setdefault(u - 1, []).append(v - 1)
g.setdefault(v - 1, []).append(u - 1)
st = [0]
rank = [0] * n
tree = [0] * n
msk = [0] * n
rd = dict()
while len(st) > 0:
top = st.pop()
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL FUNC_CALL VAR BIN_OP VAR NUMBER LIST BIN_OP VAR NUMBER EXPR FUNC_CALL FUNC_CALL VAR BIN_OP VAR NUMBER LIST BIN_OP VAR NUMBER ASSIGN VAR LIST NUM... |
Barbara was late for her math class so as a punishment the teacher made her solve the task on a sheet of paper. Barbara looked at the sheet of paper and only saw n numbers a_1, a_2, β¦, a_n without any mathematical symbols. The teacher explained to Barbara that she has to place the available symbols between the numbers ... | n = int(input())
a = list(map(int, input().split()))
s = input()
usable = []
if "+" in s:
usable.append(0)
if "*" in s:
usable.append(1)
if "-" in s:
usable.append(2)
usable = tuple(usable)
if len(usable) == 1:
ans = [s] * (n - 1)
ansPr = []
for i in range(n - 1):
ansPr.append(str(a[i]))... | 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 ASSIGN VAR LIST IF STRING VAR EXPR FUNC_CALL VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUM... |
Barbara was late for her math class so as a punishment the teacher made her solve the task on a sheet of paper. Barbara looked at the sheet of paper and only saw n numbers a_1, a_2, β¦, a_n without any mathematical symbols. The teacher explained to Barbara that she has to place the available symbols between the numbers ... | n = int(input())
A = list(map(int, input().split()))
symbols = list(input())
def solve1(array):
j = 0
solution = []
first = True
while j < len(array):
i = j
if not first:
solution.append("+")
first = False
if array[j] == 0:
j += 1
whi... | 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_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR VAR IF VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR VAR NUMBER VA... |
Barbara was late for her math class so as a punishment the teacher made her solve the task on a sheet of paper. Barbara looked at the sheet of paper and only saw n numbers a_1, a_2, β¦, a_n without any mathematical symbols. The teacher explained to Barbara that she has to place the available symbols between the numbers ... | from itertools import groupby, product
def main():
n = int(input())
ar = [int(t) for t in input().split()]
ops = set(input())
if len(ops) == 1:
ans = [ops.pop()] * (n - 1)
elif ops == {"+", "-"}:
ans = ["+"] * (n - 1)
elif ops == {"*", "-"}:
ans = ["*"] * (n - 1)
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR STRING STRING ASSIGN VAR BIN_OP LIST STRING BIN_OP VAR NUMBER IF VAR STRING STRING ASS... |
Given an infinite supply of each denomination of Indian currency { 1, 2, 5, 10, 20, 50, 100, 200, 500, 2000 } and a target value N.
Find the minimum number of coins and/or notes needed to make the change for Rs N. You must return the list containing the value of coins required.
Example 1:
Input: N = 43
Output: 20 20 2... | class Solution:
def minPartition(self, N):
coins = [2000, 500, 200, 100, 50, 20, 10, 5, 2, 1]
ans = []
idx = 0
while N and idx < len(coins):
if coins[idx] > N:
idx += 1
else:
N -= coins[idx]
ans.append(coins[idx... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR RETURN VAR |
Given an infinite supply of each denomination of Indian currency { 1, 2, 5, 10, 20, 50, 100, 200, 500, 2000 } and a target value N.
Find the minimum number of coins and/or notes needed to make the change for Rs N. You must return the list containing the value of coins required.
Example 1:
Input: N = 43
Output: 20 20 2... | class Solution:
def minPartition(self, N):
dict = [1, 2, 5, 10, 20, 50, 100, 200, 500, 2000]
ans = []
def help(n, ans):
if n == 0:
return 0
for i in range(len(dict) - 1, -1, -1):
if dict[i] <= n:
ans.append(dict[i]... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST FUNC_DEF IF VAR NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CAL... |
Given an infinite supply of each denomination of Indian currency { 1, 2, 5, 10, 20, 50, 100, 200, 500, 2000 } and a target value N.
Find the minimum number of coins and/or notes needed to make the change for Rs N. You must return the list containing the value of coins required.
Example 1:
Input: N = 43
Output: 20 20 2... | class Solution:
def minPartition(self, N):
coins = [1, 2, 5, 10, 20, 50, 100, 200, 500, 2000]
ans = []
i = 9
while i >= 0:
while N >= coins[i]:
ans.append(coins[i])
N -= coins[i]
i -= 1
if N == 0:
re... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR NUMBER WHILE VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER RETURN VAR |
Given an infinite supply of each denomination of Indian currency { 1, 2, 5, 10, 20, 50, 100, 200, 500, 2000 } and a target value N.
Find the minimum number of coins and/or notes needed to make the change for Rs N. You must return the list containing the value of coins required.
Example 1:
Input: N = 43
Output: 20 20 2... | class Solution:
def minPartition(self, N):
currency = [1, 2, 5, 10, 20, 50, 100, 200, 500, 2000]
n = len(currency)
target = N
i = n - 1
out = []
while i >= 0:
curr = currency[i]
if target >= curr:
target = target - curr
... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST WHILE VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER RETURN VAR |
Given an infinite supply of each denomination of Indian currency { 1, 2, 5, 10, 20, 50, 100, 200, 500, 2000 } and a target value N.
Find the minimum number of coins and/or notes needed to make the change for Rs N. You must return the list containing the value of coins required.
Example 1:
Input: N = 43
Output: 20 20 2... | class Solution:
def minPartition(self, N):
Coin = [1, 2, 5, 10, 20, 50, 100, 200, 500, 2000]
Cn = 10
ans = []
while N > 0:
if Coin[Cn - 1] > N:
Cn -= 1
else:
ans.append(Coin[Cn - 1])
N -= Coin[Cn - 1]
re... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER RETURN VAR |
Given an infinite supply of each denomination of Indian currency { 1, 2, 5, 10, 20, 50, 100, 200, 500, 2000 } and a target value N.
Find the minimum number of coins and/or notes needed to make the change for Rs N. You must return the list containing the value of coins required.
Example 1:
Input: N = 43
Output: 20 20 2... | class Solution:
def minPartition(self, N):
a = [1, 2, 5, 10, 20, 50, 100, 200, 500, 2000]
b = 0
c = []
for i in range(9, -1, -1):
while b + a[i] <= N:
b += a[i]
c.append(a[i])
return c | CLASS_DEF FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER WHILE BIN_OP VAR VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR RETURN VAR |
Given an infinite supply of each denomination of Indian currency { 1, 2, 5, 10, 20, 50, 100, 200, 500, 2000 } and a target value N.
Find the minimum number of coins and/or notes needed to make the change for Rs N. You must return the list containing the value of coins required.
Example 1:
Input: N = 43
Output: 20 20 2... | class Solution:
def minPartition(self, N):
l = [1, 2, 5, 10, 20, 50, 100, 200, 500, 2000]
ans = []
for i in range(-1, -11, -1):
if N // l[i] != 0:
ans += [l[i]] * (N // l[i])
N %= l[i]
return ans | CLASS_DEF FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP VAR VAR VAR NUMBER VAR BIN_OP LIST VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR RETURN VAR |
Given an infinite supply of each denomination of Indian currency { 1, 2, 5, 10, 20, 50, 100, 200, 500, 2000 } and a target value N.
Find the minimum number of coins and/or notes needed to make the change for Rs N. You must return the list containing the value of coins required.
Example 1:
Input: N = 43
Output: 20 20 2... | class Solution:
def minPartition(self, sm):
arr, out = [1, 2, 5, 10, 20, 50, 100, 200, 500, 2000][::-1], []
for i in arr:
if sm // i > 0:
out.extend([i] * (sm // i))
sm -= i * (sm // i)
return out | CLASS_DEF FUNC_DEF ASSIGN VAR VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER LIST FOR VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP LIST VAR BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR RETURN VAR |
Given an infinite supply of each denomination of Indian currency { 1, 2, 5, 10, 20, 50, 100, 200, 500, 2000 } and a target value N.
Find the minimum number of coins and/or notes needed to make the change for Rs N. You must return the list containing the value of coins required.
Example 1:
Input: N = 43
Output: 20 20 2... | class Solution:
def minPartition(self, N):
coins = [1, 2, 5, 10, 20, 50, 100, 200, 500, 2000]
res = []
for i in range(len(coins) - 1, -1, -1):
while N >= coins[i]:
N -= coins[i]
res.append(coins[i])
return res | CLASS_DEF FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER WHILE VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR RETURN VAR |
Given an infinite supply of each denomination of Indian currency { 1, 2, 5, 10, 20, 50, 100, 200, 500, 2000 } and a target value N.
Find the minimum number of coins and/or notes needed to make the change for Rs N. You must return the list containing the value of coins required.
Example 1:
Input: N = 43
Output: 20 20 2... | class Solution:
def minPartition(self, N):
brr = [1, 2, 5, 10, 20, 50, 100, 200, 500, 2000]
brr = brr[::-1]
ans = []
for i in range(len(brr)):
if brr[i] <= N:
for j in range(N // brr[i]):
ans.append(brr[i])
N = N % brr[... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR RETURN VAR |
Given an infinite supply of each denomination of Indian currency { 1, 2, 5, 10, 20, 50, 100, 200, 500, 2000 } and a target value N.
Find the minimum number of coins and/or notes needed to make the change for Rs N. You must return the list containing the value of coins required.
Example 1:
Input: N = 43
Output: 20 20 2... | class Solution:
def minPartition(self, N):
currency = [2000, 500, 200, 100, 50, 20, 10, 5, 2, 1]
i = 0
ans = []
while i < len(currency):
if currency[i] > N:
i += 1
elif currency[i] == N:
ans.append(currency[i])
... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR RETURN VAR IF VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR RETURN VAR |
Given an infinite supply of each denomination of Indian currency { 1, 2, 5, 10, 20, 50, 100, 200, 500, 2000 } and a target value N.
Find the minimum number of coins and/or notes needed to make the change for Rs N. You must return the list containing the value of coins required.
Example 1:
Input: N = 43
Output: 20 20 2... | class Solution:
def minPartition(self, N):
coins = [1, 2, 5, 10, 20, 50, 100, 200, 500, 2000]
ans = []
while N > 0:
for i in range(9, -1, -1):
num = N // coins[i]
ans += [coins[i]] * num
N = N % coins[i]
return ans | CLASS_DEF FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST WHILE VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR BIN_OP LIST VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR RETURN VAR |
Given an infinite supply of each denomination of Indian currency { 1, 2, 5, 10, 20, 50, 100, 200, 500, 2000 } and a target value N.
Find the minimum number of coins and/or notes needed to make the change for Rs N. You must return the list containing the value of coins required.
Example 1:
Input: N = 43
Output: 20 20 2... | class Solution:
def minPartition(self, N):
coins = [2000, 500, 200, 100, 50, 20, 10, 5, 2, 1]
ans = []
i = 0
while i < len(coins) or N <= 0:
while i < len(coins) and coins[i] > N:
i += 1
if i >= len(coins):
break
N ... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR RETURN VAR |
Given an infinite supply of each denomination of Indian currency { 1, 2, 5, 10, 20, 50, 100, 200, 500, 2000 } and a target value N.
Find the minimum number of coins and/or notes needed to make the change for Rs N. You must return the list containing the value of coins required.
Example 1:
Input: N = 43
Output: 20 20 2... | class Solution:
def minPartition(self, n):
arr = [2000, 500, 200, 100, 50, 20, 10, 5, 2, 1]
ans = []
for i in arr:
temp = n // i
ans += temp * [i]
n -= temp * i
return ans | CLASS_DEF FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR LIST VAR VAR BIN_OP VAR VAR RETURN VAR |
Given an infinite supply of each denomination of Indian currency { 1, 2, 5, 10, 20, 50, 100, 200, 500, 2000 } and a target value N.
Find the minimum number of coins and/or notes needed to make the change for Rs N. You must return the list containing the value of coins required.
Example 1:
Input: N = 43
Output: 20 20 2... | class Solution:
def minPartition(self, N):
u = [1, 2, 5, 10, 20, 50, 100, 200, 500, 2000]
u = u[::-1]
i = 0
v = []
while N != 0:
if N >= u[i]:
N = N - u[i]
v.append(u[i])
else:
i += 1
return v | CLASS_DEF FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER RETURN VAR |
Given an infinite supply of each denomination of Indian currency { 1, 2, 5, 10, 20, 50, 100, 200, 500, 2000 } and a target value N.
Find the minimum number of coins and/or notes needed to make the change for Rs N. You must return the list containing the value of coins required.
Example 1:
Input: N = 43
Output: 20 20 2... | class Solution:
def minPartition(self, N):
arr = [1, 2, 5, 10, 20, 50, 100, 200, 500, 2000]
curr = len(arr) - 1
ans = []
while N > 0:
if arr[curr] <= N:
ans.append(arr[curr])
N = N - arr[curr]
else:
curr = curr ... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST WHILE VAR NUMBER IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR |
Given an infinite supply of each denomination of Indian currency { 1, 2, 5, 10, 20, 50, 100, 200, 500, 2000 } and a target value N.
Find the minimum number of coins and/or notes needed to make the change for Rs N. You must return the list containing the value of coins required.
Example 1:
Input: N = 43
Output: 20 20 2... | class Solution:
def minPartition(self, N):
currency = [1, 2, 5, 10, 20, 50, 100, 200, 500, 2000]
i = len(currency) - 1
res = []
while i >= 0 and N != 0:
if N >= currency[i]:
quotient = N // currency[i]
res += [currency[i]] * quotient
... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST WHILE VAR NUMBER VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR BIN_OP LIST VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER RETURN VAR |
Given an infinite supply of each denomination of Indian currency { 1, 2, 5, 10, 20, 50, 100, 200, 500, 2000 } and a target value N.
Find the minimum number of coins and/or notes needed to make the change for Rs N. You must return the list containing the value of coins required.
Example 1:
Input: N = 43
Output: 20 20 2... | currencies = [1, 2, 5, 10, 20, 50, 100, 200, 500, 2000]
num_currencies = len(currencies)
class Solution:
def minPartition(self, N):
i = num_currencies - 1
taken = []
while i >= 0 and N > 0:
while currencies[i] <= N:
N -= currencies[i]
taken.appe... | ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST WHILE VAR NUMBER VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER RETURN VAR |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.