description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
n, k = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) mod = 1000000007 ans = 1 for x in range(0, n // k): po = 10 ** (k - 1) p = c[x] * po q = (c[x] + 1) * po res = 0 if p % b[x] == 0: res -= 1 if q % b[x] == 0: res += 1 ...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR...
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
import sys n, k = map(int, sys.stdin.readline().split()) msa = [int(i) for i in sys.stdin.readline().split()] msb = [int(i) for i in sys.stdin.readline().split()] sch = 1 for i in range(n // k): cha = msa[i] chb = msb[i] chx = (pow(10, k) - 1) // cha + 1 if chb != 0: chx = ( chx ...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR NUM...
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
import time MM = 1000000007 def func(a, b, k): if b == 0: return divmod(10**k - 1, a)[0] - divmod(10 ** (k - 1) - 1, a)[0] else: return ( divmod(10**k - 1, a)[0] - divmod((b + 1) * 10 ** (k - 1) - 1, a)[0] + divmod(b * 10 ** (k - 1) - 1, a)[0] +...
IMPORT ASSIGN VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN BIN_OP FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER VAR NUMBER RETURN BIN_OP BIN_OP BIN_OP FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER...
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
def main(): n, k = map(int, input().split()) tk0, tk1, res = 10 ** (k - 1), 10**k, 1 for a, b in zip(map(int, input().split()), map(int, input().split())): res *= (tk1 - 1) // a - ( (tk0 * (b + 1) - 1) // a - (tk0 * b - 1) // a - 1 if b else (tk0 - 1) // a ) res %= 100000...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP NUMBER VAR NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR BIN_OP BIN_OP BIN_OP BIN...
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
n, k = map(int, input().split()) a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] res, MOD = 1, int(1000000000.0 + 7) pow10 = 10**k for i in range(n // k): lo = pow10 // 10 * b[i] - 1 up = pow10 // 10 * (b[i] + 1) - 1 tmp = (pow10 - 1) // a[i] + 1 tmp -= up // a[i] tmp += ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP B...
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
n, k = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) ans = 1 for i in range(n // k): count = 1 + (10**k - 1) // A[i] count -= (10 ** (k - 1) * (B[i] + 1) - 1) // A[i] - (10 ** (k - 1) * B[i] - 1) // A[ i ] ans = ans * count % (10**9 + 7) print(...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP NUMBER BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR VA...
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
mask = 10**9 + 7 def count(a, x): return x // a + 1 n, k = map(int, input().split()) aa = list(map(int, input().split())) bb = list(map(int, input().split())) big = 10**k - 1 small = 10 ** (k - 1) result = 1 for i in range(n // k): a, b = aa[i], bb[i] sum = 0 sum += count(a, big) sum -= count(a,...
ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NU...
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
n, k = [int(i) for i in input().split()] sum = 1 a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] for i in range(n // k): if n == 0: x = (10**k - 1) // a[i] - ((b[i] + 1) * 10 ** (k - 1) - 1) // a[i] else: x = ( (10**k - 1) // a[i] - ((b[i] + 1)...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR BIN_OP BIN_...
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
n, k = list(map(int, input().split())) a = list(map(int, input().split())) b = list(map(int, input().split())) t = 10 ** (k - 1) res = 1 q = 10**9 + 7 for i in range(n // k): res1 = ((t * 10 - 1) // a[i] + 1) % q z = (t * b[i] - 1) // a[i] + 1 if b[i] == 0: z = 0 x = (t * b[i] + t - 1) // a[i] +...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR ...
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
M = 10**9 + 7 def good(k, a, b): t = (10**k - 1) // a + 1 s = (b * 10 ** (k - 1) - 1) // a + 1 e = ((b + 1) * 10 ** (k - 1) - 1) // a + 1 return (t - (e - s)) % M def total_good(k, ai, bi): p = 1 for a, b in zip(ai, bi): p = p * good(k, a, b) % M return p n, k = map(int, input(...
ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER VAR NUMB...
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
import sys import time inp = list(map(int, input().split())) n = inp[0] k = inp[1] a = list(map(int, input().split())) b = list(map(int, input().split())) cnt = 10**k cnt1 = 10 ** (k - 1) l = n // k ans = 1 for i in range(l): c = (cnt - 1) // a[i] + 1 c -= ( ((b[i] + 1) * cnt1 - 1) // a[i] + 1 ...
IMPORT IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP NUMBER BIN_OP ...
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
n, k = map(int, input().split()) ara = list(map(int, input().split())) arb = list(map(int, input().split())) sum1 = 1 p_k = 10**k p_k1 = 10 ** (k - 1) p_k2 = 10 ** (k - 2) M = 10**9 + 7 for i in range(n // k): k = 0 if p_k % ara[i] == 0: k = -1 if (arb[i] + 1) * p_k1 % ara[i] == 0: k = k + 1...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUM...
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
n, k = [int(_) for _ in input().split()] a = [int(_) for _ in input().split()] b = [int(_) for _ in input().split()] MOD = 10**9 + 7 ans = 1 for i in range(n // k): alls = (10**k - 1) // a[i] + 1 subt = (b[i] * 10 ** (k - 1) + (10 ** (k - 1) - 1)) // a[i] subt -= (b[i] * 10 ** (k - 1) - 1) // a[i] alls ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBE...
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
import sys n, k = sys.stdin.readline().split() n = int(n) k = int(k) a = [int(x) for x in sys.stdin.readline().split()] b = [int(x) for x in sys.stdin.readline().split()] MOD = 10**9 + 7 res = 1 for i in range(0, n // k): lo = b[i] * 10 ** (k - 1) - 1 up = (b[i] + 1) * 10 ** (k - 1) - 1 tmp = (10**k - 1) /...
IMPORT ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VA...
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
def cnt(l, r, x): return (r - l) // x + (l % x == 0) + (l % x > r % x) n, k = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) ans = 1 for i in range(n // k): l = b[i] * pow(10, k - 1) r = (b[i] + 1) * pow(10, k - 1) - 1 ans = ans * (cnt(0, pow(10, k) -...
FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR NUMBER BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR...
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
n, k = map(int, input().split()) As = list(map(int, input().split())) Bs = list(map(int, input().split())) def solve(n, k, As, Bs): mod = 10**9 + 7 c = 1 for a, b in zip(As, Bs): c *= f(a, b, k, mod) c %= mod return c def f(a, b, k, mod): total = (10**k - 1) // a + 1 p = ((b ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR ...
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
mod = 10**9 + 7 n, k = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) ans = 1 for i in range(n // k): cnt = (10**k - 1) // a[i] - (10 ** (k - 1) * (b[i] + 1) - 1) // a[i] if b[i] != 0: cnt += (10 ** (k - 1) * b[i] - 1) // a[i] + 1 ans = ans * cnt % ...
ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN...
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
n, k = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) answer = list() for i in range(n // k): res = 0 m = "1" + "0" * k m = int(m) - 1 q = str(b[i]) + "9" * (k - 1) q = int(q) c = str(b[i] - 1) + "9" * (k - 1) c = int(c) c = max(c, -1) ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP STRING BIN_OP STRING VAR ASSIGN...
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
n, k = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) d = n // k r = [0] * d for i in range(d): r[i] = int("1" * k) * 9 // a[i] + 1 x = int(str(b[i]) + (k - 1) * "9") // a[i] + 1 if b[i] > 0: x -= int(str(b[i] - 1) + (k - 1) * "9") // a[i] + 1 r...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP BIN_OP FUNC_CA...
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
def c(a, b, k): v = (10**k - 1) // a + 1 v -= (10 ** (k - 1) * (b + 1) - 1) // a - (10 ** (k - 1) * b - 1) // a return v MOD, v = 1000000007, 1 n, k = map(int, input().split()) for a, b in zip(map(int, input().split()), map(int, input().split())): v = v * c(a, b, k) % MOD print(v)
FUNC_DEF ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR RETURN VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL...
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
n, k = [int(tmp) for tmp in input().split()] a = [int(tmp) for tmp in input().split()] b = [int(tmp) for tmp in input().split()] BIG = 10**9 + 7 m = n // k ans = [0] * m for i in range(m): ans[i] = (10**k + a[i] - 1) // a[i] x = 10 ** (k - 1) * b[i] % a[i] if x != 0: ans[i] -= (10 ** (k - 1) + x + a...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VA...
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
R = lambda: map(int, input().split()) n, k = R() t = 1 mod = 10**9 + 7 def gn(x, p): if x < 0: return 0 return x // p + 1 def solve(a, b, k): if k == 1: return 9 // a if b % a == 0 else 9 // a + 1 m = b * pow(10, k - 1, a) % a w = 10 ** (k - 1) - 1 + m r = gn(10**k - 1, a) - ...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER RETURN BIN_OP BIN_OP VAR VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN BIN_OP VAR VAR NUMBER BIN_OP NUMBER VAR BIN_OP BIN_OP NUMBER VAR NUMBER...
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
def get_arr(Len): buff = input().split() a = [] for i in range(Len): a.append(int(buff[i])) return a base = int(1000000000.0 + 7) buff = input().split() n = int(buff[0]) k = int(buff[1]) a = get_arr(n // k) b = get_arr(n // k) c = [] for i in range(n // k): ans = 0 if b[i] != 0: ...
FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_...
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
MOD = 10**9 + 7 n, k = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) k1, k2, ans = 10**k, 10 ** (k - 1), 1 for i in range(n // k): z, x = a[i], b[i] if b[i] > 0: c = (x * k2 - 1) // z + (k1 - 1) // z - ((x + 1) * k2 - 1) // z + 1 else: c = ...
ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP NUMBER VAR BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER FOR VAR...
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
import sys n, k = map(int, input().split()) def getNumber(l, r, num): d = l // num if d * num < l: d += 1 l = num * d if l > r: return 0 return (r - l) // num + 1 ans = 1 mod = 10**9 + 7 a = list(map(int, input().split())) b = list(map(int, input().split())) for i in range(0, n ...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR RETURN NUMBER RETURN BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR F...
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
import sys input = sys.stdin.readline n, k = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) mod = 10**9 + 7 ans = 1 for i in range(n // k): ans *= ( (10**k - 1) // a[i] - ((b[i] + 1) * 10 ** (k - 1) - 1) // a[i] + (b[i] * 10 ** (k - 1) - 1)...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BI...
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
def ndivide(k, a, b): return (b - a) // k + (b % k < a % k) + (a % k == 0) n, k = (int(x) for x in input().split()) A = [int(x) for x in input().split()] B = [int(x) for x in input().split()] N = 1 for i in range(n // k): a = B[i] * 10 ** (k - 1) b = (B[i] + 1) * 10 ** (k - 1) - 1 N *= (ndivide(A[i], ...
FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL V...
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into bl...
def divisible(left, right, by): left_div = (left + by - 1) // by * by right -= left_div if right < 0: return 0 return right // by + 1 n, k = map(int, input().split()) aa = list(map(int, input().split())) bb = list(map(int, input().split())) ans = 1 mod = 1000000007 for a, b in zip(aa, bb): ...
FUNC_DEF ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR VAR IF VAR NUMBER RETURN NUMBER RETURN BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL ...
You've got table a, consisting of n rows, numbered from 1 to n. The i-th line of table a contains ci cells, at that for all i (1 < i ≤ n) holds ci ≤ ci - 1. Let's denote s as the total number of cells of table a, that is, <image>. We know that each cell of the table contains a single integer from 1 to s, at that all ...
def find(A, target): for i in range(len(A)): for j in range(len(A[i])): if A[i][j] == target: return [i + 1, j + 1] n = int(input()) C = list(map(int, input().split())) X = [] for i in range(n): Y = list(map(int, input().split())) X.append(Y) cnt = 1 tot = 0 ans = [] fo...
FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR RETURN LIST BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR F...
You've got table a, consisting of n rows, numbered from 1 to n. The i-th line of table a contains ci cells, at that for all i (1 < i ≤ n) holds ci ≤ ci - 1. Let's denote s as the total number of cells of table a, that is, <image>. We know that each cell of the table contains a single integer from 1 to s, at that all ...
import sys input = sys.stdin.readline def prog(): n = int(input()) cs = list(map(int, input().split())) nums = [] locations = {} locations2 = {} i = 1 for c in cs: curr_nums = list(map(int, input().split())) for j in range(c): num = curr_nums[j] num...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR V...
You've got table a, consisting of n rows, numbered from 1 to n. The i-th line of table a contains ci cells, at that for all i (1 < i ≤ n) holds ci ≤ ci - 1. Let's denote s as the total number of cells of table a, that is, <image>. We know that each cell of the table contains a single integer from 1 to s, at that all ...
n = int(input()) I = lambda: map(int, input().split()) li = list(I()) dd = {} arr = [[(0) for i in range(51)] for j in range(51)] l2 = [] c = 0 for i in range(1, n + 1): l1 = list(I()) l2 = l2 + l1 c = c + len(l1) for j in range(li[i - 1]): arr[i][j + 1] = l1[j] dd[l1[j]] = [i, j + 1] l3...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR...
You've got table a, consisting of n rows, numbered from 1 to n. The i-th line of table a contains ci cells, at that for all i (1 < i ≤ n) holds ci ≤ ci - 1. Let's denote s as the total number of cells of table a, that is, <image>. We know that each cell of the table contains a single integer from 1 to s, at that all ...
n = int(input()) col = list(map(int, input().split())) arr = [list(map(int, input().split())) for _ in range(n)] mm = sum(col) ans = [(0, 0)] * (mm + 1) res = [] for i in range(n): for j in range(col[i]): ans[arr[i][j]] = i, j b = 0 for i in range(n): for j in range(col[i]): b += 1 if ar...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR...
You've got table a, consisting of n rows, numbered from 1 to n. The i-th line of table a contains ci cells, at that for all i (1 < i ≤ n) holds ci ≤ ci - 1. Let's denote s as the total number of cells of table a, that is, <image>. We know that each cell of the table contains a single integer from 1 to s, at that all ...
n = int(input()) c = [0] + list(map(int, input().split())) m = sum(c) p, q, r, t = [0] * (m + 1), {}, [0] * m, [] k = 0 for i in range(1, n + 1): s = str(i) + " " for j in range(1, c[i] + 1): r[k] = s + str(j) k += 1 k = 0 for i in range(n): for x in tuple(map(int, input().split())): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER DICT BIN_OP LIST NUMBER VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN V...
You've got table a, consisting of n rows, numbered from 1 to n. The i-th line of table a contains ci cells, at that for all i (1 < i ≤ n) holds ci ≤ ci - 1. Let's denote s as the total number of cells of table a, that is, <image>. We know that each cell of the table contains a single integer from 1 to s, at that all ...
n = int(input()) p = [[0, 0]] l = [0] v = [] for i, c in enumerate(map(int, input().split())): p.extend([[i + 1, j + 1] for j in range(c)]) l.extend(list(map(int, input().split()))) for i in range(1, len(l)): if l[i] != i: j = l.index(i) v.append(p[i] + p[j]) l[i], l[j] = l[j], l[i] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST LIST NUMBER NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_C...
You've got table a, consisting of n rows, numbered from 1 to n. The i-th line of table a contains ci cells, at that for all i (1 < i ≤ n) holds ci ≤ ci - 1. Let's denote s as the total number of cells of table a, that is, <image>. We know that each cell of the table contains a single integer from 1 to s, at that all ...
n, k = int(input()), 1 c = [0] + list(map(int, input().split())) p, q, t = [0] * (sum(c) + 1), {}, [] for i in range(1, n + 1): for j, x in enumerate(tuple(map(int, input().split())), 1): p[x], q[i, j] = (i, j), x for i in range(1, n + 1): for j in range(1, c[i] + 1): if p[k] != (i, j): ...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER DICT LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR...
You've got table a, consisting of n rows, numbered from 1 to n. The i-th line of table a contains ci cells, at that for all i (1 < i ≤ n) holds ci ≤ ci - 1. Let's denote s as the total number of cells of table a, that is, <image>. We know that each cell of the table contains a single integer from 1 to s, at that all ...
def search(t): for i in range(n - 1, -1, -1): for j in range(len(mas[i])): if mas[i][j] == t: return i, j def print1(a, b, c, d): ans.append((a, b, c, d)) n = int(input()) counts = list(map(int, input().split())) d = dict() need = dict() mas = [[] for i in range(n)] s = s...
FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR RETURN VAR VAR FUNC_DEF EXPR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSI...
You've got table a, consisting of n rows, numbered from 1 to n. The i-th line of table a contains ci cells, at that for all i (1 < i ≤ n) holds ci ≤ ci - 1. Let's denote s as the total number of cells of table a, that is, <image>. We know that each cell of the table contains a single integer from 1 to s, at that all ...
def find(a, p, n): for i in range(n): l = len(a[i]) for j in range(l): if a[i][j] == p: return [i + 1, j + 1] n = int(input()) b = list(map(int, input().split())) a = [] for i in range(n): c = list(map(int, input().split())) a.append(c) p = 1 d = [] for i in ran...
FUNC_DEF FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR RETURN LIST BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR ...
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
from itertools import chain def main(n, a, info=False): winner = a[-1] looser = 3 - winner csw, csl, pw, pl, ans = [0], [0], [-1], [-1], [] nw, nl = a.count(winner), a.count(looser) for i in range(n): if a[i] == winner: pw.append(i) else: pl.append(i) ...
FUNC_DEF NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR VAR VAR VAR VAR LIST NUMBER LIST NUMBER LIST NUMBER LIST NUMBER LIST ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBE...
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
n = int(input()) line = input().split() lst = [] for num in line: lst.append(int(num)) cnt1 = [0] cnt2 = [0] c1 = 0 c2 = 0 for num in lst: if num == 1: c1 += 1 cnt1.append(c2) else: c2 += 1 cnt2.append(c1) w = lst[n - 1] ans = [] c1 = len(cnt1) c2 = len(cnt2) for t in range(n...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIG...
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the ne...
import itertools n = int(input()) a = [int(x) for x in input().split()] winner = a[-1] looser = 3 - winner serve_win_cnt, serve_loose_cnt, win_pos, loose_pos, result = [0], [0], [-1], [-1], [] win_cnt = a.count(winner) for i in range(n): if a[i] == winner: win_pos.append(i) else: loose_pos.appe...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR VAR VAR VAR VAR LIST NUMBER LIST NUMBER LIST NUMBER LIST NUMBER LIST ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL V...
Little X has met the following problem recently. Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image> Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the foll...
a = int(input()) sm = 30 * 45 * 10**30 // 10 + 1 l = 1 r = 10**30 l += a - sm % a r += a - sm % a print(l, r)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER NUMBER BIN_OP NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER VAR BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR
Little X has met the following problem recently. Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image> Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the foll...
n = int(input()) sum = 135 * 10**30 x = -1 * sum - 1 x = x % n if x <= 0: x += n print(x + 1, x + 10**30)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP NUMBER NUMBER
Little X has met the following problem recently. Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image> Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the foll...
import sys s = 81000000000000000001 n = int(input()) temp = (n - s % n) % n print("%d %d\n" % (temp + 1, 1000000000000000000 + temp))
IMPORT ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING BIN_OP VAR NUMBER BIN_OP NUMBER VAR
Little X has met the following problem recently. Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image> Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the foll...
def g(x): global arr z = 0 while 10**z <= x: z += 1 z -= 1 ans = 0 while x > 0: y = x // 10**z ans += 10**z * y * (y - 1) // 2 ans += y * arr[z] ans += y * (x % 10**z) x %= 10**z z -= 1 return ans def f(x): r = 0 while x > 0: ...
FUNC_DEF ASSIGN VAR NUMBER WHILE BIN_OP NUMBER VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR BIN_OP VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR VAR NUM...
Little X has met the following problem recently. Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image> Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the foll...
a = int(input()) t = 1000000000000000000000000000 d = 27 * 45 * 100000000000000000000000000 if d % a == 0: print(1, t - 1) else: print(a - d % a, t + (a - d % a) - 1)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR BIN_OP VAR VAR NUMBER
Little X has met the following problem recently. Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image> Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the foll...
a = int(input()) x = 45 * 18 for i in range(17): x *= 10 d = x % a print(str(a - d) + " " + str(a - d + 1000000000000000000 - 1))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP VAR VAR STRING FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER
Little X has met the following problem recently. Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image> Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the foll...
n = input() n = int(n) if n < 46: a = 0 while n: if n >= 10: a = a * 10 + 9 n -= 9 else: a = a * 10 + n n = 0 print(a, a) exit(0) p = 1 for i in range(1, n): p *= 10 m = p // 10 * i * 45 + 1 if m + p > n: k = n - m ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER WHILE VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBE...
Little X has met the following problem recently. Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image> Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the foll...
a = int(input()) l = 1 r = 10**200 cur = [0] cnt = [1] for i in range(300): cur.append(cur[-1] * 10 + 45 * cnt[-1]) cnt.append(cnt[-1] * 10) def calc(x): global cur global cnt res = 0 a = [int(i) for i in str(x)] tot = 0 for i in range(len(a)): if a[i] != 0: for j i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VA...
Little X has met the following problem recently. Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image> Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the foll...
A = int(input()) l = 1 r = 10**100 cnt = 10**99 * 100 * 45 + 1 cnt = -cnt % A l += cnt r += cnt print(l, r)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR
Little X has met the following problem recently. Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image> Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the foll...
n = int(input()) x = 10**18 k = 774 * x % n def inv(a): for i in range(a): if i * n + 1 == (i * n + 1) // a * a: return (i * n + 1) // a if n % 9 == 0: offset = k // 9 elif n % 3 == 0: n //= 3 k //= 3 offset = k * inv(3) % n else: offset = k * inv(9) % n l = x - offset r ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR RETURN BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_O...
Little X has met the following problem recently. Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image> Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the foll...
def f(x, l): return (45 * l + 10 * x) * 10 ** (l - 1) a = int(input()) L = 1 x = 0 if a < 10000: a *= 10000 while f(x, L + 1) < a: L += 1 while f(x + 1, L) < a: x += 1 now = f(x, L) add = a - now di = 0 t = 0 while di < x: if di + 9 <= x: t = t * 10 + 9 di += 9 else: t ...
FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER WHILE FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER WHILE FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER ASSIGN V...
Little X has met the following problem recently. Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image> Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the foll...
a = int(input()) k = 19 x = 45 * k * 10 ** (k - 1) % a l = a - x r = l + 10**k - 1 print(l, r)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR
Little X has met the following problem recently. Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image> Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the foll...
a = int(input()) print( 0 + (a - 10**100 // 10 * 100 * 45 % a), 10**100 - 1 + (a - 10**100 // 10 * 100 * 45 % a), )
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP NUMBER BIN_OP VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP NUMBER NUMBER NUMBER NUMBER NUMBER VAR BIN_OP BIN_OP BIN_OP NUMBER NUMBER NUMBER BIN_OP VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP NUMBER NUMBER NUMBER NUMBER NUMBER VAR
Little X has met the following problem recently. Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image> Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the foll...
n = int(input()) exp = 19 sum = 10 ** (exp - 1) * exp * 45 sum += 1 l = 1 r = 10**19 dif = n - sum % n l += dif r += dif print(l, r)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR
Little X has met the following problem recently. Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image> Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the foll...
def vzlom(a): b = 45 * 10**19 * 20 c = a + (a - b) % a return c, 10**20 + c - 1 print(*vzlom(int(input())))
FUNC_DEF ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR BIN_OP BIN_OP BIN_OP NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR
Little X has met the following problem recently. Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image> Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the foll...
def sumfunc(k): return 45 * 10 ** (k - 1) * k a = int(input()) val = sumfunc(18) val %= a rev = (a - val) % a if rev == 0: print(1, 10**18 - 1) else: print(rev, 10**18 + rev - 1)
FUNC_DEF RETURN BIN_OP BIN_OP NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP NUMBER NUMBE...
Little X has met the following problem recently. Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image> Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the foll...
try: while True: a = int(input()) b = 10**17 % a b = (b * 45 * 18 + 1) % a print(1 + (a - b), int(1e18) + (a - b)) except EOFError: pass
WHILE NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER VAR EXPR FUNC_CALL VAR BIN_OP NUMBER BIN_OP VAR VAR BIN_OP FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR
You have n devices that you want to use simultaneously. The i-th device uses ai units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·ai units of power. The i-th device currently has bi units of power stored. All devices can store an arbitrary amount of power. You have a si...
n__power = input().split() n = int(n__power[0]) power = int(n__power[1]) items = [] for _ in range(n): p__a = input().split() p = int(p__a[0]) a = int(p__a[1]) time = a / p items.append((time, p, a)) items.sort() sys_power = -power sys_amount = 0 sys_time = None while len(items) > 0: t, p, a = i...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FU...
You have n devices that you want to use simultaneously. The i-th device uses ai units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·ai units of power. The i-th device currently has bi units of power stored. All devices can store an arbitrary amount of power. You have a si...
def solve(): n, p = map(int, input().split()) persec = [] cur = [] for i in range(n): a, b = map(int, input().split()) persec.append(a) cur.append(b) if sum(persec) <= p: print(-1) return full_time = 0 curtime = [(cur[i] / persec[i]) for i in range(len...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR NUMBER ASSIGN VAR BIN_OP...
You have n devices that you want to use simultaneously. The i-th device uses ai units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·ai units of power. The i-th device currently has bi units of power stored. All devices can store an arbitrary amount of power. You have a si...
n, p = [int(x) for x in input().split()] a = [] pl = 0 pn = 0 t = 0 for i in range(n): x, y = [int(x) for x in input().split()] a += [(x, y / x)] a.sort(key=lambda x: x[1]) pn, t = 0, a[0][1] pl = t * p for i in range(1, n): ec, et = a[i - 1][0], a[i][1] pn += ec ts = et - t if pn * ts <= pl + p...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR LIST VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER NUMBER ASSI...
You have n devices that you want to use simultaneously. The i-th device uses ai units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·ai units of power. The i-th device currently has bi units of power stored. All devices can store an arbitrary amount of power. You have a si...
def check(t): global a, b, p, n x = 0 for i in range(n): x += max(0, t * a[i] - b[i]) return x / t <= p n, p = map(int, input().split()) p = float(p) a, b = [(0) for i in range(n)], [(0) for i in range(n)] s = 0 for i in range(n): a[i], b[i] = map(float, input().split()) s += a[i] if s...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR VAR VAR VAR RETURN BIN_OP VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR V...
You have n devices that you want to use simultaneously. The i-th device uses ai units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·ai units of power. The i-th device currently has bi units of power stored. All devices can store an arbitrary amount of power. You have a si...
from sys import stdin, stdout n, p = map(int, stdin.readline().rstrip().split()) powerData = [] powerList = [] for i in range(n): a, b = map(int, stdin.readline().rstrip().split()) deathTime = b / a powerData.append((a, b, deathTime)) powerList.append(a) powerData.sort(key=lambda x: x[2]) if sum(powerL...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR V...
You have n devices that you want to use simultaneously. The i-th device uses ai units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·ai units of power. The i-th device currently has bi units of power stored. All devices can store an arbitrary amount of power. You have a si...
if 1: N, P = [int(i) for i in input().split()] p = [] b = [] for _ in range(N): pp, bb = [int(i) for i in input().split()] p.append(pp) b.append(bb) else: N, P = 10000, 999999999 p = [100000] * N b = [100000] * N sp = sum(p) sb = sum(b) if P >= sp: print(-1) else:...
IF NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIS...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
n = int(input()) for i in range(n): p = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) d = [] for i in range(len(a)): d.append([a[i], b[i]]) d.sort(key=lambda x: x[0], reverse=True) c = 1 ma = d[0][1] for i in range(len(d)): if d[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VA...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
t = int(input()) for l in range(t): n = int(input()) arr = list(map(int, input().split())) ar = list(map(int, input().split())) nums = [] for i in range(n): nums.append([arr[i], ar[i]]) nums.sort(key=lambda x: x[0]) maxil = [None for _ in range(n)] maxi = 0 cnt = 0 for i ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR 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 FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR VAR ...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
for i in range(int(input())): n_trainer = int(input()) pokemon_trainer_powers = [ (i, j) for i, j in zip(map(int, input().split()), map(int, input().split())) ] pokemon_trainer_powers = sorted(pokemon_trainer_powers, key=lambda x: x[0]) pokemon_trainer_qualifiers = 0 mx_b = 0 for ptp...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR NUMBER IF VAR NUMB...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
def sort_by_wtr_pwr(arr): return arr[1] def find_qualifiers(no_of_pokemons, gnd_pwr, wtr_pwr): pokemon_pwr = [(gnd_pwr[i], wtr_pwr[i]) for i in range(no_of_pokemons)] pokemon_pwr.sort(key=sort_by_wtr_pwr, reverse=False) no_of_qualifiers = 1 max_gnd_pwr_a_pokemon_has_had = pokemon_pwr[no_of_pokemon...
FUNC_DEF RETURN VAR NUMBER FUNC_DEF ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR F...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
t = int(input()) count = 0 for i in range(t): N = int(input()) a = list(map(int, input().strip().split()))[:N] b = list(map(int, input().strip().split()))[:N] c = [(a[i], b[i]) for i in range(N)] c.sort() ans, mx = 0, 0 for i in range(N - 1, -1, -1): if c[i][1] > mx: ans ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
t = int(input()) while t > 0: n = int(input()) a = list(map(int, input().split()))[:n] b = list(map(int, input().split()))[:n] c = [] for i in range(len(a)): d = 0 for j in range(n): if a[i] > a[j] or b[i] > b[j]: d = d + 1 elif a[i] < a[j] and...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR F...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
T = int(input()) for _ in range(T): N = int(input()) X = list(map(int, input().split())) Y = list(map(int, input().split())) Z = list(zip(X, Y)) Z.sort(key=lambda x: x[0]) answer = 0 maximum = -1 for A, B in reversed(Z): if B > maximum: answer += 1 maximum...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIG...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
for _ in range(int(input())): n = int(input()) a = [int(x) for x in input().split()] b = [int(x) for x in input().split()] b = [x for _, x in sorted(zip(a, b))] a.sort() ans = 1 mx = b[n - 1] for i in range(n - 2, -1, -1): if b[i] > mx: ans += 1 mx = b[i] ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR BIN_OP...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
t = int(input()) for i in range(t): tra = 0 wtr = 0 n = int(input()) array_g = list(map(int, input().split())) array_w = list(map(int, input().split())) f = list(zip(array_g, array_w)) f.sort() for i in range(-1, -n - 1, -1): if f[i][1] > wtr: wtr = f[i][1] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
for i in range(int(input())): n = 0 n = int(input()) everyones_win = [] max1 = 1 a = list(map(int, input().split())) b = list(map(int, input().split())) for i in range(n): win_proper = 0 for j in range(n): if a[i] < a[j] and b[i] < b[j]: break ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER F...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
x = int(input()) for i in range(x): n = int(input()) A = list(map(int, input().split(" "))) B = list(map(int, input().split(" "))) b = [] vect = [] k = 1 for i in range(n): vect.append([A[i], B[i]]) vect = sorted(vect) for i in range(n): b.append(vect[i][1]) c = [...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL ...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = [[a[i], b[i]] for i in range(n)] c.sort(key=lambda x: x[0]) a = [c[i][0] for i in range(n)] b = [c[i][1] for i in range(n)] total = 0 max_ = 0 for i in range...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VA...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
t = int(input()) while t > 0: n = int(input()) ground = list(map(int, input().split(" "))) water = list(map(int, input().split(" "))) power = [(ground[i], water[i]) for i in range(n)] power.sort() ans, mx = 0, 0 for i in reversed(range(n)): if power[i][1] > mx: ans += 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VA...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
def sol(): n = int(input()) ground = list(map(int, input().split())) water = list(map(int, input().split())) c = [(ground[i], water[i]) for i in range(n)] c.sort() ans, mx = 0, 0 for i in range(n - 1, -1, -1): if c[i][1] > mx: ans += 1 mx = max(mx, c[i][1]) pr...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER N...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
for _ in range(int(input())): n = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) d = {} for i in range(n): d[A[i]] = B[i] mx = 0 count = 0 for i in reversed(sorted(d.keys())): if mx < d[i]: count += 1 mx = d[i]...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR 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 DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
def solve(n, arr, brr): t = [] for i in range(n): t.append((arr[i], brr[i])) t.sort(key=lambda x: x[0], reverse=True) count = 0 maxn = 0 for i in range(0, n): a = t[i][0] b = t[i][1] if b > maxn: maxn = b count += 1 print(count) t = i...
FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
from sys import stdin def pokeman(n, arr1, arr2): arr = [(arr1[i], arr2[i]) for i in range(n)] arr.sort(key=lambda x: x[0]) maxo = -1 count = 0 for i in range(n - 1, -1, -1): if arr[i][1] > maxo: count += 1 maxo = arr[i][1] return count t = int(stdin.readline(...
FUNC_DEF ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR V...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
def pokemon(n, a, b): count = 0 for i in range(len(a)): flag = True for j in range(len(a)): if i == j: pass elif a[i] < a[j] and b[i] < b[j]: flag = False break if flag: count += 1 return count t = ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VA...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
for _ in range(int(input())): n = int(input()) a = sorted(zip(map(int, input().split()), map(int, input().split())), reverse=True) ans = 1 mx = a[0][1] for i, j in a: if j > mx: ans += 1 mx = j print(ans)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR E...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
for _ in range(int(input())): N = int(input()) land = list(map(int, input().split())) water = list(map(int, input().split())) zipArr = sorted(zip(land, water)) tempTuple = zip(*zipArr) newLand, newWater = [list(element) for element in tempTuple] newLand = newLand[::-1] newWater = newWate...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_C...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
for T in range(int(input())): lent = int(input()) land = list(map(lambda x: int(x), input().split())) water = list(map(lambda x: int(x), input().split())) count = 0 l = [] for i in range(lent): l.append([land[i], water[i]]) l.sort(reverse=True) m = 0 for i in range(len(l)): ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = sorted([(a[i], b[i]) for i in range(n)], reverse=True) _max = c[0][1] counter = 1 for _c in c: if _c[1] > _max: _max = _c[1] counter += 1...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBE...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
def strength(n, A, B): c = [(A[i], B[i]) for i in range(n)] c.sort() mx = 0 count = 0 for i in reversed(range(n)): if c[i][1] > mx: count += 1 mx = max(mx, c[i][1]) print(count) for i in range(int(input())): n = int(input()) A = list(map(int, input().split()...
FUNC_DEF ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_C...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
T = int(input()) for m in range(T): N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) d = {} for i in range(N): d[A[i]] = B[i] d = sorted(d.items(), reverse=True) count = 1 mx = d[0][1] for i in d: if i[1] > mx: count...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR FU...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
t = int(input()) for i in range(t): n = int(input()) gp = list(map(int, input().split(" "))) wp = list(map(int, input().split(" "))) lst = [i for i in range(n)] p = list(zip(gp, lst)) p.sort(key=lambda x: x[0]) q = [g[1] for g in p] x = n - 2 cnt = 1 maxi = wp[q[n - 1]] while...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_C...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
for _ in range(int(input())): t = int(input()) count = 1 gPokemon = list(map(int, input().split())) wPokemon = list(map(int, input().split())) trainer = zip(gPokemon, wPokemon) trainer = sorted(trainer) count_max = trainer[-1][1] for i in range(t - 2, -1, -1): if count_max < trai...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NU...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
for i in range(int(input())): n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) p = [(a[i], b[i]) for i in range(n)] p = sorted(p, key=lambda x: x[0]) mx = p[n - 1][1] ans = 1 for i in reversed(range(n)): if p[i][1] > mx: ans += ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN V...
There are N Pokemon trainers numbered from 1 to N. Each trainer has one Pokemon. All the trainers have arrived to participate in a contest. There are two battle arenas, one in ground and other in water. Each Pokemon may have different power in both the arenas. When two Pokemon fight in an arena, the Pokemon having ...
for _ in range(int(input())): n = int(input()) G = list(map(int, input().split())) W = list(map(int, input().split())) tup = [] res = 1 for i in range(n): tup.append((G[i], W[i])) tup.sort(key=lambda x: x[0], reverse=True) for i in range(1, n): j = i - 1 flag = 1 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR EX...
Mandarin chinese , Russian and Vietnamese as well. Chef is organising a contest with $P$ problems (numbered $1$ through $P$). Each problem has $S$ subtasks (numbered $1$ through $S$). The difficulty of a problem can be calculated as follows: - Let's denote the score of the $k$-th subtask of this problem by $SC_k$ and t...
p, s = map(int, input().split()) a = [] for i in range(p): temp = [] temp.append(list(map(int, input().split()))) temp.append(list(map(int, input().split()))) temp = [[temp[0][i], temp[1][i]] for i in range(s)] temp.sort() cnt = 0 for j in range(s - 1): if temp[j][1] > temp[j + 1][1]...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER VAR VAR NUMBER VAR VAR FUNC_...
Mandarin chinese , Russian and Vietnamese as well. Chef is organising a contest with $P$ problems (numbered $1$ through $P$). Each problem has $S$ subtasks (numbered $1$ through $S$). The difficulty of a problem can be calculated as follows: - Let's denote the score of the $k$-th subtask of this problem by $SC_k$ and t...
def mi(): return map(int, input().split()) def li(): return list(mi()) def si(): return str(input()) def ni(): return int(input()) p, s = mi() A = [] for at in range(p): d = [] n = 0 L = li() X = li() for i in range(s): d.append((L[i], X[i])) d.sort() for i in...
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ...
Mandarin chinese , Russian and Vietnamese as well. Chef is organising a contest with $P$ problems (numbered $1$ through $P$). Each problem has $S$ subtasks (numbered $1$ through $S$). The difficulty of a problem can be calculated as follows: - Let's denote the score of the $k$-th subtask of this problem by $SC_k$ and t...
ans = [] x, y = map(int, input().split()) for _ in range(x): A = list(map(int, input().split())) B = list(map(int, input().split())) L = list(zip(A, B)) L.sort() co = 1 for i in range(y - 1): if L[i][1] > L[i + 1][1]: co += 1 ans.append([co, _]) ans.sort() for i in ans: ...
ASSIGN VAR LIST ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR...
Mandarin chinese , Russian and Vietnamese as well. Chef is organising a contest with $P$ problems (numbered $1$ through $P$). Each problem has $S$ subtasks (numbered $1$ through $S$). The difficulty of a problem can be calculated as follows: - Let's denote the score of the $k$-th subtask of this problem by $SC_k$ and t...
p, s = map(int, input().split(" ")) pn = [] def getScore(ps): c = 0 for i in range(1, s): if ps[i - 1][1] > ps[i][1]: c += 1 return c for i in range(p): ps = [] ns = list(map(int, input().split(" "))) sc = list(map(int, input().split(" "))) for j in range(s): ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ST...
Mandarin chinese , Russian and Vietnamese as well. Chef is organising a contest with $P$ problems (numbered $1$ through $P$). Each problem has $S$ subtasks (numbered $1$ through $S$). The difficulty of a problem can be calculated as follows: - Let's denote the score of the $k$-th subtask of this problem by $SC_k$ and t...
p, s = input().split() p = int(p) s = int(s) n = [(0) for i in range(p)] for prob in range(p): points = list(map(int, input().split())) nop = list(map(int, input().split())) for i in range(s): nop[i] = [points[i], nop[i]] nop.sort() for i in range(s): nop[i] = nop[i][1] sorted_no...
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR V...
Mandarin chinese , Russian and Vietnamese as well. Chef is organising a contest with $P$ problems (numbered $1$ through $P$). Each problem has $S$ subtasks (numbered $1$ through $S$). The difficulty of a problem can be calculated as follows: - Let's denote the score of the $k$-th subtask of this problem by $SC_k$ and t...
pavan, sai = list(map(int, input().split())) narr = [] for k in range(900): narr.append([-1]) for i2 in range(pavan): sc = list(map(int, input().split())) ns1 = list(map(int, input().split())) ns = [x for _, x in sorted(zip(sc, ns1))] count = 0 for i in range(sai - 1): if ns[i] > ns[i + ...
ASSIGN 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 NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VA...
Mandarin chinese , Russian and Vietnamese as well. Chef is organising a contest with $P$ problems (numbered $1$ through $P$). Each problem has $S$ subtasks (numbered $1$ through $S$). The difficulty of a problem can be calculated as follows: - Let's denote the score of the $k$-th subtask of this problem by $SC_k$ and t...
p, s = map(int, input().split()) sc = [] n = [] diff = [] for i in range(2 * p): inp = [int(i) for i in input().split()] if i % 2: j = sc[-1] for i in range(s): n.append([j[i], inp[i]]) else: sc.append(inp) for j in range(0, len(n), s): tp = n[j : j + s] tp.sort(k...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR VAR EXPR FUNC...
Mandarin chinese , Russian and Vietnamese as well. Chef is organising a contest with $P$ problems (numbered $1$ through $P$). Each problem has $S$ subtasks (numbered $1$ through $S$). The difficulty of a problem can be calculated as follows: - Let's denote the score of the $k$-th subtask of this problem by $SC_k$ and t...
p, s = map(int, input().split()) sc = [([0] * s) for _ in range(p)] ns = [([0] * s) for _ in range(p)] ans = [[i + 1, 0] for i in range(p)] for i in range(p): sc[i] = list(map(int, input().split())) ns[i] = list(map(int, input().split())) zipped_pair = zip(sc[i], ns[i]) zipped_pair2 = zip(sc[i], ns[i]) ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_...
Mandarin chinese , Russian and Vietnamese as well. Chef is organising a contest with $P$ problems (numbered $1$ through $P$). Each problem has $S$ subtasks (numbered $1$ through $S$). The difficulty of a problem can be calculated as follows: - Let's denote the score of the $k$-th subtask of this problem by $SC_k$ and t...
p, s = tuple(map(int, input().split())) ans = {} for i in range(p): score = list(map(int, input().split())) contestant = list(map(int, input().split())) d = {} for j in range(s): d[score[j]] = contestant[j] inc_score = list(d.keys()) inc_score.sort() new = [] for j in range(s): ...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSI...