prompt
stringlengths
254
13.2k
text
stringlengths
405
46.7k
timeout
float64
0.5
30
test_cases
dict
solutions
listlengths
1
13.8k
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Rabbits and cats are competing. The rules are as follows. First, each of the two animals wrote n2...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Rabbits and cats are competing. The rules are as follows. First, each of the two animals wrote n2...
1
{ "input": [ "3 2 2 10\n1 2 3\n4 5 6\n7 8 9\n1 2 3\n6 5 4\n7 8 9\n11\n4\n7\n5\n10\n9\n2\n1\n3\n8", "3 2 1 10\n1 2 3\n4 5 6\n7 8 9\n1 2 3\n6 5 4\n7 8 9\n11\n4\n7\n5\n10\n9\n2\n1\n3\n8", "3 2 4 10\n1 2 3\n4 5 6\n7 8 9\n1 2 3\n6 5 4\n7 8 9\n11\n4\n7\n5\n10\n9\n2\n1\n3\n8", "3 3 4 11\n1 2 3\n8 5 6\n7 8 9\...
[ "# coding: utf-8\nn,u,v,m=map(int,input().split())\nusa=[list(map(int,input().split())) for i in range(n)]\nneko=[list(map(int,input().split())) for i in range(n)]\nusadic={}\nnekodic={}\nusatable=[0 for i in range(2*n+2)]\nnekotable=[0 for i in range(2*n+2)]\nfor i in range(n):\n for j in range(n):\n usa...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Taro came to a square to look for treasure. There are many treasures buried in this square, but Ta...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Taro came to a square to look for treasure. There are many treasures buried in this square, but Ta...
5
{ "input": [ "5 5\n10 5\n-3 -8\n2 11\n6 0\n-1 3\n-3 1 3 13\n-1 -1 9 5\n-3 -8 10 11\n0 0 5 5\n-10 -9 15 10", "3 1\n1 1\n2 4\n5 3\n0 0 5 5", "4 2\n-1 1\n0 3\n4 0\n2 1\n-3 1 5 1\n4 0 4 0", "2 3\n0 0\n0 0\n-1 -1 1 1\n0 0 2 2\n1 1 4 4", "5 5\n10 5\n-3 -8\n2 11\n6 0\n-1 3\n-3 1 3 13\n-1 -1 9 9\n-3 -8 10...
[ "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Broken crypto generator JAG (Japanese Alumni Group) is a mysterious organization composed of many...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Broken crypto generator JAG (Japanese Alumni Group) is a mysterious organization composed of many...
8
{ "input": [ "A+A++A\nZ-Z--Z+-Z\n[ESREVER]\nJ---?---J\n++++++++A+++Z-----------A+++Z\n[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L\n.", "A+A++A\nZ-Z--Z+-Z\n[ESRVEER]\nJ---?---J\n++++++++A+++Z-----------A+++Z\n[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L\n.", "A+A++A\nZ-ZZ--+-Z\n[ESRVEER]\nJ---?---J\...
[ "def pm_to_chr(s):\n s=s.group()\n if s[-1]=='?':\n return 'A'\n ans=chr((((ord(s[-1])+s.count('+')-s.count('-'))-ord('A'))%26)+ord('A'))\n return ans\n\ndef reverse(s):\n s=s.group()\n s=s[1:-1]\n ans=''.join(reversed(s))\n return ans\n\nimport re\n\ns=input()\nwhile s!='.':\n s=r...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: B-Mansion and courier Problem Statement Taro lives alone in a mansion. Taro, who loves studying,...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: B-Mansion and courier Problem Statement Taro lives alone in a mansion. Taro, who loves studying,...
8
{ "input": [ "1 1 5\n3", "1 1 5\n6", "1 1 10\n6", "1 2 10\n6", "1 0 10\n6", "1 1 10\n10", "1 2 9\n9", "1 1 5\n5", "1 1 19\n6", "1 2 20\n6", "1 0 19\n2", "1 1 5\n1", "1 1 33\n6", "1 1 20\n6", "1 1 58\n6", "1 2 37\n6", "1 1 101\n6", "1 2 62\n6", ...
[ "l_raw = input().split()\nl = [int(n) for n in l_raw]\na_raw = input().split()\na_ = [int(n) for n in a_raw]\n\nstudy = 0\nstate = 0\nnow=0\n\nfor a in a_:\n if state==0:\n if l[1]<a-now:\n study+=a-now-l[1]\n now=a\n state=1\n elif state==1:\n if 2*l[1]<a-now:\n ...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: problem Given a sequence $ a_i $ of length $ N $. Output all integers $ K (1 \ le K \ le N) $ tha...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: problem Given a sequence $ a_i $ of length $ N $. Output all integers $ K (1 \ le K \ le N) $ tha...
1
{ "input": [ "8\n5 2 4 9 4 9 2 5", "8\n5 2 4 4 4 9 2 5", "8\n5 2 4 4 4 14 2 0", "8\n-1 10 7 2 2 1 -1 -1", "8\n-1 0 3 32 0 4 -1 0", "8\n0 1 1 -16 -1 0 1 1", "8\n0 1 1 -24 -1 1 1 0", "8\n-1 1 0 -2 1 0 -1 -2", "8\n5 2 4 4 4 14 2 5", "8\n5 2 4 4 4 11 2 0", "8\n5 2 6 4 4 11 2 0"...
[ "from collections import Counter\n\nn = int(input())\na = input().split()\n# a = list(map(int, input().split()))\nans = ''\n# t1, t2 = [], []\nt1, t2 = Counter(), Counter()\nfor i in range(n):\n t1.update(a[i])\n t2.update(a[n-1-i])\n t3 = t1 & t2\n t1 -= t3\n t2 -= t3\n if t1 == t2:\n ans ...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Shell Sort Shell Sort is a generalization of Insertion Sort to arrange a list of $n$ elements $A$...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Shell Sort Shell Sort is a generalization of Insertion Sort to arrange a list of $n$ elements $A$...
6
{ "input": [ "5\n5\n1\n4\n3\n2", "3\n3\n2\n1", "5\n5\n1\n4\n5\n2", "3\n6\n2\n1", "5\n6\n1\n4\n5\n2", "3\n0\n2\n1", "5\n6\n1\n4\n9\n2", "3\n-1\n2\n1", "5\n6\n1\n4\n6\n2", "3\n0\n2\n0", "5\n5\n1\n4\n9\n2", "3\n0\n1\n0", "5\n7\n1\n4\n9\n2", "3\n1\n1\n0", "5\n7\...
[ "def insertionSort(a, n, g):\n global cnt\n for i in range(g, n):\n v = a[i]\n j = i - g\n while j >= 0 and a[j] > v:\n a[j+g] = a[j]\n j = j - g\n cnt = cnt + 1\n a[j+g] = v\n\ndef shellSort(a, n):\n global cnt\n global G\n global m\n c...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Write a program which reads a $ n \times m$ matrix $A$ and a $m \times 1$ vector $b$, and prints t...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Write a program which reads a $ n \times m$ matrix $A$ and a $m \times 1$ vector $b$, and prints t...
1
{ "input": [ "3 4\n1 2 0 1\n0 3 0 1\n4 1 1 0\n1\n2\n3\n0", "3 4\n1 4 0 1\n0 3 0 1\n4 1 1 0\n1\n2\n3\n0", "3 4\n1 2 0 1\n0 3 0 1\n4 1 2 0\n1\n2\n3\n0", "3 4\n1 4 0 1\n0 3 1 1\n4 1 1 0\n1\n2\n3\n0", "3 4\n1 4 0 1\n0 3 1 1\n4 1 1 0\n1\n2\n0\n0", "3 4\n1 4 -1 1\n0 3 0 1\n4 1 1 0\n1\n2\n3\n0", ...
[ "n, m = list(map(int, input().split()))\nmatrix_a = [list(map(int, input().split())) for i in range(n)]\nmatrix_b = [int(input()) for i in range(m)]\nfor i in range(n):\n print(sum([x*y for (x,y) in zip(matrix_b,matrix_a[i])]))", "n, m = map(int, input().split())\n\nA = [list(map(int, input().split())) for _ i...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Alice's hair is growing by leaps and bounds. Maybe the cause of it is the excess of vitamins, or m...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Alice's hair is growing by leaps and bounds. Maybe the cause of it is the excess of vitamins, or m...
1
{ "input": [ "4 7 3\n1 2 3 4\n0\n1 2 3\n0\n1 1 3\n0\n1 3 1\n0\n", "10 24 2\n1 1 1 1 1 1 1 1 1 1\n0\n1 1 1\n0\n1 1 1\n0\n1 3 2\n1 5 2\n1 7 2\n1 9 2\n0\n1 10 1\n0\n1 10 1\n0\n1 10 1\n0\n1 1 1\n0\n1 2 2\n1 4 2\n0\n1 6 2\n1 8 2\n0\n", "10 30 2\n1 1 1 1 1 1 1 1 1 1\n0\n1 1 1\n1 10 1\n0\n1 1 1\n1 10 1\n0\n1 2 2...
[ "n, m, l = map(int, input().split())\na = list(map(int, input().split()))\nnexxt = {}\nprevv = {}\nnexxt[-1] = n\nprevv[n] = -1\n\nsumm = 0\np = -1\nl += 1\nfor k in range(n):\n if a[k] < l:\n p1 = p\n p = k\n nexxt[k] = n\n prevv[k] = p1\n nexxt[p1] = k\n if k - prevv[k...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Let's call an array good if there is an element in the array that equals to the sum of all other e...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Let's call an array good if there is an element in the array that equals to the sum of all other e...
1
{ "input": [ "5\n2 5 1 2 2\n", "4\n8 3 5 2\n", "5\n2 1 2 4 3\n", "3\n3 3 3\n", "5\n5 5 2 2 1\n", "4\n2 2 4 8\n", "2\n1 5\n", "6\n16 4 4 4 4 16\n", "4\n1 1 1 2\n", "6\n4 4 1 1 1 1\n", "3\n1 2 3\n", "3\n1 3 1\n", "4\n1 2 3 4\n", "5\n4 6 7 8 18\n", "7\n1 2 3 4 ...
[ "n=int(input())\na=list(map(int,input().split()))\ns=sum(a)\nd=dict()\nfor i in range(n):\n if a[i] in d:\n d[a[i]].append(i+1)\n else:\n d[a[i]]=[i+1]\nans=[]\nfor k in d.keys():\n if (s-k)%2>0:\n continue\n m=(s-k)//2\n #print(m)\n if m in d and (m!=k or len(d[k])>1):\n ...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: You are given an n × m table, consisting of characters «A», «G», «C», «T». Let's call a table nice...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: You are given an n × m table, consisting of characters «A», «G», «C», «T». Let's call a table nice...
1
{ "input": [ "2 2\nAG\nCT\n", "3 5\nAGCAG\nAGCAG\nAGCAG\n", "2 2\nTG\nAC\n", "2 2\nAG\nTC\n", "2 2\nGA\nTC\n", "3 5\nGACGA\nAGCAG\nAGCAG\n", "2 2\nTG\nCA\n", "2 2\nGA\nCT\n", "2 2\nGT\nAC\n", "2 2\nGT\nCA\n", "3 5\nAGGAC\nGACGA\nGACGA\n", "3 5\nAGCAG\nAGCAG\nGACGA\n", ...
[ "from itertools import permutations\nfrom sys import stdin, stdout\nly, lx = map(int, input().split())\ngrid = [[c for c in inp] for inp in stdin.read().splitlines()]\n\nfirst = set()\nbl = []\nbpattern = []\nbcost = 1e6\nflip_row = False\n\nfor l in permutations('AGCT'):\n if bcost == 0:\n break\n if ...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: The only difference between easy and hard versions is constraints. If you write a solution in Pyt...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: The only difference between easy and hard versions is constraints. If you write a solution in Pyt...
2
{ "input": [ "7 15\n1 2 3 4 5 6 7\n", "5 100\n80 40 40 40 60\n", "3 299\n100 100 100\n", "8 2\n1 1 1 1 1 1 1 1\n", "10 50\n9 9 9 9 9 9 9 9 9 9\n", "1 100\n100\n", "1 20000000\n100\n", "2 100\n1 100\n", "2 100\n100 100\n", "1 1\n1\n", "10 50\n10 10 10 10 10 10 10 10 10 10\n"...
[ "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools\n# import time,random,resource\n\n# sys.setrecursionlimit(10**6)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\nmod2 = 998244353\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: In the city of Saint Petersburg, a day lasts for 2^{100} minutes. From the main station of Saint P...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: In the city of Saint Petersburg, a day lasts for 2^{100} minutes. From the main station of Saint P...
1
{ "input": [ "100000000\n", "101\n", "10100\n", "10001000011101100\n", "100\n", "110\n", "1\n", "1111010010000101100100001110011101111\n", "10000\n", "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\n", "111100001001101011...
[ "n=int(input(),2)\ntemp=0\nl=[]\nwhile(4**temp<n):\n l.append(4**temp)\n temp+=1\nprint(len(l))", "s = input()\nn = len(s)\nif s == '0':\n print(0)\nelif n % 2 == 0:\n print((n + 1) // 2)\nelse:\n flg = 0\n for i in range(1, n):\n if s[i] == '1':\n flg = 1\n if flg == 1:\n ...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: You are given n positive integers a_1, …, a_n, and an integer k ≥ 2. Count the number of pairs i, ...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: You are given n positive integers a_1, …, a_n, and an integer k ≥ 2. Count the number of pairs i, ...
2
{ "input": [ "6 3\n1 3 9 8 24 1\n", "10 2\n7 4 10 9 2 8 8 7 3 7\n", "100 3\n94 94 83 27 80 73 61 38 34 95 72 96 59 36 78 15 83 78 39 22 21 57 54 59 9 32 81 64 94 90 67 41 18 57 93 76 44 62 77 61 31 70 39 73 81 57 43 31 27 85 36 26 44 26 75 23 66 53 3 14 40 67 53 19 70 81 98 12 91 15 92 90 89 86 58 30 67 7...
[ "n,k=map(int,input().split())\nA=list(map(int,input().split()))\n\nimport math\n\nfrom collections import Counter\n\nC=Counter()\n\nfor x in A:\n \n L=int(math.sqrt(x))\n\n FACT=dict()\n\n for i in range(2,L+2):\n while x%i==0:\n FACT[i]=FACT.get(i,0)+1\n x=x//i\n\n if x!...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: The sequence of m integers is called the permutation if it contains all integers from 1 to m exact...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: The sequence of m integers is called the permutation if it contains all integers from 1 to m exact...
2
{ "input": [ "6\n5\n1 4 3 2 1\n6\n2 4 1 3 2 1\n4\n2 1 1 3\n4\n1 3 3 1\n12\n2 1 3 4 5 6 7 8 9 1 10 2\n3\n1 1 1\n", "6\n5\n1 4 3 1 1\n6\n2 4 1 3 2 1\n4\n2 1 1 3\n4\n1 3 3 1\n12\n2 1 3 4 5 6 7 8 9 1 10 2\n3\n1 1 1\n", "6\n5\n1 4 3 2 1\n6\n2 4 1 3 3 1\n4\n2 1 1 3\n4\n1 3 3 1\n12\n2 1 3 4 5 6 7 8 9 1 10 2\n3\n...
[ "import sys\ninput = sys.stdin.readline\n\nQ = int(input())\nQuery = []\nfor _ in range(Q):\n N = int(input())\n A = list(map(int, input().split()))\n Query.append((N, A))\n\nfor N, A in Query:\n leftOK = [True]*(N+1)\n already = set()\n MAX = 0\n for i, a in enumerate(A):\n if a in alre...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: There are n models in the shop numbered from 1 to n, with sizes s_1, s_2, …, s_n. Orac will buy s...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: There are n models in the shop numbered from 1 to n, with sizes s_1, s_2, …, s_n. Orac will buy s...
3
{ "input": [ "4\n4\n5 3 4 6\n7\n1 4 2 3 6 4 9\n5\n5 4 3 2 1\n1\n9\n", "4\n23\n3198 4895 1585 3881 2650 2366 876 2731 1052 126 2152 3621 2169 4103 1074 2594 2897 3983 3830 3460 729 576 3281\n1\n1000000000\n2\n1 1\n100\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34...
[ "import sys\nimport math\nt=int(sys.stdin.readline())\nfor _ in range(t):\n n=int(sys.stdin.readline())\n arr=list(map(int,sys.stdin.readline().split()))\n dp=[1 for x in range(n+1)]\n for i in range(n-1,0,-1):\n j=i*2\n cnt=2\n cur=1\n while j<=n:\n y=dp[j]\n ...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Naman has two binary strings s and t of length n (a binary string is a string which only consists ...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Naman has two binary strings s and t of length n (a binary string is a string which only consists ...
2
{ "input": [ "10\n1111100000\n1111100001\n", "6\n010000\n000001\n", "10\n1111100000\n0000011111\n", "8\n10101010\n01010101\n", "10\n1010111110\n1011101101\n", "12\n011001010101\n111001010101\n", "10\n1100000100\n0010000011\n", "10\n0111101111\n0111111110\n", "3\n000\n000\n", "5...
[ "# -*- coding: utf-8 -*-\n\"\"\"\n@author: Saurav Sihag\n\"\"\"\n\nrr = lambda: input().strip()\n# rri = lambda: int(rr())\nrri = lambda: int(stdin.readline())\nrrm = lambda: [int(x) for x in rr().split()]\n# stdout.write(str()+'\\n')\n\nfrom sys import stdin, stdout\n\ndef sol():\n n=rri()\n s=rr()\n t=rr...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whos...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whos...
2
{ "input": [ "4 7 3 1\n", "2 2 1 1\n", "3 3 2 2\n", "69 84 25 24\n", "4 4 2 2\n", "4 58458 2 1\n", "8 3 2 1\n", "25 94 11 12\n", "45 65 31 32\n", "1 1000 2 1\n", "4 3 2 1\n", "2 100000 1 2\n", "4 4 1 1\n", "2 1 3 1\n", "6 6 1 3\n", "10 10 1 2\n", "1 ...
[ "a1,a2,a3,a4=map(int,input().split())\n\nL=[]\ndef Solve(a1,a2,a3,a4):\n if(a3-a4<-1 or a3-a4>1 or a1<a3 or a1<a4 or a2<a3 or a2<a4):\n return -1\n\n elif(a3-a4==0):\n Ans=\"47\"*a3\n Ans+=\"4\"\n if(a1-a3==0 and a2-a4==0):\n return -1\n elif(a1-a3==0):\n ...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: You are given a matrix a consisting of positive integers. It has n rows and m columns. Construct ...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: You are given a matrix a consisting of positive integers. It has n rows and m columns. Construct ...
2
{ "input": [ "2 3\n16 16 16\n16 16 16\n", "2 2\n1 2\n2 3\n", "2 2\n3 11\n12 8\n", "2 3\n16 16 11\n16 16 16\n", "2 2\n1 2\n3 3\n", "2 2\n6 11\n12 8\n", "2 2\n1 2\n2 5\n", "2 2\n1 2\n4 3\n", "2 2\n1 1\n4 3\n", "2 2\n1 1\n8 3\n", "2 2\n6 10\n12 8\n", "1 2\n1 2\n2 0\n", ...
[ "\nn, m = list(map(int, input().split()))\n\n\nmatrix = []\nfor i in range(n):\n row = list(map(int, input().split()))\n matrix.append(row)\n#print(matrix)\n\nres = [ [ 0 for i in range(m) ] for j in range(n) ] \nfor i in range(n):\n for j in range(m):\n if (i + j) % 2:\n res[i][j] = 7207...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Just in case somebody missed it: this winter is totally cold in Nvodsk! It is so cold that one get...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Just in case somebody missed it: this winter is totally cold in Nvodsk! It is so cold that one get...
2
{ "input": [ "1 1 1\n", "5 2 4\n", "784 1 1999\n", "1000 2 1\n", "341 9 342\n", "4 4 1\n", "7 10 7\n", "13 9 1\n", "100 5 1\n", "239 123 239\n", "7 4 20\n", "1501 893 1501\n", "10 25 8\n", "5 4 5\n", "5 5 5\n", "345 1777 1\n", "5 2 5\n", "10 2 1\...
[ "\nn,m,k = map(int,input().split())\nmod = 10**9 + 7\nif k == 1 or k>n:\n print(pow(m,n,mod))\n\nelif k == n:\n print(pow(m,(n+1)//2,mod))\n\n\nelif k%2== 0:\n\n\n print(m%mod)\nelse:\n print(pow(m,2,mod))\n", "\"\"\"\nhttps://codeforces.com/contest/151/problem/D\n\nYou can build a graph with position...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Vasya has recently bought some land and decided to surround it with a wooden fence. He went to a ...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Vasya has recently bought some land and decided to surround it with a wooden fence. He went to a ...
3
{ "input": [ "1 2\n2 2\n", "2 3\n1 2\n2 3\n", "6 6\n2 1\n3 2\n2 5\n3 3\n5 1\n2 1\n", "100 1500\n3 3\n3 2\n1 3\n3 1\n2 3\n3 2\n3 2\n2 1\n3 1\n2 3\n3 3\n3 1\n1 1\n3 1\n3 3\n2 2\n2 2\n1 2\n1 1\n3 1\n2 2\n2 3\n2 3\n2 2\n3 3\n3 2\n1 1\n3 3\n2 2\n1 3\n3 3\n3 1\n1 2\n3 3\n3 3\n2 2\n1 1\n3 3\n1 3\n2 1\n1 2\n2...
[ "from sys import stdin, stdout\n\nMOD = 10 ** 9 + 7\nsze = 101\nn, l = map(int, stdin.readline().split())\ndp = [[[0, 0] for j in range(l + sze + 1)] for i in range(n)]\n\nbars = []\nchallengers = [[] for i in range(sze)]\n\nfor i in range(n):\n a, b = map(int, stdin.readline().split())\n \n bars.append((a...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Kirito is stuck on a level of the MMORPG he is playing now. To move on in the game, he's got to de...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Kirito is stuck on a level of the MMORPG he is playing now. To move on in the game, he's got to de...
2
{ "input": [ "2 2\n1 99\n100 0\n", "10 1\n100 100\n", "10 1\n10 10\n", "4 2\n2 1\n10 3\n", "2 5\n5 1\n2 1\n3 1\n1 1\n4 1\n", "1 2\n100 1\n100 1\n", "2 3\n1 1\n1 10\n17 2\n", "10 10\n2 10\n3 10\n4 10\n2 20\n3 20\n3 20\n100 50\n100 30\n150 30\n200 10\n", "6 2\n496 0\n28 8128\n", ...
[ "n,m=map(int, input().split())\nr=3\nar=[]\nfor i in range (m):\n q=list(map(int, input().split()))\n ar.append (q)\nar.sort()\nfor i in range (m):\n if n>ar[i][0]:\n n+=ar[i][1]\n else:\n r=5\n print ('NO')\n break\nif r!=5:\n print ('YES')", "s,n=map(int,input().split(...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Valera considers a number beautiful, if it equals 2k or -2k for some integer k (k ≥ 0). Recently, ...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Valera considers a number beautiful, if it equals 2k or -2k for some integer k (k ≥ 0). Recently, ...
2
{ "input": [ "1101101\n", "10\n", "111\n", "1001110101111000111010100110111000000110011011100111001111100001110011011001101110000000\n", "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n", "110\n", "1101100110101101011010101110100100101...
[ "t = input()\nj = t[0]\nd, s = 0, int(j)\nfor i in t[1: ]:\n if j != i:\n if d == 1: d, s = 0, s + 1\n else: d = 1\n j = i\n else: d = 1\nprint(s + (d and j == '1'))", "from math import *\nfrom collections import *\na = list(input())\na = a[::-1]\nn = len(a)\nct = 1\ni = 0\nwhile(i < n-...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Do you remember how Kai constructed the word "eternity" using pieces of ice as components? Little...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Do you remember how Kai constructed the word "eternity" using pieces of ice as components? Little...
1
{ "input": [ "42\n23454\n", "169\n12118999\n", "5518\n9827108589585181118358352282425981568508825302611217254345831149357236227288533838583629451589201341265988858338548185158221291825821019993179835186961954871454\n", "533\n355233333332\n", "9\n666969\n", "2559\n5252555622565626\n", "2569...
[ "def c(a, b):\n\ta = a.replace('6', '9')\n\ta = a.replace('2', '5')\n\tb = b.replace('6', '9')\n\tb = b.replace('2', '5')\n\tn = 10000\n\tfor i in '01345789':\n\t\tt = a.count(i)\n\t\tif t != 0:\n\t\t\tn = min(n, b.count(i)//t)\n\treturn n\na = input()\nb = input()\nprint(c(a, b))", "t=[*map(int,input())]\ns=[*ma...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: «Bersoft» company is working on a new version of its most popular text editor — Bord 2010. Bord, l...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: «Bersoft» company is working on a new version of its most popular text editor — Bord 2010. Bord, l...
2
{ "input": [ "30,20,10\n", "3,2,1\n", "1,2,3,1,1,2,6,6,2\n", "511,32\n", "684,698,429,694,956,812,594,170,937,764\n", "744,359,230,586,944,442\n", "37\n", "996,999,998,984,989,1000,996,993,1000,983,992,999,999,1000,979,992,987,1000,996,1000,1000,989,981,996,995,999,999,989,999,1000\n",...
[ "A=[int(num) for num in input().split(',')]\ns_a=sorted(set(A))\nprev=None\nstring=\"\"\ncount=0\nfor i in s_a:\n if prev is None:\n prev=i\n string+=str(prev)\n count+=1\n else:\n if i-(prev+count)==0:\n count+=1\n else:\n if count>1:\n ...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: George has recently entered the BSUCP (Berland State University for Cool Programmers). George has ...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: George has recently entered the BSUCP (Berland State University for Cool Programmers). George has ...
1
{ "input": [ "3\n1 1\n2 2\n3 3\n", "3\n1 10\n0 10\n10 10\n", "17\n68 69\n47 48\n30 31\n52 54\n41 43\n33 35\n38 40\n56 58\n45 46\n92 93\n73 74\n61 63\n65 66\n37 39\n67 68\n77 78\n28 30\n", "26\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\...
[ "c = 0\n\nfor _ in range(int(input())):\n n = [int(x) for x in input().split()]\n n,m = n[0],n[1]\n\n if m - n >= 2:\n c += 1\nprint(c)\n", "n=int(input())\nanwser=0\nfor i in range(n):\n a,b=map(int,input().split())\n if a<=(b-2):\n anwser=anwser+1\n else:\n continue\nprint...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: A permutation is a sequence of integers from 1 to n of length n containing each number exactly onc...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: A permutation is a sequence of integers from 1 to n of length n containing each number exactly onc...
1
{ "input": [ "9\n1 2 3 1 2 1 4 2 5\n", "4\n4 3 2 1\n", "4\n1 2 2 3\n", "2\n1000 1\n", "5\n2 2 1 1 3\n", "100\n12 18 1 1 14 23 1 1 22 5 7 9 7 1 1 1 3 8 4 2 1 6 9 1 3 2 11 1 11 2 3 2 1 4 2 7 1 16 3 4 2 13 3 1 5 11 2 10 20 24 3 21 5 2 6 2 1 10 10 5 17 1 1 4 19 8 5 5 3 9 4 2 7 8 10 4 9 1 3 3 9 7 6...
[ "def fail():\n print(-1)\n import sys\n sys.exit()\n\nn = int(input())\ncount = (n + 1) * [ 0 ]\nassign = n * [ None ]\nfor i, x in enumerate(map(int, input().split())):\n if x > n:\n fail()\n count[x] += 1\n assign[i] = count[x]\n\nfor i in range(2, n):\n if count[i - 1] < count[i]:\n fail()\n\nprint(...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: One popular blog site edits the uploaded photos like this. It cuts a rectangular area out of them ...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: One popular blog site edits the uploaded photos like this. It cuts a rectangular area out of them ...
2
{ "input": [ "2 1\n", "2 2\n", "5 5\n", "15 13\n", "9 10\n", "47 46\n", "49829224 49889315\n", "483242 484564\n", "644590722 593296648\n", "971840165 826141527\n", "49728622 49605627\n", "99692141 99232337\n", "48298903 49928606\n", "792322809 775058858\n", ...
[ "from math import ceil,floor\nl = []\n\nfor i in range(39):\n l.append(2**i)\nh,w = map(int,input().split())\nh1 = 0\nw1 = 0\nmaxi = 0\n\nfor i in l:\n\n if i<=w:\n a = ceil(i*0.8)\n b = floor(i*1.25)\n if a<=h<=b:\n if i*h>=maxi:\n maxi = i * h\n ...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Alice and Bob love playing one-dimensional battle ships. They play on the field in the form of a l...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Alice and Bob love playing one-dimensional battle ships. They play on the field in the form of a l...
1
{ "input": [ "11 3 3\n5\n4 8 6 1 11\n", "5 1 3\n1\n3\n", "5 1 3\n2\n1 5\n", "200000 1 199999\n2\n2 200000\n", "5000 1660 2\n20\n1 100 18 102 300 81 19 25 44 88 1337 4999 1054 1203 91 16 164 914 1419 1487\n", "50 1 1\n50\n1 13 21 37 30 48 23 19 6 49 36 14 9 24 44 10 41 28 20 2 15 11 45 3 25 33 ...
[ "import sys\n\ndef minp():\n\treturn sys.stdin.readline().strip()\n\ndef mint():\n\treturn int(minp())\n\ndef mints():\n\treturn map(int, minp().split())\n\ndef solve():\n\tn, k, a = mints()\n\ta += 1\n\tm = mint()\n\tx = list(mints())\n\tl = 0\n\tr = m + 1\n\twhile r - l > 1:\n\t\tc = (l + r) // 2\n\t\tb = x[:c]\n...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Someone gave Alyona an array containing n positive integers a1, a2, ..., an. In one operation, Aly...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Someone gave Alyona an array containing n positive integers a1, a2, ..., an. In one operation, Aly...
1
{ "input": [ "5\n1 3 3 3 6\n", "2\n2 1\n", "4\n1 2 2 3\n", "4\n1 4 1 1\n", "2\n3 3\n", "4\n1 2 1 2\n", "3\n3 3 1\n", "3\n2 4 1\n", "2\n1 1\n", "3\n2 2 2\n", "4\n2 2 2 1\n", "4\n2 2 2 3\n", "7\n1 2 2 2 5 5 1\n", "4\n1 4 4 3\n", "4\n2 2 3 2\n", "4\n2 4 1 2...
[ "import sys\nn = int(input())\narr = list(map(int,input().split()))\narr.sort()\nans = 1\nfor i in range(1,n+1):\n if arr[i-1]>=ans:\n ans+=1\nprint(ans)", "input()\nal = list(map(int, input().split()))\nal.sort()\ncur = 1\nfor a in al:\n if cur<=a:\n cur+=1\nprint(cur)", "n = int(input())\n...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Dr. Bruce Banner hates his enemies (like others don't). As we all know, he can barely talk when he...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Dr. Bruce Banner hates his enemies (like others don't). As we all know, he can barely talk when he...
1
{ "input": [ "2\n", "1\n", "3\n", "18\n", "57\n", "100\n", "86\n", "34\n", "82\n", "99\n", "81\n", "19\n", "10\n", "98\n", "5\n", "4\n", "85\n", "76\n", "77\n", "33\n", "12\n", "41\n", "60\n", "24\n", "27\n", "88\n...
[ "x = int(input())\n\nfeelings = ''\nfor _ in range(x):\n\tif _ == x - 1:\n\t\tif _ % 2 != 0:\n\t\t\tfeelings = feelings + 'I love it '\n\t\telse:\n\t\t\tfeelings = feelings + 'I hate it '\n\telse:\n\t\tif _ % 2 != 0:\n\t\t\tfeelings = feelings + 'I love that '\n\t\telse:\n\t\t\tfeelings = feelings + 'I hate that '\...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: The organizers of a programming contest have decided to present t-shirts to participants. There ar...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: The organizers of a programming contest have decided to present t-shirts to participants. There ar...
1
{ "input": [ "0 1 0 1 1 0\n3\nXL\nS,M\nXL,XXL\n", "1 1 2 0 1 1\n5\nS\nM\nS,M\nXXL,XXXL\nXL,XXL\n", "5 1 5 2 4 3\n20\nL,XL\nS,M\nL,XL\nXXL,XXXL\nS,M\nS,M\nXL,XXL\nL,XL\nS,M\nL,XL\nS,M\nM,L\nXXL,XXXL\nXXL,XXXL\nL\nXXL,XXXL\nXL,XXL\nM,L\nS,M\nXXL\n", "1 2 4 4 1 1\n10\nXL\nXL\nS,M\nL\nM,L\nL\nS,M\nM\nXL,X...
[ "\nfrom math import *\nfrom sys import *\n\ndef conv(s):\n\tif s==\"S\" or s==\"S\\n\":\n\t\treturn 1\n\tif s==\"M\" or s==\"M\\n\":\n\t\treturn 2\n\tif s==\"L\" or s==\"L\\n\":\n\t\treturn 3\n\tif s==\"XL\" or s==\"XL\\n\":\n\t\treturn 4\n\tif s==\"XXL\" or s==\"XXL\\n\":\n\t\treturn 5\n\treturn 6\n\ndef uncon(x):...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Bear Limak prepares problems for a programming competition. Of course, it would be unprofessional ...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Bear Limak prepares problems for a programming competition. Of course, it would be unprofessional ...
1
{ "input": [ "4\nVKVK\n", "7\nVVKEVKK\n", "5\nLIMAK\n", "20\nVKVKVVVKVOVKVQKKKVVK\n", "5\nBVVKV\n", "15\nVKKHKKKKZVKKVKV\n", "52\nVAVBVCVDVEVFVGVHVIVJVKVLVMVNVOVPVQVRVSVTVUVVVWVXVYVZ\n", "75\nVAKKVKVKKZVVZAVKKVKVZKKVKVVKKAVKKKVVZVKVKVKKKKVVVVKKVZKVVKKKVAKKZVKKVKVVKVK\n", "51\nAVVVV...
[ "# http://codeforces.com/contest/771/problem/D\n\"\"\"\nDP-solution.\n\nFor each state (v, k, x, v_is_last_letter) we trial a step along the v, k and x\naxes and check that\ndp[future_state] = min(dp[future_state], dp[state] + cost_of_move)\nHence this implicitly reults in the one with least cost.\n\nV, K, X are ar...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: A permutation p of size n is an array such that every integer from 1 to n occurs exactly once in t...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: A permutation p of size n is an array such that every integer from 1 to n occurs exactly once in t...
2
{ "input": [ "4 2\n", "4 1\n", "5 4\n", "5 3\n", "1000 2\n", "400 4\n", "200 3\n", "400 3\n", "800 3\n", "200 1\n", "600 3\n", "200 2\n", "400 2\n", "800 4\n", "1000 4\n", "1000 1\n", "1000 3\n", "200 4\n", "400 1\n", "600 2\n", "800 ...
[ "import math\n\nnk=input().split()\nn=int(nk[0])\nk=int(nk[1])\nL=[0]*5\nL[1]=1\nL[2]=(n*(n-1))//2\nL[3]=(n*(n-1)*(n-2))//3\nL[4]=(3*n*(n-1)*(n-2)*(n-3))//8\ns=0\nfor i in range(0,k+1):\n\ts+=L[i]\nprint(s)\n\n\n", "from math import factorial as fac\npc = {3: 2, 2: 1, 4:9}\nn, k = [int(x) for x in input().split()...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: It's New Year's Eve soon, so Ivan decided it's high time he started setting the table. Ivan has bo...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: It's New Year's Eve soon, so Ivan decided it's high time he started setting the table. Ivan has bo...
1
{ "input": [ "4 7 10\n", "5 2 3\n", "5 2 8\n", "6 12 6\n", "5 5 8\n", "26 93 76\n", "8 7 10\n", "6 75 91\n", "12 97 13\n", "4 3 2\n", "3 2 5\n", "9 4 6\n", "4 5 1\n", "5 20 8\n", "3 9 9\n", "41 67 34\n", "2 1 1\n", "99 99 99\n", "2 90 95\n", ...
[ "#problem 911b\nn,a,b=list(map(int,input().split()))\nprint(max(min(a//i,b//(n-i)) for i in range(1,n)))", "n,a,b=map(int,input().split())\nt=2\no=[]\nwhile(t<=n):\n\tl=min(a,b)\n\tk=max(a,b)\n\ta=l\n\tb=k\n\tr=n//t\n\te=n-r\n\tl=min(r,e)\n\tk=max(r,e)\n\tr=l\n\te=k\n\td=a//r\n\tq=b//e\n\to.append(min(d,q))\n\twh...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal repre...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal repre...
2
{ "input": [ "47\n", "4500\n", "73\n", "444000000\n", "447777\n", "3696\n", "12\n", "100\n", "1024\n", "123\n", "74777443\n", "1007\n", "4\n", "7748\n", "474\n", "74710000\n", "19\n", "70070077\n", "888999577\n", "2145226\n", "7474747...
[ "from itertools import permutations as p\ndef ck(num,arr):\n for i in arr:\n if i>=num:\n print(i)\n return\n\nx = input()\nz = len(x)\n\nif z == 1:\n print(47)\nelif z == 2 :\n if int(x) <= 74:\n arr = [47,74]\n ck(int(x),arr)\n else:\n print(4477)\neli...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: There are K items placed on a grid of squares with R rows and C columns. Let (i, j) denote the squ...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: There are K items placed on a grid of squares with R rows and C columns. Let (i, j) denote the squ...
3
{ "input": [ "2 5 5\n1 1 3\n2 4 20\n1 2 1\n1 3 4\n1 4 2", "2 2 3\n1 1 3\n2 1 4\n1 2 5", "4 5 10\n2 5 12\n1 5 12\n2 3 15\n1 2 20\n1 1 28\n2 4 26\n3 2 27\n4 5 21\n3 5 10\n1 3 10", "2 5 5\n1 1 3\n2 4 20\n2 2 1\n1 3 4\n1 4 2", "4 5 3\n2 5 12\n1 5 12\n2 3 15\n1 2 20\n1 1 28\n2 4 26\n3 2 27\n4 5 21\n3 5...
[ "import sys\n\ninput = sys.stdin.readline\nR, C, k = map(int, input().split())\nxs = [[0] * C for _ in range(R)]\nfor _ in range(k):\n r, c, v = map(int, input().split())\n xs[r - 1][c - 1] = v\n\ndp = [[[0] * (C + 1) for _ in range(R + 1)] for _ in range(4)]\nfor i in range(R):\n for j in range(C):\n ...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: We have three boxes A, B, and C, each of which contains an integer. Currently, the boxes A, B, and...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: We have three boxes A, B, and C, each of which contains an integer. Currently, the boxes A, B, and...
2
{ "input": [ "100 100 100", "41 59 31", "1 2 3", "000 100 100", "41 82 31", "2 2 3", "010 100 100", "41 82 46", "2 2 5", "010 000 100", "41 18 46", "2 2 7", "010 000 110", "41 5 46", "3 2 7", "010 010 110", "41 5 7", "3 2 12", "011 010 110", ...
[ "X, Y, Z = map(int,input().split())\n\nprint(Z, X, Y)", "x, y, z = map(int, input().split())\nprint(z,x,y)", "a,b,c = input().split()\nprint(' '.join([c,a,b]))", "s=input().split()\nprint(\"%s %s %s\" % (s[2],s[0],s[1]))", "a,b,c=input().split()\nprint(\"{} {} {}\".format(c,a,b))", "*s,c=input().split();p...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Takahashi and Aoki are training for long-distance races in an infinitely long straight course runn...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Takahashi and Aoki are training for long-distance races in an infinitely long straight course runn...
2
{ "input": [ "1 2\n10 10\n12 4", "100 1\n101 101\n102 1", "12000 15700\n3390000000 3810000000\n5550000000 2130000000", "1 2\n10 10\n12 5", "100 1\n111 101\n102 1", "100 2\n100 101\n102 1", "1 1\n1 20\n12 5", "100 2\n100 101\n102 0", "1 1\n2 20\n12 5", "100 2\n100 111\n102 0", ...
[ "t = list(map(int, input().split()))\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nx = t[0] * (a[0] - b[0])\ny = x + t[1] * (a[1] - b[1])\nif x*y > 0:\n\tprint(0)\nelif x*y == 0:\n\tprint('infinity')\nelif abs(x) % abs(y) == 0:\n\tprint(2 * (abs(x) // abs(y)))\nelse:\n\tprint(2 * (abs...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: You are given two non-negative integers L and R. We will choose two integers i and j such that L \...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: You are given two non-negative integers L and R. We will choose two integers i and j such that L \...
2
{ "input": [ "4 5", "2020 2040", "3 5", "4 10", "2020 3053", "1 5", "8 10", "2845 3053", "2 5", "6 8", "5 12", "9 10", "543 3053", "1 8", "1022 3053", "0 8", "1022 2650", "-1 8", "1022 4340", "-1 15", "0 15", "-2 15", "-4 15",...
[ "l,r = map(int,input().split())\nr = min(r, l+4038)\nans = 2018\nfor i in range(l,r):\n for j in range(l+1,r+1):\n if ans > i*j%2019:\n ans = i*j%2019\nprint(ans)", "L,R=map(int,input().split())\nleft,right=L%2019,R%2019\nprint(0 if R-L>=2019 else min([i*j%2019 for i in range(left,right+1) fo...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: You are given positive integers A and B. If A is a divisor of B, print A + B; otherwise, print B ...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: You are given positive integers A and B. If A is a divisor of B, print A + B; otherwise, print B ...
2
{ "input": [ "4 12", "8 20", "1 1", "1 12", "4 20", "1 0", "1 2", "4 24", "1 -1", "6 24", "6 36", "6 10", "6 17", "6 32", "5 32", "5 52", "5 10", "2 16", "1 16", "3 19", "5 19", "4 28", "8 28", "22 28", "22 14", "1...
[ "a,b = list(map(int,input().split()))\nprint(a+b if b%a == 0 else b-a)\n", "a, b = (int(i) for i in input().split())\nprint(a+b) if b%a == 0 else print(b-a)", "#118_A\nA,B=map(int,input().split())\nprint(A+B if B%A==0 else B-A)", "a,b=map(int, input().split())\nc=b%a\nif c==0:\n print(a+b)\nelse:\n print(b-...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: You are given an integer L. Construct a directed graph that satisfies the conditions below. The gr...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: You are given an integer L. Construct a directed graph that satisfies the conditions below. The gr...
2
{ "input": [ "4", "5", "8", "2", "1", "9", "6", "3", "10", "17", "18", "33", "16", "12", "20", "40", "36", "32", "65", "24", "34", "66", "48", "68", "72", "129", "64", "130", "136", "80", "160",...
[ "import math\nl = int(input())\nn = math.floor(math.log2(l)) + 1\ne = []\nfor v in range(n-1):\n e.append([v+1, v+2, 0])\n e.append([v+1, v+2, 2**v])\n if (l>>v)&1:\n e.append([v+1, n, l-2**v])\n l -= 2**v\nprint(n, len(e))\nfor x in e:\n print(\" \".join(map(str, x)))", "l=bin(int(input()))[2:];n=len(l...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: There are N people. The name of the i-th person is S_i. We would like to choose three people so t...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: There are N people. The name of the i-th person is S_i. We would like to choose three people so t...
2
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ", "5\nMASHIKE\nRUMOI\nOBIRA\nOROBAH\nHOROKANAI", "5\nCHOKUD@I\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZY\nZZZ\nZ\nZZZZZZZZZZ", "5\nDHOKUD@I\nRNG\nMAKOTO\nAOKI\nRINGN", ...
[ "import itertools\nN = int(input())\n# N=10^5\ncount={}\nfor i in range(N):\n c = input()[0]\n count[c] = count.get(c, 0)+1\ns = 0\nfor a,b,c in itertools.combinations(\"MARCH\", 3):\n s += count.get(a,0)*count.get(b,0)*count.get(c,0)\nprint(s)\n \n\n", "_,*l=open(0)\nimport itertools as it\nprint(sum...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: For a string S, let f(S) be the lexicographically smallest cyclic shift of S. For example, if S = ...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: For a string S, let f(S) be the lexicographically smallest cyclic shift of S. For example, if S = ...
2
{ "input": [ "2 2 0", "1 1 1", "2 1 0", "1 1 0", "0 2 0", "1 0 1", "2 0 0", "1 0 0", "2 2 1", "2 0 1", "3 2 0", "3 0 1", "3 3 0", "3 1 1", "6 3 0", "2 1 1", "6 3 1", "4 1 1", "6 3 2", "4 2 1", "6 0 2", "5 2 1", "6 0 1", "7...
[ "a,b,c = map(int,input().split())\n\nL = [[0] for _ in range(a)] + [[1] for _ in range(b)] + [[2] for _ in range(c)]\nwhile len(L) > 1:\n L[0] += L.pop()\n L.sort()\nprint(''.join(('a','b','c')[i] for i in L[0]))", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,fu...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operat...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operat...
2
{ "input": [ "5\n3 -6 4 -5 7", "4\n1 -3 1 0", "6\n-1 4 3 2 -5 4", "5\n3 -6 4 -8 7", "4\n1 -3 1 -1", "6\n-1 4 3 2 -5 0", "4\n1 -5 1 -1", "6\n-1 4 2 2 -5 0", "5\n3 -8 4 -12 7", "4\n1 -5 0 -1", "6\n-1 4 1 2 -5 0", "5\n3 -5 4 -12 7", "6\n-1 8 1 2 -5 0", "6\n-1 8 2 2...
[ "n=int(input())\na=list(map(int,input().split()))\nu=0\ns=1\nx=0\ny=0\nfor i in a:\n u+=i\n if s*u<=0:\n x+=1-s*u\n u=s\n s=s*(-1)\ns=-1\nu=0\nfor i in a:\n u+=i\n if s*u<=0:\n y+=1-s*u\n u=s\n s=-1*s\nprint(min(x,y))", "n=int(input())\nA=list(map(int,input().split()))\ndef c...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordina...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordina...
2
{ "input": [ "6\n40", "101\n80", "3\n100", "6\n36", "101\n141", "3\n101", "6\n38", "101\n233", "3\n111", "6\n59", "101\n416", "3\n001", "6\n106", "101\n221", "3\n011", "6\n174", "101\n27", "3\n010", "6\n95", "101\n37", "3\n110", "...
[ "#!/usr/bin/env python3\nimport math\nx = int(input())\np = int(input())/100\nprint(math.ceil(x / 2) / p)\n", "print((int(input())+1)//2/int(input())*100)", "x = int(input())\np = int(input()) / 100\nprint(((x + 1) // 2) / p)\n", "\nx = int(input())\n\np = int(input())\n\nif x % 2 == 0:\n print (100 * (x//...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from...
1
{ "input": [ "5", "1", "4", "2", "3", "8", "11", "10", "7", "6", "12", "14", "9", "19", "16", "15", "13", "23", "32", "58", "99", "34", "54", "35", "40", "67", "41", "62", "49", "24", "17", ...
[ "import math\nn = int(input())\na = 100000\nfor _ in range(n):\n a *= 1.05\n a = 1000 * math.ceil(a / 1000)\nprint(a)\n\n", "import sys\nimport math\n\nn = int(input())\ndebt = 100000\nfor i in range(1,n+1):\n\tdebt = math.ceil((debt*1.05)/1000)*1000\nprint(debt)", "import math\ndebt = 100000\nrate = 1.05...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: In a world, a mysterious snake made of only letters lives. Two types of snakes are currently ident...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: In a world, a mysterious snake made of only letters lives. Two types of snakes are currently ident...
1
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~", "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#===>~", "3\n>'======#======~\n>QQ=^=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#===>~", "3\n>(======#======~\n~~=Q=Q=Q=Q=Q=Q=Q=^=QQ>\n>'===#==~>=", "3\n>'======#======~\n>QQ=^=Q=Q=Q=Q=Q=Q=Q=~~\...
[ "import re\n\nSNAKE_A = re.compile(r\">'(=+)#\\1~\")\nSNAKE_B = re.compile(r\">\\^(Q=)+~~\")\n\n\ndef answer(regex, string, output):\n result = regex.fullmatch(string)\n\n if result is not None:\n print(output)\n else:\n print(\"NA\")\n\n\nfor _ in range(int(input())):\n\n snake = input()\...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Kobous...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Kobous...
1
{ "input": [ "3 10\n1 4\n4 1\n2 5", "3 10\n1 4\n4 1\n1 5", "3 13\n1 4\n4 1\n1 5", "3 13\n1 4\n1 1\n1 5", "3 13\n1 4\n1 2\n1 5", "2 13\n1 4\n1 2\n1 5", "2 13\n1 4\n1 2\n1 3", "2 13\n1 6\n1 2\n1 3", "3 10\n1 0\n4 1\n2 5", "3 10\n1 4\n2 1\n1 5", "3 16\n1 4\n1 1\n1 5", "3 1...
[ "for i in range(4):\n t,n=map(int,input().split())\n if t==1:\n print(f'{6000*n}')\n elif t==2:\n print(f'{4000*n}')\n elif t==3:\n print(f'{3000*n}')\n elif t==4:\n print(f'{2000*n}')\n", "tn=[map(int,input().split()) for _ in range(4)]\nt,n=[list(i) for i in zip(*tn)]\...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Mr. Dango's family has an extremely huge number of members. Once it had about 100 members, and now...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Mr. Dango's family has an extremely huge number of members. Once it had about 100 members, and now...
1
{ "input": [ "3 2\n0 1 2\n1 2 1\n2 1\n0 1 100\n2 1\n0 1 0\n2 1\n0 1 -1\n0 0", "3 2\n0 1 2\n1 2 1\n2 1\n0 1 100\n2 1\n0 0 0\n2 1\n0 1 -1\n0 0", "3 2\n0 1 2\n1 2 1\n2 1\n1 1 100\n2 1\n0 0 0\n2 1\n0 1 -1\n0 0", "3 2\n0 2 2\n0 2 1\n2 1\n0 1 100\n2 1\n0 1 0\n2 1\n0 1 -1\n0 0", "3 2\n0 1 2\n1 2 1\n2 1\n...
[ "# AOJ 1065 The House of Huge Family\n# Python3 2018.7.10 bal4u\n\n# UNION-FIND library\nclass UnionSet:\n\tdef __init__(self, nmax):\n\t\tself.size = [1]*nmax\n\t\tself.id = [i for i in range(nmax+1)]\n\tdef root(self, i):\n\t\twhile i != self.id[i]:\n\t\t\tself.id[i] = self.id[self.id[i]]\n\t\t\ti = self.id[i]\n\...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Example Input 10 3 3 7 8 9 2 5 Output 23 A:
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Example Input 10 3 3 7 8 9 2 5 Output 23 A: ```import sys reader=(token for line in sys.stdin...
1
{ "input": [ "10 3\n3 7\n8 9\n2 5", "10 3\n3 7\n8 9\n3 5", "10 3\n3 7\n8 9\n3 8", "10 3\n2 8\n8 9\n3 8", "10 3\n3 7\n8 9\n1 8", "9 3\n3 7\n8 9\n1 5", "10 3\n3 10\n8 9\n1 5", "10 3\n3 4\n8 9\n4 5", "18 3\n3 7\n7 9\n2 5", "18 3\n3 7\n7 9\n1 5", "18 3\n3 7\n7 17\n1 5", "15...
[ "import sys\nreader=(token for line in sys.stdin for token in line.split())\n\nwhile 1:\n try:\n n=int(next(reader))\n m=int(next(reader))\n except: break\n\n a=[1]*(n+1)\n for i in range(m):\n c=int(next(reader))-1\n d=int(next(reader))-1\n for i in range(c,d):\n a[i]=3\n print(sum(a))", ...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Problem N idols, numbered from 1 to n in order, are lined up in a row. Idle i can transmit inform...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Problem N idols, numbered from 1 to n in order, are lined up in a row. Idle i can transmit inform...
1
{ "input": [ "10 3\n2 5 7", "100000 1\n1", "10 5\n2 5 6 8 10", "3 2\n1 3", "10 3\n2 5 8", "10 3\n3 5 7", "100001 1\n1", "110001 1\n1", "10 1\n2 2 8", "3 1\n2 2 12", "1 1\n1 3 12", "10 3\n2 5 6 8 10", "10 1\n1 4 8", "8 1\n2 2 7", "10 1\n3 0 8", "17 2\n2 2...
[ "n, m = map(int, input().split())\na =list(map(int, input().split()))\nt = max(a[0] - 1, n - a[-1])\nfor i in range(1, m):t = max(t, (a[i] - a[i - 1]) // 2)\nprint(t)\n", "n, m = map(int, input().split())\nli = list(map(int, input().split()))\nprint(max(li[0]-1, n-li[-1], *[(li[i]-li[i-1])//2 for i in range(1,m)]...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Mary Thomas has a number of sheets of squared paper. Some of squares are painted either in black o...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Mary Thomas has a number of sheets of squared paper. Some of squares are painted either in black o...
8
{ "input": [ "3 40\n.a....a....a....a....f....f....f....f...\nbc#.#cd#.#de#.#eb#.#cb#.#dc#.#ed#.#eb#.\n.#....#....#....#....#....#....#....#...", "3 40\n.a....a....a....a....f....f....f....f...\nbc#.#cd#.#de#.#eb#.#cb#.#dc#.#ed#.#be#.\n.#....#....#....#....#....#....#....#...", "3 40\n.a....a....a....a......
[ "from collections import deque\nfrom string import ascii_lowercase, ascii_uppercase, digits\nimport sys\nreadline = sys.stdin.readline\nwrite = sys.stdout.write\n\nD = [\n (1, 5, 2, 3, 0, 4), # 'U'\n (3, 1, 0, 5, 4, 2), # 'R'\n (4, 0, 2, 3, 5, 1), # 'D'\n (2, 1, 5, 0, 4, 3), # 'L'\n]\np_dice = (0, 0, 0,...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Let's solve the geometric problem Mr. A is still solving geometric problems today. It is importan...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Let's solve the geometric problem Mr. A is still solving geometric problems today. It is importan...
2
{ "input": [ "1 2", "1 3", "1 6", "3 2", "4 5", "3 10", "3 14", "2 14", "2 17", "3 11", "2 39", "2 13", "3 19", "2 15", "3 38", "3 23", "2 31", "3 55", "3 29", "1 42", "2 35", "2 41", "3 26", "3 47", "2 65", "1 30"...
[ "def gcd(m, n):\n r = m % n\n return gcd(n, r) if r else n\np, q = map(int, input().split())\nq //= gcd(p, q)\n\nx = q; y = 1; k = 2\nwhile k*k <= x:\n if x % k == 0:\n while x % k == 0: x //= k\n y *= k\n k += 1\ny *= x\n\nprint(y)", "import fractions\na,b=map(int,input().split())\nb//=...
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output A:
Q: Write python code to solve the following coding problem that obeys the constraints and passes the example test cases. The output code needs to read from and write to standard IO. Please wrap your code answer using ```: Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output A: `...
1
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "", "4 5 2\n0 0 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "4 5 2\n0 1 2 0\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "4 5 2\n0 1 2 0\n0 2 1 2\n1 2 2 1\n0 3 1 3\n2 3 2 1", "4 5 3\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "4 ...
[ "import heapq\n\nclass MinCostFlow:\n class Edge:\n def __init__(self,to,cap,rev,cost):\n self.to = to\n self.cap = cap\n self.rev = rev\n self.cost = cost\n\n def __init__(self,n,inf=1000000007):\n self.n = n\n self.inf = inf\n self.e = ...