description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | def main():
s = input()
l = ""
ns = ""
nb1 = 2
inc = 0
for x in range(len(s)):
if s[x] != l:
inc = 0
if inc == 0:
nb1 += 1
ns += s[x]
elif inc == 1 and nb1 >= 2:
nb1 = 0
ns += s[x]
inc += 1
l = s[... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR ... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | MOD = 10**9 + 7
I = lambda: list(map(int, input().split()))
s = input()
res = ""
d = []
n = len(s)
if n < 3:
print(s)
else:
res += s[:3]
i = 3
j = 2
if res[j] == res[j - 1] and res[j - 1] == res[j - 2]:
res = res[:j]
j -= 1
while i < n:
res += s[i]
i += 1
... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBE... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | s = list(input())
n = len(s)
a = [1] * n
prev = -1
cnt = 1
prev_cnt = 0
for i in range(n):
if s[i] == prev:
cnt += 1
else:
prev_cnt = cnt
cnt = 1
if prev_cnt < 2:
if cnt >= 3:
a[i] = 0
cnt -= 1
elif cnt >= 2:
a[i] = 0
cnt -= 1
p... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER IF VAR NUMBER ASSI... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | s = list(input())
l = len(s)
ln = []
if l < 2:
ln = s
else:
ln = s[0:2]
j = 2
for i in range(2, l):
if s[i] != ln[j - 1] or s[i] != ln[j - 2]:
if ln[j - 1] != ln[j - 2] or i == l - 1 or s[i] != s[i + 1]:
ln.append(s[i])
j += 1
print("".join(ln)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NU... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | a = str(input())
l = list(a)
l1 = []
l1.append(l[0])
if len(l) == 1:
print(l[0])
else:
l1.append(l[1])
for i in range(2, len(l)):
if (
l1[-1] == l1[-2] == l[i]
or len(l1) > 2
and l1[-2] == l1[-3]
and l1[-1] == l[i]
):
continue
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER VAR VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER VA... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | s = input()
stack = []
i = 0
n = len(s)
while i < n:
if len(stack) < 2:
stack.append(s[i])
i += 1
elif s[i] == stack[-1] == stack[-2]:
i += 1
elif len(stack) >= 3 and s[i] == stack[-1] and stack[-2] == stack[-3]:
i += 1
else:
stack.append(s[i])
i += 1
prin... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF FUNC_CALL VAR VAR NUMBER VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR V... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | def fun1(st):
le = len(st)
stack = [0] * le
i = 0
x = 0
sh = 0
h = 0
ans = list(st)
while i < len(ans):
if ans[i] == "#":
stack[i] = stack[i - 1]
i += 1
continue
if i > 0 and ans[i] == ans[i - 1]:
stack[i] = stack[i - 1] + 1... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VA... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | a = input()
n = len(a)
if n <= 2:
print(a)
else:
res = ""
a += "_"
n = len(a)
i = 0
mode = 0
while i < n - 1:
c = 1
while i < n - 1 and a[i] == a[i + 1]:
c += 1
i += 1
if c == 1:
res += a[i]
mode = 0
elif mode ==... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR STRING VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NU... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | from sys import stdin, stdout
def main():
from sys import stdin, stdout
ip = stdin.readline().strip()
t = ip[0]
for ch in ip[1:]:
if len(t) > 2:
if ch == t[-1] and t[-2] == t[-3] or ch == t[-1] and t[-1] == t[-2]:
continue
else:
t += ch
... | FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER IF VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR IF FUNC_CALL VAR VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | s, t = input(), 1
k = list(s)
for i in range(1, len(s)):
t = t + 1 if s[i] == s[i - 1] else 1
if t > 2:
k[i] = "|"
k = "".join(k).replace("|", "") + "||"
t, k = 0, list(k)
for i in range(1, len(k)):
if k[i] == k[i - 1] and t:
t = 0
k[i] = "|"
if k[i] == k[i - 1]:
t = 1
... | ASSIGN VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER IF VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP FUNC_CALL FUNC_CALL STRING VAR STRING STRING STRING ASSIGN VAR VAR NUMBER FUNC_CALL VAR ... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | s = input()
t = s[0]
j = 0
b = []
for i in range(0, len(s)):
if s[i] == t and j == 0:
j = 1
b.append(s[i])
elif s[i] == t and j == 1:
j = 2
b.append(s[i])
elif s[i] != t and j == 1:
b.append(s[i])
elif s[i] != t and j == 2:
j = 3
b.append(s[i])
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR V... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | s = input()
ans = []
p_count = c_count = 0
p_char = c_char = ""
d_used = False
for c in s:
if c == c_char:
c_count += 1
if c_count <= 2:
if c_count == 2 and p_count >= 2:
continue
if c_count == 2:
d_used = True
ans.append(c)
els... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER IF VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | l = input()
ans = ""
ct = []
i = 0
while i < len(l):
t = l[i]
c = 0
while t == l[i]:
i = i + 1
c = c + 1
if i == len(l):
break
if c == 1:
ans = ans + t
ct.append(c)
else:
if c >= 3:
c = 2
if len(ct) > 0:
if c... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER ... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | s = list(input())
n = len(s)
count = 0
i = 0
answer = [1] * n
while i < n - 2:
if s[i] != s[i + 1] or answer[i] != 1:
i += 1
else:
j = i + 2
while j < n and s[j] == s[i]:
answer[j] = -1
j += 1
while j < n - 1 and s[j] == s[j + 1]:
answer[j + 1]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR WHILE VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR NUMBER VAR NUMBER WHI... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | s = input().strip()
arr = []
i = 0
while i < len(s):
j = i
cc = 0
while j < len(s) and s[i] == s[j]:
j += 1
cc += 1
arr.append([s[i], cc])
i = j
pre = -1
ans = ""
for i in range(len(arr)):
if pre == -1:
pre = arr[i][1]
ans += arr[i][0] * min(2, arr[i][1])
elif... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR V... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | s = input()
n = len(s)
if n == 1 or n == 2:
print(s)
else:
ans = [s[0], s[1]]
for i in range(2, n):
k = len(ans) - 1
if s[i] != ans[k]:
ans.append(s[i])
elif ans[k] != ans[k - 1]:
if k >= 2:
if ans[k - 1] != ans[k - 2]:
ans.... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER IF VAR BIN_... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | s = input()
i = 0
n = len(s)
l = []
while i < n:
cnt = s[i]
while i + 1 < n and s[i] == s[i + 1]:
cnt += s[i + 1]
i += 1
l.append(cnt)
i += 1
for i in range(len(l)):
if len(l[i]) > 2:
l[i] = l[i][:2]
ans1, t1 = "", 0
for i in l:
if len(i) == 2:
if t1:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST WHILE VAR VAR ASSIGN VAR VAR VAR WHILE BIN_OP VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR NUMBE... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | def fixing_typos(s):
s = list(s)
ans = [s[0]]
i = 1
double = False
triple = False
while i < len(s):
if s[i] == ans[-1]:
if triple:
i += 1
continue
if double:
i += 1
continue
triple = True
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER IF VAR VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER RETURN FUNC_CALL STRING VA... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | s = input()
s1 = ""
for i in range(len(s)):
if (
len(s1) > 1
and s[i] == s1[-1]
and s1[-1] == s1[-2]
or len(s1) > 2
and s[i] == s1[-1]
and s1[-2] == s1[-3]
):
continue
else:
s1 += s[i]
print(s1) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | s = input()
C = [0] * len(s)
ind = -1
x = True
for i in range(len(s)):
if x:
C[i] = 1
y = True
x = False
ind += 1
continue
if y:
if s[i] == s[ind]:
C[i] = 1
z = True
y = False
ind += 1
continue
el... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR IF VAR VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | t = list(input().strip())
d = []
for i in range(len(t) - 1):
if t[i] == t[i + 1]:
d.append(i)
for i in range(len(d) - 1):
if d[i + 1] - d[i] == 1:
t[d[i]] = ""
a = "".join(t)
if len(a) < 3:
print(a)
else:
ans = a[:3]
for i in range(3, len(a)):
if not (a[i] == ans[-1] and ans[... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR VAR STRING ASSIGN VAR FUNC_CA... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | import sys
t = 1
for __ in range(t):
s1 = input()
ans = []
ch = 4
for i in range(len(s1)):
if i <= len(s1) - 3:
if s1[i] == s1[i + 1] == s1[i + 2]:
continue
if i <= len(s1) - 2:
if s1[i] == s1[i + 1]:
if ch != -1:
... | IMPORT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER IF V... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | s = list(input())
pre = s[0]
ns = []
prec = 0
ns.append(pre)
posc = 1
for i in s[1:]:
if i == pre:
if prec != 2 and posc < 2:
ns.append(i)
posc += 1
pre = i
else:
prec = posc
posc = 1
ns.append(i)
pre = i
print("".join(ns)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR NUMBER IF VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR EXPR FUNC... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | s = list(input())
n = len(s)
cnt = 0
prev = s[0]
ans = []
chk = False
for x in range(n):
if s[x] == prev:
cnt += 1
else:
if cnt == 1:
ans.append(s[x - 1])
chk = False
elif cnt >= 2 and chk:
ans.append(s[x - 1])
chk = False
elif cnt ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR N... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | n = input()
ar = [""]
pair = 0
for i in n:
if ar[-1] == i and pair == 0:
ar.append(i)
pair = 2
elif ar[-1] != i:
ar.append(i)
if pair > 0:
pair -= 1
s = ""
s += "".join(i for i in ar if i != "")
print(s) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST STRING ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR STRING VAR FUNC_CALL STRING VAR VAR VAR VAR STRING EXPR FUNC_CALL VAR VAR |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | w = list(input())
a = ["@"]
x = 0
y = 0
for s in w:
if a[len(a) - 1] == s:
if x < 2:
if y <= 1:
a.append(s)
y += 1
elif y == 0:
a.append(s)
y += 1
else:
x = y
y = 0
a.append(s)
y += 1
a.pop(0)
pri... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR V... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | import sys
input = lambda: sys.stdin.readline().strip("\r\n")
s = list(input())
n = len(s)
ans = []
for i in range(n):
if (
len(ans) >= 2
and ans[-1] == ans[-2] == s[i]
or len(ans) > 2
and ans[-3] == ans[-2]
and ans[-1] == s[i]
):
continue
ans.append(s[i])
pr... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | s = input()
ans = []
index_shift = 0
for i, si in enumerate(s):
ans.append(si)
if i >= 2:
if s[i - 2] == s[i - 1] == si:
ans.pop(i - index_shift)
index_shift += 1
elif i >= 3:
if (
ans[i - 3 - index_shift] == ans[i - 2 - index_shift]
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER IF VAR NUMBER IF VAR BIN_OP BIN_OP VAR NUMBER VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR BIN_OP BIN_... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | s = input()
pre, ls, ans, last = [s[0], 1], len(s), [s[0]], 0
for i in range(1, ls):
if s[i] == pre[0]:
if last == 2 or pre[1] >= 2:
continue
else:
ans.append(s[i])
pre[1] += 1
else:
last = pre[1]
pre = [s[i], 1]
ans.append(s[i])
print(... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR LIST VAR NUMBER NUMBER FUNC_CALL VAR VAR LIST VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | s = input()
l = ""
if len(s) <= 2:
print(s)
elif len(s) <= 3:
if s[0] == s[1] == s[2]:
print(s[:2])
else:
print(s)
else:
for i in range(len(s)):
if i < 2:
l += s[i]
elif i == 2 and s[2] == s[1] and s[1] != s[0]:
l += s[i]
elif l[-1] != s[i]... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUM... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | s = input()
ans = ""
l = 0
for i in s:
tr = True
if l > 1:
if i == ans[l - 1] and ans[l - 1] == ans[l - 2]:
tr = False
if l > 2:
if i == ans[l - 1] and ans[l - 2] == ans[l - 3]:
tr = False
if tr:
ans += i
l += 1
print(ans) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR VAR ... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | s = input()
last = s[0]
final = []
i = 1
curr = 1
prev = 0
while i < len(s):
if s[i] == last:
curr += 1
elif curr >= 2:
if prev == 2:
final.append(s[i - 1])
prev = 1
curr = 1
last = s[i]
else:
final.append(s[i - 1])
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR BI... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | import sys
s = sys.stdin.readline()[:-1]
ans = ""
if len(s) < 3:
ans = s
else:
last = s[0]
lastCount = 1
count = 1
i = 1
ans = last
fixed = False
while i < len(s):
if s[i] == last:
count = count + 1
if count == 2 and (lastCount < 2 or fixed):
... | IMPORT ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR STRING IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER VAR ASSIGN VAR... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | s = input()
s1 = list(s[:2])
for i in range(2, len(s)):
if not s[i] == s[i - 1] == s[i - 2]:
s1.append(s[i])
ans = s1[:3]
if len(ans) >= 3:
for i in range(3, len(s1)):
if not (s1[i] == s1[i - 1] and s1[i - 2] == s1[i - 3]):
ans += s1[i]
else:
s1[i] = "!"
for i in ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER ... |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | from sys import stdin
input = stdin.readline
def typo(s):
ans = ""
for i in s:
try:
if ans[-1] == ans[-2] == i:
continue
if ans[-1] == i and ans[-2] == ans[-3] and ans[-2] != i:
continue
except:
pass
ans += i
retu... | ASSIGN VAR VAR FUNC_DEF ASSIGN VAR STRING FOR VAR VAR IF VAR NUMBER VAR NUMBER VAR IF VAR NUMBER VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR VAR RETURN VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR |
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | s = input()
def encode(s):
enc = []
i = 0
n = len(s)
curChar = s[i]
count = 0
while i < n:
if s[i] == curChar:
count += 1
else:
enc.append(curChar)
enc.append(count)
curChar = s[i]
count = 1
i += 1
enc.appe... | ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR RETURN... |
This is the hard version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.
You are given a binary table of size n × m. This table consists of symbols 0 and 1.
You can make such operat... | 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... |
This is the hard version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.
You are given a binary table of size n × m. This table consists of symbols 0 and 1.
You can make such operat... | from sys import stdin, stdout
def solve(x, y):
c = 0
for i in range(x, x + 2):
for j in range(y, y + 2):
if s[i][j] == "1":
c += 1
if c == 0:
return 1
if c == 4 or c == 3:
aux = []
z = 0
for i in range(x, x + 2):
for j in ... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR STRING VAR NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMB... |
This is the hard version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.
You are given a binary table of size n × m. This table consists of symbols 0 and 1.
You can make such operat... | import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
n, m = map(int, input().split())
A = [list(map(int, list(input().strip()))) for i in range(n)]
ANS = []
for i in range(n - 2):
for j in range(m - 1):
if A[i][j] == 1 and A[i][j + 1] == 1:
A... | 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 VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL... |
This is the hard version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.
You are given a binary table of size n × m. This table consists of symbols 0 and 1.
You can make such operat... | def flip(x, y):
global mat
if mat[x][y]:
mat[x][y] = 0
else:
mat[x][y] = 1
def func(x1, y1, x2, y2):
global mat, k
ones, z = [], []
if mat[x1][y1] == 1:
ones.append((x1 + 1, y1 + 1))
else:
z.append((x1 + 1, y1 + 1))
if mat[x2][y1] == 1:
ones.appe... | FUNC_DEF IF VAR VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER FUNC_DEF ASSIGN VAR VAR LIST LIST IF VAR VAR VAR NUMBER 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 VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER E... |
This is the hard version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.
You are given a binary table of size n × m. This table consists of symbols 0 and 1.
You can make such operat... | import sys
readline = sys.stdin.readline
T = int(readline())
Ans = []
for qu in range(T):
N, M = map(int, readline().split())
ans = []
G = [list(map(int, readline().strip())) for _ in range(N)]
for i in range(N - 2):
for j in range(M - 1):
if G[i][j]:
ans.append(f"{i... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CA... |
This is the hard version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.
You are given a binary table of size n × m. This table consists of symbols 0 and 1.
You can make such operat... | t = int(input())
for _ in range(t):
n, m = map(int, input().split())
a = [list(map(int, input())) for i in range(n)]
def add(x, y, z):
a[x[0]][x[1]] ^= 1
a[y[0]][y[1]] ^= 1
a[z[0]][z[1]] ^= 1
ans.append(" ".join(map(lambda x: str(x + 1), (*x, *y, *z))))
ans = []
for... | 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 VAR VAR FUNC_CALL VAR VAR FUNC_DEF VAR VAR NUMBER VAR NUMBER NUMBER VAR VAR NUMBER VAR NUMBER NUMBER VAR VAR NUMBER VAR NUMBER NUMBER EXPR FUNC_C... |
This is the hard version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.
You are given a binary table of size n × m. This table consists of symbols 0 and 1.
You can make such operat... | import sys
input = sys.stdin.readline
testcase = int(input())
def op(s):
if s == "1":
return "0"
else:
return "1"
for _ in range(testcase):
h, w = map(int, input().split())
grid = [list(input().rstrip()) for i in range(h)]
ans = []
for i in range(h - 2):
for j in ran... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF VAR STRING RETURN STRING RETURN STRING 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 FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBE... |
This is the hard version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.
You are given a binary table of size n × m. This table consists of symbols 0 and 1.
You can make such operat... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n, m = map(int, input().split())
table = [list(map(int, list(input().strip()))) for _ in range(n)]
def add(a, b, c):
table[a[0]][a[1]] = 1 - table[a[0]][a[1]]
table[b[0]][b[1]] = 1 - table[b[0]][b[1]]
table[c... | 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 VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR NUMBER VAR NUMBER BIN_OP NUMBER VAR VAR NUMBER VA... |
This is the hard version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.
You are given a binary table of size n × m. This table consists of symbols 0 and 1.
You can make such operat... | import sys
from itertools import permutations
input = lambda: sys.stdin.readline().rstrip("\r\n")
def countSet(arr):
n = len(arr)
m = len(arr[0])
cnt = 0
for i in range(n):
for j in range(m):
if arr[i][j] == 1:
cnt += 1
return cnt
def applyInPlace(grid, igrid... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF IF VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP NUMBER VAR VAR VAR I... |
This is the hard version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.
You are given a binary table of size n × m. This table consists of symbols 0 and 1.
You can make such operat... | import sys
def minp():
return sys.stdin.readline().strip()
def mint():
return int(minp())
def mints():
return map(int, minp().split())
def solve():
n, m = mints()
a = [list(map(int, minp())) for i in range(n)]
ans = []
for i in range(n - 2):
l = a[i]
ll = a[i + 1]
... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBE... |
This is the hard version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.
You are given a binary table of size n × m. This table consists of symbols 0 and 1.
You can make such operat... | t = int(input())
def countone(i, j):
count = 0
ans = []
if arr[i][j] == "1":
count += 1
ans.append(i + 1)
ans.append(j + 1)
if arr[i + 1][j] == "1":
count += 1
ans.append(i + 2)
ans.append(j + 1)
if arr[i][j + 1] == "1":
count += 1
an... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST IF VAR VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR... |
This is the hard version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.
You are given a binary table of size n × m. This table consists of symbols 0 and 1.
You can make such operat... | import sys
Z = sys.stdin.readline
O = []
def S(q, x, y):
s = sum(sum(i) for i in q)
v = [
(x, y, x + 1, y, x, y + 1),
(x, y, x + 1, y + 1, x, y + 1),
(x, y, x + 1, y, x + 1, y + 1),
(x + 1, y + 1, x + 1, y, x, y + 1),
]
if s > 3:
return v
if s > 2:
... | IMPORT ASSIGN VAR VAR ASSIGN VAR LIST FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_... |
This is the hard version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.
You are given a binary table of size n × m. This table consists of symbols 0 and 1.
You can make such operat... | s, res = [], []
def solve1(x, y, c1, c2, c3, c4):
if c1 == "1":
res.append([x, y, x, y + 1, x + 1, y])
solve2(x, y, "0", "1", "1", "0")
elif c2 == "1":
res.append([x, y, x, y + 1, x + 1, y])
solve2(x, y, "1", "0", "1", "0")
elif c3 == "1":
res.append([x, y, x, y + 1... | ASSIGN VAR VAR LIST LIST FUNC_DEF IF VAR STRING EXPR FUNC_CALL VAR LIST VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR STRING STRING STRING STRING IF VAR STRING EXPR FUNC_CALL VAR LIST VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR STRING STRING STRING STR... |
This is the hard version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.
You are given a binary table of size n × m. This table consists of symbols 0 and 1.
You can make such operat... | for _ in range(0, int(input())):
n, m = map(int, input().split())
mat = [[char for char in input()] for _ in range(0, n)]
answer = []
def update(changes):
answer.append((changes[0], changes[1], changes[2]))
for x, y in changes:
if mat[x][y] == "0":
mat[x][y] ... | FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR LIST FUNC_DEF EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER FOR VAR VAR VAR IF VAR VAR VAR STRING ASSIGN VAR VAR VAR STRING ASS... |
This is the hard version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.
You are given a binary table of size n × m. This table consists of symbols 0 and 1.
You can make such operat... | import sys
input = sys.stdin.readline
def main():
n, m = map(int, input().split())
alst = [list(input().strip()) for _ in range(n)]
rev = {"1": "0", "0": "1"}
ans = []
for i in range(n - 2):
for j in range(m - 2):
if alst[i][j] == "1":
alst[i][j] = "0"
... | 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 FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT STRING STRING STRING STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR STRING... |
This is the hard version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.
You are given a binary table of size n × m. This table consists of symbols 0 and 1.
You can make such operat... | from sys import stdin
def c(x1, y1, x2, y2, x3, y3):
ans.append((x1 + 1, y1 + 1, x2 + 1, y2 + 1, x3 + 1, y3 + 1))
a[x1][y1] ^= 1
a[x2][y2] ^= 1
a[x3][y3] ^= 1
return
tt = int(stdin.readline())
for loop in range(tt):
n, m = map(int, stdin.readline().split())
a = []
ans = []
for i ... | FUNC_DEF EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR NUMBER RETURN 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 VA... |
Recently Polycarpus has learned the "bitwise AND" operation (which is also called "AND") of non-negative integers. Now he wants to demonstrate the school IT teacher his superb manipulation with the learned operation.
For that Polycarpus came to school a little earlier and wrote on the board a sequence of non-negative ... | n = int(input())
p = [0] * n
for i in range(n):
t = list(map(int, input().split()))
t.pop(i)
s = 0
for j in t:
s |= j
p[i] = s
print(" ".join(map(str, p))) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR |
Recently Polycarpus has learned the "bitwise AND" operation (which is also called "AND") of non-negative integers. Now he wants to demonstrate the school IT teacher his superb manipulation with the learned operation.
For that Polycarpus came to school a little earlier and wrote on the board a sequence of non-negative ... | n = int(input())
a = []
for i in range(n):
a.append(list(map(int, input().split())))
ans = [0] * n
for i in range(n):
for j in range(n):
if j != i:
ans[i] |= a[i][j]
print(ans[i], end=" ") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING |
Recently Polycarpus has learned the "bitwise AND" operation (which is also called "AND") of non-negative integers. Now he wants to demonstrate the school IT teacher his superb manipulation with the learned operation.
For that Polycarpus came to school a little earlier and wrote on the board a sequence of non-negative ... | n = int(input())
a = [0] * n
for i in range(n):
for x in map(int, input().split()):
if x != -1:
a[i] |= x
print(*a) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Recently Polycarpus has learned the "bitwise AND" operation (which is also called "AND") of non-negative integers. Now he wants to demonstrate the school IT teacher his superb manipulation with the learned operation.
For that Polycarpus came to school a little earlier and wrote on the board a sequence of non-negative ... | n = int(input())
A = [0] * n
ans = [0] * n
for i in range(n):
A[i] = list(map(int, input().split()))
for j in range(n):
if j == i:
continue
ans[i] |= A[i][j]
for i in range(n):
print(ans[i], " ", end="") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING... |
Recently Polycarpus has learned the "bitwise AND" operation (which is also called "AND") of non-negative integers. Now he wants to demonstrate the school IT teacher his superb manipulation with the learned operation.
For that Polycarpus came to school a little earlier and wrote on the board a sequence of non-negative ... | n = int(input())
if n == 1:
print(0)
else:
m = [[0] * n] * n
a = [int(0)] * n
for i in range(0, n):
m[i] = input().split()
a[i] = int(m[i][(i + 1) % n])
for j in range(0, n):
if j != i:
a[i] = a[i] | int(m[i][j])
for i in range(0, n):
print... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST BIN_OP LIST NUMBER VAR VAR ASSIGN VAR BIN_OP LIST FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR FOR V... |
Recently Polycarpus has learned the "bitwise AND" operation (which is also called "AND") of non-negative integers. Now he wants to demonstrate the school IT teacher his superb manipulation with the learned operation.
For that Polycarpus came to school a little earlier and wrote on the board a sequence of non-negative ... | n = int(input())
if n > 1:
p = [0] * n
r = format(n - 1, "b")[::-1]
l = len(r) - 1
for i in range(n):
t = list(map(int, input().split()))
t.pop(i)
s = 0
for j in range(l):
if r[j] == "1":
s |= t.pop()
t = [(t[k] | t[k + 1]) for k in... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER STRING NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | def convert(arr, m):
res = []
for val in arr:
num = 1
while val % m == 0:
val //= m
num *= m
if len(res) > 0 and res[-1][0] == val:
res[-1][1] += num
else:
res.append([val, num])
return res
for i in range(int(input())):
n,... | FUNC_DEF ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER VAR VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER NUMBER VAR VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR LIST VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | def solve():
n, m = map(int, input().split())
arr = list(map(int, input().split()))
k = int(input())
brr = list(map(int, input().split()))
crr = []
for num in arr:
temp = num
while num % m == 0:
num //= m
ext = 0
if len(crr) > 0 and crr[-1][0] == num:
... | 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 FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR VAR WHILE BIN_OP VAR VAR NUMBER VAR VAR AS... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | for _ in range(int(input())):
n, m = map(int, input().split())
a = list(map(int, input().split()))
k = int(input())
b = list(map(int, input().split()))
cpt = 0
crem = a[0]
ok = True
mstep = a.copy()
ac = [None] * n
bc = [None] * k
for i in range(n):
q = divmod(mstep[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 FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | def main():
for _ in range(int(input())):
n, m = map(int, input().split())
a = list(map(int, input().split()))
k = int(input())
b = list(map(int, input().split()))
aa, bb = [], []
for i in range(n):
c = 1
while a[i] % m == 0:
a[... | 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 FUNC_CALL 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 ASSIGN VAR VAR LIST LIST FOR VA... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | t = int(input())
for jkjk in range(t):
n, m = tuple(map(int, input().split()))
arr = list(map(int, input().split()))
k = int(input())
b = list(map(int, input().split()))
a_mod = []
b_mod = []
for i in range(len(arr)):
p = 1
while arr[i] % m == 0:
arr[i] = arr[i] /... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR ... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | def f(arr, n, m):
ar = []
for i in range(n):
p = 1
x = arr[i]
while x % m == 0:
x = x // m
p *= m
tm = [x, p]
ar.append(tm)
li = []
i = 0
while i < len(ar):
li.append(ar[i])
j = i + 1
while j < len(ar) and ar[i][... | FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR LIST VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | import sys
input = sys.stdin.readline
def solve():
n, m = map(int, input().split())
A = list(map(int, input().split()))
k = int(input())
B = list(map(int, input().split()))
if abs(n - k) % (m - 1) > 0:
return "No"
arr1 = []
arr2 = []
for i in range(n):
v1 = A[i]
... | 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER NU... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | def cal(n, a, m):
c, d = [], []
for i in range(n):
e = 1
while a[i] % m == 0:
a[i] //= m
e *= m
if len(c) == len(d) and len(d) == 0 or c[len(c) - 1] != a[i]:
c.append(a[i])
d.append(e)
else:
d[len(d) - 1] += e
return... | FUNC_DEF ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR NUMBER VAR VAR VAR VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUM... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | def reduce(l, m):
d = []
last = l[0]
c = 1
for i in l[1:]:
if i != last:
d.append([last, c])
last = i
c = 1
else:
c += 1
d.append([last, c])
for i in range(len(d)):
while d[i][0] % m == 0:
d[i] = [d[i][0] // m, d... | FUNC_DEF ASSIGN VAR LIST ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR WHILE BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR LIST BIN_OP VAR VAR NUM... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | def listbreak(x, m):
nt = 1
while x % m == 0:
x //= m
nt *= m
return [x, nt]
t = int(input())
for _ in range(t):
n1, m = map(int, input().split())
a = list(map(int, input().split()))
n2 = int(input())
b = list(map(int, input().split()))
na, nb = [listbreak(a[0], m)], [l... | FUNC_DEF ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER VAR VAR VAR VAR RETURN LIST 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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR A... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | for _ in range(int(input())):
na, x = map(int, input().split())
a = (*map(int, input().split()),)
nb = int(input())
b = (*map(int, input().split()),)
x_to_the = [1]
mx = max(max(a), max(b))
while x_to_the[-1] <= mx:
x_to_the.append(x_to_the[-1] * x)
m = len(x_to_the)
A = [[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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FU... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | t = int(input())
def my_reduce(s, m):
extras = []
for k in s:
time = 1
while k % m == 0:
time *= m
k /= m
time = max(time, 1)
extras += [[int(k), time]]
i = 1
typer = extras[0][0]
prev = 0
while i < len(extras):
if extras[i][0] ==... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR LIST LIST FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | for _ in range(int(input())):
n, m = map(int, input().split())
a = [[1, int(x)] for x in input().split()]
k = int(input())
b = [[1, int(x)] for x in input().split()]
while True:
while a and b and a[-1][1] == b[-1][1]:
t = min(a[-1][0], b[-1][0])
a[-1][0] -= t
... | 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 NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR WHILE NUMBER WHILE VAR VAR VAR NUMBE... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | T = int(input())
for i in range(T):
n, m = list(map(int, input().split()))
arr = list(map(int, input().split()))
arr_2 = arr.copy()
k = int(input())
brr = list(map(int, input().split()))
brr_2 = brr.copy()
for i in range(n):
while arr_2[i] % m == 0:
arr_2[i] //= m
for... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL ... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | for _ in range(int(input())):
n, m = map(int, input().split())
a = list(map(int, input().split()))
k = int(input())
b = list(map(int, input().split()))
i = 0
c = [1] * n
while i < n:
if a[i] % m == 0:
temp = a[i] // m
a[i] = temp
c[i] = c[i] * 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 FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | def mi():
return map(int, input().split())
def li():
return list(mi())
def si():
return str(input())
def ni():
return int(input())
def find(x, m):
count = 0
while x % m == 0:
count += 1
x //= m
return x, m**count
def check(a, m):
new = [[0, 0]]
for i in a:
... | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER VAR NUMBER VAR VAR RETURN VAR BIN_OP VAR VAR FUNC_DEF ASSIGN VAR LIST LIST ... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | def spread(num):
times = 0
while num % m == 0:
times += 1
num = int(num / m)
return num, m**times
def append(arr, x, times=1):
if not arr or arr[-1][0] != x:
arr.append([x, times])
else:
arr[-1][1] += times
def flatten(a):
new_a = []
for x in a:
if... | FUNC_DEF ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR RETURN VAR BIN_OP VAR VAR FUNC_DEF NUMBER IF VAR VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR NUMBER NUMBER VAR FUNC_DEF ASSIGN VAR LIST FOR VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VA... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | t = int(input())
for _ in range(t):
n, m = [int(x) for x in input().split()]
a0 = [int(x) for x in input().split()]
k = int(input())
b0 = [int(x) for x in input().split()]
a = []
b = []
for i in range(n):
q = a0[i]
j = 1
while q % m == 0:
j *= m
... | 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 FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR F... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | t = int(input())
for _ in range(t):
n, m = map(int, input().split())
arra = list(map(int, input().split()))
k = map(int, input().split())
arrb = list(map(int, input().split()))
v = []
for q in [arra, arrb]:
r = []
for i in q:
tms = 1
vl = i
whi... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR ... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | def int_input():
a = int(input())
return a
def int_list_input():
a = list(map(int, input().split()))
return a
def expand(a, m):
b = []
for i in a:
x = i
while x % m == 0:
x = x // m
if b and b[-1][0] == x:
b[-1][1] += i // x
else:
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR RETURN VAR FUNC_DEF ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR VAR WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR NUMBER NUMBER VAR VAR NUMBER NUMBER BIN_OP VAR VAR EXPR F... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | t = int(input())
for _ in range(t):
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
k = int(input())
b = list(map(int, input().split()))
fl = True
pointer_n, pointer_k = 0, 0
while pointer_n < n and pointer_k < k:
if a[pointer_n] == b[pointer_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 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 ASSIGN VAR ... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | t = int(input())
for _ in range(t):
n, m = map(int, input().split())
lst = list(map(int, input().split()))
nls = []
top = -1
for i in lst:
cnt = 1
while i % m == 0:
i //= m
cnt *= m
if nls and nls[top][0] == i:
nls[top][1] += cnt
el... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER VAR VAR VAR VAR IF VAR VAR VAR NUMBER V... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | def expand(a, m):
b = []
for x in a:
t = x
while t % m == 0:
t //= m
if b and b[-1][0] == t:
b[-1][1] += x // t
else:
b.append([t, x // t])
return b
for _ in range(int(input())):
_, m = map(int, input().split())
a = map(int, input... | FUNC_DEF ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR VAR WHILE BIN_OP VAR VAR NUMBER VAR VAR IF VAR VAR NUMBER NUMBER VAR VAR NUMBER NUMBER BIN_OP VAR VAR EXPR FUNC_CALL VAR LIST VAR BIN_OP VAR VAR RETURN 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 VA... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | def newList(nums, m, newnums):
for num in nums:
x = num
while x % m == 0:
x //= m
if not newnums or newnums[-1][0] != x:
newnums.append([x, num // x])
else:
newnums[-1][1] += num // x
return newnums
for _ in range(int(input())):
n, m = ma... | FUNC_DEF FOR VAR VAR ASSIGN VAR VAR WHILE BIN_OP VAR VAR NUMBER VAR VAR IF VAR VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR LIST VAR BIN_OP VAR VAR VAR NUMBER NUMBER BIN_OP VAR VAR RETURN 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 ... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | def decom(a, m):
c = 1
while a % m == 0:
a = a // m
c = c * m
return a, c
for time in range(int(input())):
t, m = map(int, input().split())
a = [int(k) for k in input().split()]
t = input()
b = [int(k) for k in input().split()]
arep = [], []
brep = [], []
for j ... | FUNC_DEF ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN 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 VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VA... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | t = int(input())
for tt in range(t):
n, m = map(int, input().split())
a = list(map(int, input().split()))
k = int(input())
b = list(map(int, input().split()))
a1 = []
for i in range(n):
q = a[i]
x = 1
while q % m == 0:
x *= m
q //= m
a1 += ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR F... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | import sys
def solve1(a, m):
r = []
for x in a:
z = 1
while x % m == 0:
z *= m
x //= m
if r and r[-1][0] == x:
r[-1][1] += z
else:
r.append([x, z])
return r
def solve():
inp = sys.stdin.readline
n, m = map(int, inp()... | IMPORT FUNC_DEF ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER VAR VAR VAR VAR IF VAR VAR NUMBER NUMBER VAR VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR LIST VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ... |
Fishingprince is playing with an array $[a_1,a_2,\dots,a_n]$. He also has a magic number $m$.
He can do the following two operations on it:
Select $1\le i\le n$ such that $a_i$ is divisible by $m$ (that is, there exists an integer $t$ such that $m \cdot t = a_i$). Replace $a_i$ with $m$ copies of $\frac{a_i}{m}$. The... | for _ in range(int(input())):
n, m = map(int, input().split())
a = list(map(int, input().split()))
k = int(input())
b = list(map(int, input().split()))
def expand(arr, z):
e = []
for x in arr:
c = 1
while x % z == 0:
c *= z
x =... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST FOR VAR VAR ASS... |
Email address in Berland is a string of the form A@B, where A and B are arbitrary strings consisting of small Latin letters.
Bob is a system administrator in «Bersoft» company. He keeps a list of email addresses of the company's staff. This list is as a large string, where all addresses are written in arbitrary order... | a = input()
b = a.split("@")
ans = []
flag = True
for i in b[1:-1]:
if len(i) < 2:
flag = False
break
if len(b) < 2:
flag = False
if b[0] and b[-1] and flag:
ind = 0
index_list = []
str_len = len(a)
temp = ""
j = 0
ans = []
while j != str_len:
temp += a[j]
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR NUMBER NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING A... |
Email address in Berland is a string of the form A@B, where A and B are arbitrary strings consisting of small Latin letters.
Bob is a system administrator in «Bersoft» company. He keeps a list of email addresses of the company's staff. This list is as a large string, where all addresses are written in arbitrary order... | entrada = input()
salida = ""
lista = []
pos = -1
ultimapos = -1
rip = 0
for x in entrada:
pos += 1
if x == "@":
lista.append(pos)
if (
len(entrada) < 3
or len(lista) == 0
or lista[0] == 0
or lista[-1] == len(entrada) - 1
):
print("No solution")
else:
for i in range(len(lista)):
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR NUMBER IF VAR STRING EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER NUMBER VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR... |
Email address in Berland is a string of the form A@B, where A and B are arbitrary strings consisting of small Latin letters.
Bob is a system administrator in «Bersoft» company. He keeps a list of email addresses of the company's staff. This list is as a large string, where all addresses are written in arbitrary order... | ans, capt = [], ""
for x in input():
if x == "@":
if capt and capt[-1] != "@":
capt += x
else:
ans = []
break
elif capt and capt[-1] == "@":
ans.append(capt + x)
capt = ""
else:
capt += x
if ans:
ans[-1] += capt
print(",".jo... | ASSIGN VAR VAR LIST STRING FOR VAR FUNC_CALL VAR IF VAR STRING IF VAR VAR NUMBER STRING VAR VAR ASSIGN VAR LIST IF VAR VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR STRING VAR VAR IF VAR VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR STRING |
Email address in Berland is a string of the form A@B, where A and B are arbitrary strings consisting of small Latin letters.
Bob is a system administrator in «Bersoft» company. He keeps a list of email addresses of the company's staff. This list is as a large string, where all addresses are written in arbitrary order... | import sys
email_string = sys.stdin.readline().strip()
n_characters_before_at, cur_string, all_emails = 0, "", []
found_at = False
i = 0
if email_string[-1] == "@":
print("No solution")
sys.exit(0)
while i < len(email_string):
if email_string[i] == "@":
found_at = True
if n_characters_befor... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER STRING LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER V... |
Email address in Berland is a string of the form A@B, where A and B are arbitrary strings consisting of small Latin letters.
Bob is a system administrator in «Bersoft» company. He keeps a list of email addresses of the company's staff. This list is as a large string, where all addresses are written in arbitrary order... | s = input()
au = [pos for pos, char in enumerate(s) if char == "@"]
dis = [(au[i + 1] - au[i]) for i in range(len(au) - 1)]
dis = [(1) for i in dis if i <= 2]
if len(au) == 0 or au[0] == 0 or au[-1] == len(s) - 1 or sum(dis) > 0:
print("No solution")
elif len(au) == 1:
print(s)
else:
res = []
i = 0
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER VAR NUMBER NUMBER VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR N... |
Email address in Berland is a string of the form A@B, where A and B are arbitrary strings consisting of small Latin letters.
Bob is a system administrator in «Bersoft» company. He keeps a list of email addresses of the company's staff. This list is as a large string, where all addresses are written in arbitrary order... | A = input().split("@")
if len(A[0]) == 0 or len(A[-1]) == 0 or any([(len(x) < 2) for x in A[1:-1]]):
print("No solution")
elif len(A) == 1:
print("No solution")
elif len(A) == 2:
print("@".join(A))
else:
result = [A[0] + "@" + A[1][0]]
for i in range(1, len(A) - 2):
result += [A[i][1:] + "@"... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR NUMBER NUMBER FUNC_CALL VAR VAR NUMBER NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING VAR AS... |
Email address in Berland is a string of the form A@B, where A and B are arbitrary strings consisting of small Latin letters.
Bob is a system administrator in «Bersoft» company. He keeps a list of email addresses of the company's staff. This list is as a large string, where all addresses are written in arbitrary order... | import sys
def main():
str = input()
dogs = []
cnt = 0
n = len(str)
for i in range(n):
if str[i] == "@":
cnt += 1
dogs.append(i)
ok = 1
k = len(dogs)
for i in range(k - 1):
if dogs[i + 1] - dogs[i] < 3:
ok = 0
break
if... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER VAR VAR NUMBER ASSI... |
Email address in Berland is a string of the form A@B, where A and B are arbitrary strings consisting of small Latin letters.
Bob is a system administrator in «Bersoft» company. He keeps a list of email addresses of the company's staff. This list is as a large string, where all addresses are written in arbitrary order... | string = input()
lst = string.split("@")
if len(lst) == 1:
print("No solution")
exit()
middle = lst[1:-1]
if not (lst[0].isalpha() and lst[-1].isalpha()):
print("No solution")
exit()
if len(lst) == 2:
print(string)
exit()
if not all(list(map(lambda x: len(x) > 1 and x.isalpha(), middle))):
p... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER IF FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR I... |
Email address in Berland is a string of the form A@B, where A and B are arbitrary strings consisting of small Latin letters.
Bob is a system administrator in «Bersoft» company. He keeps a list of email addresses of the company's staff. This list is as a large string, where all addresses are written in arbitrary order... | p = input()
s = p.split("@")
ans = ""
ans2 = []
if p.count("@") == 0:
print("No solution")
else:
for j in range(1, len(s) - 1):
if len(s[j]) <= 1:
ans = "No solution"
if s[0] == "" or s[-1] == "":
ans = "No solution"
if ans != "":
print(ans)
else:
email = ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR LIST IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR STRING IF VAR NUMBER STRING VAR NUMBER STRING ASSIGN VAR STRING IF V... |
Email address in Berland is a string of the form A@B, where A and B are arbitrary strings consisting of small Latin letters.
Bob is a system administrator in «Bersoft» company. He keeps a list of email addresses of the company's staff. This list is as a large string, where all addresses are written in arbitrary order... | lista = input().split("@")
ver = True
if len(lista) < 2:
ver = False
for i in range(1, len(lista) - 1):
if len(lista[i]) < 2:
ver = False
break
lista[i] = lista[i][0] + "," + lista[i][1:]
if not lista[0] or not lista[-1] or not ver:
print("No solution")
else:
print("@".join(lista)) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR NUMBER STRING VAR VAR NUMBER IF VAR NUMBER VAR NUMBER VAR EXPR FUN... |
Email address in Berland is a string of the form A@B, where A and B are arbitrary strings consisting of small Latin letters.
Bob is a system administrator in «Bersoft» company. He keeps a list of email addresses of the company's staff. This list is as a large string, where all addresses are written in arbitrary order... | s = input()
l = []
n = len(s)
if s[n - 1] == "@" or s[0] == "@":
print("No solution")
else:
flag = 0
d = 0
e = 0
for i in range(n):
l.append(0)
for i in range(n):
if s[i] == "@":
l[i] = l[i] + 1
e = 1
for i in range(n):
if flag == 0 and l[i] > ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR BIN_OP VA... |
Email address in Berland is a string of the form A@B, where A and B are arbitrary strings consisting of small Latin letters.
Bob is a system administrator in «Bersoft» company. He keeps a list of email addresses of the company's staff. This list is as a large string, where all addresses are written in arbitrary order... | s = input()
a = s.split("@")
n = len(a)
valid = True
if n == 1:
valid = False
username = []
host = []
for i in range(n):
if len(a[i]) == 0:
valid = False
break
if i == 0:
username.append(a[i])
elif i == n - 1:
host.append(a[i])
else:
if len(a[i]) < 2:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR BIN_OP VAR NUMBER EXPR FUNC_... |
Email address in Berland is a string of the form A@B, where A and B are arbitrary strings consisting of small Latin letters.
Bob is a system administrator in «Bersoft» company. He keeps a list of email addresses of the company's staff. This list is as a large string, where all addresses are written in arbitrary order... | s = input().split("@")
if len(s) > 1 and s[0] and s[-1] and min(map(len, s[1:-1] + ["__"])) > 1:
for i in range(1, len(s) - 1):
s[i] = s[i][0] + "," + s[i][1:]
print("@".join(s))
else:
print("No solution") | ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER LIST STRING NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR NUMBER STRING VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_C... |
Email address in Berland is a string of the form A@B, where A and B are arbitrary strings consisting of small Latin letters.
Bob is a system administrator in «Bersoft» company. He keeps a list of email addresses of the company's staff. This list is as a large string, where all addresses are written in arbitrary order... | n = input()
n = n.strip()
naslovi = []
try:
pos = True
A = ""
i = 0
while i < len(n):
if n[i] == "@":
if len(A) != 0:
A += n[i]
if n[i + 1] != "@":
A += n[i + 1]
naslovi.append(A)
A = ""
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF FUNC_CALL VAR VAR NUMBER VAR VAR VAR IF VAR BIN_OP VAR NUMBER STRING VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR BIN_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.