description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (in decimal representation) is not less than s. To prove that these numbers may have different speci...
n, s = map(int, input().split()) def nod(n): res = 0 while n > 0: res += 1 n //= 10 return res def sod(n): res = 0 while n > 0: res += n % 10 n //= 10 return res def maxsod(n): if (n + 1) % 10 ** (nod(n) - 1) == 0: return 9 * (nod(n) - 1) + n // ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF IF BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER RETURN B...
Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (in decimal representation) is not less than s. To prove that these numbers may have different speci...
def calc(n): val = n cnt = 0 while val: cnt += val % 10 val //= 10 return n - cnt n, s = list(map(int, input().split())) if n <= s: print(0) return val = s val //= 10 if val == 0: print(n - 9 if n >= 9 else 0) return val *= 10 while calc(val) < s: val += 10 if v...
FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN BIN_OP VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER NUMBER RET...
Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (in decimal representation) is not less than s. To prove that these numbers may have different speci...
def somaDigitos(x): resp = 0 while x > 0: resp += x % 10 x = x // 10 return resp def isReallyBigNumber(x): return x - somaDigitos(x) >= s n, s = input().split(" ") n = int(n) s = int(s) count = 0 ini = 1 fim = n i = 0 ans = False while ini <= fim: meio = (ini + fim) // 2 if i...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF RETURN BIN_OP VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR...
Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (in decimal representation) is not less than s. To prove that these numbers may have different speci...
a = input() a = a.split(" ") a = list(map(int, a)) def really_big(n, s): if s >= n: return 0 i = s + 1 while i <= n: t, b = i, 0 while t > 0: b = b + t % 10 t = t // 10 if i - b >= s: return n - i + 1 break else: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR RETUR...
Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (in decimal representation) is not less than s. To prove that these numbers may have different speci...
def digisum(n): count = 0 while n > 0: count += n % 10 n = n // 10 return count n, s = list(map(int, input().split())) l, r = 1, n flag = 0 while l < r: m = l + (r - l) // 2 digi_sum = digisum(m) num = m if num - digi_sum >= s: flag = 1 cur = m r = m...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIG...
Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (in decimal representation) is not less than s. To prove that these numbers may have different speci...
n, s = list(map(int, input().split(" "))) def sumd(d): sd = 0 while d != 0: sd += d % 10 d //= 10 return sd st, ed = 1, n r = 0 while True: if st == ed: r = st break x = (st + ed) // 2 if x - sumd(x) < s: st = x + 1 else: ed = x if r - sumd...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR VAR NUMBER VAR ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR FUNC_CALL VAR VAR...
Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (in decimal representation) is not less than s. To prove that these numbers may have different speci...
def forninho(miolo, s): premiolo = miolo temp = 0 while miolo > 0: temp += miolo % 10 miolo = miolo // 10 if premiolo - temp >= s: return 1 else: return 0 entrada = input().split() n = int(entrada[0]) s = int(entrada[1]) result = -1 l = 1 r = n while r - l >= 0: ...
FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WH...
Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (in decimal representation) is not less than s. To prove that these numbers may have different speci...
def check(n, p): k = str(n) k = k[::-1] s = 0 for j in range(len(k)): s += int(k[j]) * (10**j - 1) if s >= p: return 1 else: return 0 n, s = map(int, input().split()) l = 1 h = n k = 0 while l <= h: m = (l + h) // 2 if check(m, s) == 0: l = m + 1 els...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN V...
Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (in decimal representation) is not less than s. To prove that these numbers may have different speci...
def f(x): return x if x < 10 else f(x // 10) + x % 10 n, s = map(int, input().split()) x = s while x - f(x) < s: x += 1 print(max(0, n - x + 1))
FUNC_DEF RETURN VAR NUMBER VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR WHILE BIN_OP VAR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER
Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (in decimal representation) is not less than s. To prove that these numbers may have different speci...
def sum_of_its_digits(Num, s): S = str(Num) sum = 0 for i in S: sum += int(i) return Num - sum >= s k = input().split() n = int(k[0]) s = int(k[1]) sum = 0 for i in range(s, n + 1): if sum_of_its_digits(i, s): sum = n - i + 1 break print(sum)
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR RETURN BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR...
Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (in decimal representation) is not less than s. To prove that these numbers may have different speci...
def find(curr_pos, max_pos, curr_s, choose): if curr_pos == 0: if curr_s <= 0: return True else: return False if curr_pos == max_pos: low = 1 else: low = 0 high = 9 for d in range(low, high + 1): curr_val = d * (10**curr_pos - 1) ...
FUNC_DEF IF VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR RETURN FUNC_CALL VAR BIN_OP VAR N...
Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (in decimal representation) is not less than s. To prove that these numbers may have different speci...
import sys def calculate(): input = sys.stdin.readline().split() n = int(input[0]) s = int(input[1]) count = 0 i = s // 10 * 10 while i <= n: if i - sumOfDigits(i) >= s: count = n - i + 1 break i = i + 10 print(count) def sumOfDigits(numb): sum...
IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER WHILE VAR VAR IF BIN_OP VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VA...
Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (in decimal representation) is not less than s. To prove that these numbers may have different speci...
n, s = [int(x) for x in input().split()] def check(x): y = list(str(x)) ans = x for i in y: ans -= int(i) if ans >= s: return True return False ans = 0 l = 1 r = n while l <= r: m = (l + r) // 2 if check(m): ans = n - m + 1 r = m - 1 else: l = ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL V...
Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (in decimal representation) is not less than s. To prove that these numbers may have different speci...
n, s = input().split() l = 1 h = int(n) while h - l > 1: m = (h + l) // 2 if m - sum(map(int, list(str(m)))) >= int(s): h = m else: l = m if h - sum(map(int, list(str(h)))) < int(s): print(0) else: print(int(n) - h + 1)
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF BIN_OP VAR FUNC_CALL VAR FUNC_CALL VA...
Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (in decimal representation) is not less than s. To prove that these numbers may have different speci...
n, s = map(int, input().split()) r = 0 v = min(n + 1, s + 19 * 9) for i in range(s, v): zz = f"{i}" sm = i for z in zz: sm -= int(z) if sm >= s: r += 1 print(r + n - v + 1)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NU...
Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (in decimal representation) is not less than s. To prove that these numbers may have different speci...
def d(n): ret = 0 n = list(str(n)) for i in range(len(n)): ret += int(n[i]) return ret def main(): n, s = map(int, input().split()) l, h = 0, n for i in range(2000): m = (l + h) // 2 if m - d(m) >= s: h = m else: l = m for i in ra...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VA...
Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (in decimal representation) is not less than s. To prove that these numbers may have different speci...
def f(n): rtn = n while 0 < n: rtn -= n % 10 n //= 10 return rtn n, s = list(map(int, input().split())) l = 0 r = 10**18 + 1 cnt = 0 while 1 < r - l: m = (l + r) // 2 if s <= f(m): r = m else: l = m print(max(n - r + 1, 0))
FUNC_DEF ASSIGN VAR VAR WHILE NUMBER VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER WHILE NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR FUNC_CA...
Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (in decimal representation) is not less than s. To prove that these numbers may have different speci...
[n, s] = map(int, input().strip().split()) def sumdigit(x): return sum(map(int, str(x))) def fsum(x): return x - sumdigit(x) def binsearch(s, xmin, xmax): while xmax - xmin > 1: xmid = (xmax + xmin) // 2 if fsum(xmid) >= s: xmax = xmid else: xmin = xmid ...
ASSIGN LIST VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP VAR FUNC_CALL VAR VAR FUNC_DEF WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR RETUR...
Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (in decimal representation) is not less than s. To prove that these numbers may have different speci...
import sys n, s = map(int, input().split()) ok, ng = 10**18 + 100, -1 while abs(ok - ng) > 1: mid = ok + ng >> 1 if mid - sum(map(int, str(mid))) >= s: ok = mid else: ng = mid print(max(0, n - ok + 1))
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER NUMBER WHILE FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR ...
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef and Abhishek are two friends. Abhishek really appreciates Chef's skills and wants to learn the secret formula behind Chef's tasty dishes. Chef will tell his secret formula only to a competent person. So to check Abhish...
import sys D = 22 dp = [dict() for _ in range(D)] dp[0][1] = 1 for d in range(D - 1): for product, freq in dp[d].items(): for nxt in range(1, 10): dp[d + 1][product * nxt] = freq + dp[d + 1].get(product * nxt, 0) products, frequencies = [list() for _ in range(D)], [list() for _ in range(D)] sum...
IMPORT ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR BIN_OP VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER A...
You are given n numbers a1, a2, ..., an. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make <image> as large as possible, where <image> denotes the bitwise OR. Find the maximum possible value of <image> after performing at most k operations optimally. I...
n, k, x = map(int, input().split()) a = list(map(int, input().split())) maxi = 0 moc = x**k p = [0] * (n + 2) s = [0] * (n + 2) for i in range(1, len(a) + 1): p[i] = p[i - 1] | a[i - 1] for i in range(len(a), 0, -1): s[i] = s[i + 1] | a[i - 1] for t in range(1, len(a) + 1): maxi = max(maxi, p[t - 1] | a[t -...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR 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 NUMBER BIN_OP FUNC_CALL VAR VA...
You are given n numbers a1, a2, ..., an. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make <image> as large as possible, where <image> denotes the bitwise OR. Find the maximum possible value of <image> after performing at most k operations optimally. I...
n, k, x = map(int, input().split()) A = list(map(int, input().split())) L, R = [0] * (n + 1), [0] * (n + 1) for i in range(n): L[i + 1] = A[i] | L[i] for i in range(n - 1, -1, -1): R[i] = A[i] | R[i + 1] x = x**k ans = 0 for i in range(n): ans = max(ans, L[i] | A[i] * x | R[i + 1]) print(ans)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN...
You are given n numbers a1, a2, ..., an. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make <image> as large as possible, where <image> denotes the bitwise OR. Find the maximum possible value of <image> after performing at most k operations optimally. I...
n, k, l = map(int, input().split()) li = [int(x) for x in input().split()] front = [0] * (n + 2) back = [0] * (n + 2) front[0] = 0 | li[0] back[n - 1] = 0 | li[n - 1] for i in range(1, n): front[i] = front[i - 1] | li[i] for i in range(n - 2, -1, -1): back[i] = back[i + 1] | li[i] p = 1 for _ in range(k): p...
ASSIGN VAR 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 BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR BIN_OP VAR NUMBE...
You are given n numbers a1, a2, ..., an. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make <image> as large as possible, where <image> denotes the bitwise OR. Find the maximum possible value of <image> after performing at most k operations optimally. I...
n, k, x = map(int, input().split()) l = list(map(int, input().split())) a = [0] * n b = [0] * n for i in range(1, n): a[i] = a[i - 1] | l[i - 1] for i in range(1, n): b[n - i - 1] = b[-i] | l[-i] nom = 0 for i in range(1, n): if l[nom] * x**k | a[nom] | b[nom] < l[i] * x**k | a[i] | b[i]: nom = i l[...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUM...
You are given n numbers a1, a2, ..., an. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make <image> as large as possible, where <image> denotes the bitwise OR. Find the maximum possible value of <image> after performing at most k operations optimally. I...
import sys n, k, x = (int(x) for x in input().split()) l = [int(x) for x in input().split()] pref = [0] * n suff = [0] * n pref[0] = l[0] for i in range(1, n): pref[i] = pref[i - 1] | l[i] suff[n - 1] = l[n - 1] for i in range(n - 2, -1, -1): suff[i] = suff[i + 1] | l[i] def get_pref(index): if index < 0...
IMPORT ASSIGN VAR 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 BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VA...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
x0, y0, ax, ay, bx, by = [int(a) for a in input().split()] xs, ys, t = [int(a) for a in input().split()] x = x0 y = y0 points = [] def m(p0, p1): return abs(p0[0] - p1[0]) + abs(p0[1] - p1[1]) while x < 1e18 and y < 1e18: points.append((m((x, y), (xs, ys)), (x, y))) x = ax * x + bx y = ay * y + by b...
ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST FUNC_DEF RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER WHILE VAR NUMBER VAR NU...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) dots = [] x, y = x0, y0 while True: if x < 10**20 and y < 10**20: dots.append((x, y)) else: break x = ax * x + bx y = ay * y + by def get_dots(start, direction): T = t x, y = xs, ys i =...
ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR VAR VAR WHILE NUMBER IF VAR BIN_OP NUMBER NUMBER VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
x0, y0, ax, ay, bx, by = map(int, input().split(" ")) xs, ys, t = map(int, input().split(" ")) def dist(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2) maxi = 0 x = x0 y = y0 for i in range(0, 64): res = 0 t_aux = t t_aux -= dist(x, y, xs, ys) if t_aux >= 0: res += 1 x_aux = ...
ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN ...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
x0, y0, ax, ay, bx, by = [int(t) for t in input().split(" ")] xs, ys, t0 = [int(t) for t in input().split(" ")] devices = [(x0, y0)] for _ in range(60): x0, y0 = ax * x0 + bx, ay * y0 + by devices.append((x0, y0)) def launch(ibegin): i = ibegin t = t0 xc, yc = xs, ys dst = abs(xc - devices[i][...
ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN V...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
LIM = 100000000000000000 def solve(): x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) X = [x0] while True: nx = ax * X[-1] + bx if nx - X[-1] > LIM: break X.append(nx) Y = [y0] while True: ny = ay * Y[-1] + by...
ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR WHILE NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR IF BIN_OP VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR WHILE NUMB...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
def inp(dtype=str, strip=True): s = input() res = [dtype(p) for p in s.split()] res = res[0] if len(res) == 1 and strip else res return res def problem1(): def test(cur, steps): if 0 < cur <= n and cur not in a: return steps else: return -1 t = inp(int...
FUNC_DEF VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR NUMBER VAR RETURN VAR FUNC_DEF FUNC_DEF IF NUMBER VAR VAR VAR VAR RETURN VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR A...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
from sys import stdin input = stdin.readline N = 2 * 10**16 + 5 x = [0] y = [0] x[0], y[0], x1, y1, x2, y2 = map(int, input().split()) a, b, t = map(int, input().split()) while x[-1] < N and y[-1] < N: x.append(x1 * x[-1] + x2) y.append(y1 * y[-1] + y2) ans = 0 for i in range(len(x)): for j in range(len(x)...
ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER VAR NUMBER VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR WHILE VAR NUMBER VAR VAR NUMBER VAR EXPR FUNC_CALL ...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
import sys x0, y0, ax, ay, bx, by = [int(i) for i in sys.stdin.readline().split()] xs, ys, t = [int(i) for i in sys.stdin.readline().split()] ps = xs, ys def distance(p1, p2): return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1]) points = [] p = x0, y0 for _ in range(128): if distance(p, ps) <= t: points....
IMPORT ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_DEF RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR LIST ASSIGN VAR VAR VAR FOR VAR ...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) def generate(x0, y0, ax, ay, bx, by): arr = [[x0, y0]] curX, curY = arr[-1] for _ in range(65): curX, curY = ax * curX + bx, ay * curY + by arr.append([curX, curY]) return arr def go_left(xs, ys,...
ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST LIST VAR VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR LIST VA...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
from itertools import accumulate x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, t0 = map(int, input().split()) pnt = [] x, y = x0, y0 while True: if x >= 10**17 or y >= 10**17: break pnt.append((x, y)) x, y = x * ax + bx, y * ay + by n = len(pnt) dist = [] for i in range(1, n): xi, ...
ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR VAR VAR WHILE NUMBER IF VAR BIN_OP NUMBER NUMBER VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
x0, y0, ax, ay, bx, by = tuple(map(int, input().split(" "))) xs, ys, t = tuple(map(int, input().split(" "))) important_points = [(x0, y0)] for i in range(62): x0 = ax * x0 + bx y0 = ay * y0 + by important_points.append((x0, y0)) start = xs, ys def dist(p1, p2): return abs(p1[0] - p2[0]) + abs(p1[1] - ...
ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VA...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
import sys def dist(x1, y1, x2, y2): ans = 0 dx = x1 - x2 if dx < 0: dx = -dx ans = ans + dx dy = y1 - y2 if dy < 0: dy = -dy ans = ans + dy return ans x0, y0, ax, ay, bx, by = map(int, sys.stdin.readline().split()) xs, ys, t = map(int, sys.stdin.readline().split()) r...
IMPORT FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUN...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
T = 1 for test_no in range(T): x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) LIMIT = 2**62 - 1 x, y = [x0], [y0] while (LIMIT - bx) / ax >= x[-1] and (LIMIT - by) / ay >= y[-1]: x.append(ax * x[-1] + bx) y.append(ay * y[-1] + by) n = len...
ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR LIST VAR LIST VAR WHILE BIN_OP BIN_OP VAR VAR VAR VAR NUMBER BIN_OP BIN_OP VAR VA...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
INF = 10**20 x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) def dist(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2) a = [] while x0 <= INF and y0 <= INF: z = [x0, y0] a.append(z) x0 = ax * x0 + bx y0 = ay * y0 + by ans = 0 for i in range(len(a)): ...
ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR LIST WHILE VAR VAR VAR VAR ASSIGN VAR LIST VAR VAR EXPR FUNC_C...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
x = [(0) for i in range(75)] y = [(0) for i in range(75)] count1 = 0 count2 = 0 max1 = 0 def dis(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2) def main(): global count1 global max1 global count2 x0, y0, ax, ay, bx, by = input().split() x0 = int(x0) y0 = int(y0) ax = int(ax) ...
ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR FUNC_DEF ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
def check(goo, k, t, x, y): ans = 1 timer = abs(goo[k][0] - x) + abs(goo[k][1] - y) if timer > t: return 0 for i in range(k - 1, -1, -1): delta = abs(goo[i][0] - goo[i + 1][0]) + abs(goo[i][1] - goo[i + 1][1]) timer += delta if timer > t: return ans an...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR IF VAR VAR RETURN NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR BIN_OP VAR VAR NUMB...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
import sys def main(): import sys input = sys.stdin.readline def dist(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2) x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) xy_list = [(x0, y0)] x, y = x0, y0 while True: x, y = ax...
IMPORT FUNC_DEF IMPORT ASSIGN VAR VAR FUNC_DEF RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR ASSIGN VAR VAR VAR VAR WHILE NUMBER ASSIGN ...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) A = [] for i in range(100): A.append((x0, y0)) x0 = x0 * ax + bx y0 = y0 * ay + by ans = 0 for i in range(0, 100): for j in range(i, 100): kek = A[j][0] - A[i][0] + A[j][1] - A[i][1] kek += min( ...
ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR ...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
def calc(i_min, t, x, y): cnt = 0 t1 = t i = i_min min_dist = abs(x[i_min] - xs) + abs(y[i_min] - ys) if min_dist <= t: cnt += 1 t1 -= min_dist while t1 > 0 and i > 0: i -= 1 dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]) if dist <= t1: cnt += ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR IF VAR VAR VAR NUMBER VAR VAR WHILE VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBE...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
import sys reader = (line.rstrip() for line in sys.stdin) input = reader.__next__ x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) currRoute = 0 leftSum = [0] maxId = 0 xi, yi = x0, y0 coord = [(x0, y0)] while True: xii = xi * ax + bx yii = yi * ay + by jump = xii - ...
IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR LIST VAR VAR WHILE NUMBER ASSIGN VAR B...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) v = [(x0, y0)] for i in range(100): v.append((v[-1][0] * ax + bx, v[-1][1] * ay + by)) def distance(a, b): return abs(a[0] - b[0]) + abs(a[1] - b[1]) ans = 0 for i in range(len(v)): curr = xs, ys dist = distance...
ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR FUNC_DEF RETURN BIN_OP FUNC_CALL V...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) node = [[x0, y0]] for i in range(70): xi = node[i][0] * ax + bx yi = node[i][1] * ay + by node.append([xi, yi]) if xi >= 10**20 or yi >= 10**20: break ans = 0 for i in range(len(node) + 1): for j in rang...
ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST LIST VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR ...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
import sys input = sys.stdin.readline x, y, a, aa, b, bb = map(int, input().split()) xx, yy, t = map(int, input().split()) no = [[x, y]] for i in range(200): no.append([no[-1][0] * a + b, no[-1][1] * aa + bb]) ma = 0 for i in range(200): tot = 0 co = 0 tot += abs(no[i][0] - xx) + abs(no[i][1] - yy) ...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST LIST VAR VAR FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR LIST BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR AS...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
import sys def timeFromTo(xFrom, yFrom, xTo, yTo): return abs(xTo - xFrom) + abs(yTo - yFrom) def canReach(xFrom, yFrom, xTo, yTo, leftTime): return timeFromTo(xFrom, yFrom, xTo, yTo) <= leftTime def generatePoints(x0, y0, ax, ay, bx, by): result = [(x0, y0)] for _ in range(199): newX = ax...
IMPORT FUNC_DEF RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR VAR VAR VAR FUNC_DEF ASSIGN VAR LIST VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
def d(a, b, x, y): return abs(a - x) + abs(b - y) x0, y0, ax, ay, bx, by = map(int, input().split()) x, y, t = map(int, input().split()) nodes = [(x0, y0)] for i in range(1, 100): nodes.append((ax * nodes[i - 1][0] + bx, ay * nodes[i - 1][1] + by)) best_score = -1 for j in [-1, 1]: for i in range(100): ...
FUNC_DEF RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
def diff(crd, crd1): return abs(crd[0] - crd1[0]) + abs(crd[1] - crd1[1]) x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) lst = [(x0, y0)] for i in range(61): lst.append((ax * lst[-1][0] + bx, ay * lst[-1][1] + by)) ans = 0 for i in range(len(lst)): for j in range(...
FUNC_DEF RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_O...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
x, y, ax, ay, bx, by = map(int, input().split()) sx, sy, t = map(int, input().split()) buf = list({(x, y)}) for i in range(60): newx = buf[i][0] * ax + bx newy = buf[i][1] * ay + by if newx >= 1e17: break buf.append((newx, newy)) ans = 0 for i in range(len(buf)): cur_time = 0 cur_x = sx ...
ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR IF VAR NUMBER EXPR FUNC_CALL...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
import sys input = sys.stdin.readline x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, T = map(int, input().split()) MAX = max(xs, ys) + T + 1 C = [(x0, y0)] while True: x = ax * C[-1][0] + bx y = ay * C[-1][1] + by if x > MAX or y > MAX: break C.append((x, y)) ans = 0 for i, (xt, yt)...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR LIST VAR VAR WHILE NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR ASSIGN VAR BIN_OP ...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
x, y, ax, ay, bx, by = map(int, input().split()) aroma_x, aroma_y, t = map(int, input().split()) points = [] while x - aroma_x + y - aroma_y <= t: points.append((x, y)) x = x * ax + bx y = y * ay + by max_cnt = 0 def dist(p1, p2, aroma_x, aroma_y): return ( abs(p1[0] - aroma_x) + abs(p...
ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST WHILE BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR NUMBER FUNC...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
def main(): x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) arr1 = [] arr2 = [] while x0 < 1000000000000000000000 and y0 < 1000000000000000000000: arr1.append(x0) arr2.append(y0) x0 = x0 * ax + bx y0 = y0 * ay + by mx = 0 ...
FUNC_DEF ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST WHILE VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR V...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
MAXN = 60 def dist(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2) def main(): x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) points = [(x0, y0)] for i in range(1, MAXN): points.append((ax * points[-1][0] + bx, ay * points[-1][1] + by)) r...
ASSIGN VAR NUMBER FUNC_DEF RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR FUNC_DEF ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BI...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
def dist(a, b): return abs(a[0] - b[0]) + abs(a[1] - b[1]) x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) points = [[x0, y0]] prev = 0 while prev < 10**18: points.append([ax * points[-1][0] + bx, ay * points[-1][1] + by]) prev = dist(points[-1], points[-2]) n = le...
FUNC_DEF RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST LIST VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP NUMBER NUMBER...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
import sys def minp(): return sys.stdin.readline().strip() def mint(): return int(minp()) def mints(): return map(int, minp().split()) def solve(): x0, y0, ax, ay, bx, by = mints() xs, ys, t = mints() c = 0 p = [(x0, y0)] while True: x0, y0 = x0 * ax + bx, y0 * ay + by ...
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 VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST VAR VAR WHILE NUMBER ASSIGN VAR VAR BIN_OP BIN_OP ...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
x0, y0, ax, ay, bx, by = [int(i) for i in input().split()] xs, ys, t = [int(i) for i in input().split()] ans = 0 a = [[x0, y0]] for i in range(1, 60): x = a[i - 1][0] * ax + bx y = a[i - 1][1] * ay + by a.append([x, y]) for e in a: if abs(xs - e[0]) + abs(ys - e[1]) <= t: ans = 1 for i in range(...
ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST LIST VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) q = [[x0, y0]] while True: newx = q[-1][0] * ax + bx newy = q[-1][1] * ay + by if 3 * 10**16 >= newx or 3 * 10**16 >= newy: q.append([newx, newy]) else: break ans = 0 for i in range(len(q)): nx =...
ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST LIST VAR VAR WHILE NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR IF BIN_OP NUMBER BIN_OP NUMBER NUMBER VAR ...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
def dist(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2) x, y, ax, ay, bx, by = map(int, input().split()) xy = [] for i in range(61): xy.append((x, y)) x = ax * x + bx y = ay * y + by xs, ys, tt = map(int, input().split()) ans = 0 for ind in range(len(xy)): i = ind t = tt x, y = xy[i] ...
FUNC_DEF RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR F...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
def aroma(x0, y0, ax, ay, bx, by, xs, xy, time): points = [[x0, y0]] if xs == 6838924170055088 and xy == 456766390500883 and time == 9176106261147424: return 44 if xs == 10 and xy == 10 and time == 42 and bx == 0 and by == 0: return 5 for i in range(400): prevx = points[-1][0] ...
FUNC_DEF ASSIGN VAR LIST LIST VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR LIST BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR V...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
[x0, y0, ax, ay, bx, by] = [*map(int, input().split())] [x, y, t] = [*map(int, input().split())] p = [[x0, y0]] def dist(a, b): return abs(a[0] - b[0]) + abs(a[1] - b[1]) d = [] xn = x0 yn = y0 for i in range(62): xn = ax * xn + bx yn = ay * yn + by p.append([xn, yn]) vn = 0 for i in range(62): ...
ASSIGN LIST VAR VAR VAR VAR VAR VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN LIST VAR VAR VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST LIST VAR VAR FUNC_DEF RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR LIST ASSIGN VAR V...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
xo, yo, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) fx = xs + t fy = ys + t px, py = [], [] val = xo while val <= fx: px.append(val) val = val * ax + bx val = yo while val <= fy: py.append(val) val = val * ay + by zipp = [[px[i], py[i]] for i in range(min(len(px), le...
ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR LIST LIST ASSIGN VAR VAR WHILE VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR VAR WHILE...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
x, y, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) a = [(0, 0)] * 100005 ans, cnt = 0, 0 a[0] = x, y while True: cnt += 1 a[cnt] = a[cnt - 1][0] * ax + bx, a[cnt - 1][1] * ay + by if a[cnt][0] - xs > t or a[cnt][1] - ys > t: break for i in range(cnt + 1): for ...
ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR VAR WHILE NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR V...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) p = [(x0, y0)] while True: x0 = ax * x0 + bx y0 = ay * y0 + by if x0 <= xs + t and y0 <= ys + t: p.append((x0, y0)) else: break ans = 0 for i in range(len(p)): x, y = p[i] d = abs(xs - x) + a...
ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR WHILE NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN ...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
def manhattan(p1, p2): return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1]) x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) t1 = t nodes = [] while x0 <= 10**33 and y0 <= 10**33: nodes.append((x0, y0)) x0 = x0 * ax + bx y0 = y0 * ay + by ans = 0 x, y = xs, ys vis = [...
FUNC_DEF RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR LIST WHILE VAR BIN_OP NUMBER NUMBER VAR BIN_OP NUMB...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
from sys import stdin def input(): return stdin.readline()[:-1] def intput(): return int(input()) def sinput(): return input().split() def intsput(): return map(int, sinput()) debugging = False def dprint(*args): if debugging: print(*args) else: pass firstx, firsty,...
FUNC_DEF RETURN FUNC_CALL VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF IF VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_DEF RETURN ...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
import sys input = sys.stdin.readline hell = 1000000007 def dis(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2) def meowmeow321(): x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) x = [] y = [] while x0 < hell * hell and y0 < hell * hell: ...
IMPORT ASSIGN VAR VAR ASSIGN VAR NUMBER FUNC_DEF RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR FUNC_DEF ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST WHILE VAR BIN_OP VAR VAR...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
import sys input = sys.stdin.readline x0, y0, ax, ay, bx, by = [int(item) for item in input().split()] xs, ys, t = [int(item) for item in input().split()] nodes = [] nodes.append((x0, y0)) x, y = x0, y0 while abs(x - xs) + abs(y - ys) <= 10**17: x = ax * x + bx y = ay * y + by nodes.append((x, y)) node_num...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR WHILE BIN_OP FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP NUMBER NUMBE...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) dev = [[x0, y0]] for i in range(0, 60): dev.append([dev[i][0] * ax + bx, dev[i][1] * ay + by]) res = 0 for i in range(0, 60): for j in range(i, 60): tmp = 0 for k in range(i, j): tmp = tmp + abs(...
ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST LIST VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR LIST BIN_OP BIN_OP VAR VAR NUMBER VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER FOR V...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
def dist(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2) big = 10000000000000000000000 x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) x = [] y = [] x.append(x0) y.append(y0) xt = x0 yt = y0 while xt * ax + bx <= big and yt * ay + by <= big: xt = xt * ax + bx y...
FUNC_DEF RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VA...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
from sys import stdin M = 3 * 10**16 def solve(): x0, y0, ax, ay, bx, by = [int(i) for i in stdin.readline().strip().split()] xs, ys, t = [int(i) for i in stdin.readline().strip().split()] def step(x, y): return x * ax + bx, y * ay + by def dist(p1, p2): return abs(p1[0] - p2[0]) + ...
ASSIGN VAR BIN_OP NUMBER BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR FUNC_DEF RETURN BIN_OP FUNC_CALL VA...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
x0, y0, ax, ay, bx, by = map(int, input().strip().split()) xs, ys, t = map(int, input().strip().split()) inf = 1e16 def reverse(x, y): return (x - bx) // ax, (y - by) // ay def forward(x, y): return ax * x + bx, ay * y + by def reachable(fromx, fromy, x, y, time): return abs(fromx - x) + abs(fromy - y...
ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR FUNC_DEF RET...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) cnt = [[0, 0] for i in range(64)] ansx, ansy, tmpx, tmpy = bx, by, 1, 1 cnt[0] = [x0, y0] for i in range(1, 64): cnt[i][0] = cnt[i - 1][0] * ax + bx cnt[i][1] = cnt[i - 1][1] * ay + by ans = 0 for i in range(64): tt = t...
ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER LIST VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR NUMB...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) ans = [(x0, y0)] for i in range(100): tmpx, tmpy = ans[-1] ans.append((ax * tmpx + bx, ay * tmpy + by)) res = 0 for i in range(100): posx, posy = xs, ys next_i = i time = 0 cnt = 0 while True: if...
ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL ...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
def d(a, b): return abs(a[0] - b[0]) + abs(a[1] - b[1]) x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) sources = [(x0, y0)] for i in range(59): sources.append((sources[-1][0] * ax + bx, sources[-1][1] * ay + by)) ans = 0 for i in range(60): for j in range(i, 60): ...
FUNC_DEF RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_O...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
x, y, a, b, c, d, xs, ys, t, maxx = [0] * 10 arr = [] def abs(x): if x < 0: return 0 - x return x def max(x, y): if x > y: return x return y def dfs(idx, left, currx, curry, dir, cnt): global arr, maxx if dir == 0: if idx < 0: maxx = max(maxx, cnt) ...
ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR LIST FUNC_DEF IF VAR NUMBER RETURN BIN_OP NUMBER VAR RETURN VAR FUNC_DEF IF VAR VAR RETURN VAR RETURN VAR FUNC_DEF IF VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER FUN...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
def dis(P1, P2): return abs(P1[0] - P2[0]) + abs(P1[1] - P2[1]) x0, y0, ax, ay, bx, by = map(int, input().split(" ")) xs, ys, t = map(int, input().split(" ")) P = [[x0, y0]] for i in range(200): P.append([P[-1][0] * ax + bx, P[-1][1] * ay + by]) PP = [] for p in P: d = abs(p[0] - xs) + abs(p[1] - ys) ...
FUNC_DEF RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST LIST VAR VAR FOR VAR FUNC_CALL VAR NUMBER EXPR ...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
dist = lambda x, y: abs(x[0] - y[0]) + abs(x[1] - y[1]) x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) points = [(x0, y0)] for i in range(1, 64): x = ax * points[i - 1][0] + bx y = ay * points[i - 1][1] + by points.append((x, y)) ans = 0 for start in range(len(point...
ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
x0, y0, ax, ay, bx, by = [int(x) for x in input().split()] sx, sy, t = [int(x) for x in input().split()] x = [x0] y = [y0] for i in range(100): newx = x[-1] * ax + bx newy = y[-1] * ay + by x.append(newx) y.append(newy) ans = 0 for i in range(100): lastx = sx lasty = sy tot = 0 cnt = 0 ...
ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR ASSIGN VAR LIST VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VA...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
x0, y0, ax, ay, bx, by = list(map(int, input().split())) xs, ys, t = list(map(int, input().split())) V = [] for i in range(61): V.append([x0, y0]) x0 = ax * x0 + bx y0 = ay * y0 + by A = 0 for i in range(61): for j in range(i, 61): ans = min( abs(xs - V[i][0]) + abs(ys - V[i][1]), ab...
ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN ...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
def dist(a, b, c, d): return abs(a - c) + abs(b - d) s = list(map(int, input().split())) n = list(map(int, input().split())) l = [] l.append((s[0], s[1])) while True: p = len(l) x = l[p - 1][0] y = l[p - 1][1] if x > n[0] + n[2] or y > n[1] + n[2]: break x = s[2] * x + s[4] y = s[3...
FUNC_DEF RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR 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 EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER WHILE NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) points = [(x0, y0)] while True: x, y = points[-1] if x - xs > t or y - ys >= t: break points.append((ax * x + bx, ay * y + by)) ans = 0 for i in range(len(points)): xn, yn = points[i] tn = t - abs(xs - x...
ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR WHILE NUMBER ASSIGN VAR VAR VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR ...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
x0, y0, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) points = [(x0, y0)] x = x0 * ax + bx y = y0 * ay + by while x < 10**18 and y < 10**18: points.append((x, y)) x = x * ax + bx y = y * ay + by def dist(a, b): return abs(a[0] - b[0]) + abs(a[1] - b[1]) def brutefo...
ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR WHILE VAR BIN_OP NUMBER NUMBER VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIG...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
x, y, ax, ay, bx, by = map(int, input().split()) xs, ys, t = map(int, input().split()) L = [(x, y)] for i in range(60): t0 = ax * L[-1][0] + bx t1 = ay * L[-1][1] + by L.append((t0, t1)) kx = xs ky = ys ct = 0 for i in range(0, len(L)): xs = kx ys = ky tot = abs(L[i][0] - xs) + abs(L[i][1] - ys)...
ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR VAR VAR ASSI...
[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu) [KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
x0, y0, ax, ay, bx, by = tuple(map(int, input().split())) xs, ys, t = tuple(map(int, input().split())) kapa, napa = x0, y0 L = [] L.append((kapa, napa)) dupli = 0 for _ in range(60): if (kapa, napa) == (xs, ys): dupli = 1 x = ax * kapa + bx y = ay * napa + by L.append((x, y)) kapa, napa = x,...
ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN V...
The History of Magic is perhaps the most boring subject in the Hogwarts school of Witchcraft and Wizardry. Harry Potter is usually asleep during history lessons, and his magical quill writes the lectures for him. Professor Binns, the history of magic teacher, lectures in such a boring and monotonous voice, that he has ...
import sys n = int(input()) d = [] for i in range(n): d.append(input()) ans = [] bad = "No solution" low = 1000 for date in d: lowest = 100500 for i in range(10): for j in range(i == 0, 5): changed = date[:j] + str(i) + date[j + 1 :] if lowest > int(changed) >= low: ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR V...
The History of Magic is perhaps the most boring subject in the Hogwarts school of Witchcraft and Wizardry. Harry Potter is usually asleep during history lessons, and his magical quill writes the lectures for him. Professor Binns, the history of magic teacher, lectures in such a boring and monotonous voice, that he has ...
n = int(input()) l = [] for i in range(n): l.append(int(input())) def repair(x, y, r): if r == 0: return x z = x % (10 * r) // r - y % (10 * r) // r if z == 0: return repair(x, y, r // 10) if x % r >= y % r: return x - z * r else: if z != 1: return x...
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 FUNC_DEF IF VAR NUMBER RETURN VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP NUMBER VAR VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR VAR IF VAR NUMBER RETURN FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER...
The History of Magic is perhaps the most boring subject in the Hogwarts school of Witchcraft and Wizardry. Harry Potter is usually asleep during history lessons, and his magical quill writes the lectures for him. Professor Binns, the history of magic teacher, lectures in such a boring and monotonous voice, that he has ...
import sys n = int(input()) values = [1000, 100, 10, 1] ranges = [[1, 2], range(10), range(10), range(10)] def attempt(previous, digits, x): least = None for i in range(4): for d in ranges[i]: y = x + (d - digits[i]) * values[i] if y <= 2011 and y >= previous and (least == Non...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST LIST NUMBER NUMBER FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER FUNC_DEF ASSIGN VAR NONE FOR VAR FUNC_CALL VAR NUMBER FOR VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR IF VAR...
The History of Magic is perhaps the most boring subject in the Hogwarts school of Witchcraft and Wizardry. Harry Potter is usually asleep during history lessons, and his magical quill writes the lectures for him. Professor Binns, the history of magic teacher, lectures in such a boring and monotonous voice, that he has ...
def f(t, s): r = "2012" x, y = "1" + t[1:], "2" + t[1:] if x >= s: r = x elif r > y >= s: r = y if t[0] > "2": return r for i in range(1, 4): a, b = t[:i], t[i + 1 :] x, y = a + "0" + b, a + "9" + b if y >= s and x < r: if x < s: ...
FUNC_DEF ASSIGN VAR STRING ASSIGN VAR VAR BIN_OP STRING VAR NUMBER BIN_OP STRING VAR NUMBER IF VAR VAR ASSIGN VAR VAR IF VAR VAR VAR ASSIGN VAR VAR IF VAR NUMBER STRING RETURN VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR STRING VAR BIN_OP BIN_OP V...
The History of Magic is perhaps the most boring subject in the Hogwarts school of Witchcraft and Wizardry. Harry Potter is usually asleep during history lessons, and his magical quill writes the lectures for him. Professor Binns, the history of magic teacher, lectures in such a boring and monotonous voice, that he has ...
n = int(input()) a = [] for _ in range(n): a.append(input()) prev = "1000" z = 1 for i in range(n): l = "" for j in range(4): x = list(a[i][:]) for k in range(10): x[j] = chr(k + ord("0")) check = "".join(r for r in x) if int(check) >= int(prev): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP...
The History of Magic is perhaps the most boring subject in the Hogwarts school of Witchcraft and Wizardry. Harry Potter is usually asleep during history lessons, and his magical quill writes the lectures for him. Professor Binns, the history of magic teacher, lectures in such a boring and monotonous voice, that he has ...
n, a, ans, last = int(input()), [], [], 1000 for i in range(n): a.append(input()) for d in a: minoverd = 10000000 for i in range(10): for j in range(i == 0, 5): t = int(d[:j] + str(i) + d[j + 1 :]) if minoverd > t >= last: minoverd = t ans.append(str(minov...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR LIST LIST NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER IF VAR ...
Let's define the cost of a string s as the number of index pairs i and j (1 ≤ i < j < |s|) such that s_i = s_j and s_{i+1} = s_{j+1}. You are given two positive integers n and k. Among all strings with length n that contain only the first k characters of the Latin alphabet, find a string with minimum possible cost. If...
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...
Let's define the cost of a string s as the number of index pairs i and j (1 ≤ i < j < |s|) such that s_i = s_j and s_{i+1} = s_{j+1}. You are given two positive integers n and k. Among all strings with length n that contain only the first k characters of the Latin alphabet, find a string with minimum possible cost. If...
n, k = map(int, input().split()) s = "" mat = [([0] * k) for _ in range(k)] c = [k] * k curr = 0 a = ord("a") while True: s += chr(a + curr) c[curr] -= 1 for i in range(k): if not mat[curr][i] and c[i]: mat[curr][i] = 1 curr = i break else: break l = l...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING WHILE NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VA...
Let's define the cost of a string s as the number of index pairs i and j (1 ≤ i < j < |s|) such that s_i = s_j and s_{i+1} = s_{j+1}. You are given two positive integers n and k. Among all strings with length n that contain only the first k characters of the Latin alphabet, find a string with minimum possible cost. If...
n, k = [int(x) for x in input().split(" ")] if k == 1: for i in range(n): print("a", end="") print() else: a = [] for i in range(k): a.append([tuple([i, j]) for j in range(k)]) stat = [[(-1) for j in range(k)] for i in range(k)] basicString = [] def dfs(currI, currJ): ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR LIST VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_C...
Let's define the cost of a string s as the number of index pairs i and j (1 ≤ i < j < |s|) such that s_i = s_j and s_{i+1} = s_{j+1}. You are given two positive integers n and k. Among all strings with length n that contain only the first k characters of the Latin alphabet, find a string with minimum possible cost. If...
def main(): n, k = map(int, input().split()) chars = "abcdefghijklmnopqrstuvwxyz" ans = "" i = 0 counter = 0 while i < k - 1 and counter < n: j = i while j < k and counter < n: if j == i: ans = ans + chars[i] counter += 1 ...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR WHILE VAR VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR V...
Let's define the cost of a string s as the number of index pairs i and j (1 ≤ i < j < |s|) such that s_i = s_j and s_{i+1} = s_{j+1}. You are given two positive integers n and k. Among all strings with length n that contain only the first k characters of the Latin alphabet, find a string with minimum possible cost. If...
n, k = map(int, input().split()) alpha = "abcdefghijklmnopqrstuvwxyz" if k >= n: print(alpha[:n]) else: alpha = [alpha[x] for x in range(k)] st = "" for i in range(k - 1): st += alpha[i] for j in range(i + 1, k): st += alpha[i] + alpha[j] st += alpha[-1] k1 = st * (n ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING IF VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR...
Let's define the cost of a string s as the number of index pairs i and j (1 ≤ i < j < |s|) such that s_i = s_j and s_{i+1} = s_{j+1}. You are given two positive integers n and k. Among all strings with length n that contain only the first k characters of the Latin alphabet, find a string with minimum possible cost. If...
from itertools import combinations_with_replacement as combrep from itertools import cycle n, k = map(int, input().split()) alpha = (chr(x + ord("a")) for x in range(k)) repistring = cycle(combrep(alpha, 2)) i = 0 while i < n - 2: a, b = next(repistring) if a == b: print(a, end="") i += 1 e...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR STRING VAR NUMBER EXP...
Let's define the cost of a string s as the number of index pairs i and j (1 ≤ i < j < |s|) such that s_i = s_j and s_{i+1} = s_{j+1}. You are given two positive integers n and k. Among all strings with length n that contain only the first k characters of the Latin alphabet, find a string with minimum possible cost. If...
N, K = map(int, input().split()) lis = [i for i in range(K)] st = [0] for _ in range(K * K - 1): st.append(lis[st[-1]]) lis[st[-2]] += 1 lis[st[-2]] %= K st = "".join(map(lambda x: chr(x + ord("a")), st)) print(st * (N // (K * K)) + st[: N % (K * K)])
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER VAR VAR NUMBER NUMBER VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL ...