description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Nadeko's birthday is approaching! As she decorated the room for the party, a long garland of Dianthus-shaped paper pieces was placed on a prominent part of the wall. Brother Koyomi will like it!
Still unsatisfied with the garland, Nadeko decided to polish it again. The garland has n pieces numbered from 1 to n from le... | n = int(input())
s = input()
dp = [([-1] * (n + 1)) for x in range(26)]
for c in range(26):
for l in range(n):
n_c = 0
for r in range(l, n):
if s[r] == chr(ord("a") + c):
n_c += 1
dp[c][r - l + 1 - n_c] = max(dp[c][r - l + 1 - n_c], r - l + 1)
all_res = []
for... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR STRING VAR VAR NUMBER ASSIGN VAR V... |
Nadeko's birthday is approaching! As she decorated the room for the party, a long garland of Dianthus-shaped paper pieces was placed on a prominent part of the wall. Brother Koyomi will like it!
Still unsatisfied with the garland, Nadeko decided to polish it again. The garland has n pieces numbered from 1 to n from le... | import sys
input = sys.stdin.buffer.readline
n = int(input())
s = str(input().strip())[2:-1]
ans = [([0] * (n + 1)) for i in range(26)]
segs = [[[0, -1]] for i in range(26)]
for i in range(n):
c = ord(s[i]) - ord("a")
if i > 0 and s[i] != s[i - 1]:
segs[c].append([i, i])
else:
segs[c][-1][1... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR V... |
Nadeko's birthday is approaching! As she decorated the room for the party, a long garland of Dianthus-shaped paper pieces was placed on a prominent part of the wall. Brother Koyomi will like it!
Still unsatisfied with the garland, Nadeko decided to polish it again. The garland has n pieces numbered from 1 to n from le... | from sys import stdin, stdout
def main():
n = int(stdin.readline())
s = stdin.readline()
d = {chr(i): [(0) for j in range(n + 1)] for i in range(97, 123)}
for i in range(97, 123):
for j in range(n):
dp = 1 if s[j] == chr(i) else 0
d[chr(i)][1 - dp] = max(d[chr(i)][1 - d... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR B... |
Nadeko's birthday is approaching! As she decorated the room for the party, a long garland of Dianthus-shaped paper pieces was placed on a prominent part of the wall. Brother Koyomi will like it!
Still unsatisfied with the garland, Nadeko decided to polish it again. The garland has n pieces numbered from 1 to n from le... | import sys
n = int(sys.stdin.readline().strip())
s = sys.stdin.readline().strip()
ans = [([-1] * (n + 1)) for x in range(26)]
for c in range(26):
for l in range(n):
nrOfC = 0
for r in range(l, n):
if s[r] == chr(97 + c):
nrOfC += 1
ans[c][r - l + 1 - nrOfC] =... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR FUNC_CALL VAR BIN_OP NUMBER VAR VAR NUMBER... |
Nadeko's birthday is approaching! As she decorated the room for the party, a long garland of Dianthus-shaped paper pieces was placed on a prominent part of the wall. Brother Koyomi will like it!
Still unsatisfied with the garland, Nadeko decided to polish it again. The garland has n pieces numbered from 1 to n from le... | from sys import stdin
n = int(stdin.readline())
s = list(stdin.readline())[:-1]
cnt = [([0] * 26) for i in range(n + 1)]
for j in range(26):
x = chr(j + 97)
for i in range(n):
if s[i] == x:
cnt[i + 1][j] += 1
for i in range(1, n + 1):
cnt[i][j] += cnt[i - 1][j]
d = [([0] * (n + ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CAL... |
Nadeko's birthday is approaching! As she decorated the room for the party, a long garland of Dianthus-shaped paper pieces was placed on a prominent part of the wall. Brother Koyomi will like it!
Still unsatisfied with the garland, Nadeko decided to polish it again. The garland has n pieces numbered from 1 to n from le... | import sys
input = sys.stdin.readline
N = int(input())
S = list(map(lambda x: ord(x) - ord("a"), list(input())[:-1]))
res = [([0] * (N + 1)) for _ in range(26)]
for c in range(26):
for l in range(N):
x = 0
for r in range(l + 1, N + 1):
x += S[r - 1] != c
res[c][x] = max(res[... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR ... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | def calc(l, r):
global max_diff
diff = 0
while l >= 0 and r < n:
diff += A[l] * (B[r] - B[l]) + A[r] * (B[l] - B[r])
max_diff = max(max_diff, diff)
l -= 1
r += 1
n = int(input())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))
res = sum(a * b for a... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER 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... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans, final = 0, 0
for i in range(n):
ans += a[i] * b[i]
temp = ans
final = ans
for i in range(n - 1):
ans = temp
left = i
right = i + 1
while left >= 0 and right <= n - 1:
ans += (a[left] - a[right]) * (... | 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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NU... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | import sys
def get_ints():
return list(map(int, sys.stdin.readline().strip().split()))
N = int(input())
A = get_ints()
B = get_ints()
total = 0
for i in range(N):
total += A[i] * B[i]
ans = total
for i in range(N):
x, y = i - 1, i + 1
temp_total = total
while 0 <= x < N and 0 <= y < N:
t... | IMPORT FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMB... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | t = 1
for i in range(t):
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
ans = 0
temp = 0
for i in range(n):
temp += a[i] * b[i]
ans = temp
temp1 = temp
for i in range(n):
x = i - 1
y = i + 1
temp = temp1
... | ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR 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 VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FOR ... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = sum([(a[i] * b[i]) for i in range(n)])
def go(l, r):
diff = 0
mx = 0
while l >= 0 and r < n:
diff += a[l] * (b[r] - b[l])
diff += a[r] * (b[l] - b[r])
mx = max(mx, diff)
l -= 1
... | 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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR VAR BIN... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | import sys
input = sys.stdin.readline
def solve():
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
init = 0
for i in range(n):
init += a[i] * b[i]
dp1 = [(0) for j in range(n)]
dp2 = [(0) for j in range(n)]
m = 0
for i in range(1, n... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIG... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | n = int(input())
a = [0] * 5111
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
pre = [0] * 5111
suf = [0] * 5111
for i in range(n):
if i == 0:
pre[i] = a[i] * b[i]
else:
pre[i] = pre[i - 1] + a[i] * b[i]
for j in range(n - 1, -1, -1):
suf[j] = suf[j + 1] + a[... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL ... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | from sys import stdin
input = stdin.readline
_int = lambda: int(input())
_mult = lambda: map(int, input().split())
_list = lambda: list(map(int, input().split()))
def solve():
n = _int()
a = _list()
b = _list()
ans = 0
org = 0
for i in range(n):
org += a[i] * b[i]
ans = org
fo... | ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
prod = m = sum(a[i] * b[i] for i in range(n))
for i in range(n):
def g(l, r=i + 1, d=prod):
global m
while l >= 0 and r < n:
d = d - (a[l] - a[r]) * (b[l] - b[r])
m = max(m, d)
... | 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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FUNC_DEF BIN_OP VAR NUMBER VAR WHILE VAR NUMBER... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
cum = 0
for a, b in zip(A, B):
cum += a * b
ans = cum
for i in range(n):
count = cum
for j in range(1, min(i, n - 1 - i) + 1):
count += (A[i - j] - A[i + j]) * (B[i + j] - B[i - j])
if ans < count:
... | 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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VA... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | import sys
def solve(N, A, B):
s = 0
for i in range(N):
s += A[i] * B[i]
maxs = s + 0
for i in range(N - 1):
x = s + 0
swaps = min(i + 1, N - i - 1)
for j in range(swaps):
x += (A[i - j] - A[i + j + 1]) * (B[i + j + 1] - B[i - j])
if x > maxs:
... | IMPORT FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR ... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
p = sum([(a[i] * b[i]) for i in range(n)])
rez = p
for i in range(0, n - 1):
x = i
y = i + 1
dx = 0
while x >= 0 and y < n:
dx -= (a[y] - a[x]) * (b[y] - b[x])
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR ... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
base_sum = sum([(a * b) for a, b in zip(a, b)])
max_possible_sum = base_sum
for num in range(1, 2 * n - 2):
if num % 2 == 0:
left = num // 2 - 1
right = num // 2 + 1
else:
left = (num - 1) // 2
... | 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 VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER IF BIN_OP VAR NUMBER ... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | import sys
def I():
return int(sys.stdin.readline().rstrip())
def MI():
return map(int, sys.stdin.readline().rstrip().split())
def LI():
return list(map(int, sys.stdin.readline().rstrip().split()))
def LI2():
return list(map(int, sys.stdin.readline().rstrip()))
def S():
return sys.stdin.re... | IMPORT FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR 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 VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL V... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
num = 0
for i in range(n):
num += a[i] * b[i]
ans = 0
for i in range(1, n - 1):
ruiseki = 0
for j in range(1, min(i, n - 1 - i) + 1):
ruiseki += (a[i - j] - a[i + j]) * (b[... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP ... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | I = lambda: [*map(int, input().split())]
(n,) = I()
a = I()
b = I()
m = p = sum(a[i] * b[i] for i in range(n))
for i in range(n):
def g(l, d=p, r=i + 1):
global m
while l >= 0 and r < n:
d -= (a[l] - a[r]) * (b[l] - b[r])
m = max(m, d)
l -= 1
r += 1
... | ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FUNC_DEF VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR V... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
Base = 0
for i in range(N):
Base += A[i] * B[i]
Ans = Base
for i in range(1, N - 1):
Value = Base
L = i - 1
R = i + 1
while L >= 0 and R < N:
Value += (A[L] - A[R]) * (B[R] - B[L])
L -= 1
... | 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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | import sys
input = sys.stdin.buffer.readline
I = lambda: list(map(int, input().split()))
(n,) = I()
a = I()
b = I()
ans = an = sum(a[i] * b[i] for i in range(n))
for i in range(n):
l = r = i
temp = an
while l >= 0 and r < n:
temp -= (a[l] - a[r]) * (b[l] - b[r])
ans = max(ans, temp)
... | IMPORT ASSIGN VAR 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 ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR WHILE VAR NUMBER VAR V... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = []
S = 0
for i in range(n):
C.append(A[i] * B[i])
S += C[i]
ANS = S
for i in range(n):
XS = S
ANS = max(ANS, XS)
for j in range(i + 1):
if i - j >= 0 and i + j ... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR ... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | n = int(input())
array1 = list(map(int, input().split()))
array2 = list(map(int, input().split()))
totalSum = sum([(array2[i] * array1[i]) for i in range(n)])
maxSum = totalSum
for i in range(n):
start = i
end = i
curSum = totalSum
while start >= 0 and end < n:
curSum += (array1[start] - array1[... | 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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | n = int(input())
a = [*map(int, input().split())]
b = [*map(int, input().split())]
def sum(l1, l2):
x = 0
for i in range(len(l1)):
x += l1[i] * l2[i]
return x
m = s = sum(a, b)
for i in range(n):
for x in (i - 1, i):
temp = s
k = i + 1
while x >= 0 and k < n:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR V... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | def main():
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
def computePref(A, B):
cur = 0
pref = []
for a, b in zip(A, B):
cur += a * b
pref.append(cur)
return pref
pref = computePref(A, B)
suf = ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN V... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | def solvecaso():
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
min = 0
for i in range(n):
min += a[i] * b[i]
max = 0
for i in range(n):
ini = i
fin = ini + 1
accum = 0
while ini >= 0 and fin < n:
a... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN V... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | import sys
def main():
n = int(input())
a = readIntArr()
b = readIntArr()
default = 0
for i in range(n):
default += a[i] * b[i]
def swapDiff(l, r):
return (a[r] - a[l]) * (b[l] - b[r])
maxDelta = 0
for center in range(n):
temp = 0
temp2 = 0
l1,... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NU... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | def readline():
return map(int, input().split())
def main():
n = int(input())
a = list(readline())
b = list(readline())
max_diff = 0
for begin in range(n):
for end in (begin, begin + 1):
index_sum = begin + end
diff = 0
for i in range(end, min(n, ind... | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN 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 NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL ... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | def func(l, r, d):
global ans
while l >= 0 and r < n:
d -= (a[l] - a[r]) * (b[l] - b[r])
ans = max(ans, d)
l -= 1
r += 1
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
p = 0
for i in range(n):
ans += a[i] * b[i]
p += a[i... | FUNC_DEF WHILE VAR NUMBER VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER 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 VAR FUNC_CALL FUNC_CALL VAR A... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
pre = [0] * (n + 2)
suf = [0] * (n + 2)
for i in range(n):
pre[i + 1] = pre[i] + a[i] * b[i]
for i in range(n, 0, -1):
suf[i] = suf[i + 1] + a[i - 1] * b[i - 1]
ans = pre[n]
tmp = ans
for pivot in range(n):
tmp = pre[n]... | 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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUM... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | from itertools import accumulate
from sys import stdin
input = stdin.readline
rn = lambda: int(input())
rns = lambda: map(int, input().split())
rl = lambda: list(map(int, input().split()))
rs = lambda: input()
YN = lambda x: print("YES") if x else print("NO")
mod = 10**9 + 7
n = rn()
a = rl()
b = rl()
prods = [(a[i] *... | ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CA... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | from sys import stderr, stdin
input = stdin.readline
def dbp(*args, **kwargs):
print(*args, file=stderr, **kwargs)
def get_int_list():
return [int(x) for x in input().strip().split()]
def slow_solve(alist, blist):
n = len(alist)
ans = sum(alist[i] * blist[i] for i in range(n))
for l in range(... | ASSIGN VAR VAR FUNC_DEF EXPR FUNC_CALL VAR VAR VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER A... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
old = sum(x * y for x, y in zip(a, b))
ans = old
for i in range(n):
d = 0
s = old
while i - d >= 0 and i + d < n:
s -= (a[i + d] - a[i - d]) * (b[i + d] - b[i - d])
d += 1
ans = max(ans, s)
d... | 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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHI... |
You are given two integer arrays a and b of length n.
You can reverse at most one subarray (continuous subsegment) of the array a.
Your task is to reverse such a subarray that the sum β_{i=1}^n a_i β
b_i is maximized.
Input
The first line contains one integer n (1 β€ n β€ 5000).
The second line contains n integers ... | import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
tmp = sum([(A[i] * B[i]) for i in range(N)])
ans = tmp
for i in range(N):
l, r = i - 1, i + 1
res = tmp
while 0 <= l and r < N:
delta = -(A[r] - A[l]) * (B[r] - B[l])
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
s = list(map(int, list(input().strip())))
ans = len(s)
for i in range(10):
for j in range(10):
idx = 0
isSwapped = False
delete = 0
while idx < len(s):
match = i if is... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VA... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | from sys import stdin
for _ in range(int(stdin.readline())):
s = stdin.readline()
n = len(s)
if len(s) > 2:
m = 2
else:
print(0)
continue
for i in range(10):
m = max(m, s.count(str(i)))
s1 = s[0]
for i in s[1:n]:
if i != s1[-1]:
s1 += i
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER FOR VAR VAR NUMBER VAR IF VAR VA... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | for _ in range(int(input())):
S = input()
ans = 0
for i in range(10):
for j in range(10):
c = str(i)
l = 0
for k in S:
if k == c:
l += 1
if c == str(j):
c = str(i)
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BI... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | t = int(input())
for i in range(t):
s = input()
n = len(s)
ans = 2
for j in range(10):
for k in range(10):
l = [str(j), str(k)]
c = 0
a = 0
for p in s:
if p == l[a]:
c += 1
a ^= 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR NUMBER... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | def calc(a, b, s):
t = 0
for i in range(len(s)):
if t & 1 and s[i] == b:
t += 1
elif t & 1 == 0 and s[i] == a:
t += 1
return len(s) - t // 2 * 2
for _ in range(int(input())):
s = input()
ans = 1000000
for i in range(0, 10):
temp = s.count(str(i)[... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER F... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | t = int(input())
def find(s, i, j):
res = 0
for ch in s:
if ch == i:
res += 1
i, j = j, i
if i != j and res % 2 == 1:
res -= 1
return res
for _ in range(t):
s = input()
correct = 0
for i in range(10):
for j in range(10):
correct... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR IF VAR VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR F... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | import gc
def calc(arr):
counts = []
for i in range(10):
for j in range(10):
s = i + j
target = i
count = 0
for a in arr:
if int(a) == target:
target = s - target
else:
count += 1
... | IMPORT FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CA... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | t = int(input())
while t > 0:
a = list(str(input()))
d = {}
d["0"] = []
d["1"] = []
d["2"] = []
d["3"] = []
d["4"] = []
d["5"] = []
d["6"] = []
d["7"] = []
d["8"] = []
d["9"] = []
for i in range(len(a)):
d[a[i]].append(i)
co = 0
g = d.keys()
for i ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR STRING LIST ASSIGN VAR STRING LIST ASSIGN VAR STRING LIST ASSIGN VAR STRING LIST ASSIGN VAR STRING LIST ASSIGN VAR STRING LIST ASSIGN VAR STRING LIST ASSIGN VAR STRING LIST ASSIGN VAR ... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | t = int(input())
for case in range(t):
s = list(map(int, list(input())))
maxCounter = 0
for i in range(10):
for j in range(10):
prev = -1
counter = 0
for k in s:
if (k == i or k == j) and (i != j and k != prev or i == j):
counte... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | for _ in range(int(input())):
s = input().strip()
dp = [0] * 10
for c in s:
dp[ord(c) - ord("0")] += 1
ans = max(dp)
for i in range(10):
for j in range(i + 1, 10):
a, b = str(i), str(j)
f = None
cnt = 0
for c in s:
if c ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | def sol(s, x, y):
c = 0
for i in s:
if int(i) == x:
c += 1
x, y = y, x
if x != y and c & 1:
c -= 1
return c
for i in range(int(input())):
ans = 0
s = input()
n = len(s)
for x in range(10):
for y in range(10):
ans = max(ans, so... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR IF VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VA... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | T = int(input())
for _ in range(0, T):
s = input()
n = len(s)
pre = [0] * 10
for i in range(0, len(s)):
pre[ord(s[i]) - 48] += 1
ans = n - 2
for i in range(10):
ans = min(ans, n - pre[i])
for i in range(10):
for j in range(10):
k1 = str(i)
k2 =... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIG... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | for _ in range(int(input())):
s = input()
x = [0] * 10
for i in s:
x[int(i)] += 1
mmm = max(x)
lll = [i for i in range(10) if x[i] > mmm / 2]
pat = []
for i in lll:
for j in lll:
if i != j:
pat.append((i, j))
if len(pat) < 1:
print(len(... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR VAR FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VA... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | def func(i, j, s):
p = [i, j]
need = 0
count = 0
for k in s:
if k == p[need]:
count += 1
need ^= 1
if i != j and count % 2 == 1:
count -= 1
return count
for _ in range(int(input())):
s = input()
ans = 2
for i in range(10):
for j in ra... | FUNC_DEF ASSIGN VAR LIST VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR ... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | t = int(input())
for _ in range(t):
s = list(input())
n = len(s)
ans = n - 2
lis = [str(i) for i in range(10)]
for i in lis:
for j in lis:
cnt = 0
swt = 1
for k in range(n):
if swt:
if s[k] == i:
... | 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 VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER FOR VAR VAR FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR IF VAR VAR ... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | def numOfChars(s, c):
ans = 0
for k in s:
if k == c:
ans += 1
return ans
def calcMaxSubseq(s, charOne, charTwo):
maxL = 0
counter = 0
for c in s:
if counter == 0 and c == charOne:
counter = 1
maxL += 1
elif counter == 1 and c == charT... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER VAR VAR ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER RETURN BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | t = int(input())
for _ in range(t):
s = input()
if len(s) == 2:
print(0)
continue
d = {}
d1 = {}
for i in range(10):
for j in range(10):
if i == j:
d1[str(i)] = 0
else:
d[str(i) + str(j)] = 0
n = len(s)
for j in ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUN... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | for _ in range(int(input())):
s = input()
n = len(s)
a = [0] * 10
for x in s:
a[int(x)] += 1
a = [x for x in a if x]
a.sort(reverse=True)
if len(a) == 1:
print(0)
else:
ans = a[0]
for x in range(10):
for y in range(10):
if x != ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR F... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | import sys
input = sys.stdin.readline
(T,) = map(int, input().split())
for _ in range(T):
s = input().strip()
R = 0
for i in range(10):
for j in range(10):
tmp = 0
x = [i, j]
r = 0
for c in s:
c = int(c)
if x[tmp] == c:... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR ... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | import sys
input = sys.stdin.readline
def inp():
return int(input())
def inlt():
return list(map(int, input().split()))
def insr():
s = input()
return s[: len(s) - 1]
def invr():
return map(int, input().split())
T = inp()
for t in range(T):
S = insr()
if len(S) < 3:
print(... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR RETURN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR ... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | import sys
input = lambda: sys.stdin.readline().rstrip()
for _ in range(int(input())):
a = [int(i) for i in input()]
n = len(a)
ans = 0
p = [0, 0]
for i in range(0, 10):
for j in range(0, 10):
cnt = 0
cur = [i, j]
ind = 0
for k in a:
... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIS... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | def solve_util(s, x, y):
res = 0
for c in s:
if c == x:
res += 1
x, y = y, x
if x != y and res % 2 == 1:
return res - 1
return res
def solve(s):
ans = 0
a = [str(i) for i in range(10)]
for x in a:
for y in a:
ans = max(ans, solve_... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR IF VAR VAR BIN_OP VAR NUMBER NUMBER RETURN BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER FOR VAR VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR RETU... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | def count(s, a):
b = 0
cur = 0
for i in s:
if i == a[0]:
b = 1
elif b and i == a[1]:
cur += 1
b = 0
return cur
t = int(input())
for k in range(t):
s = input()
mx = 0
for i in range(10):
for j in range(10):
if i == j:
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | for _ in range(int(input())):
s = input()
ans = 1000000
for i in range(10):
temp = 0
for j in s:
if j != str(i):
temp += 1
ans = min(ans, temp)
for i in range(10):
for j in range(10):
temp = 0
l = True
for k ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR V... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | def main(x, y):
c = x
count = 0
for i in range(n):
if s[i] == c:
count += 1
if c == x:
c = y
else:
c = x
if count & 1:
if x == y:
return count
return count - 1
return count
a = "0123456789"
for ... | FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF BIN_OP VAR NUMBER IF VAR VAR RETURN VAR RETURN BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FU... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | def alt(a, i, j):
c = 0
now = i
for k in range(len(a)):
if a[k] == i and now == i:
now = j
elif a[k] == j and now == j:
now = i
c += 1
return c * 2
def main():
for _ in range(int(input())):
a = list(input())
x = [i for i in range(... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR ASSIGN VAR VAR IF VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER RETURN BIN_OP VAR NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | possibles = []
for i in range(10):
for j in range(10):
possibles.append(str(i) + str(j))
for _ in range(int(input())):
s = input()
max = 2
for st in possibles:
length = 0
j = 0
for digit in s:
if digit == st[j]:
length += 1
if j... | ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR NUMBER IF VA... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | for _ in range(int(input())):
s = input()
we = len(s)
d = {}
l = []
for i in s:
if i not in d:
d[i] = 1
else:
d[i] += 1
for i in d:
l.append(d[i])
l_pair = []
for i in d:
for j in d:
if i != j:
ss = i + j... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR LIST FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR VAR FOR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUN... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | def checker(a, b, arr):
fr = [-1, -1]
for i in range(len(arr)):
if arr[i] == a or arr[i] == b:
if fr[0] == -1 and fr[1] == -1:
if arr[i] == b:
a, b = b, a
fr[0] = 1
fr[1] = 0
elif arr[i] == a and fr[0] == fr[1]:
... | FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR IF VAR NUMBER NUMBER VAR NUMBER NUMBER IF VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER IF VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER NUMBER IF VAR VAR VAR VAR NUMBER BIN_OP... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | import sys
INP = lambda: sys.stdin.readline().strip()
INT = lambda: int(INP())
MAP = lambda: map(int, INP().split())
ARR = lambda: [int(i) for i in INP()]
def JOIN(arr, x=" "):
return x.join([str(i) for i in arr])
def EXIT(x="NO"):
print(x)
exit()
def do(f, arr, a, b):
xx = 0
for x in arr:
... | IMPORT ASSIGN 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 FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_DEF STRING RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_DEF STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VA... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | for _ in range(int(input())):
s = str(input())
l = list(s)
if len(list(set(l))) == 1:
print(0)
else:
l1 = [0] * 10
l2 = [-1] * 10
for i in range(len(s)):
l1[int(s[i])] += 1
l2[int(s[i])] = 1
ans = min(len(s) - max(l1), len(s) - 2)
l... | 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 IF FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FU... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | from sys import stdin, stdout
def input():
return stdin.readline().strip()
T = int(input())
def ans1(S):
return max(S.count(i) for i in "0123456789")
def ans2(S):
ret = float("-inf")
for i in "0123456789":
for j in "0123456789":
ret = max(ret, ans3(S, i, j))
return ret
... | FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING FOR VAR STRING FOR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | T = int(input())
def isGood(st):
if len(st) <= 2:
return True
even = st[0]
odd = st[1]
for i, c in enumerate(st):
if i % 2 == 0:
if c != even:
return False
elif c != odd:
return False
if len(st) % 2 != 0 and even != odd:
retur... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER IF VAR VAR RETURN NUMBER IF VAR VAR RETURN NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR VAR RETURN NUMBER RETURN NUMBER ... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | import sys
def main():
for _ in range(int(input())):
s = input()
max_ = 0
for i in range(10):
for j in range(10):
max_ = max(max_, solve(s, str(i), str(j)))
print(len(s) - max_)
def solve(s1, x, y):
greed = 0
for char in s1:
if char == ... | IMPORT FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR NU... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | def ct(s, a, b):
tm = [a, b]
id = 0
res = 0
for n in s:
if n == tm[id]:
res += 1
id ^= 1
if res % 2 and a != b:
res -= 1
return len(s) - res
def solv():
s = list(map(int, input()))
res = 10**10
p = 0
q = 0
for n in range(10):
... | FUNC_DEF ASSIGN VAR LIST VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER VAR VAR VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | for _ in range(int(input())):
napis = input()
count = [[(0) for _ in range(10)] for _ in range(10)]
for x in napis:
d = int(x)
for p in range(10):
count[d][p] = count[p][d] + 1
print(
len(napis)
- max(
max([max(i) for i in count]) // 2 * 2, max([co... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR BIN_... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | t = int(input())
for i in range(t):
stro = input()
cntm = 0
for too in range(10):
for ga in range(10):
if too != ga:
f = 0
cnt = 0
for c in stro:
if f == 0 and int(c) == too:
cnt += 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER FUNC_CALL VAR VA... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | from sys import stdin
for _ in range(int(stdin.readline())):
t = stdin.readline().strip()
array = [[(0) for i in range(10)] for j in range(10)]
flag = [[(0) for i in range(10)] for j in range(10)]
ans = 0
freq = [0] * 10
for i in t:
x = int(i)
freq[x] += 1
for j in range... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | def searchPattern(s, a, b):
check = 0
count = 0
for letter in s:
if not check and letter == a:
count += 1
check = 1
elif check and letter == b:
count += 1
check = 0
if a != b and count % 2 == 1:
count -= 1
return count
def min... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR FOR VAR VAR ASSIGN... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | for _ in range(int(input())):
alpha = [0] * 10
s = [i for i in input()]
n = len(s)
ans = 200000.0 + 1
for i in range(10):
for j in range(10):
turn, cnt = 0, 0
for x in s:
if int(x) == i and turn == 0:
turn += 1
t... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR VAR NUMBER VAR ... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | for _ in range(int(input())):
s = input()
n = len(s)
cnt = [0] * 10
ind = [[] for i in range(10)]
for i in range(n):
cnt[int(s[i])] += 1
ind[int(s[i])] += [i]
ans = n - max(cnt)
for i in range(10):
for j in range(i + 1, 10):
l = 0
r = 0
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR LIST VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR FOR ... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | for i in " " * int(input()):
s = input()
countL = [0] * 10
for i in s:
countL[int(i)] += 1
mx = max(countL)
for i in range(10):
for j in range(10):
if i == j:
continue
frontcount = 0
count = 0
for k in s:
... | FOR VAR BIN_OP STRING FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR ... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | t = int(input())
for _ in range(t):
s = list(map(int, input().strip()))
n = len(s)
rm = n - max([s.count(i) for i in range(10)])
for i in range(10):
for j in range(10):
sw = 1
add = 0
for k in range(n):
if sw:
if s[k] == i:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSI... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | t = int(input())
for _ in range(t):
st = input()
sp = list(set(st))
moc = 0
mm = 0
for i in sp:
for j in sp:
if i == j:
coc = st.count(i)
mm = max(mm, coc)
continue
bo = False
coc = 0
for s in st:... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FOR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
s = input().rstrip()
l = len(s)
b = 9999999
for i in range(10):
k = s.count(str(i))
b = min(b, l - k)
b_count = 0
for i in range(10):
for j in range(10):
count = 0
last = st... | 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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | w = int(input())
for _ in range(w):
A = list(map(int, list(input())))
MAX = 0
for i in range(10):
for j in range(10):
cur = i
l = 0
for k in A:
if k == cur:
if cur == i:
cur = j
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR NUMBER ... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | def solve():
s = input()
ans = 0
for i in range(10):
for j in range(10):
x, y = str(i), str(j)
l = 0
for ch in s:
if ch == x:
l += 1
x, y = y, x
if l % 2 != 0 and x != y:
l -= 1
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | t = int(input())
def swap(x, y):
return y, x
for _ in range(t):
s = input()
mx = 0
for i in range(10):
for j in range(10):
cur = 0
x, y = i, j
for a in s:
if int(a) == x:
cur += 1
x, y = swap(x, y)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR FOR VAR VAR IF FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR IF B... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | t = int(input())
while t:
s = input()
arr = [0] * 10
ans = 10000000
for i in s:
arr[int(i)] += 1
for i in range(10):
for j in range(i):
if not arr[i] or not arr[j]:
continue
cnt = 0
cntt = 0
for k in s:
i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER ... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | t = int(input())
while t > 0:
num = input()
ans = 0
sum = 0
for i in range(0, 10):
for j in range(0, 10):
state = 0
sum = 0
c1 = str(i)
c2 = str(j)
for k in num:
if c1 != c2:
if state == 0 and c1 == k... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR VAR IF VAR NUMBER ... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | for _ in range(int(input())):
s = input()
o = max(s.count(i) for i in {*s})
l = [[(0) for i in range(10)] for i in range(10)]
for i in "0123456789":
k = 0
q = {}
for m in range(10):
q[m] = set()
for j in s:
if j == i:
k += 1
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FOR VAR VAR IF VAR ... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | from sys import stdin
input = stdin.readline
def answer():
count = [0] * 10
for i in s:
count[int(i)] += 1
ans = n - max(count)
for v1 in range(10):
for v2 in range(10):
x, take = 0, 0
for i in range(n):
if take == 0:
if int(... | ASSIGN VAR VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR ... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | t = int(input())
for _ in range(t):
st = input()
ans = 2000001
l = len(st)
s = set(st)
for j in s:
c = st.count(j)
if l - c < ans:
ans = l - c
arr = []
for j in s:
arr.append(j)
for i in range(len(arr)):
for j in range(i + 1, len(arr)):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_C... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | def minErase(s):
n = len(s)
maxCnt = 0
for i in range(10):
for j in range(10):
currChar = i
cnt = 0
for c in s:
if int(c) == currChar:
cnt += 1
currChar = j if currChar == i else i
maxCnt = max(ma... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR BIN... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | def comb(a, x, y):
flag = True
count = 0
for ele in a:
if flag:
if ele == x:
flag = False
elif ele == y:
count += 1
flag = True
return len(a) - 2 * count
T = int(input())
for case in range(T):
a = input()
ans = float("inf")
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR IF VAR VAR ASSIGN VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CA... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | import sys
T = int(sys.stdin.readline().strip())
for t in range(0, T):
s = sys.stdin.readline().strip()
l = len(s)
S = [int(s[i]) for i in range(0, l)]
ans = l
for i in range(0, 10):
for j in range(0, 10):
if i == j:
ans = min(ans, l - S.count(i))
els... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR ASSIGN ... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | def fun(s, a, b):
ct = 0
for i in s:
if i == a:
a, b = b, a
ct += 1
if ct % 2 != 0:
return ct - 1
return ct
for _ in range(int(input())):
s = input()
n = len(s)
d = {}
maxi = 0
for i in range(10):
for j in range(10):
if i ... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR V... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | def main():
t = int(input())
for i in range(t):
s = input()
n = len(s)
ar = [[0, ""] for i in range(100)]
al = "0123456789"
ar2 = [0] * 10
for i in s:
ar2[int(i)] += 1
for j in al:
ind = int("".join(sorted([i, j])))
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER STRING VAR FUNC_CALL VAR NUMBER ASSIGN VAR STRING ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | from sys import stdin, stdout
for _ in range(int(input())):
s = input().strip()
n = len(s)
ans = 0
for i in range(10):
i = str(i)
for j in range(10):
j = str(j)
c1, c2 = 0, 0
for k in s:
if k == i and c1 == c2:
c1 +... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR IF VAR VAR VAR VAR VAR NUMBER I... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | for _ in range(int(input())):
s = input()
n = len(s)
if n == 1 or n == 2:
print(0)
else:
dic = {}
for i in range(n):
if s[i] in dic:
dic[s[i]] += 1
else:
dic[s[i]] = 1
mx = 0
for i in dic.keys():
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VA... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | ans = []
for i in range(10):
for j in range(10):
ans.append(str(i) + str(j))
for case in range(int(input())):
st = input()
n = len(st)
ans1 = 0
for s in ans:
count = 0
f = s[0]
for i in st:
if i == f:
count += 1
if f == s[0]... | ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VA... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | for _ in range(int(input())):
s = input().strip()
n = len(s)
freq = [(0) for i in range(10)]
for ch in s:
freq[ord(ch) - ord("0")] += 1
freq.sort()
maxx = 0
for i in range(10):
for j in range(i + 1, 10):
seq = 0
last = ""
for ch in s:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP... |
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$.
Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$.
Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.
Y... | n = int(input())
for i in range(n):
s = input()
l = len(s)
d = dict()
for i in "0123456789":
d[i] = 0
for i in s:
d[i] = d[i] + 1
maxi = 0
for i in "0123456789":
if d[i] > maxi:
maxi = d[i]
maxi1 = 0
for i in "0123456789":
for j in "0123456... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR STRING ASSIGN VAR VAR NUMBER FOR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR STRING IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR V... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.