source
stringclasses 4
values | task_type
stringclasses 1
value | in_source_id
stringlengths 0
138
| problem
stringlengths 219
13.2k
| gold_standard_solution
stringlengths 0
413k
| problem_id
stringlengths 5
10
| metadata
dict | verification_info
dict |
---|---|---|---|---|---|---|---|
code_contests
|
verifiable_code
|
821_A. Okabe and Future Gadget Laboratory
|
Solve the following coding problem using the programming language python:
Okabe needs to renovate the Future Gadget Laboratory after he tried doing some crazy experiments! The lab is represented as an n by n square grid of integers. A good lab is defined as a lab in which every number not equal to 1 can be expressed as the sum of a number in the same row and a number in the same column. In other words, for every x, y such that 1 β€ x, y β€ n and ax, y β 1, there should exist two indices s and t so that ax, y = ax, s + at, y, where ai, j denotes the integer in i-th row and j-th column.
Help Okabe determine whether a given lab is good!
Input
The first line of input contains the integer n (1 β€ n β€ 50) β the size of the lab.
The next n lines contain n space-separated integers denoting a row of the grid. The j-th integer in the i-th row is ai, j (1 β€ ai, j β€ 105).
Output
Print "Yes" if the given lab is good and "No" otherwise.
You can output each letter in upper or lower case.
Examples
Input
3
1 1 2
2 3 1
6 4 1
Output
Yes
Input
3
1 5 2
1 1 1
1 2 3
Output
No
Note
In the first sample test, the 6 in the bottom left corner is valid because it is the sum of the 2 above it and the 4 on the right. The same holds for every number not equal to 1 in this table, so the answer is "Yes".
In the second sample test, the 5 cannot be formed as the sum of an integer in the same row and an integer in the same column. Thus the answer is "No".
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
def good(lab):
for i, line in enumerate(lab):
for j, item in enumerate(line):
if item == 1:
continue
flag = False
for k, x in enumerate(line):
if j==k:
continue
col = [l[j] for l in lab]
for m, y in enumerate(col):
if m==i:
continue
if x+y==item:
flag = True
if not flag:
return "No"
return "Yes"
def main():
N = int(input())
lab = [[int(item) for item in input().split()] for _ in range(N)]
print(good(lab))
if __name__ == "__main__":
main()
```
|
vfc_81073
|
{
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 1 2\n2 3 1\n6 4 1\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 5 2\n1 1 1\n1 2 3\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1 1 1 1\n1 12 1 2\n4 4 1 3\n5 10 6 1\n",
"output": "Yes\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
847_A. Union of Doubly Linked Lists
|
Solve the following coding problem using the programming language python:
Doubly linked list is one of the fundamental data structures. A doubly linked list is a sequence of elements, each containing information about the previous and the next elements of the list. In this problem all lists have linear structure. I.e. each element except the first has exactly one previous element, each element except the last has exactly one next element. The list is not closed in a cycle.
In this problem you are given n memory cells forming one or more doubly linked lists. Each cell contains information about element from some list. Memory cells are numbered from 1 to n.
For each cell i you are given two values:
* li β cell containing previous element for the element in the cell i;
* ri β cell containing next element for the element in the cell i.
If cell i contains information about the element which has no previous element then li = 0. Similarly, if cell i contains information about the element which has no next element then ri = 0.
<image> Three lists are shown on the picture.
For example, for the picture above the values of l and r are the following: l1 = 4, r1 = 7; l2 = 5, r2 = 0; l3 = 0, r3 = 0; l4 = 6, r4 = 1; l5 = 0, r5 = 2; l6 = 0, r6 = 4; l7 = 1, r7 = 0.
Your task is to unite all given lists in a single list, joining them to each other in any order. In particular, if the input data already contains a single list, then there is no need to perform any actions. Print the resulting list in the form of values li, ri.
Any other action, other than joining the beginning of one list to the end of another, can not be performed.
Input
The first line contains a single integer n (1 β€ n β€ 100) β the number of memory cells where the doubly linked lists are located.
Each of the following n lines contains two integers li, ri (0 β€ li, ri β€ n) β the cells of the previous and the next element of list for cell i. Value li = 0 if element in cell i has no previous element in its list. Value ri = 0 if element in cell i has no next element in its list.
It is guaranteed that the input contains the correct description of a single or more doubly linked lists. All lists have linear structure: each element of list except the first has exactly one previous element; each element of list except the last has exactly one next element. Each memory cell contains information about one element from some list, each element of each list written in one of n given cells.
Output
Print n lines, the i-th line must contain two integers li and ri β the cells of the previous and the next element of list for cell i after all lists from the input are united in a single list. If there are many solutions print any of them.
Example
Input
7
4 7
5 0
0 0
6 1
0 2
0 4
1 0
Output
4 7
5 6
0 5
6 1
3 2
2 4
1 0
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
if __name__=='__main__':
n=int(input())
dl=[[0,0]]
end=0
for i in range(n):
dl.append(list(map(int,input().split())))
for i in range(1,n+1):
if not dl[i][0]:
dl[end][1]=i
dl[i][0]=end
j=i
while(dl[j][1]):
#print(dl[j])
#j+=1
j=dl[j][1]
end=j
for node in dl[1:]:
print(*node)
```
|
vfc_81077
|
{
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7\n4 7\n5 0\n0 0\n6 1\n0 2\n0 4\n1 0\n",
"output": "4 7\n5 6\n0 5\n6 1\n3 2\n2 4\n1 0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n",
"output": "0 2\n1 3\n2 4\n3 5\n4 6\n5 7\n6 8\n7 9\n8 10\n9 11\n10 12\n11 13\n12 14\n13 15\n14 16\n15 17\n16 18\n17 19\n18 20\n19 21\n20 22\n21 23\n22 24\n23 25\n24 26\n25 27\n26 28\n27 29\n28 30\n29 31\n30 32\n31 33\n32 34\n33 35\n34 36\n35 37\n36 38\n37 39\n38 40\n39 41\n40 42\n41 43\n42 44\n43 45\n44 46\n45 47\n46 48\n47 49\n48 50\n49 51\n50 52\n51 53\n52 54\n53 55\n54 56\n55 57\n56 58\n57 59\n58 60\n59 61\n60 62\n61 63\n62 64\n63 65\n64 66\n65 67\n66 68\n67 69\n68 70\n69 71\n70 72\n71 73\n72 74\n73 75\n74 76\n75 77\n76 78\n77 79\n78 80\n79 81\n80 82\n81 83\n82 84\n83 85\n84 86\n85 87\n86 88\n87 89\n88 90\n89 91\n90 92\n91 93\n92 94\n93 95\n94 96\n95 97\n96 98\n97 99\n98 100\n99 0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n2 0\n0 1\n0 4\n3 5\n4 0\n",
"output": "2 3\n0 1\n1 4\n3 5\n4 0\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
893_F. Subtree Minimum Query
|
Solve the following coding problem using the programming language python:
You are given a rooted tree consisting of n vertices. Each vertex has a number written on it; number ai is written on vertex i.
Let's denote d(i, j) as the distance between vertices i and j in the tree (that is, the number of edges in the shortest path from i to j). Also let's denote the k-blocked subtree of vertex x as the set of vertices y such that both these conditions are met:
* x is an ancestor of y (every vertex is an ancestor of itself);
* d(x, y) β€ k.
You are given m queries to the tree. i-th query is represented by two numbers xi and ki, and the answer to this query is the minimum value of aj among such vertices j such that j belongs to ki-blocked subtree of xi.
Write a program that would process these queries quickly!
Note that the queries are given in a modified way.
Input
The first line contains two integers n and r (1 β€ r β€ n β€ 100000) β the number of vertices in the tree and the index of the root, respectively.
The second line contains n integers a1, a2, ..., an (1 β€ ai β€ 109) β the numbers written on the vertices.
Then n - 1 lines follow, each containing two integers x and y (1 β€ x, y β€ n) and representing an edge between vertices x and y. It is guaranteed that these edges form a tree.
Next line contains one integer m (1 β€ m β€ 106) β the number of queries to process.
Then m lines follow, i-th line containing two numbers pi and qi, which can be used to restore i-th query (1 β€ pi, qi β€ n).
i-th query can be restored as follows:
Let last be the answer for previous query (or 0 if i = 1). Then xi = ((pi + last) mod n) + 1, and ki = (qi + last) mod n.
Output
Print m integers. i-th of them has to be equal to the answer to i-th query.
Example
Input
5 2
1 3 2 3 5
2 3
5 1
3 4
4 1
2
1 2
2 3
Output
2
5
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
py2 = round(0.5)
if py2:
from future_builtins import ascii, filter, hex, map, oct, zip
range = xrange
def sync_with_stdio(b):
if b: return
import os, sys
from io import BytesIO, IOBase
# FastIO for PyPy2 and PyPy3 (works with interactive) by Pajenegod
class FastI(object):
def __init__(self, fd=0, buffersize=2**14):
self.stream = stream = BytesIO(); self.bufendl = 0
def read2buffer():
s = os.read(fd, buffersize + os.fstat(fd).st_size); pos = stream.tell()
stream.seek(0,2); stream.write(s); stream.seek(pos); return s
self.read2buffer = read2buffer
# Read entire input
def read(self):
while self.read2buffer(): pass
return self.stream.read() if self.stream.tell() else self.stream.getvalue()
def readline(self):
while self.bufendl == 0: s = self.read2buffer(); self.bufendl += s.count(b"\n") + (not s)
self.bufendl -= 1; return self.stream.readline()
def input(self): return self.readline().rstrip(b'\r\n')
# Read all remaining integers, type is given by optional argument
def readnumbers(self, zero=0):
conv = ord if py2 else lambda x:x
A = []; numb = zero; sign = 1; c = b"-"[0]
for c in self.read():
if c >= b"0"[0]: numb = 10 * numb + conv(c) - 48
elif c == b"-"[0]: sign = -1
elif c != b"\r"[0]: A.append(sign*numb); numb = zero; sign = 1
if c >= b"0"[0]: A.append(sign*numb)
return A
class FastO(IOBase):
def __init__(self, fd=1):
stream = BytesIO()
self.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)
self.write = stream.write if py2 else lambda s: stream.write(s.encode())
sys.stdin, sys.stdout = FastI(), FastO()
global input
input = sys.stdin.input
import sys
class ostream:
def __lshift__(self,a):
if a == endl:
sys.stdout.write("\n")
sys.stdout.flush()
else:
sys.stdout.write(str(a))
return self
def tie(self, val):pass
cout = ostream()
endl = object()
class istream:
tiedto = cout
inp = None
def __rlshift__(a,b):
if a.tiedto == cout:
sys.stdout.flush()
if type(b)==tuple or type(b)==list:
return type(b)(type(c)(a.get()) for c in b)
return type(b)(a.get())
def tie(self, val):
self.tiedto = val
def get(a):
while not a.inp:
a.inp = sys.stdin.readline().split()[::-1]
return a.inp.pop()
cin = istream()
class Vector:
def __lshift__(self, other):
self.type = other
return self
def __rshift__(self, other):
if type(other) == tuple:
return [self.type(other[1])]*other[0]
else:
return [self.type()]*other
vector = Vector()
sync_with_stdio(False);
cin.tie(0); cout.tie(0);
########################## PERSISTENT SEGMENTTREE (surprisingly good memory effecient)
BIG = 10**9
vals = []
L = []
R = []
# Create a persistant segmenttree of size n
def create(n):
ind = len(vals)
vals.append(BIG)
L.append(-1)
R.append(-1)
if n==1:
L[ind] = -1
R[ind] = -1
else:
mid = n//2
L[ind] = create(mid)
R[ind] = create(n - mid)
return ind
# Set seg[i]=val for segment tree ind, of size n,
def setter(ind, i, val, n):
ind2 = len(vals)
vals.append(BIG)
L.append(-1)
R.append(-1)
if n==1:
vals[ind2] = val
return ind2
mid = n//2
if i < mid:
L[ind2] = setter(L[ind], i, val, mid)
R[ind2] = R[ind]
else:
L[ind2] = L[ind]
R[ind2] = setter(R[ind], i - mid, val, n - mid)
vals[ind2] = min(vals[L[ind2]], vals[R[ind2]])
return ind2
# Find minimum of seg[l:r] for segment tree ind, of size n
def minimum(ind, l, r, n):
if l==0 and r==n:
return vals[ind]
mid = n//2
if r <= mid:
return minimum(L[ind], l, r, mid)
elif mid<=l:
return minimum(R[ind], l - mid, r - mid, n - mid)
else:
return min( minimum(L[ind], l, mid, mid), minimum(R[ind], 0, r - mid, n - mid))
######################################################################
import sys
inp = sys.stdin.readnumbers()
ii = 0
n = inp[ii]
ii += 1
r = inp[ii]-1
ii += 1
A = inp[ii:ii+n]
ii += n
coupl = [[] for _ in range(n)]
for _ in range(n-1):
x,y = inp[ii]-1, inp[ii+1]-1
ii += 2
coupl[x].append(y)
coupl[y].append(x)
# Start reordering the nodes after DFS ordering
found = [False]*n
found[r] = True
Qdum = [r]
Q = []
while Qdum:
node = Qdum.pop()
Q.append(node)
for nei in coupl[node]:
if not found[nei]:
found[nei] = True
Qdum.append(nei)
mapper = [-1]*n
for i,node in enumerate(Q):
mapper[node] = i
couplprim = []
for node in range(n):
couplprim.append([mapper[nei] for nei in coupl[Q[node]]])
rprim = 0
assert(rprim == mapper[r])
Aprim = [A[Q[i]] for i in range(n)]
# Nodes has been reordered, now figure out some DFS stuff like dfs, family size
depth = [-1]*n
family_size = [0]*n
depth[rprim] = 0
Qprim = [rprim]
first_time = [True]*n
while Qprim:
node = Qprim.pop()
if first_time[node]:
first_time[node] = False
Qprim.append(node)
for nei in couplprim[node]:
if depth[nei] == -1:
depth[nei] = depth[node]+1
Qprim.append(nei)
else:
f = 1
for nei in couplprim[node]:
f += family_size[nei]
family_size[node] = f
# Time to bucket sort the nodes in order of depth
D = [[] for _ in range(2*n)]
for node in range(n):
D[depth[node]].append(node)
##################### PERSISTENT SEGMENT TREE PART
# So simple, yet so much going on
Dseg = [0]*(2*n)
ind = create(n)
for i,nodes in enumerate(D):
for node in nodes:
ind = setter(ind, node, Aprim[node], n)
Dseg[i] = ind
#############################
m = inp[ii]
ii += 1
ans = 0
for _ in range(m):
p = inp[ii]
ii += 1
q = inp[ii]
ii += 1
x = mapper[(p + ans)%n]
k = (q + ans)%n
ans = minimum(Dseg[depth[x]+k], x, x + family_size[x], n)
cout << ans << "\n"
```
|
vfc_81085
|
{
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 6, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 2\n1 3 2 3 5\n2 3\n5 1\n3 4\n4 1\n2\n1 2\n2 3\n",
"output": "2\n5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3\n1 3 2\n1 2\n1 3\n2\n2 3\n1 1\n",
"output": "2\n1\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
915_C. Permute Digits
|
Solve the following coding problem using the programming language python:
You are given two positive integer numbers a and b. Permute (change order) of the digits of a to construct maximal number not exceeding b. No number in input and/or output can start with the digit 0.
It is allowed to leave a as it is.
Input
The first line contains integer a (1 β€ a β€ 1018). The second line contains integer b (1 β€ b β€ 1018). Numbers don't have leading zeroes. It is guaranteed that answer exists.
Output
Print the maximum possible number that is a permutation of digits of a and is not greater than b. The answer can't have any leading zeroes. It is guaranteed that the answer exists.
The number in the output should have exactly the same length as number a. It should be a permutation of digits of a.
Examples
Input
123
222
Output
213
Input
3921
10000
Output
9321
Input
4940
5000
Output
4940
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
import copy
Num1, Num2 = sorted(list(input())), list(input())
Num1.reverse()
Temp1, Temp2, i, j, Result= copy.copy(Num1), copy.copy(Num2), 0, 0, []
if len(Temp1) < len(Temp2):
print(''.join(Temp1))
exit()
while True:
if i + 1 > len(Temp1):
Temp1.append(Result[len(Result) - 1])
Temp1.sort()
Temp1.reverse()
i = Temp1.index(Result[len(Result) - 1]) + Temp1.count(Result[len(Result) - 1])
del Result[len(Result) - 1]
j -= 1
elif i + 1 == len(Temp1):
if Temp1[i] < Temp2[j]:
print(''.join(Result) + Temp1[i] + ''.join(Temp1[:i] ))
exit()
elif Temp1[i] == Temp2[j]:
if j == len(Temp2) - 1:
print(''.join(Result) + Temp1[i])
exit()
elif j == 0:
Start = i;
Result.append(Temp1[i])
del Temp1[i]
i, j = 0, j + 1
else:
Temp1.append(Result[len(Result) - 1])
Temp1.sort()
Temp1.reverse()
i = Temp1.index(Result[len(Result) - 1]) + Temp1.count(Result[len(Result) - 1])
del Result[len(Result) - 1]
j -= 1
else:
if Temp1[i] < Temp2[j]:
print(''.join(Result) + Temp1[i] + ''.join(Temp1[:i] + Temp1[i + 1:]))
exit()
elif Temp1[i] == Temp2[j]:
if j == 0:
Start = i;
Result.append(Temp1[i])
del Temp1[i]
i, j = 0, j + 1
elif Temp1[i] > Temp2[j]:
i += 1
```
|
vfc_81089
|
{
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4940\n5000\n",
"output": "4940\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3921\n10000\n",
"output": "9321\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
938_D. Buy a Ticket
|
Solve the following coding problem using the programming language python:
Musicians of a popular band "Flayer" have announced that they are going to "make their exit" with a world tour. Of course, they will visit Berland as well.
There are n cities in Berland. People can travel between cities using two-directional train routes; there are exactly m routes, i-th route can be used to go from city vi to city ui (and from ui to vi), and it costs wi coins to use this route.
Each city will be visited by "Flayer", and the cost of the concert ticket in i-th city is ai coins.
You have friends in every city of Berland, and they, knowing about your programming skills, asked you to calculate the minimum possible number of coins they have to pay to visit the concert. For every city i you have to compute the minimum number of coins a person from city i has to spend to travel to some city j (or possibly stay in city i), attend a concert there, and return to city i (if j β i).
Formally, for every <image> you have to calculate <image>, where d(i, j) is the minimum number of coins you have to spend to travel from city i to city j. If there is no way to reach city j from city i, then we consider d(i, j) to be infinitely large.
Input
The first line contains two integers n and m (2 β€ n β€ 2Β·105, 1 β€ m β€ 2Β·105).
Then m lines follow, i-th contains three integers vi, ui and wi (1 β€ vi, ui β€ n, vi β ui, 1 β€ wi β€ 1012) denoting i-th train route. There are no multiple train routes connecting the same pair of cities, that is, for each (v, u) neither extra (v, u) nor (u, v) present in input.
The next line contains n integers a1, a2, ... ak (1 β€ ai β€ 1012) β price to attend the concert in i-th city.
Output
Print n integers. i-th of them must be equal to the minimum number of coins a person from city i has to spend to travel to some city j (or possibly stay in city i), attend a concert there, and return to city i (if j β i).
Examples
Input
4 2
1 2 4
2 3 7
6 20 1 25
Output
6 14 1 25
Input
3 3
1 2 1
2 3 1
1 3 1
30 10 20
Output
12 10 12
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
from __future__ import division, print_function
import os
import sys
import io
class FastI():
""" FastIO for PyPy3 by Pajenegod """
stream = io.BytesIO()
newlines = 0
def read1(self):
b, ptr = os.read(0, (1 << 13) + os.fstat(0).st_size), self.stream.tell()
self.stream.seek(0, 2)
self.stream.write(b)
self.stream.seek(ptr)
return b
def read(self):
while self.read1():
pass
return self.stream.read() if self.stream.tell() else self.stream.getvalue()
def readline(self):
while self.newlines == 0:
b = self.read1()
self.newlines += b.count(b'\n') + (not b)
self.newlines -= 1
return self.stream.readline()
def readnumber(self, var=int):
""" Read numbers till EOF. Use var to change type. """
b = self.read()
num, sign = var(0), 1
for char in b:
if char >= b'0' [0]:
num = 10 * num + char - 48
elif char == b'-' [0]:
sign = -1
elif char != b'\r' [0]:
yield sign * num
num, sign = var(0), 1
if b and b[-1] >= b'0' [0]:
yield sign * num
sys.stdin = FastI()
input = sys.stdin.readline
sys.stdout, stream = io.IOBase(), io.BytesIO()
sys.stdout.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)
sys.stdout.write = lambda s: stream.write(s.encode())
sys.stdin = FastI()
input = sys.stdin.readline
big = 3E12
class segheap:
def __init__(self, data):
n = len(data)
m = 1
while m < n:
m *= 2
self.n = n
self.m = m
self.data = [big] * (2 * m)
for i in range(n):
self.data[i + m] = data[i]
for i in reversed(range(m)):
self.data[i] = min(self.data[2 * i], self.data[2 * i + 1])
def mini(self):
i = 1
while i < self.m:
if self.data[i] == self.data[2 * i]:
i = 2 * i
else:
i = 2 * i + 1
i -= self.m
self.setter(i, big)
return i
def setter(self, ind, val):
ind += self.m
if val < self.data[ind]:
while ind > 0 and self.data[ind] > val:
self.data[ind] = val
ind //= 2
elif val > self.data[ind]:
old_val = self.data[ind]
self.data[ind] = val
ind //= 2
while ind > 0 and self.data[ind] == old_val:
self.data[ind] = min(self.data[2 * ind], self.data[2 * ind + 1])
ind //= 2
inp = sys.stdin.readnumber(float)
n, m = int(next(inp)), int(next(inp))
coupl = [[] for _ in range(n)]
cost = [[] for _ in range(n)]
for _ in range(m):
v = int(next(inp) - 1)
u = int(next(inp) - 1)
w = next(inp)
coupl[v].append(u)
coupl[u].append(v)
cost[u].append(w)
cost[v].append(w)
best = [next(inp) for i in range(n)]
Q = segheap(best)
while Q.data[1] != big:
c = Q.data[1]
node = Q.mini()
if best[node] != c:
continue
for j in range(len(coupl[node])):
nei = coupl[node][j]
C = c + 2 * cost[node][j]
if C < best[nei]:
best[nei] = C
Q.setter(nei, C)
for x in best:
sys.stdout.write(str(int(x)))
sys.stdout.write(' ')
```
|
vfc_81093
|
{
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 2\n1 2 4\n2 3 7\n6 20 1 25\n",
"output": "6 14 1 25 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3\n1 2 1\n2 3 1\n1 3 1\n30 10 20\n",
"output": "12 10 12 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7 7\n1 6 745325\n2 3 3581176\n2 4 19\n3 6 71263060078\n5 4 141198\n7 4 163953\n5 6 15994\n1 297404206755 82096176217 14663411 187389745 21385 704393\n",
"output": "1 335807 7498159 335769 53373 21385 663675 ",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
963_D. Frequency of String
|
Solve the following coding problem using the programming language python:
You are given a string s. You should answer n queries. The i-th query consists of integer k_i and string m_i. The answer for this query is the minimum length of such a string t that t is a substring of s and m_i has at least k_i occurrences as a substring in t.
A substring of a string is a continuous segment of characters of the string.
It is guaranteed that for any two queries the strings m_i from these queries are different.
Input
The first line contains string s (1 β€ \left | s \right | β€ 10^{5}).
The second line contains an integer n (1 β€ n β€ 10^5).
Each of next n lines contains an integer k_i (1 β€ k_i β€ |s|) and a non-empty string m_i β parameters of the query with number i, in this order.
All strings in input consists of lowercase English letters. Sum of length of all strings in input doesn't exceed 10^5. All m_i are distinct.
Output
For each query output the answer for it in a separate line.
If a string m_{i} occurs in s less that k_{i} times, output -1.
Examples
Input
aaaaa
5
3 a
3 aa
2 aaa
3 aaaa
1 aaaaa
Output
3
4
4
-1
5
Input
abbb
7
4 b
1 ab
3 bb
1 abb
2 bbb
1 a
2 abbb
Output
-1
2
-1
3
-1
1
-1
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
vfc_81097
|
{
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 500000000}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "aaaaa\n5\n3 a\n3 aa\n2 aaa\n3 aaaa\n1 aaaaa\n",
"output": "3\n4\n4\n-1\n5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "abbb\n7\n4 b\n1 ab\n3 bb\n1 abb\n2 bbb\n1 a\n2 abbb\n",
"output": "-1\n2\n-1\n3\n-1\n1\n-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "aabbaaabbbbbaaaaababbaabbabbaabbabbbaabbbbaabaabab\n2\n3 abbaabb\n1 aaaababbaab\n",
"output": "-1\n11\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "aabbaabbababbaa\n26\n2 abbaabba\n1 aabbaabbababba\n4 ab\n2 aabbaa\n1 bbaa\n2 bbababba\n4 abb\n1 aa\n2 aabbab\n3 aabb\n4 ba\n1 abbaba\n1 bbaabbab\n1 bab\n1 abbababb\n4 abba\n1 aab\n2 abbab\n1 bbaabbababbaa\n2 bbaabba\n4 bb\n2 baabbababb\n1 aabbaabbababb\n1 abbaabbabab\n7 a\n1 baabbab\n",
"output": "-1\n14\n11\n-1\n4\n-1\n-1\n2\n-1\n-1\n11\n6\n8\n3\n8\n-1\n3\n-1\n13\n-1\n-1\n-1\n13\n11\n14\n7\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "aabbaaabbbbbaaaaababbaabbabbaabbabbbaabbbbaabaabab\n2\n3 abbaaab\n1 aaaababbaab\n",
"output": "-1\n11\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "aabbaabbababbaa\n26\n2 abbaabba\n1 aabbaabbababba\n4 ab\n2 aabbaa\n1 bbaa\n2 bbababba\n4 abb\n1 aa\n2 aabbab\n3 aabb\n4 ba\n1 ababba\n1 bbaabbab\n1 bab\n1 abbababb\n4 abba\n1 aab\n2 abbab\n1 bbaabbababbaa\n2 bbaabba\n4 bb\n2 baabbababb\n1 aabbaabbababb\n1 abbaabbabab\n7 a\n1 baabbab\n",
"output": "-1\n14\n11\n-1\n4\n-1\n-1\n2\n-1\n-1\n11\n6\n8\n3\n8\n-1\n3\n-1\n13\n-1\n-1\n-1\n13\n11\n14\n7\n",
"type": "stdin_stdout"
}
]
}
|
|
code_contests
|
verifiable_code
|
990_G. GCD Counting
|
Solve the following coding problem using the programming language python:
You are given a tree consisting of n vertices. A number is written on each vertex; the number on vertex i is equal to a_i.
Let's denote the function g(x, y) as the greatest common divisor of the numbers written on the vertices belonging to the simple path from vertex x to vertex y (including these two vertices).
For every integer from 1 to 2 β
10^5 you have to count the number of pairs (x, y) (1 β€ x β€ y β€ n) such that g(x, y) is equal to this number.
Input
The first line contains one integer n β the number of vertices (1 β€ n β€ 2 β
10^5).
The second line contains n integers a_1, a_2, ..., a_n (1 β€ a_i β€ 2 β
10^5) β the numbers written on vertices.
Then n - 1 lines follow, each containing two integers x and y (1 β€ x, y β€ n, x β y) denoting an edge connecting vertex x with vertex y. It is guaranteed that these edges form a tree.
Output
For every integer i from 1 to 2 β
10^5 do the following: if there is no pair (x, y) such that x β€ y and g(x, y) = i, don't output anything. Otherwise output two integers: i and the number of aforementioned pairs. You have to consider the values of i in ascending order.
See the examples for better understanding.
Examples
Input
3
1 2 3
1 2
2 3
Output
1 4
2 1
3 1
Input
6
1 2 4 8 16 32
1 6
6 3
3 4
4 2
6 5
Output
1 6
2 5
4 6
8 1
16 2
32 1
Input
4
9 16 144 6
1 3
2 3
4 3
Output
1 1
2 1
3 1
6 2
9 2
16 2
144 1
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict, deque, Counter, OrderedDict
import threading
def main():
ans = 1
flag = True
primes = []
for i in range(2, 500):
v = 1
for p in primes:
if i % p == 0: v = 0
if v: primes.append(i)
n = int(input())
a = [*map(int,input().split())]
if sum(a) == n: flag = False
for i in range(n):
x = a[i]
a[i] = []
for p in primes:
if x % p == 0:
a[i].append([p,1])
x = x//p
while x % p == 0: x //= p
if x != 1:a[i].append([x,1])
adj = [[] for i in range(n)]
for i in range(n-1):
x, y =map(int,input().split())
adj[x-1].append(y-1)
adj[y-1].append(x-1)
leaves = []
for i in range(n):
if len(adj[i]) == 1: leaves.append(i)
for i in range(n-1):
x = leaves.pop()
y = adj[x][0]
adj[y].remove(x)
if len(adj[y]) == 1: leaves.append(y)
for nx in a[x]:
for ny in a[y]:
if nx[0] == ny[0]:
ans = max([ans, nx[1] + ny[1]])
ny[1] = max([ny[1],nx[1]+1])
if not flag:print(0)
else:print(ans)
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# endregion
if __name__ == "__main__":
"""sys.setrecursionlimit(400000)
threading.stack_size(40960000)
thread = threading.Thread(target=main)
thread.start()"""
main()
```
|
vfc_81101
|
{
"difficulty": "13",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 500000000}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n9 16 144 6\n1 3\n2 3\n4 3\n",
"output": "1 1\n2 1\n3 1\n6 2\n9 2\n16 2\n144 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n1 2 4 8 16 32\n1 6\n6 3\n3 4\n4 2\n6 5\n",
"output": "1 6\n2 5\n4 6\n8 1\n16 2\n32 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 2 3\n1 2\n2 3\n",
"output": "1 4\n2 1\n3 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n2 3 4\n1 2\n2 3\n",
"output": "1 3\n2 1\n3 1\n4 1\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
aprileasy-the-one-with-the-queries-3
|
Solve the following coding problem using the programming language python:
You are given a string S and Q query strings (q1, q2, ... , qQ). For each query string, report whether or not it is a subsequence of S.
Input :
The first line contains a string S.
The next line contains a single integer, Q.
The following Q lines each contain 1 query string qi.
Output :
Output Q lines. On the i^th line print "Yes" (without quotes) if qi is a sub-sequence of S, otherwise print "No" (without quotes).
Constraints :
1 β€ |S|, |q[i]|, Q β€ 100,000
Sum of lengths of all query strings β€ 1,000,000
All strings consist of lowercase english letters only. ('a'-'z')
SAMPLE INPUT
hello
5
world
lo
elo
hl
ol
SAMPLE OUTPUT
No
Yes
Yes
Yes
No
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
ind=0
z=""
f=0
x=raw_input()
for _ in xrange(input()):
f=0
z=x
y=raw_input()
for i in xrange(len(y)):
if y[i] in z:
ind=z.index(y[i])
z=z[ind+1:]
else:
f=1
break
if f==1:
print "No"
else:
print "Yes"
```
|
vfc_81105
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "hello\n5\nworld\nlo\nelo\nhl\nol\n\nSAMPLE",
"output": "No\nYes\nYes\nYes\nNo\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "hello\n5\nworld\nln\nelo\nhl\nol\n\nSAMPLE",
"output": "No\nNo\nYes\nYes\nNo\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "hello\n5\nwolrd\nlo\nelo\nhl\nol\n\nSAMPLE",
"output": "No\nYes\nYes\nYes\nNo\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
chandu-and-his-playing-area
|
Solve the following coding problem using the programming language python:
Little chandu is very fond of playing games. Recently, He found a few straws each of length 1 inches in the store room. He took all of them and decided to mark a rectangular area on the floor with straws and warn rest of the family members to not to enter that area so that he can play in peace. He wants to maximize that area. But, unable to do so, He seeks for your help. You being the elder brother of chandu, write a program for him to find maximum area that he can cover in inches using N straws.
Input:
First line of input contains an integer t. then, t lines follow each containing a single integer N - No of straws.
Output:
Print the area of largest rectangle that can be formed using the given sticks.
Constraints:
0 β€ t β€ 25000
1 β€ N β€ 10^{10}
SAMPLE INPUT
3
6
9
11
SAMPLE OUTPUT
2
4
6
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
import sys
import math
t=input()
for i in range(0,t):
m = input();
if m%2 == 1 :
m=m-1;
b=m/4;
a=m/2-b;
n= a*b;
print n;
```
|
vfc_81109
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n6\n9\n11\n\nSAMPLE",
"output": "2\n4\n6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100\n1207244\n255313\n56\n83269\n638451\n347617\n29369\n233941\n61\n7937\n85\n6\n80\n2485\n7\n6394\n92\n80883\n278\n14467\n9\n7\n2018983\n2607\n916\n18515\n3600328\n1\n1\n11995\n743468\n3403\n507\n149\n36\n38208\n47423\n974\n81\n494913\n192\n85\n9\n8492427\n655\n9912940\n40843\n4716\n46470\n435483\n26548\n8\n9762\n346\n3718\n75600\n7343\n5965\n54811\n67237\n746552\n36\n8979\n81771\n7\n51885\n652\n383899\n596\n6\n98\n4863286\n3509\n27\n7\n220578\n26441\n4\n6512222\n679\n1\n4190\n4656091\n7\n5\n2963\n9659536\n682\n10920\n59\n6150025\n75\n24638\n932\n2760\n6010581\n4276\n5112517\n90\n6",
"output": "91089879721\n4074013584\n196\n433347489\n25476150156\n7552305216\n53904964\n3420495225\n225\n3936256\n441\n2\n400\n385641\n2\n2555202\n529\n408868620\n4830\n13079072\n4\n2\n254768019770\n424452\n52441\n21423012\n810147606724\n0\n0\n8991002\n34546541689\n723350\n16002\n1369\n81\n91240704\n140552880\n59292\n400\n15308617984\n2304\n441\n4\n4507581210342\n26732\n6141648715225\n104254310\n1390041\n134966306\n11852785770\n44049769\n4\n5956040\n7482\n863970\n357210000\n3369060\n2223081\n187758506\n282542481\n34833743044\n81\n5037780\n417895806\n2\n168246841\n26569\n9211104650\n22201\n2\n600\n1478221919862\n769129\n42\n2\n3040915880\n43692100\n1\n2650564711080\n28730\n0\n1097256\n1354948380506\n2\n1\n548340\n5831664733456\n29070\n7452900\n210\n2363924700036\n342\n37939440\n54289\n476100\n2257941996025\n1142761\n1633613740641\n506\n2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10000\n1207244\n255313\n56\n83269\n638451\n347617\n29369\n233941\n61\n7937\n85\n6\n80\n2485\n7\n6394\n92\n80883\n278\n14467\n9\n7\n2018983\n2607\n916\n18515\n3600328\n1\n1\n11995\n743468\n3403\n507\n149\n36\n38208\n47423\n974\n81\n494913\n192\n85\n9\n8492427\n655\n9912940\n40843\n4716\n46470\n435483\n26548\n8\n9762\n346\n3718\n75600\n7343\n5965\n54811\n67237\n746552\n36\n8979\n81771\n7\n51885\n652\n383899\n596\n6\n98\n4863286\n3509\n27\n7\n220578\n26441\n4\n6512222\n679\n1\n4190\n4656091\n7\n5\n2963\n9659536\n682\n10920\n59\n6150025\n75\n24638\n932\n2760\n6010581\n4276\n5112517\n90\n6\n81355\n28083\n3190024\n1\n7\n944\n1\n87901\n1\n913004\n25\n325\n609\n888\n811373\n616\n853977\n76\n59\n22\n61769\n9351\n5\n962\n35\n53082\n90\n7392\n2898564\n335566\n1246\n890956\n76\n5\n304\n7705923\n2\n576\n2397\n4617\n311\n70\n231\n9962367\n4125\n401129\n98903\n4\n7932460\n579641\n43295\n6847675\n250\n440396\n6\n3399107\n54\n14917\n7346\n1424807\n818958\n497\n4971\n2\n4835\n3782526\n96846\n8\n7\n58\n5958832\n868\n6553\n353\n8006\n99864\n9292\n84219\n400440\n329897\n3746920\n937474\n395\n265\n47\n4103\n43795\n1740321\n5507\n4\n250220\n335\n8941687\n4309\n4240352\n9\n954587\n4798087\n47235\n8888132\n8363\n756\n23569\n8\n46113\n80272\n38\n25443\n3274625\n774\n487488\n9\n6861514\n14\n604764\n55\n181414\n807547\n7655632\n82847\n9\n53554\n52163\n77090\n50181\n98223\n5512192\n443\n69\n28\n867027\n337755\n80572\n9270\n97364\n348\n6270663\n22265\n26\n61175\n20923\n67466\n4549\n2287458\n76168\n1396389\n964803\n8052\n17921\n438\n4183169\n454\n4199\n8307\n2735199\n6\n1\n11\n6230\n1975\n160\n4\n104\n490\n860\n4234915\n31024\n3981\n7555889\n846\n65\n7\n6\n4672246\n6542197\n3\n2\n932\n3020\n7\n4\n201\n5946\n630201\n7053607\n73199\n1880\n474\n77\n604\n419\n182637\n809986\n3\n968052\n804\n120180\n6794\n358\n44741\n1735\n89725\n4697245\n964382\n1178\n37\n89\n571068\n18659\n75\n9344\n11\n570\n9526\n68\n66\n331\n7343148\n776\n854\n31493\n6518\n383\n512\n5827429\n5949610\n40337\n989\n592093\n7095\n73683\n15\n67053\n984483\n81\n2747\n74\n58\n484\n40\n587\n195\n403\n12\n101\n36349\n132184\n9\n614\n5713\n2139\n3615922\n5323688\n90043\n4\n8740\n9797\n85520\n65534\n8\n650\n65608\n6400\n49\n829105\n758343\n58576\n5696366\n44\n20\n57759\n775\n33699\n16990\n42\n76270\n12188\n90\n1530\n754\n8651894\n7906535\n172314\n1442\n94\n39023\n1\n39393\n350\n366355\n476426\n5420\n2\n9542309\n2081558\n7495\n70241\n295\n3\n82567\n6\n779\n8541\n7113\n50396\n51\n270\n33\n4637107\n99395\n757449\n5\n9864437\n39929\n6163183\n90806\n8016\n7529\n580\n43515\n76\n16\n7\n894308\n18\n36758\n5239450\n6399567\n245\n9909\n96330\n3\n16476\n2\n6\n54362\n44613\n7509203\n9269\n72762\n42745\n69\n31374\n967996\n92\n60\n63\n1884054\n751\n6660069\n84116\n1757673\n83\n60\n2154300\n38790\n19029\n930611\n90\n38\n37583\n307190\n353131\n2740034\n876\n8532198\n840\n8\n130\n495583\n7949\n99190\n24\n4\n471\n375478\n99\n232\n189289\n926147\n3\n79272\n8474771\n425879\n60\n853837\n95008\n346\n62\n665\n87\n9550\n435019\n35823\n4\n830\n56\n496145\n16\n189\n574752\n5\n5669041\n4\n152\n46\n847\n389152\n16645\n811922\n349417\n332\n5673558\n706937\n142\n2954067\n749\n495\n51112\n43352\n64843\n182\n4194\n6407\n4784\n421720\n243466\n28879\n398256\n109419\n32\n8363\n3402\n123374\n3650966\n9\n835\n6379\n16396\n761\n5096\n1403\n2129778\n860\n8\n9095\n78\n761584\n2\n907\n41842\n9178\n6190190\n9828120\n6228\n2\n2038\n917\n56223\n2844109\n2813\n3636933\n8730\n11253\n1\n9\n9\n978915\n7310\n13152\n31\n631593\n5\n748\n732\n877\n777808\n40987\n6\n22\n8734733\n89\n93\n466847\n1\n7\n58971\n2\n5\n99\n8\n412613\n1\n6\n3\n947820\n7096621\n25939\n29\n63\n7442\n2519061\n10600\n8250351\n6173320\n9354\n5306530\n624\n5866631\n1480063\n7\n23\n208843\n930\n47947\n2977\n71\n656964\n9451443\n5\n6048559\n5\n524\n35\n4295436\n263\n5\n3119\n9539\n37269\n324883\n417\n2952\n6115\n870\n948\n96\n3\n9585\n8435459\n641\n7\n289\n30\n410091\n28603\n8\n927592\n1107352\n736\n119\n973\n4440\n229\n8\n883243\n5784137\n8189136\n7\n1346244\n8602457\n2\n77\n59631\n93701\n42687\n112414\n6379\n2229\n39\n4070\n272\n97459\n3694745\n63\n3411646\n8878539\n7838093\n29\n5475251\n2\n1156844\n374050\n7806\n76819\n56313\n5\n688435\n87\n88\n44\n841\n7\n70546\n7131\n382\n778\n5\n80150\n7\n845910\n56902\n454\n9112215\n69669\n7\n90\n9\n4044361\n73\n9\n6016\n5951122\n94\n22576\n2626596\n20\n9\n6\n1183\n5\n17045\n2658544\n4561\n19958\n22578\n6758\n1491\n87300\n58982\n18973\n15\n5544874\n580\n414\n2092300\n9830\n848\n814725\n248101\n2866785\n20\n78\n7368210\n62300\n83174\n67\n712115\n7\n67\n33\n74\n71\n4\n546\n8379\n396084\n7973\n92\n62732\n727563\n16534\n1512\n73\n224364\n8193\n452688\n832\n288154\n3\n33701\n9\n25\n685\n6\n85963\n9270\n8508\n9\n68808\n56\n58302\n2\n688\n7688453\n2394\n9504\n595\n9\n677\n179\n90653\n499\n28137\n8364\n5114260\n5058016\n220\n68689\n155\n247743\n11763\n6\n1\n700\n26595\n7\n4273\n4\n78\n5\n212248\n327\n41925\n1539\n178\n92062\n4\n2683583\n50\n41043\n640337\n36966\n3415868\n129105\n9\n940\n846\n43688\n290605\n54039\n64251\n9\n738\n6394\n8\n47\n5\n875110\n6579\n91\n356\n759559\n845\n3068\n786\n4488\n81365\n2761\n47043\n1195875\n886\n81565\n8814\n255400\n2\n64\n507779\n135377\n56930\n944578\n93373\n2840\n7\n48481\n931\n3\n2611\n985598\n7\n899\n77\n95\n3213\n7\n8566910\n18758\n79\n4347834\n5928235\n3152\n945693\n600045\n441304\n9666\n8\n12922\n805\n916370\n4\n938148\n7405281\n20\n442\n2820\n67\n629771\n88\n7\n72528\n484\n8\n548462\n588682\n626788\n6\n85\n7512292\n639\n19905\n536\n5803476\n942\n818906\n97766\n72\n2428\n2649914\n1\n7327\n1865664\n35578\n847082\n889\n23\n422\n9629\n536275\n8452\n7376\n6667\n15\n774\n403408\n2\n5\n4\n5286\n96589\n1645\n4\n6484445\n7267741\n939\n8892049\n88\n560\n984172\n85162\n76035\n320\n51\n115649\n71\n78\n703738\n3\n9\n17870\n552\n260719\n1\n5\n3682628\n95613\n27857\n142\n67054\n8678749\n5103601\n589645\n440372\n811\n49899\n95783\n72\n737\n80107\n41904\n4908\n59\n4805894\n8057\n31524\n233\n25\n4405\n291580\n30741\n591331\n38732\n1\n482710\n9\n377\n5795\n329752\n509\n6629\n5409085\n8424311\n9000\n452\n384288\n6445618\n6380\n80055\n229789\n4233\n5\n6762051\n42155\n342\n8530277\n4\n5\n480\n8619\n5\n574\n120\n2160\n48069\n3\n1799\n6586\n831105\n36683\n5599365\n631\n664\n727\n3232902\n19\n46\n745\n495354\n13\n905932\n1570\n680\n6269\n505\n67191\n7444071\n7\n362648\n749530\n865\n459310\n4\n7\n45666\n145\n7\n787\n665\n938\n2630\n55\n8\n3\n227076\n3\n2353890\n65826\n563350\n31691\n942\n7\n5\n6\n6037791\n5804517\n2\n7075773\n215\n9742922\n31\n31\n95436\n9814424\n39\n32\n628\n4324\n88\n7177\n23\n786648\n947\n1918\n39096\n6929156\n180\n8\n72\n799\n7016919\n5\n34349\n442\n6368104\n2376\n3395330\n3622505\n904701\n40\n747\n3\n9170122\n6328613\n6\n454\n84545\n16\n7\n6956\n7856495\n957173\n94648\n587347\n744\n648319\n271\n74355\n681\n17216\n79126\n7817728\n11936\n13\n8\n91266\n823\n969676\n17572\n706593\n4157\n44645\n232\n5732\n60193\n48093\n4235680\n908758\n564\n65826\n558398\n9\n32\n1076\n6642645\n61\n6\n9730352\n577\n8\n35\n44\n5\n732\n74\n43499\n316535\n62043\n9954\n1776223\n7684\n6\n36\n671\n44145\n573\n634131\n7\n79\n322\n857409\n829\n29360\n24\n797\n3519\n4\n71791\n174286\n97\n1\n4076\n726\n88\n8398254\n1223\n15\n2\n9669747\n71\n5\n75\n7102309\n6196958\n167\n82\n157801\n3506514\n3765679\n6\n8\n7\n53852\n27637\n382\n31555\n704977\n226\n5986423\n887329\n842\n4212828\n940\n33\n7054\n3354927\n43794\n210\n897687\n75\n10\n1368\n290666\n993069\n7768\n88\n24\n449\n391\n120837\n8629\n39549\n2136\n704648\n14\n85320\n1\n59\n242944\n129960\n828\n111765\n8182508\n5988\n8\n27\n52229\n81\n189263\n5\n8334\n80870\n287\n839\n90\n56\n7599\n87\n4\n413\n2951\n314\n53877\n3675\n489\n47\n8345\n4\n29\n6520627\n89\n4737\n6080\n4093627\n5674670\n8\n26892\n83323\n7680747\n601\n96\n9546\n8493\n4165\n45908\n75312\n9704904\n2\n26828\n2\n607463\n662608\n8613\n716\n390\n74238\n1306499\n6\n9352\n9221\n29\n32014\n10939\n3049\n39\n32786\n766\n700756\n3139385\n3262986\n79189\n3054\n7052442\n9415\n65035\n2\n6\n552727\n7\n7\n908699\n5107\n1179235\n92\n1524\n989135\n30\n50\n792\n3341\n576360\n2100\n4\n33\n499\n76\n9257086\n574\n341\n1\n7293\n528\n43\n1\n2526701\n21\n582\n6553\n3299637\n795508\n193\n602\n4678\n3789741\n900\n239519\n42640\n3854\n16371\n6\n363\n58035\n8596681\n67836\n8\n5743\n290\n4378\n9\n1\n4720\n115809\n927\n5214832\n97105\n2\n5421\n156311\n7279\n32\n5\n2978\n443\n8007524\n2774945\n359\n8\n90566\n50686\n9812591\n442\n9\n4793\n9\n9519\n2\n2007\n4856\n959173\n507985\n78377\n15\n2150960\n44\n72\n91\n7570\n418707\n17\n57\n20\n6\n40127\n20\n32130\n294030\n5957\n6\n8690365\n5345938\n4\n41515\n224\n27523\n21\n26211\n313145\n5\n29167\n6\n6\n404422\n956605\n2968\n435869\n7335843\n137760\n3640028\n374525\n240747\n942\n604\n190650\n2\n70\n8235367\n698981\n8996243\n370813\n943\n7390349\n928196\n2\n6179\n5282374\n8039558\n84\n2859\n7247\n15\n7\n1507\n32\n96748\n77533\n1\n7\n628\n9692\n403\n4751\n9463252\n73345\n52907\n1\n33742\n7657721\n4127\n698\n3443924\n445\n230\n630605\n3\n4105\n52626\n458830\n3885932\n67381\n1105110\n9\n9353\n402\n7\n804630\n945\n7235404\n4335386\n31052\n1846\n7543491\n954\n9587947\n3\n9\n489680\n102\n343941\n7537\n875564\n861\n405077\n99859\n976885\n3274\n226161\n94\n86\n124974\n8\n8415\n15131\n1\n787\n6038\n557828\n68\n8\n6442201\n7423358\n960447\n3983035\n66\n2613499\n789966\n5662586\n45\n4330\n3178144\n35693\n8263\n1646\n680172\n4\n30\n4753\n23\n21517\n4\n7501278\n15\n450\n310\n343\n88043\n4640445\n409195\n96525\n4420\n4\n7186\n2\n12632\n721\n9\n8311\n59117\n9462166\n12344\n1963\n7351473\n914\n285637\n716806\n3\n107423\n95629\n1\n4131061\n825\n80\n5452998\n186\n7815\n4501988\n5\n1091652\n280\n15144\n8766946\n3821484\n91337\n77020\n1787434\n3199\n79382\n453309\n787\n475\n4268\n899380\n7609\n88824\n674\n42714\n330927\n36\n5667\n3558\n97\n4578809\n6394157\n1\n66\n3556\n5\n1075511\n9\n558\n9590831\n42928\n4565389\n221\n28388\n99\n8558\n473\n102\n5\n21567\n28\n65\n77\n8\n194844\n571\n2\n9431\n58\n99589\n51030\n1939278\n6\n74441\n90\n16\n6951\n70\n32\n5758218\n881\n9\n4\n8945\n108\n3975\n39448\n710803\n826\n6684176\n94808\n44819\n3350209\n2262\n391369\n323506\n80191\n8577375\n79\n9215856\n16244\n4011\n888120\n53997\n6701\n89\n9005\n336660\n3443615\n1604\n6\n7\n90869\n6\n999288\n2\n6659\n5147289\n60587\n564\n769\n69038\n58\n7089\n513330\n944\n2\n707585\n2\n1049\n13\n61580\n2618984\n2\n9048744\n389680\n6448683\n2\n165\n5\n312\n4823582\n8\n47631\n1189563\n783\n87\n3402151\n5120\n42938\n4\n3\n99769\n4791\n91\n990\n749410\n26482\n8\n511350\n5474641\n95\n1016794\n7\n804880\n796401\n56\n95012\n58047\n91\n959\n82\n5353\n24390\n850\n1517\n2494801\n855\n980997\n90\n34944\n89\n85\n57898\n2277143\n6901\n2259601\n5\n8803\n33485\n7286663\n5\n4711\n6\n294\n141\n700804\n602\n19\n7148248\n99348\n719315\n5063509\n159\n2704599\n505064\n989348\n71\n64\n69474\n251\n2\n6682524\n235\n14\n1261\n3\n40606\n1510100\n2\n220\n65\n94321\n4\n10751\n504794\n708504\n2\n81\n230\n699\n142684\n31\n660355\n139\n61\n89\n15876\n62\n8452\n243\n35\n7707\n49032\n2\n5284\n2795864\n8885\n1937\n7166863\n721\n77\n66\n134230\n45142\n57\n5893722\n8367430\n59646\n31617\n40\n500345\n3215360\n1573957\n63\n7\n25\n6\n255574\n538771\n479\n338\n7483393\n7816\n554\n30\n2498\n933\n97908\n8682936\n9\n6\n6270855\n6855084\n42\n8855\n78484\n576947\n8430231\n73\n7\n970345\n5104856\n54\n80\n98\n192885\n48\n2297569\n18\n7784\n62542\n7\n6307899\n342\n6\n81159\n85382\n69008\n24\n6\n599234\n59998\n59\n1\n718\n2356001\n5936574\n8089919\n2252235\n1671494\n78\n28\n1\n3035591\n41942\n720\n9\n103110\n373\n6949\n65358\n2399\n8146\n6\n28\n410386\n225\n742\n85470\n45562\n250926\n34023\n698035\n4\n1978452\n174366\n161\n64994\n67771\n83754\n7371792\n3\n2642\n618\n60\n7\n9\n9524523\n69289\n3958\n43\n313367\n7\n9031\n1535\n602\n70533\n171586\n7822207\n8936\n1144\n772772\n67419\n49104\n219289\n6\n207\n59363\n8291\n3798\n4069558\n18808\n9257\n8786786\n87\n98670\n3819149\n9656038\n197\n3199888\n9212168\n7\n3318465\n310812\n5753261\n84342\n534\n22358\n847\n503\n514887\n4\n30\n6\n505098\n48183\n22\n9892\n1017940\n68\n17\n86363\n27905\n747\n844709\n7\n25\n974\n2848\n4806\n87363\n779\n1124265\n879\n6\n614245\n343157\n9\n1145\n78\n6887099\n4\n73010\n69213\n9\n44\n25690\n6489\n4\n5\n66473\n742\n14\n449\n2\n7\n51404\n1957\n70\n1681\n73696\n170592\n9\n313\n518\n5286050\n882\n11\n768\n9649383\n33958\n900943\n960\n947\n752\n7\n4164\n7779828\n993925\n605\n650707\n32\n30958\n84\n49301\n298954\n33\n9372167\n9\n27904\n186\n30185\n16299\n67608\n9175\n2143611\n13193\n9464466\n15984\n33166\n611533\n3062429\n7615145\n34\n18086\n5364\n22\n4\n57391\n7158041\n50\n7896\n2474\n42108\n5120\n907\n48595\n80608\n7\n2\n38\n3462\n520024\n8612\n4\n26210\n5297842\n50\n492\n420797\n12\n44607\n653\n9632\n6\n23758\n217\n4030\n81\n8\n4708\n2\n44903\n8\n7480\n69\n6873352\n6\n4927714\n15643\n134707\n3\n868\n6\n559867\n734\n413067\n332\n2942\n97262\n227\n99\n108\n440\n1587015\n16\n9056712\n2939224\n8823454\n1545\n5\n72355\n33\n13\n2443\n8561394\n7682\n8316\n983976\n67014\n176573\n33\n682\n347976\n13608\n656072\n7944\n8107\n4127\n80379\n9\n368\n475\n5242557\n25205\n23857\n982177\n6\n1481367\n10\n7\n93453\n4646\n3\n945268\n461\n422459\n29240\n364809\n1683770\n13528\n15970\n482\n150395\n8815602\n62836\n176042\n35161\n799368\n46\n695\n515122\n9292779\n3475\n5\n66\n43749\n703\n73\n347947\n431\n481\n5534\n522057\n74\n3\n497148\n55\n67\n97371\n256196\n8657\n3329\n690\n134095\n664\n4499\n184448\n9196\n8457940\n40162\n1452683\n899\n9\n82\n75285\n69511\n5\n30\n8\n1\n726228\n456078\n4\n8368\n970236\n235692\n11432\n81730\n533455\n45\n9753512\n833166\n65\n31150\n7326315\n3448433\n4764797\n3109081\n79\n5056883\n84709\n82939\n224930\n1\n6\n8455294\n81362\n3041\n622\n9\n1875\n2\n1863\n932242\n496419\n6523\n798992\n3805\n81601\n6991\n53783\n251017\n684325\n39\n461738\n7092782\n5854\n2287\n43\n626\n7187232\n751105\n88837\n55392\n6\n5\n6\n44628\n6300\n630\n6\n445\n194207\n327\n4116\n595\n269\n5\n98318\n6423\n9049\n29272\n223\n272\n4663437\n677974\n37\n2\n9\n57910\n638663\n3548968\n962\n431976\n2692\n191\n555603\n2154\n2013916\n5\n4\n66\n28\n990313\n30075\n27028\n271304\n782\n657\n7155\n30\n5084105\n265\n40150\n86\n19\n5249\n24\n856434\n97335\n8213\n62921\n2\n82273\n96277\n9\n41373\n136975\n9278698\n91523\n67847\n890635\n46408\n588\n8039254\n41871\n7\n7722361\n155\n9\n4863362\n45\n5\n6500940\n79\n5547847\n891817\n17\n451333\n96\n1\n43331\n460684\n273128\n74\n37\n4767204\n190\n771139\n50\n675\n20\n5815\n74544\n84283\n32\n786752\n2916853\n2\n7642\n9864\n63472\n11\n3\n588008\n11\n18434\n43\n494\n1665\n9774804\n8\n29\n8366\n8713\n16\n12218\n808\n6\n9475\n71692\n3458\n426419\n15895\n28272\n558854\n256\n29967\n84006\n851359\n141\n873720\n286\n5801\n295\n103\n857621\n3310200\n7792\n66\n26\n2658651\n5623783\n4755\n3205669\n21465\n928\n66339\n73\n62\n1\n3668\n9154961\n2387770\n8221498\n142\n42527\n24181\n5925092\n994\n439\n455\n441192\n293670\n67269\n65007\n9\n8\n2\n2\n16\n534\n6402\n7307375\n514386\n6526936\n5927777\n75838\n4819212\n375\n19952\n53\n157850\n5908\n8434\n7\n9\n9141\n62\n4546\n34\n1875\n962689\n269\n8294118\n335781\n8871625\n70\n93540\n957\n928\n528962\n63\n16\n7176992\n2625\n2310259\n5055\n833351\n30\n304530\n50341\n50647\n563915\n1666\n5\n71\n373095\n1793138\n920\n55\n6\n861723\n9386044\n7894894\n592510\n45\n1\n630167\n95\n857\n9277479\n65\n2\n53917\n3748\n760919\n55\n415\n720036\n6657637\n159159\n971\n655\n4553908\n58\n56191\n13712\n76516\n864812\n9411523\n4071\n62465\n7879961\n7\n52872\n461689\n5532\n348\n41307\n4\n18247\n5\n6563\n8\n2316\n677644\n4\n1\n829922\n4807612\n669\n5912\n676\n3693543\n5634385\n18217\n969\n2064\n81905\n867309\n677\n7\n4864643\n13491\n7817\n92757\n81841\n27\n3758\n537\n17\n732\n792\n1354\n7400\n217759\n41458\n30560\n25050\n10839\n861\n6342\n75\n49\n21\n4\n191624\n2\n894\n18102\n24843\n67\n955154\n88\n130\n530256\n8147\n10544\n92\n54\n176\n337\n9285249\n2\n4176893\n796\n586818\n1\n293789\n65568\n8822235\n1707250\n53\n36\n472\n973\n46\n810289\n51\n1282457\n58\n4646442\n4\n461\n960\n815\n2314250\n156914\n191423\n7\n6641\n14\n521237\n1159397\n522898\n96\n5217\n34422\n569493\n8\n43\n3\n96\n5\n378\n118461\n5257\n26170\n7\n7963\n237\n4662\n96258\n7966\n1432\n9255969\n3602\n5529120\n873\n24808\n4\n3020833\n6\n5024255\n46\n16373\n1\n92976\n8382\n808782\n59713\n9\n489\n4161\n4\n334\n1108930\n12\n87811\n12\n5063601\n1384\n183221\n43929\n881659\n4300544\n3998\n950201\n556\n98\n9114899\n5\n6515705\n199\n12\n4493\n15783\n725\n59\n1\n90432\n73\n66603\n533395\n6519232\n1016\n32\n776519\n8\n9\n507\n20370\n4814371\n9\n75757\n6956\n32022\n50\n413578\n59786\n3\n409544\n8905678\n1194\n924\n49481\n224081\n8357917\n6706171\n660367\n324750\n875\n90855\n5097117\n5555148\n27\n4\n96\n8952\n9\n5236391\n6\n572890\n305\n544773\n6035\n4624366\n212620\n78\n1686302\n295\n3381479\n9861\n947045\n47\n5657\n3693332\n458\n9\n5555\n77\n28920\n9930\n959254\n7\n2119857\n4\n5\n4\n9510\n884447\n9867\n737\n480\n22\n5712634\n2511940\n42488\n99934\n9\n537\n814\n9987046\n57\n81\n5969944\n4\n89055\n7951308\n6\n418537\n850\n534744\n47\n785624\n40\n492\n25\n3994030\n7439\n279\n478523\n111\n6602\n59\n489276\n8\n4\n78\n5195\n89089\n75\n841\n35\n3\n93765\n7842\n5214788\n165150\n84466\n89870\n9\n6415\n66\n8016\n42\n157\n7610519\n1042\n4409062\n98\n533\n943253\n409776\n3445\n23687\n4842122\n76911\n45\n81012\n614\n65799\n63842\n2837\n2\n9\n2544\n2\n4371032\n701219\n5670\n10732\n993359\n5023936\n680\n854345\n25264\n7\n1627602\n3\n765\n80539\n5650\n8720891\n876\n29875\n32074\n95\n3999\n80681\n778445\n246123\n57\n430516\n9721\n703\n216\n82\n66781\n771\n8893973\n2501147\n27\n4\n126\n9\n763488\n4\n433\n8\n1\n868\n347\n392591\n6\n454\n5738628\n48\n481598\n5044\n5976\n5232\n7040888\n9415\n5\n84\n6612\n68806\n821\n82877\n2215\n34930\n82681\n539\n4567268\n86530\n474\n845031\n38998\n37859\n58810\n979\n7\n641487\n4140\n89780\n491\n8763\n6249\n2937106\n7720817\n4498049\n5196992\n163\n79\n419\n878027\n92593\n7101\n345016\n893\n29702\n20\n972514\n21\n3464\n8\n45311\n12\n8\n503121\n7\n4\n21378\n77397\n78\n2\n977\n9\n7696129\n3777576\n864797\n75\n442390\n3\n6\n6\n9\n8507668\n8904768\n7\n3548618\n85\n698190\n87596\n784203\n92\n1\n4283\n8238\n47\n166\n274\n5617448\n60819\n6\n619\n737318\n77\n345\n453\n17492\n77\n7013\n476\n50\n9\n90\n6913923\n6325\n391\n327\n711376\n909656\n608\n24781\n18473\n484\n9708\n2510156\n594\n672876\n84743\n3\n960305\n4\n3\n1336\n32\n9185\n3108356\n9\n185955\n80\n861737\n470225\n8941\n325\n34\n273044\n808\n5161878\n15\n1\n843\n6396\n229\n760\n732\n9\n368\n34\n52246\n208495\n8622615\n27\n39\n3728\n1972\n2115\n2851\n873335\n869\n1528298\n40\n6\n969\n3\n1401384\n60532\n832\n100\n21\n24764\n8\n9153\n921\n6\n8867998\n146\n16860\n90\n324370\n1\n1828\n6231674\n675638\n1409556\n39\n6\n406249\n63\n91\n13\n2\n497965\n9037\n607\n9917555\n233\n68\n16191\n9019785\n185982\n1046817\n90\n3\n692\n8\n76\n829\n58\n4672229\n875923\n6070\n278523\n4\n83138\n924\n7963\n4\n4402753\n822\n30998\n9623449\n4\n701\n8547\n5161\n6490475\n514580\n956780\n8\n9\n5\n4\n6626839\n99806\n8\n99\n777\n40883\n59116\n367547\n4833\n3145\n4785322\n54380\n229789\n80\n696\n463\n42\n7\n925\n526504\n133\n213\n76539\n4060\n287366\n2731\n907\n79\n90151\n601155\n7\n2829120\n4095\n81\n591420\n9\n3\n4\n7770\n780746\n69\n728\n93751\n2\n92\n487353\n4\n5\n6095\n32555\n511790\n5\n236\n62\n3684886\n31\n89470\n203\n48\n8339953\n967247\n9589580\n423375\n913\n3\n6456\n98\n4\n518505\n30218\n524\n39438\n989\n507\n776766\n77666\n80\n143\n878\n57\n967300\n517281\n8448818\n57\n245\n95\n934\n429\n962717\n365529\n245651\n4537634\n6877952\n3423\n63573\n7\n277721\n9\n767354\n49273\n64\n887982\n71\n62\n152032\n2742355\n15121\n3\n6488\n946\n23\n452\n853\n8998\n7859635\n9\n2134\n9\n1193563\n18648\n4454142\n83213\n1181\n460\n719\n24\n6322321\n510552\n9362\n71\n666095\n4877753\n86\n16678\n67645\n2\n363816\n48307\n650\n1111\n67266\n3541933\n6\n3663\n17094\n486\n2\n5\n214182\n11\n517\n716867\n3706474\n964\n720083\n9274\n6180651\n3\n31\n8480\n971726\n6\n92\n728480\n29689\n9605\n1\n5326\n376\n5293095\n76\n107\n385\n4\n232668\n7593\n43\n15930\n673\n372\n306\n5267679\n869\n8924459\n364963\n76441\n9\n7\n63\n3\n9211100\n81\n47\n9135\n553364\n15602\n1\n4\n9674\n39066\n46203\n739\n982\n80373\n552\n735679\n8152184\n41188\n21939\n6761\n60\n9\n95\n99712\n2\n1867\n73\n3933\n4506508\n34\n772449\n29\n9\n8717171\n5322106\n6587\n9601\n495963\n982\n4938\n489\n6\n505945\n175613\n45302\n7993\n3\n80\n1\n1379\n6746\n8439\n556\n80\n857261\n6636\n37\n48844\n447864\n5\n53\n94\n78492\n13\n39147\n944805\n88\n45294\n9848849\n687247\n34328\n89\n100401\n797892\n9\n3884315\n8877\n1209\n639276\n288\n45\n2369\n343\n71568\n830611\n22101\n2\n16\n6117\n249\n85757\n86\n2001604\n743605\n25\n66266\n701\n264\n2\n94724\n35432\n1259703\n8061419\n244\n99252\n5\n3736104\n43890\n189597\n73358\n2\n8967\n9786198\n291\n44\n859063\n38\n8135\n31074\n66\n5\n76\n795\n954641\n8399\n32442\n446\n48\n1228473\n691\n394242\n182\n623501\n379023\n154859\n1803\n6681\n5036\n2928893\n42\n123\n8\n99340\n69564\n7\n6\n2\n11\n2\n6737\n214\n5600406\n66026\n9784\n91\n6714\n851604\n645\n575305\n57\n3283\n178\n55168\n431492\n4983275\n73\n83228\n3960\n3522\n648184\n3\n3745\n8068445\n8\n9558\n7\n548\n680507\n15\n214134\n4048\n2498\n5104\n5\n63010\n7\n2295697\n1\n6288\n28609\n3912271\n566\n71\n305\n29855\n7270896\n97651\n642\n68570\n471\n87\n52\n12578\n7\n599\n698910\n21\n75\n9\n55\n66\n6231\n577\n552\n2962890\n22\n4379850\n959\n12\n7135387\n3789246\n637\n170790\n21326\n951769\n7\n1602123\n74\n49969\n3\n3369648\n23\n805\n909668\n7070\n765\n6632\n2\n75\n5\n3548\n53054\n67\n92\n978\n34057\n949\n7312\n766\n69856\n6\n19\n794628\n8233\n15\n7539066\n1\n379\n797155\n85\n53556\n11223\n49894\n60551\n39018\n378\n854041\n95288\n897003\n3900\n99\n986\n733\n8120210\n17\n4149\n83\n298974\n6572\n176\n588571\n938\n35668\n7132\n54707\n61495\n8497\n2383\n2871443\n332\n250353\n7621\n4212765\n4\n42418\n751\n38231\n209\n92\n11\n51984\n4\n566528\n186015\n27\n57191\n298\n82327\n7\n394\n4327009\n958105\n2\n13195\n746\n93\n3298\n42\n99\n83289\n83\n2\n1500334\n27\n395021\n10716\n293854\n1\n9\n5\n85139\n68061\n9003\n10\n1557806\n2852787\n42036\n1591\n8\n461\n15\n4\n279\n64510\n495106\n79\n93\n911\n7\n2\n3\n78225\n7713\n9889\n13241\n9\n805512\n41895\n706450\n9\n46\n64\n96\n82\n6196\n856106\n5267274\n4845\n121\n2913\n6295468\n13\n334807\n8446303\n64\n856\n774\n91353\n39\n221\n2308\n421713\n8\n5777\n44884\n771\n6\n7\n79984\n4288711\n361556\n926\n134479\n742209\n304413\n6437986\n2832\n66\n1485\n715\n7093\n7\n65538\n5119\n968087\n711752\n31200\n63\n44007\n5675951\n29357\n4\n8997\n4484\n5849329\n97491\n1911\n9171\n7\n1039\n9105435\n87\n185025\n6052\n10949\n879013\n2337873\n4\n7\n8211\n257364\n7\n97365\n713\n62\n42\n489\n61728\n76\n1133796\n7724\n16\n9\n9638\n27228\n4\n8\n634299\n718\n107\n997\n6\n54\n3528499\n705533\n226\n81\n377\n56804\n922\n52986\n894\n2684986\n7803799\n71259\n7\n5837\n18042\n80137\n651917\n99\n806\n1034333\n35\n8\n9\n33\n82605\n7170950\n470\n8\n356\n934588\n6762\n8\n392433\n8654109\n9904991\n580\n8056\n1395380\n961750\n6\n88\n2641501\n3162229\n9674\n81\n74380\n365\n2\n4\n6572\n85244\n9\n6\n34\n559\n90\n7872\n2\n878190\n3\n89\n767415\n5729\n5714\n5\n8240434\n841286\n1234796\n293183\n22110\n97095\n97\n27158\n56\n36\n58\n963\n884300\n29325\n64713\n13\n2598\n4977\n58825\n454\n1382306\n11\n2398189\n98\n6226\n595035\n72254\n7204\n537\n44\n2468528\n2\n7\n158386\n6\n3\n820030\n5764598\n71\n927\n11\n628688\n94468\n43\n102390\n78157\n126\n9\n16\n692\n878923\n627083\n1624375\n988\n3273\n97097\n397\n27\n253658\n542033\n97879\n908048\n26352\n12663\n359226\n6018604\n1944992\n718\n170\n32\n8665\n3\n297\n6004\n682037\n44\n512\n54\n399536\n5\n4588\n1282933\n7\n54\n529\n90034\n7358\n788\n2\n62\n6006\n6730\n40249\n62\n2\n90\n793461\n5\n853\n4307745\n641642\n483841\n7223\n865\n811\n7\n3408\n8861\n1783\n91213\n68\n3898451\n296\n40\n4338930\n5\n458562\n550399\n2\n4\n8\n844794\n76\n139\n2302\n4985922\n50193\n97177\n87\n357089\n8256\n556\n335\n37522\n3076186\n5207277\n28680\n84879\n98\n4988\n98\n847\n98\n5\n812939\n630163\n79885\n1277\n35258\n9915627\n8\n508849\n9960\n295963\n870\n311394\n98\n2346197\n66\n80\n8763988\n52\n8256395\n7\n7934715\n6062\n79776\n4869\n5\n9\n7\n19900\n14\n215\n73\n699294\n4180\n711313\n58456\n823\n2905\n6559645\n616590\n8367195\n77\n6565\n40152\n9789\n4\n80898\n9\n1825027\n9824\n6\n6\n426\n114\n637264\n135989\n373\n4843823\n4834679\n507022\n940500\n5\n5078\n19358\n9105\n97821\n5\n77\n32389\n318196\n9714047\n9227\n23613\n63739\n7\n75\n33\n882\n8335\n98\n83415\n4675\n87214\n61891\n23445\n9634241\n305\n2828\n7099138\n67\n866780\n347\n7975\n57670\n353\n660\n1\n4858\n7465978\n5305\n8\n2642811\n425156\n843\n7337490\n513\n65\n237\n206839\n69630\n341642\n51910\n178943\n5908\n3\n5\n54922\n948190\n95\n9\n98\n362\n6295759\n82\n1943\n28781\n38\n3239\n3797460\n90607\n9\n44914\n515\n6\n38\n532255\n967\n815952\n3\n3593\n4798162\n60200\n823096\n65\n701455\n529819\n48013\n678\n113186\n3269\n8\n4\n307503\n5747\n604032\n41813\n873\n115\n4\n9958193\n5388\n4443101\n16170\n718930\n100\n2\n7263390\n3447283\n75015\n539934\n19\n1457687\n1958\n7022\n6\n44377\n66899\n1914113\n899941\n8773\n346170\n471\n4\n77\n64318\n956\n1\n29411\n3\n1352601\n7\n57\n2693\n14\n6730266\n32806\n23\n674\n810\n1279\n8111\n9\n2\n399\n74910\n67415\n33\n394\n319538\n342754\n3\n60\n1\n8\n883\n5159\n763\n508\n30443\n7758057\n8\n942\n975161\n70036\n63688\n96\n79635\n8910\n79217\n315265\n4169266\n306\n780\n6\n2571\n425295\n9063\n4433187\n3024\n1\n767738\n3766200\n965\n50500\n3\n4582\n565941\n4\n38097\n773\n70076\n304455\n929764\n88577\n351\n30\n641\n6499618\n59\n6847\n112386\n7209434\n1\n8737\n1\n2522546\n2617783\n82\n5\n1\n9035374\n6776245\n8806242\n996916\n337\n457\n452197\n643647\n135\n38315\n33\n4\n76\n101\n1747\n46268\n889\n38473\n85\n417\n97335\n45086\n2166639\n7637848\n958317\n8401085\n380\n6375251\n33190\n47\n58052\n7265155\n1288\n752\n3758\n2\n8994\n23523\n71\n9459455\n9\n295499\n169996\n8867662\n3010\n4\n439802\n6476183\n37998\n8415845\n93765\n29536\n6336\n877542\n8233044\n24\n6\n1249419\n66389\n12313\n9154\n6\n4\n274\n58931\n4009428\n7367\n7610\n62\n57255\n9\n1147593\n998\n682\n1587\n40\n6\n63\n343\n23005\n9863\n132\n437668\n26\n8\n27\n4\n9010208\n6\n7169307\n46\n14\n9131484\n7232892\n594\n7350331\n981\n98948\n6013\n1\n962\n80\n994\n45\n86\n58\n50555\n3738844\n9454734\n7\n85\n4590\n386561\n7310\n4004\n73549\n73\n2850198\n1963\n2\n17\n78\n33959\n4659994\n63554\n837\n3340182\n1\n290\n318806\n2590\n60668\n616506\n3\n63978\n35533\n4693\n2336\n917\n10\n69\n9136\n271\n39\n950\n3\n643\n9\n444\n6368323\n19\n5\n8837627\n2236\n63187\n4140\n2\n6\n2877838\n635\n65717\n6911\n2470961\n1\n385653\n39776\n719148\n69209\n9896130\n1641\n1888\n3\n634\n8\n55\n3\n7\n9938026\n2\n78\n28438\n869914\n319941\n6952791\n9\n87\n7\n976\n673561\n9\n101\n80978\n2702529\n5\n8\n5488\n446\n9868\n6\n3179\n7918608\n495052\n811\n46363\n489474\n723496\n984\n6238474\n20748\n412612\n83\n4\n8974438\n438492\n1914989\n55\n154\n2\n904073\n553\n11657\n7\n7\n29\n89\n52\n38\n5\n7652\n970\n77\n20939\n763\n9654\n570335\n7150539\n4815847\n89857\n902\n90\n9\n22\n48\n2660995\n4845957\n475\n14\n78356\n1\n3784199\n955090\n7021\n77\n29857\n81\n8163\n683192\n4469060\n5822\n269\n6355034\n177\n1621915\n7245947\n39125\n11789\n375207\n4478\n8976\n9\n5255787\n774783\n12307\n444759\n582\n39\n40870\n96154\n843415\n79393\n3145\n3848\n705\n9\n979933\n2079950\n6021\n5\n568778\n5\n9\n830860\n4\n463\n8368\n27152\n34\n671\n7\n3230239\n12\n483\n825\n1\n84\n603\n12586\n45\n1304\n134\n125364\n6990384\n147\n39584\n66732\n356\n44417\n284\n800231\n3296\n203635\n6416\n367755\n34154\n42867\n9811\n6\n2764302\n7248025\n3\n6779\n301\n3635\n6254240\n2774623\n978\n944800\n907078\n32\n83296\n553360\n15589\n6\n76897\n17\n93372\n523\n1149\n1\n68400\n97997\n81506\n9\n271\n844\n38\n58439\n668305\n25\n8\n39237\n9\n72985\n1\n5\n5\n62\n6794\n2325\n419\n88490\n86670\n1964964\n554\n922\n189658\n839\n13275\n24914\n2\n8\n8042\n602692\n3909226\n97197\n596\n9\n288\n5423\n3\n1159\n651\n347918\n7407143\n696198\n1\n209497\n801617\n65\n302\n10\n1\n11\n2351570\n7030123\n8010403\n383\n793081\n54\n26\n73411\n59\n41433\n8647334\n176269\n111\n1\n803480\n5539787\n892\n3802550\n760212\n846965\n4778768\n26\n44\n8\n4258563\n68\n34\n4543598\n120094\n1\n1443\n1879605\n7020460\n91317\n88635\n1699\n865\n9099\n2660\n37\n953601\n2573\n422884\n5424871\n583896\n3030424\n17102\n857452\n89807\n6046001\n8\n8469519\n32\n168844\n575\n89\n4956\n14208\n72\n4\n303\n434\n6671706\n49265\n16\n4\n4\n439436\n66\n534348\n167\n68\n49392\n35\n739396\n40237\n536\n806\n1\n97\n40\n84614\n982794\n1589314\n1937\n63\n18691\n543\n1121192\n5147\n2\n74\n5472916\n9\n7483\n469\n7\n6\n6440034\n807091\n9\n72824\n934779\n535\n146\n8821464\n705596\n991\n9964\n836\n36\n5448\n624\n931\n95\n22053\n568\n53\n55\n76941\n107\n981\n954826\n5418459\n1052\n8\n94433\n577\n675206\n64\n299\n61079\n79\n383858\n56596\n6764\n5897\n539229\n123619\n2000207\n547\n343\n791514\n7\n7920423\n45434\n195849\n1762\n62\n50\n68175\n19\n43805\n35065\n1\n60905\n61977\n9\n2\n3\n1692\n89\n1858579\n3758\n927140\n31\n555\n77232\n71556\n609425\n975\n82\n98377\n4558\n8\n884150\n4887\n4\n30\n321557\n92451\n7\n32\n1\n33960\n66572\n8145\n9\n314\n118133\n30\n28\n84015\n22799\n77437\n5\n2656953\n4967\n75336\n302\n86\n1102\n2296174\n3\n278165\n4963\n217\n14\n1845666\n4\n1887924\n3\n963746\n3\n7828\n68\n1583667\n288055\n8498428\n47\n41358\n5\n5\n45\n4\n779\n3732\n23246\n7290533\n666078\n949\n224\n6539\n9273\n32788\n64\n375\n416\n580\n8\n493664\n1\n34\n6647\n4272\n6005\n3\n408\n4845511\n7229\n67044\n9867590\n6\n4\n813401\n185288\n521569\n43\n3984\n3300\n3875163\n5\n474\n1\n4\n509\n89215\n59311\n461\n6973\n607\n2815341\n5000046\n10\n80\n3176\n6368304\n212\n66340\n2961\n30\n7257\n365185\n317\n47879\n61\n5126\n6778\n790\n739383\n52\n75397\n4471748\n599\n33\n35\n296103\n1194658\n7644004\n3\n3226\n3784930\n88\n9558613\n8264\n8799\n279\n6467882\n7869365\n65803\n926\n4\n919\n698\n95166\n90786\n3\n45\n62\n251483\n9\n313256\n465\n51\n88033\n76916\n296\n7817\n1837\n21257\n5175\n5703596\n53\n6001230\n7844359\n9604119\n39450\n7\n553\n7616\n64519\n7\n2684\n21\n7086197\n8387\n199688\n92041\n58948\n94612\n60252\n4955068\n3\n3356797\n301850\n809\n4122\n13675\n8\n469\n856\n817\n419515\n701358\n61\n140\n5195\n25\n4286\n14\n3997\n6\n3932113\n7\n5524\n668\n47786\n40151\n91246\n962\n5507257\n944\n7942121\n4\n5890\n416812\n9359\n4\n7923737\n82\n9332380\n25537\n2\n57\n66870\n6\n665538\n99\n69374\n7140125\n4563717\n9782\n621800\n5186256\n3\n587411\n298677\n3\n25\n1\n37238\n13\n45\n41152\n22\n2\n4462360\n8985950\n87231\n53270\n4524072\n5\n8\n74\n169\n56269\n4\n65\n16\n161682\n9\n133\n3780\n41577\n95\n69\n95\n9391\n528789\n3192\n4777\n30\n9760\n4105225\n7\n599244\n9507\n3540\n74\n3548188\n6583347\n26637\n78\n5957\n51645\n866\n941224\n1260892\n49195\n6630\n556\n34\n628549\n4840\n9\n808\n82357\n54816\n376\n8\n3556\n1728572\n9\n516\n653163\n425\n1\n11\n933515\n366990\n786\n34\n1839\n454\n2678\n689309\n29\n2050597\n6\n4724043\n860\n958082\n9\n9\n933\n91\n9945\n57723\n5017643\n3723\n4408\n558\n6\n90343\n9\n6513690\n911996\n761\n34763\n1195\n2861\n3\n114\n8472647\n66153\n682526\n149427\n651\n7346\n262\n4527834\n78\n904\n98\n8749\n78854\n6914827\n6085410\n78142\n14268\n3239\n6\n6780716\n4032920\n1\n935842\n8524\n63\n49558\n283250\n198\n7127\n302640\n40\n2065328\n9040394\n9721399\n12\n5\n846\n8494187\n454\n206\n633745\n28784\n978854\n90305\n3598\n93929\n93\n326789\n8625811\n1\n27\n6\n44891\n1\n17344\n44\n1144184\n8\n1941\n885512\n70\n36725\n3\n7306\n551246\n3210492\n21411\n37270\n4748\n16083\n8049273\n784\n1875877\n6013\n8880\n2957\n2701\n15\n3615\n488\n846\n6289\n8267907\n453273\n9527838\n487548\n1348801\n19\n376\n36\n7\n5430544\n848\n9\n9510\n498\n14311\n7926\n1776\n1127\n5328413\n3\n468\n5845294\n91728\n26\n1156\n704\n8714284\n6784493\n7278\n1581\n2550\n95671\n27\n90725\n522200\n878618\n8176789\n1195\n8\n82\n842216\n3\n6\n3720224\n73\n7148\n11\n9011234\n53\n11710\n8\n72\n34\n107002\n942\n4710\n3241\n17841\n26\n97\n581052\n91\n5\n697086\n38454\n944406\n3447\n4\n5690\n9\n1383805\n1322459\n2700\n3998366\n421\n66\n48977\n9336426\n744070\n88\n679534\n394\n3019\n1\n863\n14\n178\n216\n728598\n9769584\n19736\n24590\n4734\n41986\n7195467\n68556\n5\n6\n7820225\n8\n11\n13\n8\n2\n1\n222\n17\n788\n7512\n6731\n4\n66\n8975\n88896\n1628925\n871\n85\n15\n64409\n7\n9\n6810\n7\n21491\n66\n464\n6\n421\n3613\n61\n2310\n564790\n7983\n5857\n97561\n827\n7092770\n977007\n9167\n134\n814916\n646\n9618957\n5888053\n850346\n9366872\n7\n8\n8372\n280053\n8680\n217\n896312\n97156\n19\n5\n244\n38593\n8595239\n5\n6391\n5751039\n491\n6338\n743379\n65\n83144\n87239\n301\n2025413\n1500402\n404\n2176401\n930\n799\n81\n8319004\n309296\n908\n28216\n84470\n14\n655\n69804\n94\n4\n6199\n914\n7036\n9\n4823230\n9417\n22\n5825\n2106\n1596\n69\n479704\n236556\n6\n3995969\n5897446\n3948510\n70\n4360145\n7\n71\n813\n312746\n274770\n754833\n8\n51515\n6\n99\n9163665\n5\n2732\n3382232\n2136\n484\n3266751\n8742708\n4803759\n691935\n777374\n2\n582\n77425\n26698\n5045458\n422\n1621403\n1982894\n318804\n3181\n51299\n1\n210119\n82\n9\n12\n7760\n61703\n766891\n37164\n644124\n663457\n9\n5\n62750\n514\n6560\n23\n7\n600909\n17344\n241\n954544\n5\n903849\n53\n8145\n3775\n9\n478835\n77792\n3\n932\n4145846\n9976\n133575\n561971\n3\n977\n252093\n6383\n77243\n5\n50\n49924\n211\n21\n27463\n3796904\n374\n1112\n7103469\n5\n35\n210775\n321234\n4779\n306\n2\n7565\n46244\n65\n30666\n787\n57855\n8\n155814\n75\n1599\n5732250\n23663\n686\n541\n5291\n9287\n7276755\n110517\n169\n22\n9420\n9844\n55\n6\n2298086\n96\n41545\n5\n93\n4756\n4858034\n69\n1130619\n134065\n69\n6\n15\n8\n6560\n8\n2047\n63185\n6\n327016\n2982643\n2412\n28117\n922915\n19836\n64\n6497896\n1702319\n8848\n7223716\n566\n4887\n28\n622\n2817394\n233\n45324\n2339001\n321856\n5375\n210675\n8919\n27\n59\n49253\n8\n35\n49\n76\n2\n585\n40402\n15660\n91\n60578\n37\n2\n72978\n494\n23\n957679\n9\n287\n202023\n76197\n6971177\n7936724\n495\n8\n690\n320\n7801871\n2787\n69821\n898\n2\n361\n29622\n89\n1\n3298\n92\n87\n3284687\n5\n474\n85890\n24035\n52\n82802\n175055\n6928410\n471715\n7716\n86909\n8\n30710\n122224\n6450\n924673\n78913\n5983009\n11\n7221\n278854\n40332\n593\n2349\n844\n2809\n665\n84\n7469\n8160879\n152054\n67\n617477\n476\n88017\n1865\n59\n65131\n3205\n3\n73\n827\n12\n7711\n23223\n8358\n5599\n3284702\n6\n5230\n6431656\n36229\n549009\n66002\n219\n277023\n62238\n8\n24176\n8\n619\n6\n990\n356\n52\n612083\n487\n9\n91\n59\n9\n64\n927047\n825\n5498\n1\n323\n4320398\n187519\n83\n5\n925723\n1908\n799\n9\n149401\n76\n726\n915\n93\n820\n11017\n81458\n10927\n5404\n205768\n9558229\n231\n20\n4615979\n19\n17216\n57995\n33\n43545\n1037254\n991\n318735\n55903\n5385\n7120267\n2697\n7395314\n2\n6\n895\n245\n874\n4988975\n93\n5812\n6972\n6932957\n64378\n184\n964743\n88\n8523\n4\n72\n3\n2782\n14\n2204\n963\n76\n60\n612787\n161\n134002\n8016820\n8435768\n3184582\n1242\n7\n661\n514\n8215\n8257\n4\n302\n4\n3068\n6\n23354\n971333\n4\n766572\n96077\n6\n35\n848\n941081\n7819605\n5622\n2\n2\n85203\n4483862\n563\n30\n6169\n3641\n178\n22784\n607\n3\n4949352\n991\n2934658\n768897\n1957195\n3\n6218\n6610049\n2096065\n2\n706\n549975\n6984\n3934571\n60708\n80\n5\n721\n41\n484\n9\n9409872\n8523788\n71\n66347\n76097\n32060\n87\n6277\n897991\n75979\n388877\n557\n2\n44505\n48\n11228\n7280198\n6137265\n704\n33\n5\n6001342\n59412\n505879\n717840\n42\n45504\n82\n594\n80333\n8464\n79777\n849203\n28\n715542\n3322274\n85\n1\n33\n9\n75629\n3139\n4814\n3\n154\n298895\n3\n6112\n968\n61\n8251579\n97485\n73\n97\n871465\n340245\n4989\n2473861\n2\n4948\n34\n84\n9316308\n1924901\n49431\n7412047\n4440089\n373\n17434\n89\n9\n64727\n5036\n92677\n6\n3058410\n16118\n6\n7\n305598\n147\n4\n209\n22\n797\n23\n51836\n654\n11997\n89527\n1\n5\n49\n898\n659\n742171\n5806\n431340\n1642895\n5173\n423061\n69184\n82\n897229\n50376\n39268\n1194538\n735\n4\n42365\n51207\n733059\n351055\n11014\n40607\n11369\n386029\n5304905\n47\n275127\n9411005\n443\n94157\n89370\n649540\n36790\n868\n97390\n1444\n72\n5005265\n80\n41\n57310\n2\n486555\n8335\n2884\n32\n3\n78\n3240865\n2000\n84\n2748193\n1036\n92\n441\n8089\n5039\n9164841\n72\n9\n65678\n506\n853\n8\n32\n265994\n2318\n78613\n4963\n72657\n391\n889\n7623\n9644\n8\n158\n85826\n937\n2860\n1\n177\n3531\n71\n7\n3418997\n7\n16056\n861363\n71\n80\n7\n9\n88\n6\n64\n87\n4\n609\n1794550\n676\n2853\n75\n52530\n1\n9362141\n1347\n685076\n826\n6077\n90542\n7\n6\n212\n628\n7833932\n77\n2\n9377767\n4174231\n282483\n54469\n964369\n454\n89293\n97174\n554491\n4606\n7\n5\n49934\n8398924\n64\n61\n89\n9\n49\n3\n5\n20\n650\n29\n693\n596347\n643\n2355\n21\n6514\n126638\n475\n7781833\n417426\n7277329\n61545\n84622\n66686\n700580\n391\n467\n494\n57149\n45213\n779055\n80\n38954\n364723\n2156\n78603\n4522258\n6466\n64\n755\n9581363\n6646\n364525\n3\n395\n45806\n59689\n870905\n4032318\n6545\n11219\n4\n6853\n11\n881041\n2701962\n717859\n2\n57\n2\n76011\n8395\n7549\n151873\n61269\n5127257\n30251\n8228\n9202823\n57\n9189\n6214\n359089\n1247\n1226397\n1\n5502481\n1168\n64\n19\n5967\n32530\n906914\n16\n145163\n80215\n1506\n635\n7162628\n257\n663\n804532\n799878\n955038\n60\n785899\n18007\n1\n50815\n293363\n247\n188\n9572\n49\n55\n930530\n488\n3374\n503131\n164060\n387913\n7715898\n53\n64\n375787\n39\n6\n558\n8125\n6409\n42\n95148\n706\n4919\n992237\n9890\n74\n5661305\n40\n4819263\n67\n6\n5484\n4007\n384784\n202929\n277770\n2571313\n301863\n525\n2242\n96206\n2\n702\n6\n134798\n780197\n7827\n67\n5116277\n474521\n25\n70\n39369\n447819\n8\n119128\n5945\n5162947\n52\n1974472\n2643\n3937234\n70\n19\n2122405\n6\n602\n7820\n1623\n809\n4821\n9416\n254\n14784\n7806\n2\n662081\n2249964\n4\n311\n951702\n1\n14287\n8959142\n7\n868\n300093\n16062\n2\n72495\n1\n39373\n9\n4\n932\n148012\n5860878\n9667\n3674\n659\n733448\n1235\n2104\n185510\n295798\n93091\n4\n985\n3839200\n28216\n2\n538\n38\n958788\n6151\n6791311\n8539103\n7611854\n681279\n9\n67\n10857\n25\n401134\n6435\n94\n282259\n12\n59018\n84\n8\n876\n380745\n4288\n46843\n2\n122598\n76145\n226653\n378893\n4191445\n7\n48318\n349771\n25\n434\n7160\n91\n3\n8312\n7\n3\n51\n6406213\n706\n94\n555708\n491\n9491\n9\n1717\n9286096\n8282920\n7278\n8052409\n91885\n4442\n1031\n75942\n4289\n90932\n5799523\n53\n316\n37971\n7685\n778408\n6743560\n55367\n705\n56\n80743\n3\n5170\n424032\n13741\n3359622\n361370\n49199\n8943\n42\n58\n93\n820999\n8491946\n1\n892\n9483032\n24\n46\n6717\n6446\n9830\n87470\n289\n69658\n5\n597292\n7761\n2688\n2\n9124\n3\n976\n6136\n929\n13975\n46\n15689\n5\n8504\n5643666\n75\n200\n124\n6856071\n4350500\n23\n661\n999722\n748922\n8\n336\n4932449\n7\n91\n59499\n5791\n364\n878\n5\n28\n4740\n1138\n9\n9\n21293\n72\n8\n2324056\n7\n127813\n440\n39\n1007\n185\n5119590\n1965\n3342\n4117\n653\n8\n39369\n8024736\n2710607\n165\n15\n10932\n869\n4056\n8023892\n2\n2105\n5\n72\n1\n2164\n99\n7823000\n8629006\n608\n926\n31\n258215\n80\n6253279\n67156\n7686\n7594987\n24\n287022\n50509\n474\n1026\n32627\n7443717\n971\n336303\n4\n6850\n9218\n81\n5679232\n6\n311537\n475715\n90073\n3532\n34\n1325\n81927\n1\n21\n7217127\n7\n265\n55\n957730\n25727\n8775126\n8\n98\n663\n8247341\n87\n121\n5\n366093\n78\n4796\n6483\n7426\n34\n82\n8394307\n5596\n6224\n7\n1026185\n3630\n387\n304\n718826\n207779\n674\n865\n20\n58\n143813\n97015\n1657\n7342343\n2\n2731309\n232\n5\n152025\n2\n813770\n6\n68309\n6\n7089\n20\n7868744\n875\n3\n117\n7726864\n4050758\n8974893\n442\n7494184\n2362\n7024\n6908506\n6482\n242151\n40003\n595970\n18\n85186\n719\n6057\n146\n470310\n65\n37385\n5066013\n5\n9\n237\n19172\n61\n2140597\n91505\n236\n1152\n13805\n7749\n3294610\n87\n459105\n7743\n2204\n6\n4811553\n1\n2573055\n2768239\n12595\n987\n3109863\n418553\n972652\n6354\n4\n659\n542956\n6214934\n780827\n156167\n295\n96\n24368\n2\n9\n57\n73082\n8\n3302588\n66\n3130631\n54451\n1\n433976\n705\n280\n6571506\n9\n5596044\n45881\n965\n30558\n594472\n923743\n7223058\n70497\n2395793\n95989\n53967\n7510352\n53\n5630010\n46572\n8385\n6389128\n303\n9901\n8\n5154\n4367386\n26431\n760900\n9771\n566\n57420\n4135310\n85925\n676725\n616\n110\n88655\n951\n1426124\n2\n29\n71\n9897\n928517\n49\n271913\n2\n6\n76\n149\n954\n8823\n41490\n7163\n7\n70\n37238\n14936\n767987\n9037956\n15\n6\n7801\n2096162\n78877\n7913\n843263\n648040\n7188798\n28607\n24\n10\n7\n47\n77832\n1799319\n127\n974\n6\n9\n4\n85\n527796\n5728\n2\n463\n171\n303662\n30\n86751\n138\n650\n91878\n6699888\n71131\n6\n594\n9\n399710\n68\n5\n2\n562392\n2\n15484\n54731\n517\n1654\n664\n2\n914\n156\n78587\n672\n8991964\n3196\n8\n9067436\n12592\n9316\n7362\n470730\n8\n9\n397130\n71924\n1819192\n86601\n3\n975\n363\n246801\n9\n4039183\n200\n52153\n898822\n80011\n978\n135224\n4632\n4795\n17\n520\n90308\n44\n2\n6438\n5\n8\n43\n40951\n154455\n6\n5543\n3\n3899332\n97\n9\n2\n63\n1528786\n2693\n8146\n1251894\n20\n8\n7\n762514\n434\n574445\n8\n7\n9678380\n4876\n48\n89589\n5450\n1661\n2\n55\n48\n4254\n51\n228\n12\n8972\n227\n9745\n6632\n933156\n6280479\n72041\n714\n115592\n36\n5\n1955491\n1343094\n7610\n23024\n16\n492\n8849\n338285\n37\n2\n707\n6\n568330\n483849\n28\n11\n6427970\n4144\n76\n966\n105\n71\n4112\n41\n3015557\n236\n5589428\n605225\n51\n608\n435\n39\n5200816\n246499\n2132080\n724\n8\n6821\n35\n902\n24\n912\n5\n394\n174\n1059\n61000\n63\n9331929\n7\n6536\n175\n5355\n6824788\n80833\n18395\n36\n4\n93\n2750000\n50447\n89838\n18831\n255419\n1959638\n824491\n2\n609\n2\n22\n21719\n8681679\n721\n880\n90697\n9509779\n4353\n4503\n618075\n62\n935\n4\n9818\n658\n3320\n2\n7389\n28615\n879957\n9648667\n4147\n1166\n1\n37575\n24\n502\n593\n3\n351\n7\n35\n932553\n79\n7743538\n534400\n5216\n240\n51\n8996\n43\n6538\n2\n1517\n883731\n5323976\n46589\n2299\n97707\n2879925\n75943\n556159\n9967082\n5176\n235\n6\n63\n87874\n31969\n9856\n846924\n512\n32834\n4706362\n1550\n154\n5926289\n1634809\n355\n879923\n8\n771616\n4\n86831\n34334\n214349\n82294\n16\n7202\n1\n1\n5783\n4890902\n7\n655781\n3070\n87\n2629111\n7\n54\n209218\n3\n9254\n4640\n66\n8484629\n593\n3692117\n3646844\n759416\n8\n8831156\n31132\n46\n2609392\n8\n21865\n33861\n4\n141994\n60\n582\n70597\n6\n69\n399\n2316838\n7848\n95796\n4272\n4\n4\n249722\n2\n31451\n32007\n748\n26885\n763\n473\n33\n55\n650\n9\n3\n901\n25483\n3105\n2\n8648185\n105491\n9749567\n89159\n9229027\n626\n391\n7363\n44\n78\n406\n71\n56\n5\n138\n61\n2783\n819029\n72057\n9454573\n1\n11\n8432\n6862\n1418759\n45108\n4\n38\n34\n9796601\n397254\n99\n51\n6\n3\n8062\n3546\n81885\n7602\n7091\n3244356\n2\n487\n35256\n9\n75201\n53\n665\n81\n1050\n15772\n8095529\n8\n9078484\n775\n19016\n91946\n865811\n1576\n30240\n7\n505\n382\n809\n297\n2433575\n852\n4428\n71660\n74346\n2\n1745\n32\n9368130\n77\n468\n2803\n5856963\n70314\n715\n1028598\n3555\n80495\n25646\n15301\n321\n82\n651\n2484901\n330\n657986\n8426\n94920\n29\n3492\n3277130\n679\n9844\n707\n76403\n19228\n2\n3599\n27\n73\n375\n35\n458962\n52\n8\n788\n270059\n144585\n9111892\n29\n6040\n471152\n64\n921457\n7606475\n2716989\n60313\n9389275\n505\n72423\n39853\n535820\n4511407\n8601299\n5\n160\n94522\n6930464\n82\n7\n689\n8955\n64\n90458\n626165\n3\n9719573\n8017\n23363\n36\n15\n4\n48457\n5605\n390\n9082\n3577\n819\n102\n1928\n50\n7457\n830\n79414\n986\n2684\n91\n9\n365\n7\n8844\n19444\n6\n308\n9\n802\n73\n851615\n66405\n11239\n72631\n80552\n323428\n6627\n7\n54668\n6934\n792\n2604\n207685\n80\n4987\n8425973\n76\n7521\n74876\n50\n3284\n1\n9\n41\n81\n250508\n23451\n7017634\n57489\n5550\n9909\n846078\n3493\n985487\n7\n702\n977\n88\n585\n19349\n9584\n63334\n4375819\n874\n3584921\n68\n57\n1\n1\n56366\n374105\n54\n1962506\n352\n508\n784\n57\n72834\n61333\n927721\n481581\n193\n4490704\n81943\n531\n5093016\n7551\n1\n7029\n17495\n545\n9\n7838158\n780\n7592536\n9888\n23\n8553763\n8114497\n23704\n42\n7\n591304\n4586006\n376817\n213\n3239\n16\n32275\n573\n3251\n8946657\n458\n502364\n4752\n209801\n97156\n101\n48\n450\n1525\n825\n25\n811967\n757322\n1462312\n9421\n923437\n96\n7\n2\n1\n55\n22253\n55170\n47\n230\n42\n335754\n691\n2\n307\n5993\n5\n7\n6028\n400126\n96078\n9290340\n17\n343\n8228\n84\n810052\n8\n764007\n3237\n6\n50319\n3355\n8\n745182\n72\n3\n9\n6\n948\n53894\n786645\n4825\n60979\n946860\n81046\n65\n3616585\n9538\n1\n9652379\n2\n9\n6553\n3130\n1211\n61703\n66737\n568\n6509939\n2020960\n8280\n3157455\n44\n18\n2\n885983\n8289\n697710\n118929\n9\n3463\n18\n1\n884\n7\n8\n3169\n9\n4751\n705272\n4\n625\n8698723\n31172\n346722\n225191\n3859583\n8467\n293097\n779904\n767\n84\n402\n8221\n25\n97\n164119\n5\n52\n3530\n8\n3020\n2405914\n1993\n5965332\n402157\n6439\n9\n623814\n510\n82\n1639570\n7561\n6672337\n82640\n63781\n6335064\n49\n5\n1024\n402208\n988506\n2\n561347\n1309069\n133901\n93\n970917\n648934\n3316961\n583069\n21286\n75351\n953\n3773688\n202406\n43\n135\n5\n53761\n190358\n999\n3\n393182\n1564126\n1198\n3412098\n772\n1\n45150\n73216\n370\n7\n3217629\n7\n26\n7\n1115\n9312\n7\n1013\n44\n7468115\n321915\n68\n13\n32066\n6780\n6\n4550\n862\n1105658\n888981\n7339\n57\n69\n5\n23\n80\n3652\n5\n35360\n95\n319\n392401\n9957\n377597\n903\n970469\n821\n6193\n25423\n443\n4\n4367\n667\n311\n64010\n1859636\n621\n731228\n34\n40\n252170\n2\n818\n3290\n825\n4\n88\n1675420\n413242\n9\n4\n1156\n103027\n7275\n86\n4956\n9261\n350\n4\n11\n7563\n520\n8071\n9203265\n70\n99\n8860\n490252\n23958\n698\n82\n63\n2945785\n128\n9783\n5645477\n6559931\n3833\n936889\n6360411\n8539171\n8539\n90\n3631182\n6926\n134804\n58\n6\n42\n6598\n391\n56\n5\n3502\n44469\n4072\n512\n78095\n8\n880313\n198\n320549\n317\n841845\n9406\n914005\n407\n2480201\n5743716\n886509\n9\n3235\n777\n782\n34\n9\n38\n5164455\n706\n8369910\n60\n767571\n56\n30285\n274129\n8\n274\n1066\n989\n182\n3513353\n200117\n286217\n388755\n40462\n7\n853\n21\n7251\n8704782\n5132873\n7\n6270\n29899\n826\n1135\n7570389\n56115\n2956\n6775\n15431\n7019\n6665\n45\n669\n818921\n3799\n7\n155887\n9380762\n40\n1245\n90376\n632\n8266265\n609775\n229\n6827\n31\n37906\n933\n2767\n674\n3031509\n4358\n3160\n20867\n9\n4487826\n430\n93\n82\n2\n56\n61\n77\n1\n9103691\n58\n347\n6\n6889736\n5072864\n28858\n95687\n8190\n4\n5111\n4763403\n40\n902\n8487\n1518\n94\n616260\n8915714\n650466\n4050241\n21\n658\n8731018\n3321\n42\n88\n3\n733381\n749038\n58973\n2368\n22\n842542\n364\n688\n2434\n667\n8487\n7216\n1029\n9429407\n116\n133854\n291226\n9287606\n5292\n6465\n2\n6405388\n40105\n4794\n366\n3506332\n2372\n9023\n57\n63\n241\n31313\n4182226\n12\n37640\n7770795\n8911076\n6809642\n842\n30455\n7042\n82\n179395\n139\n7\n1355\n4\n4875365\n9656281\n7396\n8565\n3100659\n5581709\n45928\n92578\n1\n753410\n62756\n316798\n984\n16\n83929\n63\n984836\n29\n935\n89\n613946\n954\n10129\n314\n8120013\n9\n846\n20295\n9\n773080\n81357\n73\n571\n1594\n2\n179\n641136\n514843\n95507\n631\n4\n14\n9\n5201834\n9813880\n75\n131302\n3947\n908486\n43052\n491591\n519776\n146942\n7970\n48725\n6\n155488\n9136\n637\n83\n9700582\n664328\n17\n2601483\n1826303\n59\n3309\n9314\n202527\n9438461\n5879\n85304\n7343064\n733\n889692\n6\n4251\n2\n22\n658959\n94\n476\n1119877\n46\n91031\n151\n8\n8439980\n23\n2439\n8425\n6\n2998930\n208824\n6588253\n690\n6\n76703\n4\n83\n1770\n8685658\n9812\n71\n71\n84190\n5614954\n924148\n101392\n766\n429400\n2\n8538412\n172\n8699323\n627\n289510\n66601\n45\n23\n291\n538\n2\n1167\n7175\n864844\n47654\n79\n632\n3\n2\n983\n45946\n767\n58\n79\n231147\n9096\n62\n12617\n84\n642\n705376\n915251\n8519730\n164588\n78342\n9\n3818\n244\n2830\n679\n575330\n9905873\n12\n9514103\n8014019\n45\n8952278\n2\n9299\n556074\n7951482\n7286371\n30152\n9704193\n6176130\n5\n12851\n2192055\n8\n79\n79371\n2\n61723\n332371\n8\n7649\n124563\n24185\n134408\n7\n4221937\n3\n98\n7\n3184\n19529\n219464\n2\n110826\n2080\n73584\n4275\n8\n5465\n353\n19\n5317669\n391222\n5434123\n398882\n45630\n713\n312779\n9489950\n171\n9\n4313037\n18\n4030186\n2\n609139\n420686\n4\n90\n489\n724383\n3817\n72\n66\n8580402\n5658\n4000\n5\n5818682\n663439\n62070\n35\n6626\n62\n203000\n1\n54\n73777\n1653\n75310\n6\n2877\n760551\n1108384\n5\n495625\n1226192\n781\n1027\n5\n78640\n3\n183551\n6\n891479\n7\n63782\n9369\n54457\n165\n45\n34431\n6303\n577\n8\n8321152\n780\n4576\n3\n538\n5857011\n6218255\n554938\n42\n27\n5405\n7765349\n40\n5\n596\n464063\n58238\n43801\n1895\n6397123\n5960049\n718054\n30\n53\n52\n78\n52\n2\n10291\n222982\n9011664\n3249021\n344464\n857\n46\n32\n924\n53516\n691\n1795\n4998732\n60422\n72364\n967262\n749464\n70\n4793628\n8821\n4689712\n52\n41\n624\n4616129\n69576\n33640\n31540\n39\n29\n56492\n9156596\n3224279\n865149\n71643\n5236564\n429257\n915537\n445\n92\n930958\n18581\n171\n7966339\n68\n3863\n3\n2\n51598\n100\n55\n7406\n3\n810\n929\n955403\n19\n152454\n151\n8034\n7\n4\n5914143\n86319\n732253\n7120741\n45955\n3\n44634\n9\n980\n5014718\n8\n881\n978\n458563\n1249\n114\n84331\n9594\n76384\n24\n7348666\n26\n163279\n46\n40\n5682689\n7\n6794\n84820\n15670\n6542\n766051\n4139431\n36333\n14874\n113632\n963\n60730\n2610\n36424\n2\n2\n2649863\n4951\n5\n534\n49\n819000\n3460\n3\n467\n59\n30\n62857\n888\n2\n45472\n253\n77\n89\n1\n42390\n7\n88\n319532\n26\n754\n30\n14\n669652\n9764649\n8\n301\n3453\n45227\n5\n2620\n8731\n602077\n7727093\n290\n93\n1026\n1601\n432246\n311\n849\n8511\n756\n330087\n8517\n43094\n5\n73051\n1\n5519\n845\n335\n102131\n5995540\n477\n149360\n12394\n5\n196332\n292189\n2921\n506360\n535125\n6726310\n3399447\n807878\n70\n68\n3\n358\n3883335\n215292\n3940\n40\n6\n93210\n36\n9686\n7958\n81282\n386\n2898\n3\n69\n26\n57598\n3\n7625\n674\n8000795\n43\n98\n395913\n3656234\n7615074\n639808\n351606\n753014\n9\n3714579\n1251379\n5921949\n5\n4\n4922114\n9411159\n2479895\n5\n3951\n5913\n1807836\n157\n5\n16\n5443176\n585\n797\n17206\n206877\n2\n4\n5\n81493\n3\n333\n4\n9655461\n2\n490\n303628\n69\n7475\n739104\n5\n2966\n5\n855\n2\n34\n63526\n356\n2583\n3980577\n583\n6\n32539\n1\n1\n611051\n4425\n4411\n59612\n297452\n804\n359841\n237572\n6617\n138\n2500\n5\n996\n7042220\n642\n51365\n73756\n42\n34268\n1494\n411\n822\n1003419\n87288\n59\n932\n316726\n975662\n548992\n332494\n2\n571162\n102289\n62327\n4\n9\n6330622\n131201\n2325999\n508\n4825\n3560691\n2511\n8281988\n2\n27\n1265\n1\n1\n91\n93\n711\n45598\n47\n5680\n790554\n720011\n93\n2381957\n7\n78\n5095549\n82074\n210\n46\n9200567\n887\n1\n5249\n68489\n7821\n6449809\n538398\n783145\n756\n572\n491\n47886\n60603\n4673823\n1510\n31\n50695\n1308\n66763\n605789\n61725\n49\n37116\n55848\n742618\n212\n682325\n4695596\n55\n3602037\n2405736\n1102\n5\n716107\n7\n658\n86084\n81352\n9102906\n614970\n573\n34\n402\n9\n83235\n8329921\n6483154\n7747303\n53289\n4991\n45\n1433050\n298\n294\n6586141\n5\n141030\n6808\n2\n45736\n49\n8130382\n9\n990566\n3181258\n7353032\n4135\n247287\n2758246\n312272\n7848863\n71858\n27\n8598826\n3050471\n7599935\n63880\n8306567\n4\n52683\n30\n13\n56273\n376\n260391\n9219149\n452966\n892971\n5483113\n39740\n609364\n142147\n5\n73369\n37\n2\n23\n82\n673\n3875\n29456\n3622215\n992\n470447\n2647\n7960\n340585\n4342037\n4153246\n600\n189\n544\n87\n5\n8495264\n4554\n1\n6911\n5426632\n5080\n107155\n4\n816487\n2089\n524801\n46\n261314\n875929\n660355\n1\n9043659\n99\n736629\n1\n2\n84250\n595\n69\n94\n8593754\n547\n641\n924790\n7322728\n4\n5500\n358837\n7184360\n5731\n6846\n380466\n92364\n218745\n641\n6690290\n1501902\n1205\n9257\n913\n94\n54\n79\n4588558\n5753608\n839\n38439\n5\n90288\n10010\n9265\n3566580\n13\n34903\n56851\n926\n7068493\n101675\n2483\n9300\n9792\n39\n979\n9\n2\n9320\n28\n4950801\n74\n853367\n8\n1\n5775895\n509183\n690845\n75341\n14\n1986757\n917979\n934\n9\n11748\n1102\n6784\n2781154\n3207\n1\n81130\n495\n41495\n906\n123\n72889\n192\n2491\n59\n27\n469\n894794\n214636\n709\n580218\n5411780\n476\n650\n8731143\n6526\n103368\n4147\n4131570\n9207952\n51509\n9\n29\n2038706\n9\n3840981\n626\n9782\n856\n7\n487604\n713151\n92\n1181482\n8339745\n61\n813\n385\n1221\n9389504\n768\n3235600\n5\n33234\n90735\n16\n3671095\n4367212\n453\n89447\n9\n478\n87378\n25\n740875\n2756907\n64\n7\n4\n64\n2\n7864997\n496\n4154824\n6865307\n779784\n548\n993394\n3\n562653\n8858\n7503\n9832844\n592571\n6432\n749\n798\n89\n9695730\n7\n802533\n466\n1\n5\n7617\n46328\n185\n9470613\n7778320\n426\n70\n471602\n769672\n462\n35769\n420682\n126151\n21627\n7\n149\n896\n348\n65666\n29545\n4663\n9\n5519\n163\n7023531\n9779201\n8509\n764\n3\n46\n6045731\n8416970\n2513\n5700\n723423\n1876041\n5031447\n35\n9\n72\n33465\n7322\n4\n84\n873937\n1226\n8980370\n160605\n16\n750062\n128\n531\n446404\n7686985\n269617\n2127600\n477\n7457\n300950\n962\n1\n6\n6740\n604\n9005195\n52091\n30\n765\n5199\n4746\n181339\n56\n7495543\n390598\n9198465\n231683\n83\n4497\n787\n3105827\n6393\n998872\n692\n25\n3689208\n21\n97\n34\n89\n3188239\n417150\n893\n5939106\n267\n57\n827\n9951701\n17\n2630685\n780\n6874569\n32\n1737598\n926128\n1320052\n2\n924398\n972583\n3\n445826\n95457\n67642\n1\n635\n4016\n426\n670\n96200\n955\n40\n21\n247\n954\n104741\n226\n4\n5118\n7788\n6\n507110\n875441\n78942\n64\n63614\n8486370\n82\n69789\n548\n4693522\n4\n3162\n202\n96\n218370\n842687\n794601\n12303\n297408\n9288588\n171046\n2\n547\n701\n5029\n34845\n784045\n65087\n51\n7218763\n1455\n2446\n9957\n67\n63120\n531\n329\n744\n24\n572344\n729315\n55\n394\n6695\n3\n73001\n621138\n155\n5\n4738656\n282090\n348\n800\n517955\n461\n562285\n75487\n60\n283\n99559\n9\n4\n3192\n82\n5\n5852\n577\n19\n6022877\n2219\n70\n237923\n7352749\n180205\n8194531\n79958\n4399\n7893\n857522\n71448\n89469\n6323020\n7\n258\n86\n29131\n481\n2280117\n61275\n245391\n592\n9523010\n9770\n2\n305\n2857470\n8374\n9486107\n14317\n966073\n670347\n82023\n96\n4\n52\n774\n1517\n76\n581836\n688\n600710\n5\n58\n651397\n6\n7492853\n5\n34182\n107\n854\n9\n451\n22885\n668\n1684561\n8626485\n74\n447\n6120923\n7\n411\n9\n514\n90646\n39\n5524816\n7079\n9875\n905\n1970\n52375\n4041540\n422\n526064\n7006771\n15725\n9902715\n274134\n92\n1022\n72\n7023780\n28\n654446\n5\n5990\n196\n44973\n696746\n35\n37\n81902\n6\n6565\n8\n137\n1276\n800400\n744906\n2\n5\n269926\n1531851\n1\n287197\n701\n587073\n3162851\n54\n9\n38\n71915\n13\n879247\n8847\n1607\n5\n545\n8547\n7\n9\n7128802\n648000\n23\n20\n6561\n54754\n3420\n576\n846648\n967726\n657\n853\n75\n9385\n747487\n61667\n61314\n7413\n580\n2\n998434\n1695459\n20\n318\n3\n310503\n662\n27\n81635\n312\n8414\n3\n262561\n9648377\n59156\n19114\n34679\n599\n414\n6339778\n73\n1216210\n154\n83\n7\n407\n7752\n83963\n980834\n200\n1407745\n7814775\n131858\n62582\n6292390\n9\n312\n636942\n699492\n8\n850\n3\n1700452\n9936\n26\n901\n10\n76030\n9\n99\n2056466\n27624\n585108\n808\n7388\n435\n5745\n7664\n89\n81924\n3515403\n61\n31\n85\n467985\n62\n90\n5\n280602\n6\n7704607\n2262\n3\n93078\n7986\n2\n56268\n24337\n703\n25736\n69890\n66134\n5172928\n60215\n58917\n585\n992703\n3303389\n331\n96716\n7668870\n891014\n64556\n14\n3988\n5\n46141\n20\n463076\n878509\n709\n1691\n4873322\n108427\n607\n9\n217056\n5039896\n513\n1420957\n7\n88\n16572\n1459250\n344\n7081\n728\n97715\n338205\n700\n11234\n23950\n1\n5\n76266\n3278174\n2986839\n9831\n9302023\n8\n7187731\n2269256\n6971\n253948\n62105\n944953\n246660\n9\n50056\n7478\n2390218\n978258\n17265\n1978\n36\n912\n1\n59130\n45\n7994\n4635030\n10\n5\n8323707\n279759\n3\n4\n5718543\n6587461\n363\n6\n5\n27065\n26875\n31206\n847053\n6066888\n4322702\n8730\n67602\n35\n123\n323667\n62113\n443744\n7001281\n108\n385046\n9843\n8689\n39\n743\n6052109\n23359\n12683\n6\n9\n39\n75\n9058932\n248553\n6299\n54315\n264125\n2\n769437\n441\n594\n33186\n9445\n516806\n167\n7438\n332\n371893\n73219\n778696\n9072544\n9434782\n6162\n9\n214\n4\n47722\n81089\n4051\n73\n3\n1392\n8\n435\n6\n2086486\n9725545\n586\n8393937\n761107\n6218\n835\n52\n940757\n522412\n73814\n630\n72\n1583076\n16\n12746\n5363062\n68745\n78\n486\n76277\n21524\n781\n20081\n319\n9\n263713\n77\n32719\n5\n74116\n48\n652034\n3\n370597\n21545\n9241\n95857\n2474394\n62\n50\n8\n3\n6922\n8\n9794735\n8948862\n7\n65\n721\n842723\n2729\n955936\n373\n320280\n7024\n94\n4666\n83\n424555\n9695\n8\n60682\n4752\n3\n340316\n508106\n7309370\n7\n80\n5904\n2\n6\n71856\n8077\n351711\n60323\n7\n469\n8974\n32\n4712\n61\n46\n222\n7942\n96015\n2\n83393\n5135\n4645618\n20\n3390\n6246\n489\n8588\n688622\n176\n7\n125\n28\n3435986\n696674\n371773\n6392\n4661822\n16556\n3517842\n248339\n8737831\n2837829\n5402401\n9750696\n3913173\n920451\n4146\n7882\n333008\n754249\n1595864\n9\n7749\n7288\n248985\n24\n1836\n2023\n98\n696013\n884\n375\n6593\n35677\n68450\n28070\n326\n89\n602380\n5307718\n815\n10\n83374\n701\n36\n6360\n4221\n741653\n4\n5185\n1601225\n9\n4140077\n4647\n3\n4730\n9\n2843089\n66151\n6175051\n8425\n80465\n6\n681\n29\n81\n774\n800851\n2400904\n58\n3990\n9166\n404\n6\n107\n3\n3907726\n7757\n76\n675\n4694259\n381\n699\n15\n71135\n96\n50\n703266\n52\n5982733\n1397\n75\n9132\n5\n40\n41974\n3\n5959\n93\n86306\n79551\n9000364\n6499168\n590\n87\n9380692\n997329\n97\n8132557\n2512\n4611122\n639\n888080\n321697\n452\n9\n274\n333\n85\n6653\n7\n3954\n2\n7\n8192053\n79535\n769\n406\n7795\n655\n597417\n88\n45\n239\n1\n158\n4\n369220\n32\n333665\n1\n80394\n94072\n8729727\n23\n2\n69489\n9\n102\n8056805\n755\n9585103\n9566\n6001\n806196\n36\n2568024\n1697165\n5068526\n912\n29\n97\n4879\n65493\n43348\n9696\n84\n4765\n606892\n932326\n8\n68231\n87\n880\n990\n7\n581\n76032\n3806\n2\n5134\n5\n8\n19421\n548\n69\n9\n71\n88262\n22151\n327\n104589\n5\n54\n7\n5947015\n284\n4\n720\n34363\n7652\n34064\n606\n65488\n24\n303\n29\n4311\n6175\n538\n53\n66\n8\n9422813\n723110\n51\n9518295\n5\n82\n767948\n66852\n937\n97682\n546114\n63526\n8\n65354\n4\n2069\n74018\n936\n24172\n689259\n63955\n7337488\n922\n409715\n7716\n373552\n70366\n56\n42516\n480\n4\n224784\n115790\n672\n3562935\n293\n75\n8\n3\n26\n37723\n5\n807\n141220\n857060\n882\n1112222\n45222\n19552\n102\n329\n60\n63062\n2\n210\n32925\n7\n1486181\n33203\n379\n229\n39\n860701\n975\n195\n4543179\n4529531\n60995\n9\n36\n41\n1\n1003024\n441\n90\n517397\n818\n90\n88\n1556\n3955665\n440458\n25\n398434\n7303112\n18214\n8053816\n1865\n8935\n94\n51\n5579697\n9\n25225\n99858\n68564\n29399\n436\n69\n2642\n3\n552\n9805\n10\n82258\n82570\n42079\n434581\n19921\n881\n755\n248\n272725\n61565\n54\n8969630\n11\n17\n2836\n1\n4657\n35\n3609\n77\n266586\n66954\n790\n2821524\n5274789\n1648\n160\n67\n78851\n51\n4973\n5\n234\n10324\n7\n25\n9978\n31\n91473\n209\n68\n32605\n30466\n2\n16\n8778\n4\n2826509\n785\n7\n2954940\n9\n6494\n88553\n6\n25\n12\n8362102\n8390476\n350997\n772\n3\n9021104\n7\n4995377\n68549\n556456\n2\n46\n853040\n499538\n5\n4884406\n49\n30\n651\n283701\n90527\n10732\n959477\n77\n1\n35286\n238871\n739\n99\n120\n64660\n5\n593\n788555\n9664241\n98387\n9745629\n8807\n30041\n3\n3\n3687816\n2072713\n9621\n31\n2\n61\n7152830\n2041\n5\n6634105\n4689\n723\n73890\n2474\n771233\n50\n1448\n394\n154\n6\n5949804\n25\n9\n76250\n44456\n5\n97\n62784\n42286\n49520\n61366\n498961\n706\n855\n5933\n48969\n9113\n8\n762\n4225\n4661373\n34037\n3\n5286506\n2694\n8792631\n781\n316\n6\n57327\n4664840\n5\n9933\n9430\n5\n31\n55319\n40259\n794\n2116\n12\n62\n5\n3\n168\n991731\n2\n6233\n30467\n69\n1965872\n7012\n1\n5\n937\n236\n3324902\n4500\n94226\n6\n7\n755\n3771405\n12\n6480\n6\n41\n2116\n3\n5215\n5740062\n404521\n64777\n6286\n338798\n9\n8647868\n93132\n67\n473\n175274\n7\n7482452\n1\n131718\n3962\n1495\n52861\n5959838\n2439036\n96\n629753\n91895\n13\n1779120\n96\n5836699\n3\n5\n300\n267799\n38\n32\n1\n96598\n57398\n20410\n87\n20\n5363890\n69609\n5380765\n7621506\n19818\n362813\n8504\n7\n40095\n9854069\n37\n204511\n8842\n633\n29403\n1\n974463\n51336\n590139\n1157032\n92033\n5140\n5\n78\n7353944\n478\n7530\n8\n218319\n5\n502\n7165\n882\n1920149\n2623\n7171\n6\n7033603\n7356\n131513\n2\n41\n80725\n5961881\n35\n6265\n4\n63922\n4697\n720899\n4643611\n5\n5\n60\n7394559\n62\n5593\n587\n107\n1753\n4935\n6841981\n3\n155\n6\n7\n140\n1\n2\n9112304\n274\n90\n2431\n51\n7772\n9297905\n2119087\n9437\n85260\n6\n15\n8361593\n819361\n609\n62329\n790\n199053\n8579\n9991400\n12429\n1266085\n33478\n9468747\n9997326\n4\n85\n8476\n19\n2199234\n7528\n3579\n8032993\n49\n4\n555751\n9012646\n4307\n64224\n495008\n405066\n23723\n66828\n68\n1\n9\n952991\n3321494\n2326470\n1\n119065\n115837\n28982\n49\n1\n55\n3\n70964\n13\n3\n37\n819\n540\n493\n18\n38\n120001\n3\n3120\n24\n335\n59\n9158330\n4643832\n98\n79\n61\n1874\n4\n70797\n310893\n26\n1\n394\n603\n1886\n925719\n5\n61\n6859401\n598730\n2",
"output": "91089879721\n4074013584\n196\n433347489\n25476150156\n7552305216\n53904964\n3420495225\n225\n3936256\n441\n2\n400\n385641\n2\n2555202\n529\n408868620\n4830\n13079072\n4\n2\n254768019770\n424452\n52441\n21423012\n810147606724\n0\n0\n8991002\n34546541689\n723350\n16002\n1369\n81\n91240704\n140552880\n59292\n400\n15308617984\n2304\n441\n4\n4507581210342\n26732\n6141648715225\n104254310\n1390041\n134966306\n11852785770\n44049769\n4\n5956040\n7482\n863970\n357210000\n3369060\n2223081\n187758506\n282542481\n34833743044\n81\n5037780\n417895806\n2\n168246841\n26569\n9211104650\n22201\n2\n600\n1478221919862\n769129\n42\n2\n3040915880\n43692100\n1\n2650564711080\n28730\n0\n1097256\n1354948380506\n2\n1\n548340\n5831664733456\n29070\n7452900\n210\n2363924700036\n342\n37939440\n54289\n476100\n2257941996025\n1142761\n1633613740641\n506\n2\n413654582\n49287420\n636015820036\n0\n2\n55696\n0\n482900625\n0\n52098519001\n36\n6561\n23104\n49284\n41145282649\n23716\n45579688036\n361\n210\n30\n238455364\n5463906\n1\n57840\n72\n176106170\n506\n3415104\n525104578881\n7037783772\n97032\n49612662121\n361\n1\n5776\n3711327116880\n0\n20736\n358801\n1331716\n6006\n306\n3306\n6203046019872\n1062961\n10056479524\n611350350\n1\n3932745103225\n20998908100\n117148152\n2930664950642\n3906\n12121789801\n2\n722120099952\n182\n13905441\n3372732\n126879508602\n41918262860\n15376\n1543806\n0\n1460472\n894218933792\n586196732\n4\n2\n210\n2219229925264\n47089\n2683044\n7744\n4006002\n623301156\n5396329\n443291970\n10022012100\n6801960676\n877463092900\n54928593792\n9702\n4356\n132\n1051650\n119869652\n189294606400\n1894752\n1\n3913128025\n6972\n4997109282662\n1159929\n1123786567744\n4\n56952151962\n1438851828962\n139440672\n4937430653089\n4370190\n35721\n34715664\n4\n132894784\n402724624\n90\n40455960\n670197646336\n37442\n14852784384\n4\n2942523398262\n12\n22858718481\n182\n2056939962\n40758158882\n3663043832464\n428966232\n4\n179251932\n170054640\n371429256\n157377025\n602972580\n1899016290304\n12210\n289\n49\n46983380292\n7129860282\n405740449\n5370806\n592484281\n7569\n2457575119890\n30980356\n42\n233891142\n27358130\n284478822\n1292769\n327029006360\n362597764\n121868715409\n58177681200\n4052169\n20070400\n11990\n1093680907264\n12882\n1101450\n4311852\n467581756200\n2\n0\n6\n2425806\n243542\n1600\n1\n676\n15006\n46225\n1120906036712\n60155536\n990025\n3568215216784\n44732\n256\n2\n2\n1364367667782\n2675020531401\n0\n0\n54289\n570025\n2\n1\n2500\n2209682\n24822002500\n3109584850202\n334871700\n220900\n14042\n361\n22801\n10920\n2084744281\n41004832512\n0\n58570292169\n40401\n902702025\n2884902\n8010\n125104225\n187922\n503149761\n1379006324721\n58127040120\n86730\n81\n484\n20382416289\n21757560\n342\n5456896\n6\n20306\n5671542\n289\n272\n6806\n3370113909369\n37636\n45582\n61984129\n2655270\n9120\n16384\n2122432318449\n2212366197006\n101687056\n61009\n21910808529\n3145302\n339314820\n12\n280998169\n60575300520\n400\n471282\n342\n210\n14641\n100\n21462\n2352\n10100\n9\n625\n82573569\n1092038116\n4\n23562\n2039184\n285690\n817180744380\n1771353370084\n506722610\n1\n4774225\n5997601\n457104400\n268419072\n4\n26406\n269025604\n2560000\n144\n42963340176\n35942661810\n214446736\n2028036600372\n121\n25\n208499160\n37442\n70972200\n18041256\n110\n363569556\n9284209\n506\n146306\n35532\n4678454361702\n3907079993322\n1855757162\n129960\n552\n95169780\n0\n96983104\n7656\n8388453332\n14186358342\n1836025\n0\n5690977622929\n270805231710\n3510002\n308353600\n5402\n0\n426071522\n2\n37830\n4558225\n3161284\n158734801\n156\n4556\n64\n1343922003452\n617447952\n35857967044\n1\n6081693599881\n99640324\n2374050772820\n515358102\n4016016\n3541924\n21025\n118341762\n361\n16\n2\n49986674929\n20\n84446910\n1715739768906\n2559652811772\n3721\n6135529\n579966806\n0\n16966161\n0\n2\n184701690\n124389409\n3524257167300\n5368489\n330894290\n114190596\n289\n61520492\n58563516001\n529\n225\n240\n221853717182\n35156\n2772281610289\n442218841\n193088178724\n420\n225\n290063030625\n94041506\n22629049\n54127185756\n506\n90\n88275420\n5897856006\n7793799806\n469236645072\n47961\n4549900169450\n44100\n4\n1056\n15350094920\n3948169\n614916006\n36\n1\n13806\n8811483030\n600\n3364\n2239371684\n53609150832\n0\n392753124\n4488857909556\n11335754430\n225\n45564744681\n564157504\n7482\n240\n27556\n462\n5700156\n11827541270\n80200980\n1\n43056\n196\n15384929296\n16\n2209\n20646241344\n1\n2008625907600\n1\n1444\n132\n44732\n9464954944\n17313921\n41201083380\n7630721316\n6889\n2011828773710\n31234906756\n1260\n545406620772\n34969\n15252\n163277284\n117462244\n262780310\n2070\n1099352\n2564802\n1430416\n11115484900\n3704730822\n52121180\n9912990096\n748268670\n64\n4370190\n723350\n951321492\n833097045822\n4\n43472\n2542430\n16801801\n36100\n1623076\n122850\n283497145580\n46225\n4\n5168802\n380\n36250636816\n0\n51302\n109422060\n5264730\n2394903264756\n6036996420900\n2424249\n0\n259590\n52441\n197557080\n505559394729\n494209\n826704648289\n4763306\n7912969\n0\n4\n4\n59892038712\n3339756\n10810944\n56\n24931778404\n1\n34969\n33489\n47961\n37811580304\n104990762\n2\n30\n4768471444489\n484\n529\n13621574232\n0\n2\n217341306\n0\n1\n600\n4\n10640541409\n0\n2\n0\n56147672025\n3147625964025\n42048740\n49\n240\n3461460\n396603955225\n7022500\n4254267195156\n2381867488900\n5468582\n1759953790056\n24336\n2151084222306\n136911470240\n2\n30\n2725936310\n54056\n143676182\n553536\n306\n26975106081\n5583109742460\n1\n2286565867460\n1\n17161\n72\n1153173151881\n4290\n1\n607620\n5685840\n86806489\n6596769620\n10816\n544644\n2336312\n47306\n56169\n576\n0\n5740816\n4447309479360\n25600\n2\n5184\n56\n10510863006\n51129650\n4\n53776682404\n76639278244\n33856\n870\n59049\n1232100\n3249\n4\n48757276910\n2091014329156\n4191371776656\n2\n113273306721\n4625140576996\n0\n361\n222233556\n548730625\n113880912\n789806712\n2542430\n310249\n90\n1035306\n4624\n593628860\n853195826596\n240\n727458026832\n4926777313590\n3839730387529\n49\n1873647660156\n0\n83643002521\n8744587656\n3808352\n368812820\n198190084\n1\n29621335772\n462\n484\n121\n44100\n2\n311046132\n3177306\n9120\n37830\n1\n401501406\n2\n44722733006\n202364850\n12882\n5189527748862\n303351889\n2\n506\n4\n1022302988100\n324\n4\n2262016\n2213490816180\n552\n31854736\n431187909201\n25\n4\n2\n87320\n1\n18156121\n441741012496\n1299600\n24895110\n31860380\n2854410\n138756\n476330625\n217429770\n22496049\n12\n1921601729742\n21025\n10712\n273607455625\n6039306\n44944\n41485949761\n3847100625\n513653156416\n25\n380\n3393157412756\n242580625\n432369642\n272\n31694146812\n2\n272\n64\n342\n306\n1\n18632\n4386930\n9805158441\n3972049\n529\n245956489\n33084153990\n17085822\n142884\n324\n3146200281\n4194304\n12807901584\n43264\n5189545482\n0\n70980625\n4\n36\n29241\n2\n461841590\n5370806\n4524129\n4\n295908804\n196\n212445200\n0\n29584\n3694518384769\n358202\n5645376\n22052\n4\n28561\n1980\n513611569\n15500\n49477156\n4372281\n1634728459225\n1598970366016\n3025\n294877584\n1482\n3836006160\n8646540\n2\n0\n30625\n44202552\n2\n1140624\n1\n380\n1\n2815575844\n6642\n109851361\n147840\n1980\n529713240\n1\n450100771920\n156\n105277860\n25626887056\n85405322\n729259637089\n1041740176\n4\n55225\n44732\n119290084\n5278167801\n182506590\n258003906\n4\n34040\n2555202\n4\n132\n1\n47863594506\n2704380\n506\n7921\n36058022210\n44521\n588289\n38612\n1258884\n413756281\n476100\n138309360\n89382163992\n49062\n415792881\n4855412\n4076822500\n0\n256\n16114906080\n1145416336\n202564056\n55764224880\n544895649\n504100\n2\n146894400\n54056\n0\n425756\n60712713600\n2\n50400\n361\n552\n644809\n2\n4586996684256\n21991410\n380\n1181478780722\n2196497397422\n620944\n55895834929\n22503300121\n12171826276\n5839472\n4\n10436130\n40401\n52483373556\n1\n55007604369\n3427385742400\n25\n12210\n497025\n272\n24788140806\n484\n2\n328769424\n14641\n4\n18800660340\n21659156070\n24553949809\n2\n441\n3527158193329\n25440\n24760576\n17956\n2105020855161\n55460\n41912939802\n597386922\n324\n368449\n438877762962\n0\n3354392\n217543885056\n79112130\n44846744670\n49284\n30\n11130\n5793649\n17974362692\n4464769\n3400336\n2777222\n12\n37442\n10171125904\n0\n1\n1\n1746362\n583077609\n168921\n1\n2628000874321\n3301252794225\n54990\n4941782352144\n484\n19600\n60537157849\n453285390\n361323072\n6400\n156\n835903744\n306\n380\n30952948290\n0\n4\n19958556\n19044\n4248367220\n0\n1\n847609311649\n571353409\n48497296\n1260\n281014932\n4707541677969\n1627920810000\n21730002921\n12120468649\n41006\n155613150\n573386970\n324\n33856\n401060702\n109746576\n1505529\n210\n1443538571202\n4056196\n62110161\n3364\n36\n1212201\n5313681025\n59059225\n21854448056\n93760489\n0\n14563059006\n4\n8836\n2098152\n6796023844\n16129\n2745649\n1828636857441\n4435562436006\n5062500\n12769\n9229829184\n2596624462620\n2544025\n400540182\n3300157809\n1119364\n1\n2857832512656\n111059982\n7310\n4547850539761\n1\n1\n14400\n4641870\n1\n20592\n900\n291600\n144408289\n0\n202050\n2710962\n43170866176\n84098070\n1959554825281\n24806\n27556\n32942\n653228458850\n20\n132\n34596\n15335974082\n9\n51294549289\n154056\n28900\n2455489\n15876\n282156006\n3463386135306\n2\n8219598244\n35112201306\n46656\n13185354756\n1\n2\n130336472\n1296\n2\n38612\n27556\n54990\n432306\n182\n4\n0\n3222719361\n0\n346299883256\n270816392\n19835201406\n62766006\n55460\n2\n1\n2\n2278431755256\n2105775374641\n0\n3129159337249\n2862\n5932783068630\n56\n56\n569251881\n6020182403236\n90\n64\n24649\n1168561\n484\n3218436\n30\n38675942244\n55932\n229920\n95531076\n3000825179521\n2025\n4\n324\n39800\n3077321138670\n1\n73736569\n12210\n2534546784676\n352836\n720516613056\n820158451876\n51155130625\n100\n34782\n0\n5255696093430\n2503208115409\n2\n12882\n446730496\n16\n2\n3024121\n3857781123252\n57261139849\n559890244\n21560957732\n34596\n26269764320\n4556\n345532332\n28900\n18524416\n391307742\n3819804442624\n8904256\n9\n4\n520592672\n42230\n58766971561\n19298449\n31204515904\n1079521\n124567921\n3364\n2053489\n226442304\n144552529\n1121311566400\n51615068910\n19881\n270816392\n19488020400\n4\n64\n72361\n2757794956921\n225\n2\n5917484377744\n20736\n4\n72\n121\n1\n33489\n342\n118254750\n6262110822\n240575610\n6192632\n197185287080\n3690241\n2\n81\n28056\n121793296\n20449\n25132553556\n2\n380\n6480\n45946779904\n42849\n53875600\n36\n39601\n773520\n1\n322112756\n1898475612\n576\n0\n1038361\n32942\n484\n4408166890532\n93330\n12\n0\n5843999231532\n306\n1\n342\n3152673682929\n2400143028360\n1722\n420\n1556302500\n768477527012\n886270674980\n2\n4\n2\n181252369\n47734281\n9120\n62228432\n31061947536\n3192\n2239828022630\n49209436224\n44310\n1109244984849\n55225\n64\n3109932\n703470529092\n119869652\n2756\n50365009662\n342\n6\n116964\n5280420222\n61636503289\n3771364\n484\n36\n12544\n9506\n912583681\n4652649\n97752769\n285156\n31033050244\n12\n454968900\n0\n210\n3688861696\n1055600100\n42849\n780699481\n4184589823129\n2241009\n4\n42\n170485249\n400\n2238756540\n1\n4340972\n408747306\n5112\n43890\n506\n196\n3608100\n462\n1\n10609\n543906\n6162\n181413961\n843642\n14884\n132\n4351396\n1\n49\n2657410214492\n484\n1401856\n2310400\n1047360864242\n2012617475556\n4\n45198729\n433909730\n3687116194782\n22500\n576\n5695382\n4507129\n1083681\n131721529\n354493584\n5886572603076\n0\n44983849\n0\n23063130090\n27440585104\n4635409\n32041\n9506\n344455040\n106683564000\n2\n5466244\n5313025\n49\n64056012\n7477490\n580644\n90\n67182612\n36672\n30691185721\n615983243716\n665442352262\n391921209\n582932\n3108558635210\n5538962\n264338822\n0\n2\n19094126942\n2\n2\n51608253450\n1629452\n86912051672\n529\n145161\n61149129372\n56\n156\n39204\n697225\n20761928100\n275625\n1\n64\n15500\n361\n5355852575712\n20592\n7225\n0\n3323329\n17424\n110\n0\n399013305625\n25\n21170\n2683044\n680474858281\n39552061129\n2304\n22650\n1367730\n897633079225\n50625\n3585554520\n113635600\n928332\n16748556\n2\n8190\n210496572\n4618931688900\n287607681\n4\n2060660\n5256\n1197930\n4\n0\n1392400\n838218304\n53592\n1699654549264\n589324176\n0\n1836025\n1527051006\n3310580\n64\n1\n554280\n12210\n4007527538161\n481269637696\n8010\n4\n512637522\n160566912\n6017932656756\n12210\n4\n1435204\n4\n5662020\n0\n251502\n1473796\n57500682849\n16127984016\n383924836\n12\n289164307600\n121\n324\n506\n3581556\n10957169652\n16\n196\n25\n2\n100630992\n25\n64521056\n5403352556\n2217121\n2\n4720151653281\n1786190818740\n1\n107713262\n3136\n47341280\n25\n42935256\n6128697796\n1\n53165972\n2\n2\n10222322130\n57193200801\n550564\n11873807089\n3363411115560\n1186113600\n828112740049\n8766764161\n3622414782\n55460\n22801\n2271713906\n0\n306\n4238828322122\n30535815025\n5058273132660\n8593846209\n55460\n3413577722569\n53846738401\n0\n2385480\n1743967192242\n4039655802210\n441\n510510\n3281532\n12\n2\n141752\n64\n585010969\n375700689\n0\n2\n24649\n5870929\n10100\n1410156\n5597071150969\n336208896\n174940302\n0\n71157660\n3665042224900\n1063992\n30450\n741288282361\n12321\n3306\n24853837801\n0\n1052676\n173093492\n13157810556\n943779219289\n283754025\n76329257006\n4\n5466244\n10100\n2\n40464339806\n55696\n3271941940201\n1174723235562\n60264169\n212982\n3556515086256\n56882\n5745544281182\n0\n4\n14986656400\n650\n7393420225\n3549456\n47913269881\n46225\n10255410361\n623226260\n59643896841\n669942\n3196771600\n552\n462\n976156292\n4\n4424712\n14307306\n0\n38612\n2278590\n19448254849\n289\n4\n2593871302500\n3444140249760\n57653532432\n991534990322\n272\n426898237250\n39002892572\n2004055012962\n121\n1171806\n631287455296\n79619929\n4266290\n169332\n28914621849\n1\n56\n1411344\n30\n28933641\n1\n3516823227080\n12\n12656\n6006\n7310\n484462110\n1345857532321\n10464983102\n582305161\n1221025\n1\n3227412\n0\n9972964\n32400\n4\n4316006\n218418841\n5595786588222\n9523396\n240590\n3377758785424\n52212\n5099245281\n32113177602\n0\n721217880\n571544649\n0\n1066603545225\n42436\n400\n1858449199250\n2162\n3816162\n1266743497009\n1\n74481505569\n4900\n14333796\n4803708885432\n912733747641\n521391556\n370755025\n199682519022\n639200\n393843870\n12843008929\n38612\n14042\n1138489\n50555274025\n3617604\n493106436\n28392\n114030362\n6844501092\n81\n2006472\n791210\n576\n1310342668804\n2555326934521\n0\n272\n790321\n1\n72295110006\n4\n19460\n5749001255556\n115175824\n1302672974409\n3025\n50367409\n600\n4577460\n13924\n650\n1\n29068272\n49\n256\n361\n4\n2372761521\n20306\n0\n5557806\n210\n619860609\n162753806\n235049947580\n2\n346332100\n506\n16\n3018906\n306\n64\n2072317158470\n48400\n4\n1\n4999696\n729\n987042\n97259044\n31577467700\n42642\n2792388049936\n561784804\n125540820\n701493352704\n319790\n9573056964\n6541008252\n401902256\n4598209045992\n380\n5308250113296\n16491721\n1005006\n49297320900\n182223001\n2805625\n484\n5067001\n7083747225\n741154836312\n160801\n2\n2\n516062089\n2\n62411031684\n0\n2770560\n1655910859684\n229416462\n19881\n36864\n297890340\n210\n3139984\n16469230556\n55696\n0\n31292194816\n0\n68644\n9\n237006025\n428692324516\n0\n5117485498596\n9490656400\n2599093721070\n0\n1681\n1\n6084\n1454183956920\n4\n141788556\n88441109490\n38220\n462\n723414038906\n1638400\n115229490\n1\n0\n622103364\n1434006\n506\n61256\n35100959256\n43831020\n4\n16342426406\n1873230195600\n552\n64616877402\n2\n40489488400\n39640810000\n196\n564205009\n210583632\n506\n57360\n420\n1790244\n37179506\n45156\n143641\n389001690000\n45582\n60147072001\n506\n76317696\n484\n441\n209511150\n324085980510\n2975625\n319112010000\n1\n4842200\n70073641\n3318465193890\n1\n1386506\n2\n5402\n1225\n30695390401\n22650\n20\n3193590591844\n616876569\n32338289412\n1602444579129\n1560\n457178146350\n15943102756\n61175591569\n306\n256\n301664792\n3906\n0\n2791007938161\n3422\n12\n99225\n0\n103052952\n142525125625\n0\n3025\n256\n556016400\n1\n7222656\n15926061402\n31373619876\n0\n400\n3306\n30450\n1272420241\n56\n27254212832\n1190\n225\n484\n15752961\n240\n4464769\n3660\n72\n3711402\n150258564\n0\n1745041\n488553469156\n4932841\n234256\n3210244432940\n32400\n361\n272\n1126105806\n127362510\n196\n2170997438330\n4375867800306\n222352832\n62473216\n100\n15646507396\n646158745600\n154833593121\n240\n2\n36\n2\n4082379342\n18142069556\n14280\n7140\n3500072239104\n3818116\n19182\n56\n390000\n54289\n599123529\n4712086098756\n4\n2\n2457725618082\n2937011040441\n110\n4899582\n384983641\n20804167932\n4441798615806\n324\n2\n58847967396\n1628722173796\n182\n400\n600\n2325264841\n144\n329926169664\n20\n3786916\n244468860\n2\n2486848573650\n7310\n2\n411663810\n455630370\n297631504\n36\n2\n22442586672\n224985000\n210\n0\n32220\n346921000000\n2202681928592\n4090423327920\n317034874422\n174618262002\n380\n49\n0\n575925415506\n109945710\n32400\n4\n664479506\n8649\n3017169\n266979260\n359400\n4147332\n2\n49\n10526041812\n3136\n34410\n456570056\n129743490\n3935241092\n72343530\n30453216572\n1\n244642019769\n1900218872\n1600\n264013752\n287048306\n438420782\n3396457330704\n0\n436260\n23870\n225\n2\n4\n5669782458030\n300051684\n979110\n110\n6137390622\n2\n5096306\n147072\n22650\n310922689\n1840109712\n3824181669152\n4990756\n81796\n37323535249\n284074170\n150700176\n3005451684\n2\n2652\n220240440\n4295256\n901550\n1035081394710\n22108804\n5354596\n4825475513112\n462\n608485556\n911618215369\n5827441866090\n2401\n639955200784\n5304002453764\n2\n688262707456\n6037756209\n2068750039225\n444598310\n17822\n31242510\n44732\n15750\n16569224562\n1\n56\n2\n15945249350\n145094070\n30\n6115729\n64762615225\n289\n16\n466149690\n48664576\n34782\n44595725329\n2\n36\n59292\n506944\n1443602\n477007440\n37830\n78998096356\n48180\n2\n23580980721\n7359752521\n4\n81796\n380\n2964507428850\n1\n333153756\n299393809\n4\n121\n41248506\n2630884\n1\n1\n276157924\n34410\n12\n12544\n0\n2\n165148201\n239121\n306\n176400\n339443776\n1818851904\n4\n6084\n16770\n1746395287656\n48620\n6\n36864\n5819410811370\n72071610\n50731030460\n57600\n55932\n35344\n2\n1083681\n3782857731849\n61742807361\n22801\n26463643652\n64\n59899860\n441\n151905625\n5585843382\n64\n5489843470722\n4\n48664576\n2162\n56942116\n16601550\n285677604\n5260142\n287191489506\n10876804\n5598507291572\n15968016\n68748972\n23373211689\n586154078449\n3624401133796\n72\n20443962\n1798281\n30\n1\n205850756\n3202346040100\n156\n3896676\n382542\n110817729\n1638400\n51302\n147586052\n406103104\n2\n0\n90\n749090\n16901560036\n4635409\n1\n42935256\n1754195616060\n156\n15129\n11066829601\n9\n124355952\n26569\n5798464\n2\n35277660\n2916\n1015056\n400\n4\n1385329\n0\n126011850\n4\n3496900\n289\n2952685482244\n2\n1517647829112\n15292010\n1134106652\n0\n47089\n2\n19590621122\n33672\n10663970022\n6889\n540960\n591243540\n3192\n600\n729\n12100\n157413339762\n16\n5126502015684\n539939857636\n4865833780632\n148996\n1\n327193832\n64\n9\n372710\n4581091701452\n3688320\n4322241\n60513048036\n280679762\n1948604449\n64\n29070\n7567956036\n11573604\n26901904324\n3944196\n4106702\n1063992\n403788930\n4\n8464\n14042\n1717774588321\n39702601\n35569296\n60291855936\n2\n137152826622\n6\n2\n545829769\n1349082\n0\n55845724489\n13225\n11154422610\n53436100\n8317804804\n177192588306\n11437924\n15940056\n14520\n1413647202\n4857177413900\n246772681\n1936924110\n77264100\n39936824964\n132\n30102\n16584417180\n5397232684830\n754292\n1\n272\n119617969\n30800\n324\n7566651182\n11556\n14400\n1914072\n17033904196\n342\n0\n15447258369\n182\n272\n592557306\n4102274401\n4682896\n692224\n29756\n1123825052\n27556\n1264500\n2126316544\n5285401\n4471046815225\n100811640\n131892812070\n50400\n4\n420\n354230041\n301977506\n1\n56\n4\n0\n32962944249\n13000446380\n1\n4376464\n58834868481\n3471919929\n8168164\n417487056\n17785823132\n121\n5945687270884\n43385348972\n256\n60645156\n3354679801662\n743230203664\n1418955057601\n604148652900\n380\n1598253472620\n448465329\n429919490\n3162094056\n0\n2\n4468249789152\n413735940\n577600\n24180\n4\n219492\n0\n216690\n54317196660\n15401926920\n2658530\n39899263504\n904401\n416160000\n3053756\n180781470\n3938064516\n29268708561\n90\n13325123790\n3144222281220\n2141832\n326612\n110\n24492\n3228518988864\n35259826176\n493239681\n191767104\n2\n1\n2\n124478649\n2480625\n24806\n2\n12321\n2357248152\n6642\n1058841\n22052\n4489\n1\n604151820\n2577630\n5116644\n53553124\n3080\n4624\n1359227207881\n28728046542\n81\n0\n4\n209598006\n25493071890\n787198366564\n57840\n11662704036\n452929\n2256\n19293348900\n289982\n253491103441\n1\n1\n272\n49\n61294866084\n56527842\n45657049\n4600366276\n38220\n26896\n3198732\n56\n1615507092676\n4356\n100751406\n462\n20\n1721344\n36\n45842449772\n592119222\n4214809\n247432900\n0\n423042624\n579316761\n4\n106977649\n1172617292\n5380889785950\n523517280\n287692482\n49576807622\n134606404\n21609\n4039350304782\n109568556\n2\n3727177748100\n1482\n4\n1478268121440\n121\n1\n2641388805225\n380\n1923662202482\n49708486116\n16\n12731285889\n576\n0\n117343056\n13264359241\n4662431524\n342\n81\n1420389623601\n2256\n37165863440\n156\n28392\n25\n2112662\n347300496\n443965970\n64\n38686169344\n531751599369\n0\n3650010\n6081156\n251793424\n6\n0\n21609588004\n6\n21238272\n110\n15252\n173056\n5971674577401\n4\n49\n4374372\n4743684\n16\n9329970\n40804\n2\n5609792\n321233929\n747360\n11364519420\n15788702\n49956624\n19519862082\n4096\n56122572\n441063002\n45300652760\n1225\n47711664900\n5112\n2102500\n5402\n650\n45969504025\n684839002500\n3794704\n272\n42\n441776238906\n1976682748970\n1412532\n642269207889\n28793956\n53824\n275045640\n324\n240\n0\n840889\n5238330787600\n356340348306\n4224564335250\n1260\n113028792\n36542025\n2194169700529\n61752\n11990\n12882\n12165648804\n5390129306\n282811489\n264111252\n4\n4\n0\n0\n16\n17822\n2561600\n3337357173492\n16537059812\n2662555846756\n2196158019136\n359462640\n1451550268809\n8742\n24880144\n169\n1557288906\n2181529\n4445772\n2\n4\n5221225\n240\n1291632\n72\n219492\n57923011584\n4489\n4299524587370\n7046763025\n4919107024836\n306\n546858225\n57121\n53824\n17487549840\n240\n16\n3219325885504\n430336\n333580751660\n1596432\n43404513906\n56\n5796157556\n158382225\n160313582\n19874937462\n173472\n1\n306\n8699945802\n200958992940\n52900\n182\n2\n46410300330\n5506113873121\n3895584454452\n21941756256\n121\n0\n24819324222\n552\n45796\n5379474877530\n256\n0\n181683441\n877969\n36187262670\n182\n10712\n32403240081\n2770257319281\n1583204310\n58806\n26732\n1296129879529\n210\n197332256\n11751184\n365918641\n46743737209\n5536046647280\n1035306\n243859456\n3880860600100\n2\n174715524\n13322238084\n1912689\n7569\n106636602\n1\n20807282\n1\n2691240\n4\n335241\n28700086921\n1\n0\n43048157880\n1444570821409\n27889\n2184484\n28561\n852640781610\n1984142691216\n20738916\n58564\n266256\n419266576\n47013947929\n28561\n2\n1479046361760\n11373756\n3818116\n537729721\n418611600\n42\n882660\n17956\n16\n33489\n39204\n114582\n3422500\n2963659160\n107422860\n58369600\n39218906\n7341390\n46225\n2513810\n342\n144\n25\n1\n2294984836\n0\n49952\n20480150\n38570310\n272\n57019947732\n484\n1056\n17573214096\n4147332\n6948496\n529\n182\n1936\n7056\n5388489401344\n0\n1090401673729\n39601\n21522210320\n0\n5394461809\n268697664\n4864488296922\n182168910156\n169\n81\n13924\n59049\n132\n41035415184\n156\n102793336996\n210\n1349338953710\n1\n13225\n57600\n41412\n334734566406\n1538875212\n2290148880\n2\n2755600\n12\n16980435481\n84012442801\n17088894900\n576\n1700416\n74054630\n20270071129\n4\n110\n0\n576\n1\n8930\n877048225\n1726596\n42804306\n2\n3962090\n3481\n1358390\n579100160\n3966072\n128164\n5354558976064\n810900\n1910697998400\n47524\n38464804\n1\n570339123264\n2\n1577695516032\n132\n16752649\n0\n540283536\n4391120\n40883020220\n222845184\n4\n14884\n1081600\n1\n6972\n76857859056\n9\n481912256\n9\n1602502810000\n119716\n2098098025\n120604324\n48582551810\n1155917418496\n999000\n56430002500\n19321\n600\n5192585346900\n1\n2653399913476\n2450\n9\n1261129\n15566970\n32761\n210\n0\n511121664\n324\n277239150\n17781822452\n2656274116864\n64516\n64\n37686262770\n4\n4\n16002\n25933556\n1448634906056\n4\n358685721\n3024121\n64088030\n156\n10690422630\n223397862\n0\n10482892996\n4956943789980\n89102\n53361\n153016900\n3138240400\n4365922491441\n2810794754306\n27255203372\n6591410156\n47742\n515903082\n1623786969841\n1928729331369\n42\n1\n576\n5008644\n4\n1713736264506\n2\n20512684506\n5776\n18548533249\n2275572\n1336547556372\n2825454025\n380\n177725902200\n5402\n714649591530\n6076225\n56055771121\n132\n1999396\n852543828889\n13110\n4\n1927932\n361\n52272900\n6162806\n57510514782\n2\n280861841296\n1\n1\n1\n5652506\n48890295432\n6083622\n33856\n14400\n30\n2039636701122\n394365160225\n112826884\n624175272\n4\n17956\n41412\n6233817987882\n196\n400\n2227514460196\n1\n495663432\n3951456181929\n2\n10948273956\n45156\n17871946596\n132\n38575316836\n100\n15129\n36\n997017227556\n3457740\n4830\n14311456530\n756\n2724150\n210\n14961937761\n4\n1\n380\n1686102\n496041984\n342\n44100\n72\n0\n549480481\n3843560\n1699625867809\n1704657656\n445906572\n504788556\n4\n2571212\n272\n4016016\n110\n1521\n3619999014270\n67860\n1214989232490\n600\n17689\n55607770969\n10494773136\n741321\n35064162\n1465384091430\n369696756\n121\n410184009\n23562\n270586050\n254737560\n502681\n0\n4\n404496\n0\n1194120046564\n30731667720\n2009306\n7198489\n61672507260\n1577495808256\n28900\n45618979396\n39891856\n2\n165568016900\n0\n36481\n405398090\n1995156\n4753370149506\n47961\n55778492\n64296342\n552\n999000\n406828900\n37873441321\n3786002430\n196\n11584001641\n5904900\n30800\n2916\n420\n278723025\n37056\n4943921121049\n390983207082\n42\n1\n992\n4\n36432120384\n1\n11664\n4\n0\n47089\n7482\n9632931756\n2\n12882\n2058240707649\n144\n14496039600\n1590121\n2232036\n1710864\n3098381489284\n5538962\n1\n441\n2732409\n295891602\n42025\n429276961\n306362\n76256556\n427248900\n18090\n1303746061489\n467965056\n14042\n44629731306\n95052750\n89576760\n216163506\n59780\n2\n25719018012\n1071225\n503778025\n15006\n4798290\n2439844\n539161978452\n3725687481616\n1264527238144\n1688045365504\n1640\n380\n10920\n48183103542\n535829904\n3150625\n7439752516\n49729\n55138050\n25\n59111467512\n25\n749956\n4\n128312256\n9\n4\n15820608400\n2\n1\n28563680\n374383801\n380\n0\n59536\n4\n3701899137024\n891880027236\n46742007601\n342\n12231807006\n0\n2\n2\n4\n4523775924889\n4955930820864\n2\n787043106870\n441\n30466829756\n479566201\n38435798550\n529\n0\n1145970\n4241540\n132\n1722\n4692\n1972232627044\n231176820\n2\n23870\n33977364570\n361\n7396\n12769\n19123129\n361\n3073009\n14161\n156\n4\n506\n2987644838880\n2499561\n9506\n6642\n31628488336\n51717127396\n23104\n38378025\n21325924\n14641\n5890329\n393805196521\n22052\n28297631961\n448825410\n0\n57636485776\n1\n0\n111556\n64\n5271616\n603867313921\n4\n2161180632\n400\n46411808356\n13819413136\n4995225\n6561\n72\n4659564121\n40804\n1665311530430\n12\n0\n44310\n2556801\n3249\n36100\n33489\n4\n8464\n72\n170602782\n2716859252\n4646842012062\n42\n90\n868624\n243049\n279312\n507656\n47669517222\n47089\n145980923550\n100\n2\n58564\n0\n122742319716\n229007689\n43264\n625\n25\n38328481\n4\n5234944\n52900\n2\n4915086783000\n1332\n17766225\n506\n6575993556\n0\n208849\n2427110052642\n28530419190\n124178007321\n90\n2\n10314839844\n240\n506\n9\n0\n15498009081\n5103081\n22952\n6147367333932\n3364\n289\n16382256\n5084781462916\n2161831520\n68488983616\n506\n0\n29929\n4\n361\n42849\n210\n1364357155249\n47952459380\n2302806\n4848406530\n1\n431995440\n53361\n3962090\n1\n1211514073344\n42230\n60054750\n5788171963044\n1\n30625\n4564632\n1664100\n2632890796542\n16549536025\n57214248025\n4\n4\n1\n1\n2744686367390\n622577352\n4\n600\n37636\n104458620\n218418841\n8443128882\n1459264\n617796\n1431206665230\n184824025\n3300157809\n400\n30276\n13340\n110\n2\n53361\n17325403876\n1089\n2809\n366129090\n1030225\n5161201122\n465806\n51302\n380\n507938906\n22586633232\n2\n500244998400\n1047552\n400\n21861101025\n4\n0\n1\n3773306\n38097769782\n289\n33124\n549316406\n0\n529\n14844498244\n1\n1\n2321052\n66235182\n16370562756\n1\n3481\n240\n848649052062\n56\n500305056\n2550\n144\n4347174960144\n58472801532\n5747502786025\n11202846492\n51984\n0\n2604996\n600\n1\n16802899876\n57070470\n17161\n97209740\n61009\n16002\n37710338672\n377000472\n400\n1260\n48180\n196\n58479330625\n16723662400\n4461407849820\n196\n3721\n552\n54522\n11449\n57926381041\n8350669924\n3771495156\n1286882644872\n2956638982144\n731880\n252587449\n2\n4820524900\n4\n36802010082\n151733124\n256\n49282002020\n306\n240\n1444608064\n470031591332\n14288400\n0\n2630884\n55932\n30\n12769\n45369\n5060250\n3860865413372\n4\n284622\n4\n89036890490\n21734244\n1239961309760\n432764809\n87025\n13225\n32220\n36\n2498233136400\n16291459044\n5477940\n306\n27730076052\n1487029035844\n462\n17384730\n285981921\n0\n8272630116\n145841852\n26406\n77006\n282794672\n784080143289\n2\n838140\n18262802\n14762\n0\n1\n2867120570\n6\n16641\n32118553872\n858621844542\n58081\n32407380420\n5375442\n2387527151406\n0\n56\n4494400\n59015713692\n2\n529\n33167694400\n55086084\n5764801\n0\n1772892\n8836\n1751052755802\n361\n702\n9216\n1\n3383399889\n3602404\n110\n15860306\n28224\n8649\n5852\n1734276969480\n47089\n4977871912110\n8324828840\n365192100\n4\n2\n240\n0\n5302772700625\n400\n132\n5214372\n19138232281\n15213900\n0\n1\n5849142\n95384522\n133414050\n34040\n60270\n403728649\n19044\n33826382480\n4153631498116\n106028209\n30079740\n2856100\n225\n4\n552\n621405184\n0\n217622\n324\n966289\n1269288397129\n72\n37292244544\n49\n4\n4749315800556\n1770300767202\n2710962\n5760000\n15373644090\n60270\n1523990\n14884\n2\n15998708196\n1927473409\n128266950\n3992004\n0\n400\n0\n118680\n2844282\n4449990\n19321\n400\n45930919225\n2752281\n81\n149108521\n12536385156\n1\n169\n552\n385062129\n9\n95775582\n55790912401\n484\n128221652\n6062487932944\n29519191532\n73650724\n484\n630010000\n39789477729\n4\n942993453162\n4923961\n91204\n25542112761\n5184\n121\n350464\n7310\n320123664\n43119560756\n30525625\n0\n16\n2337841\n3844\n459630721\n462\n250401160801\n34559181801\n36\n274448922\n30625\n4356\n0\n560789761\n78464164\n99178070550\n4061653760670\n3721\n615684969\n1\n872404568676\n120395756\n2246665201\n336337260\n0\n5024322\n5985604455950\n5256\n121\n46124219990\n90\n4135122\n60349592\n272\n1\n361\n39402\n56958595600\n4407900\n65780210\n12432\n144\n94321465924\n29756\n9714172160\n2070\n24297015625\n8978604780\n1498812510\n202950\n2788900\n1585081\n536150521729\n110\n930\n4\n616777225\n302446881\n2\n2\n0\n6\n0\n2835856\n2862\n1960284210302\n272464542\n5982916\n506\n2817362\n45326835801\n25921\n20685918276\n196\n673220\n1980\n190219264\n11636584129\n1552063734942\n324\n432931249\n980100\n775280\n26258906116\n0\n876096\n4068736786321\n4\n5709710\n2\n18769\n28943026002\n12\n2865835622\n1024144\n390000\n1628176\n1\n248141256\n2\n329388757776\n0\n2471184\n51151104\n956616034556\n20022\n306\n5776\n55703832\n3304120540176\n595970156\n25760\n293865306\n13806\n462\n169\n9887880\n2\n22350\n30529699256\n25\n342\n4\n182\n272\n2425806\n20736\n19044\n548669822006\n30\n1198942876406\n57360\n9\n3182108335562\n897399078032\n25281\n1823076506\n28424892\n56616395364\n2\n160424681430\n342\n156050064\n0\n709657977744\n30\n40401\n51718491889\n3124056\n36481\n2748964\n0\n342\n1\n786769\n175920432\n272\n529\n59780\n72488196\n56169\n3341584\n36672\n304991296\n2\n20\n39464603649\n4235364\n12\n3552344759522\n0\n8930\n39715906232\n441\n179265321\n7870830\n155588202\n229143906\n95150270\n8930\n45586520100\n567487684\n50288286750\n950625\n600\n60762\n33489\n4121113152756\n16\n1075369\n420\n5586590792\n2699449\n1936\n21650915306\n54990\n79512889\n3179089\n187046652\n236344502\n4511376\n354620\n515323697460\n6889\n3917257744\n3629025\n1109211282481\n1\n112455420\n35156\n91345806\n2704\n529\n6\n168896016\n1\n20059623424\n2162575512\n42\n204418506\n5550\n423598142\n2\n9702\n1170187389504\n57372704676\n0\n10880102\n34782\n529\n679800\n110\n600\n433555684\n420\n0\n140687631972\n42\n9752550025\n7177041\n5396885832\n0\n4\n1\n453029940\n289510225\n5064750\n6\n151672470852\n508649247612\n110439081\n158006\n4\n13225\n12\n1\n4830\n260096256\n15320621952\n380\n529\n51756\n2\n0\n0\n382437136\n3717184\n6110784\n10956100\n4\n40553098884\n109694202\n31191975156\n4\n132\n256\n576\n420\n2399401\n45807342702\n1734010961942\n1466521\n900\n529984\n2477057333689\n9\n7005941102\n4458751092200\n256\n45796\n37442\n521574244\n90\n3025\n332929\n11115063184\n4\n2085136\n125910841\n37056\n2\n2\n399840016\n1149564591506\n8170171321\n53592\n1130270780\n34429544704\n5791666609\n2590478983512\n501264\n272\n137641\n31862\n3143529\n2\n268451840\n1637120\n58574406462\n31661931844\n60840000\n240\n121033002\n2013525525156\n53860921\n1\n5058001\n1256641\n2138414878224\n594018756\n228006\n5255556\n2\n67340\n5181808020522\n462\n2139617536\n2289169\n7491169\n48291381009\n341602843024\n1\n2\n4212756\n4139764281\n2\n592484281\n31684\n240\n110\n14884\n238146624\n361\n80343335601\n3728761\n16\n4\n5805690\n46335249\n1\n4\n25145872050\n32220\n702\n62001\n2\n182\n778143633500\n31110962689\n3192\n400\n8836\n201668401\n53130\n175469762\n49952\n450571863762\n3806203951550\n317356410\n2\n2128681\n20344610\n401361156\n26562154441\n600\n40602\n66865167889\n72\n4\n4\n64\n426463801\n3213907743906\n13806\n4\n7921\n54590920609\n2857790\n4\n9625179664\n4680849079729\n6131801681256\n21025\n4056196\n121692834025\n57810191406\n2\n484\n436095140625\n624980370249\n5849142\n400\n345774025\n8281\n0\n1\n2699449\n454158721\n4\n2\n72\n19460\n506\n3873024\n0\n48201104756\n0\n484\n36807765462\n2050624\n2040612\n1\n4244047031772\n44235133362\n95295072601\n5372230320\n30553256\n589202802\n576\n46097310\n196\n81\n210\n57840\n48874155625\n53743561\n261727684\n9\n421850\n1547536\n216266436\n12882\n119423117352\n6\n359456605209\n600\n2422692\n22129091322\n326290032\n3243601\n17956\n121\n380851905424\n0\n2\n1567882812\n2\n0\n42028075056\n2076911881350\n306\n53592\n6\n24703037584\n557762689\n110\n655232006\n381772521\n992\n4\n16\n29929\n48281492630\n24576989670\n164911930742\n61009\n669124\n589227076\n9801\n42\n4021398810\n18362418064\n598756430\n51534448144\n43401744\n10020390\n8065207442\n2263974631801\n236437117504\n32220\n1806\n64\n4691556\n0\n5476\n2253001\n29073319081\n121\n16384\n182\n9976813456\n1\n1315609\n102869657289\n2\n182\n17424\n506632572\n3383760\n38809\n0\n240\n2254502\n2830806\n101243844\n240\n0\n506\n39348673225\n1\n45369\n1159791148096\n25731528510\n14631321600\n3259830\n46656\n41006\n2\n725904\n4906225\n198470\n519976809\n289\n949869525156\n5476\n100\n1176644596556\n1\n13142444240\n18933622400\n0\n1\n4\n44604806402\n361\n1190\n331200\n1553713636880\n157452304\n590198436\n462\n7969489984\n4260096\n19321\n6972\n87993780\n591432519162\n1694732708761\n51408900\n450267180\n600\n1555009\n600\n44732\n600\n1\n41304261990\n24819009140\n398840841\n101761\n77695410\n6144977435742\n4\n16182892944\n6200100\n5474594090\n47306\n6060388952\n600\n344039729401\n272\n400\n4800467854009\n169\n4260502617702\n2\n3934980391362\n2296740\n397763136\n1481089\n1\n4\n2\n24750625\n12\n2862\n324\n30563256152\n1092025\n31622797584\n213568996\n42230\n527076\n2689308087921\n23761451756\n4375620964602\n361\n2692881\n100761444\n5987809\n1\n409030400\n4\n208169993792\n6031936\n2\n2\n11342\n812\n25381587856\n1155796009\n8649\n1466413222980\n1460881960230\n16066956780\n55283765625\n1\n1611630\n23420760\n5180176\n598047025\n1\n361\n65561409\n6328043401\n5897668105632\n5319942\n34845409\n253908290\n2\n342\n64\n48620\n4340972\n600\n434868462\n1365392\n475392612\n239398256\n34351321\n5801161273600\n5776\n499849\n3149860021440\n272\n46956723025\n7482\n3974042\n207864306\n7744\n27225\n0\n1475010\n3483801718530\n1758276\n4\n436527793506\n11297351521\n44310\n3364922468756\n16384\n256\n3481\n2673872390\n303021056\n7294953510\n168415506\n2001264960\n2181529\n0\n1\n188526630\n56191517256\n552\n4\n600\n8190\n2477285549660\n420\n235710\n51768025\n90\n655290\n901293903225\n513090452\n4\n126079212\n16512\n2\n90\n17705895032\n58322\n41611104144\n0\n806404\n1438897411140\n226502500\n42342939076\n256\n30752357132\n17544194570\n144072009\n28730\n800691912\n667489\n4\n1\n5909842500\n2063532\n22803416064\n109265209\n47524\n812\n1\n6197849244304\n1814409\n1233821100625\n16341806\n32303771556\n625\n0\n3297302143256\n742734574220\n351693762\n18220545272\n20\n132803029662\n239610\n3081780\n2\n123076836\n279708900\n228989046784\n50618250225\n4809249\n7489604306\n13806\n1\n361\n258550320\n57121\n0\n54059256\n0\n114345422500\n2\n196\n452929\n12\n2831030026922\n67264602\n30\n28392\n41006\n102080\n4110756\n4\n0\n9900\n350719256\n284040462\n64\n9702\n6381533340\n7342519032\n0\n225\n0\n4\n48620\n1662810\n36290\n16129\n57919710\n3761714556196\n4\n55460\n59433564100\n306565081\n253510084\n576\n396348372\n4961756\n392198416\n6211961856\n1086423686172\n5852\n38025\n2\n412806\n11304686652\n5132490\n1228321131912\n571536\n0\n36838852290\n886516402500\n58081\n159390625\n0\n1312170\n20018005225\n1\n90706576\n37249\n306915361\n5793264882\n54028818481\n490356736\n7656\n56\n25600\n2640314634120\n210\n2929232\n789413312\n3248496162522\n0\n4769856\n0\n397702395132\n428298912470\n420\n1\n0\n5102373957492\n2869842671721\n4846868635160\n62115094441\n7056\n12996\n12780076401\n25892510832\n1122\n91747662\n64\n1\n361\n625\n190532\n133795489\n49284\n92505924\n441\n10816\n592119222\n127046712\n293395013940\n3646045129444\n57398097241\n4411138273441\n9025\n2540238285156\n68848506\n132\n210627169\n3298903915232\n103684\n35344\n882660\n0\n5055752\n34580280\n306\n5592579373632\n4\n5457441750\n1806165001\n4914714334140\n566256\n1\n12089112450\n2621308331070\n90240500\n4426651889521\n549480481\n54523456\n2509056\n48129997610\n4236438344121\n36\n2\n97565333670\n275460409\n9474084\n5237232\n2\n1\n4692\n217046556\n1004719555449\n3391122\n3619506\n240\n204876282\n4\n82310462404\n62250\n29070\n157212\n100\n2\n240\n7310\n33074001\n6078690\n1089\n11972079889\n42\n4\n42\n1\n5073990512704\n2\n3212434282602\n132\n12\n5211500002641\n3269670417729\n22052\n3376709444306\n60025\n611919169\n2259009\n0\n57840\n400\n61752\n121\n462\n210\n159731682\n873684653521\n5586999688172\n2\n441\n1316756\n9339289600\n3339756\n1002001\n338081769\n324\n507726789950\n240590\n0\n16\n380\n72071610\n1357221505002\n252444432\n43681\n697300987070\n0\n5256\n6352329102\n419256\n230037889\n23754978002\n0\n255824030\n78907689\n1375929\n341056\n52441\n6\n289\n5216656\n4556\n90\n56406\n0\n25760\n4\n12321\n2534720318480\n20\n1\n4881477082242\n312481\n249529412\n1071225\n0\n2\n517621972140\n25122\n269912041\n2984256\n381602707600\n0\n9295466569\n98883136\n32323365369\n299359204\n6120836811056\n168100\n222784\n0\n25122\n4\n182\n0\n2\n6172772548542\n0\n380\n50544990\n47296897962\n6397600225\n3021330549006\n4\n462\n2\n59536\n28355192100\n4\n625\n409839780\n456478599424\n1\n4\n1882384\n12432\n6086089\n2\n631230\n3919022041104\n15317280169\n41006\n134339690\n14974049792\n32715403876\n60516\n2432409865542\n26904969\n10640541409\n420\n1\n5033783588490\n12017202129\n229198690009\n182\n1482\n0\n51084136324\n19044\n8491396\n2\n2\n49\n484\n169\n90\n1\n3659569\n58806\n361\n27399990\n36290\n5824982\n20330054472\n3195637105590\n1449523293482\n504631296\n50850\n506\n4\n30\n144\n442555566752\n1467705597121\n14042\n12\n383728921\n0\n895009656450\n57012306756\n3080025\n361\n55711296\n400\n4163640\n29171956804\n1248281080225\n2118480\n4489\n2524153571322\n1936\n164412813962\n3281483339682\n95667961\n8684809\n8798721402\n1253280\n5035536\n4\n1726455404862\n37517946720\n9464852\n12363104910\n21170\n90\n104397306\n577849482\n44459198462\n393943104\n617796\n925444\n30976\n4\n60016670289\n270387000156\n2265025\n1\n20219275830\n1\n4\n43145521225\n1\n13340\n4376464\n46076944\n72\n28056\n2\n652152346040\n9\n14520\n42436\n0\n441\n22650\n9900462\n121\n106276\n1122\n982258281\n3054091779216\n1332\n97930816\n278322489\n7921\n123298816\n5041\n40023003306\n678976\n2591675372\n2572816\n8452687782\n72905982\n114843372\n6014756\n2\n477585346700\n3283365744036\n0\n2871330\n5625\n825372\n2444719873600\n481157952680\n59780\n55790440000\n51424406130\n64\n433638976\n19137955600\n15186609\n2\n369562176\n16\n544895649\n17030\n82369\n0\n292410000\n600201001\n415201752\n4\n4556\n44521\n90\n213437490\n27914389776\n36\n4\n96216481\n4\n332916516\n0\n1\n1\n240\n2884902\n337561\n10920\n489405006\n469480556\n241317720081\n19182\n53130\n2248134810\n43890\n11012442\n38794212\n0\n4\n4042110\n22702352929\n955127994942\n590441401\n22201\n4\n5184\n1837380\n0\n83810\n26406\n7565433420\n3429109538010\n30293228450\n0\n2743035876\n40161763216\n256\n5700\n6\n0\n6\n345617591556\n3088913458430\n4010408762600\n9120\n39310992900\n182\n42\n336814256\n210\n107288164\n4673524081722\n1941900489\n756\n0\n40348756900\n1918076807862\n49729\n903711656406\n36120142809\n44834251081\n1427288974864\n42\n121\n4\n1133459394240\n289\n72\n1290267674100\n901410552\n0\n129960\n220806949801\n3080428663225\n521163241\n490999122\n180200\n46656\n5173350\n442225\n81\n56834560000\n413449\n11176929841\n1839325907306\n21308408676\n573966851236\n18279900\n45951495769\n504069852\n2284632250000\n4\n4483295947020\n64\n1781768521\n20592\n484\n1535121\n12616704\n324\n1\n5700\n11772\n2781978809402\n151683856\n16\n1\n1\n12068999881\n272\n17845486569\n1722\n289\n152473104\n72\n34169152801\n101183481\n17956\n40602\n0\n576\n100\n447470562\n60367752902\n157869936912\n234256\n240\n21832256\n18360\n78566968804\n1655082\n0\n342\n1872050596441\n4\n3498770\n13689\n2\n2\n2592127370072\n40712141756\n4\n331458436\n54613119330\n17822\n1332\n4863639193956\n31116607201\n61256\n6205081\n43681\n81\n1855044\n24336\n54056\n552\n30393169\n20164\n169\n182\n369985225\n702\n60025\n56980793142\n1834980443610\n69169\n4\n557337664\n20736\n28493946402\n256\n5550\n233157630\n380\n9209185260\n200194201\n2859481\n2172676\n18172927249\n955088120\n250051502652\n18632\n7310\n39155900762\n2\n3920817791130\n129015522\n2397277444\n194040\n240\n156\n290480892\n20\n119924401\n76842756\n0\n231831076\n240064036\n4\n0\n0\n178929\n484\n215894511380\n882660\n53724286225\n56\n19182\n372798864\n320016321\n23212350736\n59292\n420\n604864836\n1298460\n4\n48857576406\n1492062\n1\n56\n6462391321\n534187656\n2\n64\n0\n72080100\n276989449\n4145296\n4\n6162\n872198089\n56\n49\n441147012\n32484300\n374770881\n1\n441212120644\n1541322\n354719556\n5700\n462\n75900\n329525939892\n0\n4835950681\n1538840\n2916\n12\n212905186472\n1\n222766064361\n0\n58050397032\n0\n3829849\n289\n156749874972\n5185944182\n4513954904449\n132\n106905260\n1\n1\n121\n1\n37830\n870489\n33773532\n3321991052689\n27728743880\n56169\n3136\n2671590\n5373124\n67190809\n256\n8742\n10816\n21025\n4\n15231509056\n0\n72\n2760582\n1140624\n2253001\n0\n10404\n1467435447506\n3265249\n280931121\n6085583275506\n2\n1\n41351222500\n2145727684\n17002073664\n110\n992016\n680625\n938555032890\n1\n14042\n0\n1\n16129\n497446112\n219854756\n13225\n3038049\n22952\n495383707225\n1562528750132\n6\n400\n630436\n2534705989776\n2809\n275062225\n547600\n56\n3290596\n8334959616\n6241\n143268930\n225\n1642242\n2871330\n39006\n34167858870\n169\n355284801\n1249783135969\n22350\n64\n72\n5479774650\n89200483560\n3651924822001\n0\n650442\n895355944056\n484\n5710441460409\n4268356\n4837800\n4830\n2614593597870\n3870430610281\n270618950\n53592\n1\n52670\n30450\n566035472\n515131112\n0\n121\n240\n3952699770\n4\n6133082596\n13456\n156\n484352064\n369754441\n5476\n3818116\n210681\n28238596\n1673142\n2033187958201\n169\n2250922594556\n3845872027010\n5764942659870\n97268906\n2\n19044\n3625216\n260160770\n2\n450241\n25\n3138385859401\n4395312\n2492206084\n529460100\n217179169\n559464409\n226893969\n1534543680289\n0\n704254961601\n5694588906\n40804\n1061930\n11686142\n4\n13689\n45796\n41616\n10999499762\n30743940260\n225\n1225\n1686102\n36\n1148112\n12\n998001\n2\n966344048784\n2\n1907161\n27889\n142718862\n100751406\n520364532\n57840\n1895616790596\n55696\n3942329380900\n1\n2168256\n10858265209\n5473260\n1\n3924099512356\n420\n5443332279025\n40755456\n0\n196\n279474806\n2\n27683801840\n600\n300796992\n3186335670961\n1301718983041\n5980470\n24164702500\n1681078206096\n0\n21565656756\n5575459561\n0\n36\n0\n86666790\n9\n121\n105842944\n30\n0\n1244541048100\n5046706087656\n475567056\n177355806\n1279201716324\n1\n4\n342\n1764\n197880489\n1\n256\n16\n1633816820\n4\n1089\n893025\n108035236\n552\n289\n552\n5510756\n17476046809\n636804\n1425636\n56\n5953600\n1053304005636\n2\n22443335721\n5647752\n783225\n342\n786852380209\n2708777784732\n44342281\n380\n2217121\n166693921\n46872\n55368913636\n99365539729\n151253102\n2747306\n19321\n72\n24692036769\n1464100\n4\n40804\n423906921\n187799616\n8836\n4\n790321\n186747572449\n4\n16641\n26663787390\n11236\n0\n6\n54465524262\n8417603756\n38612\n72\n211140\n12882\n448230\n29696594929\n49\n262808997201\n2\n1394785801110\n46225\n57370069920\n4\n4\n54289\n506\n6180196\n208239330\n1573545702510\n865830\n1214404\n19460\n2\n510104810\n4\n2651759838506\n51983544001\n36100\n75524790\n89102\n511225\n0\n812\n4486608140082\n273505444\n29115108792\n1395508092\n26406\n3372732\n4290\n1281330045722\n380\n51076\n600\n4782969\n388622082\n2988426163142\n2314513429256\n381635760\n12723489\n655290\n2\n2873631842041\n1016527732900\n0\n54737515560\n4541161\n240\n153499710\n5014410156\n2450\n3173742\n5724435600\n100\n266598734224\n5108045229702\n5906598692150\n9\n1\n44732\n4509449737662\n12882\n2652\n25101966096\n51782416\n59884697082\n509675776\n809100\n551404324\n529\n6674399809\n4650287384756\n0\n42\n2\n125944506\n0\n18800896\n121\n81822314116\n4\n235225\n49008218884\n306\n84290761\n0\n3336102\n18992009532\n644203680129\n28649256\n86815806\n1408969\n16164420\n4049423733124\n38416\n219931922961\n2259009\n4928400\n546121\n455625\n12\n816312\n14884\n44732\n2471184\n4272391851552\n12840969124\n5673731059640\n14856440769\n113703840000\n20\n8836\n81\n2\n1843175508496\n44944\n4\n5652506\n15500\n12798506\n3926342\n197136\n79242\n1774498402609\n0\n13689\n2135466371652\n525876624\n42\n83521\n30976\n4746171602041\n2876833231129\n3310580\n156025\n406406\n572046806\n42\n514427761\n17043302500\n48248099370\n4178741374809\n89102\n4\n420\n44332986916\n0\n2\n865004163136\n324\n3193369\n6\n5075146137672\n169\n8570256\n4\n324\n72\n715589250\n55460\n1386506\n656100\n19891600\n42\n576\n21101339169\n506\n1\n30370555712\n92419382\n55743918302\n742182\n1\n2023506\n4\n119682094401\n109305947610\n455625\n999183166872\n11025\n272\n149915536\n5448053153342\n34602510306\n484\n28860403572\n9702\n569270\n0\n46440\n12\n1980\n2916\n33178440350\n5965298220816\n24344356\n37791756\n1400672\n110176512\n3235920684822\n293745321\n1\n2\n3822243963136\n4\n6\n9\n4\n0\n0\n3080\n16\n38809\n3526884\n2830806\n1\n272\n5033292\n493906176\n165837087361\n47306\n441\n12\n259274404\n2\n4\n2898506\n2\n28863756\n272\n13456\n2\n11025\n815409\n225\n333506\n19936734006\n3982020\n2143296\n594872100\n42642\n3144211642056\n59658795252\n5250972\n1122\n41505505441\n26082\n5782769658121\n2166822272169\n45193019982\n5483643191524\n2\n4\n4380649\n4901820169\n4708900\n2916\n50210950084\n589955521\n20\n1\n3721\n93083904\n4617382267290\n1\n2552006\n2067152379840\n15006\n2510640\n34538178180\n256\n432057796\n475654290\n5625\n256393360609\n140700385100\n10201\n296044810000\n54056\n39800\n400\n4325364222001\n5979000976\n51529\n49758916\n445948806\n12\n26732\n304537401\n552\n1\n2400950\n52212\n3094081\n4\n1453971727056\n5541316\n30\n2119936\n277202\n159201\n289\n14382245476\n3497421321\n2\n997985016064\n2173741832682\n974420701256\n306\n1188178481296\n2\n306\n41209\n6113128782\n4718659556\n35610709264\n4\n165855762\n2\n600\n5248296119056\n1\n466489\n714968331364\n285156\n14641\n666978472656\n4777183948329\n1442255682660\n29923291272\n37769395992\n0\n21170\n374654736\n44548950\n1591040401860\n11130\n164309027850\n245741788452\n6352249401\n632025\n164467800\n0\n2759348370\n420\n4\n9\n3763600\n237946050\n36757517006\n86322681\n25930982961\n27510866496\n4\n1\n246097656\n16512\n2689600\n30\n2\n22568151529\n18800896\n3600\n56947140496\n1\n51058825444\n169\n4145296\n890192\n4\n14330124972\n378224704\n0\n54289\n1074252440982\n6220036\n1115125842\n19738142556\n0\n59536\n3971898529\n2545620\n372895410\n1\n156\n155775361\n2756\n25\n47135090\n901029999076\n8742\n77284\n3153703601689\n1\n72\n2776604942\n6449455172\n1426830\n5852\n0\n3575881\n133656721\n256\n58775222\n38612\n209192832\n4\n1517375162\n342\n159600\n2053668128906\n34993140\n29412\n18225\n1749006\n5389362\n3309446798532\n763361641\n1764\n30\n5546025\n6056521\n182\n2\n330074953962\n576\n107868996\n1\n529\n1413721\n1475030896572\n289\n79893566370\n1123322256\n289\n2\n12\n4\n2689600\n4\n261632\n249513616\n2\n6683716516\n556009581260\n363609\n49406841\n53235640712\n24591681\n256\n2638915776676\n181117910820\n4892944\n3261379553041\n20022\n1492062\n49\n24180\n496106809452\n3364\n128391561\n341932562500\n6474455296\n1804992\n2773970892\n4970670\n42\n210\n151609969\n4\n72\n144\n361\n0\n21316\n102020100\n15327225\n506\n229355880\n81\n0\n332861780\n15252\n30\n57321696980\n4\n5112\n2550805530\n362864401\n3037330926436\n3936974240761\n15252\n4\n29756\n6400\n3804323468556\n485112\n304677025\n50400\n0\n8100\n54841430\n484\n0\n679800\n529\n462\n674322632412\n1\n14042\n461068256\n36102072\n169\n428510700\n1915243932\n3000179070506\n13907131112\n3721041\n472062529\n4\n58944006\n933669136\n2600156\n53438644224\n389193984\n2237274045504\n6\n3258025\n4859972082\n101666889\n21904\n344569\n44521\n492804\n27556\n441\n3485689\n4162495608180\n1445026182\n272\n23829788161\n14161\n484176016\n217156\n210\n265119806\n641601\n0\n324\n42642\n9\n3715256\n33703830\n4366010\n1958600\n674329201800\n2\n1709556\n2585387431396\n82029249\n18838111504\n272266500\n2970\n4796324280\n242098040\n4\n36529936\n4\n23870\n2\n61256\n7921\n169\n23415273420\n14762\n4\n506\n210\n4\n256\n53713392882\n42436\n1889250\n0\n6480\n1166614929900\n2197687520\n420\n1\n53560076330\n227529\n39800\n4\n1395022500\n361\n32942\n52212\n529\n42025\n7584516\n414712860\n7461092\n1825201\n2646279364\n5709982656249\n3306\n25\n1331703306030\n20\n18524416\n210206502\n64\n118504996\n67243491282\n61256\n6349460172\n195314600\n1811716\n3168636744422\n454276\n3418166822412\n0\n2\n49952\n3721\n47742\n1555616348292\n529\n2111209\n3038049\n3004117431121\n259032930\n2116\n58170445410\n484\n4539030\n1\n324\n0\n483720\n12\n303601\n57840\n361\n225\n23469167612\n1600\n1122283500\n4016837682025\n4447636359364\n633847657170\n96410\n2\n27225\n16512\n4216862\n4260096\n1\n5700\n1\n588289\n2\n34088082\n58967865889\n1\n36727039449\n576912361\n2\n72\n44944\n55351972900\n3821637919801\n1975430\n0\n0\n453711300\n1256563652190\n19740\n56\n2377764\n828100\n1980\n32444416\n22952\n0\n1531005326244\n61256\n538263598560\n36950066176\n239413022102\n0\n2416470\n2730795910144\n274592768256\n0\n31152\n18904462542\n3048516\n967552567806\n230341329\n400\n1\n32400\n100\n14641\n4\n5534105691024\n4540935116809\n306\n275111982\n361912576\n64240225\n462\n2461761\n50399127506\n360791030\n9451533961\n19321\n0\n123787876\n144\n7879249\n3312580182450\n2354125587856\n30976\n64\n1\n2251006612560\n220611609\n15994534430\n32205891600\n110\n129413376\n420\n22052\n403326889\n4477456\n397763136\n45071502300\n49\n32000022110\n689844033192\n441\n0\n64\n4\n357474649\n615440\n1448412\n0\n1482\n5583601452\n0\n2334784\n58564\n225\n4255533718130\n593945641\n324\n576\n47465593956\n7235373721\n1555009\n382498956225\n0\n1530169\n72\n441\n5424599671929\n231577500625\n152707806\n3433651619132\n1232148840484\n8649\n18996522\n484\n4\n261840942\n1585081\n536802561\n2\n584616983006\n16236870\n2\n2\n5836883600\n1332\n1\n2704\n30\n39601\n30\n167935681\n26732\n8994001\n500931542\n0\n1\n144\n50400\n27060\n34426019306\n2106852\n11628387225\n168693793452\n1671849\n11186235225\n299151616\n420\n50313630249\n158608836\n96373489\n89182564590\n33672\n1\n112169281\n163878402\n33585876960\n7702431932\n7581762\n103052952\n8076964\n9313601049\n1758875403076\n132\n4730894742\n5535437268001\n12210\n554084521\n499187306\n26368888225\n84594006\n47089\n592800756\n130321\n324\n1565791731856\n400\n100\n205277256\n0\n14795924682\n4340972\n519841\n64\n0\n380\n656449966656\n250000\n441\n472034954304\n67081\n529\n12100\n4088484\n1586340\n5249643264100\n324\n4\n269599980\n16002\n45369\n4\n64\n4422050502\n335820\n386240409\n1538840\n329930896\n9506\n49284\n3630930\n5812921\n4\n1560\n460381392\n54756\n511225\n0\n1936\n778806\n306\n2\n730595853001\n2\n16112196\n46371530940\n306\n400\n2\n4\n484\n2\n256\n462\n1\n23104\n201275606406\n28561\n508369\n342\n172462556\n0\n5478104086225\n113232\n29333070361\n42642\n2307361\n512365860\n2\n2\n2809\n24649\n3835655661289\n361\n0\n5496405946922\n1089012255806\n4987255020\n185422689\n58125352464\n12882\n498316329\n590174142\n19216197506\n1325952\n2\n1\n155837772\n4408870272361\n256\n225\n484\n4\n144\n0\n1\n25\n26406\n49\n29929\n22226784482\n25760\n346332\n25\n2652012\n1002323940\n14042\n3784806829764\n10890279092\n3309968926224\n236728996\n447555180\n277938912\n30675771025\n9506\n13572\n15252\n204118369\n127757809\n37932820932\n400\n94838382\n8313883580\n290521\n386142150\n1278176088660\n2613072\n256\n35532\n5737656110940\n2760582\n8304859161\n0\n9702\n131136852\n222666084\n47404611076\n1016224278320\n2676496\n7865220\n1\n2934369\n6\n48514467600\n456287415590\n32207506760\n0\n196\n0\n361095006\n4403702\n3560769\n1441569024\n234610489\n1643047130596\n57191406\n4231249\n5293245797730\n196\n5276209\n2413362\n8059011984\n97032\n94002946801\n0\n1892330384400\n85264\n256\n20\n2224572\n66137556\n51405812712\n16\n1317000390\n402142862\n141752\n25122\n3206452491649\n4096\n27390\n40454483689\n39987800930\n57006098840\n225\n38602229150\n20263502\n0\n161378912\n5378828940\n3782\n2209\n5726449\n144\n182\n54117880056\n14884\n711492\n15821237306\n1682230225\n9404732484\n3720942621650\n169\n256\n8825944862\n90\n2\n19460\n4124961\n2566404\n110\n565821369\n31152\n1511670\n61533267481\n6113256\n342\n2003147686276\n100\n1451580389040\n272\n2\n1879641\n1003002\n9253670416\n2573735824\n4822260806\n413227837584\n5695041690\n17161\n314160\n578474652\n0\n30800\n2\n1135656300\n38044112401\n3827892\n272\n1636017506761\n14073076900\n36\n306\n96864964\n12533810070\n4\n886967524\n2208196\n1666000712432\n169\n243658729924\n436260\n968863223172\n306\n20\n281537421201\n2\n22650\n3822025\n164430\n40804\n1452025\n5541316\n4032\n13660416\n3808352\n0\n27396870400\n316396125081\n1\n6006\n56608543550\n0\n12755612\n5016639086010\n2\n47089\n5628450529\n16124240\n0\n328461252\n0\n96884649\n4\n1\n54289\n1369222009\n2146868183180\n5839472\n843642\n27060\n33621623044\n95172\n276676\n2150872506\n5468528550\n541609256\n1\n60516\n921216040000\n49758916\n0\n18090\n90\n57454651809\n2363906\n2882618219756\n4557266435400\n3621270082332\n29008732080\n4\n272\n7365796\n36\n10056780372\n2587272\n552\n4979348660\n9\n217695270\n441\n4\n47961\n9060374596\n1149184\n137135810\n0\n939391850\n362369296\n3210695569\n8972446729\n1098012675321\n2\n145914320\n7646190806\n36\n11772\n3204100\n506\n0\n4318084\n2\n0\n156\n2564972011809\n31152\n552\n19300711329\n15006\n5628756\n4\n184041\n5389473682576\n4287922732900\n3310580\n4052579662404\n527666841\n1233210\n66306\n360449210\n1149184\n516789289\n2102153464280\n169\n6241\n90107556\n3690241\n37869938404\n2842225092100\n191587122\n30976\n196\n407454410\n0\n1670556\n11237696064\n11799225\n705441248930\n8161767306\n151277700\n4997460\n110\n210\n529\n42127357250\n4507071679182\n0\n49729\n5620493494564\n36\n132\n2819041\n2596932\n6039306\n478187556\n5184\n303264810\n1\n22297358329\n3763600\n451584\n0\n5202961\n0\n59536\n2353156\n53824\n12204542\n132\n15382084\n1\n4519876\n1990685369972\n342\n2500\n961\n2937855990306\n1182928140625\n30\n27225\n62465254830\n35055260130\n4\n7056\n1520565204544\n2\n506\n221250750\n2095256\n8281\n48180\n1\n49\n1404225\n80940\n4\n4\n28334329\n324\n4\n337577268196\n2\n1020994209\n12100\n90\n63252\n2116\n1638137610506\n241081\n698060\n1058841\n26569\n4\n96864964\n4024774241856\n459211555452\n1681\n12\n7469289\n47089\n1028196\n4023927676729\n0\n276676\n1\n324\n0\n292681\n600\n3824958062500\n4653734034252\n23104\n53592\n56\n4167154362\n400\n2443967859080\n281870521\n3692162\n3605238271262\n36\n5148851780\n159441129\n14042\n65792\n66528492\n3463056743041\n58806\n7068689700\n1\n2932656\n5310720\n400\n2015854756864\n2\n6065917456\n14143988112\n507060324\n779689\n72\n109561\n419491842\n0\n25\n3255431731242\n2\n4356\n182\n57327922056\n41364192\n4812677269742\n4\n600\n27390\n4251163567225\n462\n900\n1\n8376459529\n380\n1437601\n2626020\n3446592\n72\n420\n4404023326352\n1957201\n2421136\n2\n65815850116\n823556\n9312\n5776\n32294426142\n2698231080\n28392\n46656\n25\n210\n1292618209\n588232262\n171396\n3369374127810\n0\n466252711929\n3364\n1\n1444456036\n0\n41388850806\n2\n291623929\n2\n3139984\n25\n3869820758596\n47742\n0\n841\n3731526704656\n1025540023410\n5034292900729\n12210\n3510174614116\n348690\n3083536\n2982965947002\n2626020\n3664788906\n100010000\n22198765056\n20\n453540912\n32220\n2292196\n1332\n13824468506\n256\n87347716\n1604029849009\n1\n4\n3481\n22972849\n225\n286384452201\n523311376\n3481\n82944\n11909401\n3751969\n678403440756\n462\n13173530176\n3746160\n303601\n2\n1446939540544\n0\n413787930432\n478946351540\n9913052\n60762\n604452603690\n10949111044\n59128244569\n2523332\n1\n27060\n18425076121\n2414087789022\n38105577642\n1524238722\n5402\n576\n37112464\n0\n4\n196\n333811170\n4\n681692968609\n272\n612552762306\n185300156\n0\n11770948036\n30976\n4900\n2699043194252\n4\n1957231778121\n131560900\n58081\n58361960\n22087309924\n53331205160\n3260785429460\n310605376\n358738706704\n575856009\n182020572\n3525336697744\n169\n1981063287506\n135559449\n4393216\n2551309787524\n5700\n6125625\n4\n1660232\n1192128779562\n43659056\n36185550625\n5965806\n20022\n206066025\n1068799299756\n461433361\n28622210761\n23716\n756\n491220732\n56406\n127114353961\n0\n49\n306\n6120676\n53883872641\n144\n4621008484\n0\n2\n361\n1369\n56882\n4864230\n107588756\n3205890\n2\n306\n86666790\n13942756\n36862656012\n5105290541121\n12\n2\n3802500\n274618445640\n388838961\n3912484\n44443175040\n26247240100\n3229926042800\n51143952\n36\n6\n2\n132\n378613764\n202346579070\n992\n59292\n2\n4\n1\n441\n17410538601\n2050624\n0\n13340\n1806\n5763163140\n56\n470347656\n1190\n26406\n527597930\n2805531200784\n316217306\n2\n22052\n4\n9985505256\n289\n1\n0\n19767797604\n0\n14984641\n187210806\n16641\n170982\n27556\n0\n52212\n1521\n385984962\n28224\n5053463536081\n638401\n4\n5138649725881\n9909904\n5424241\n3387440\n13849170806\n4\n4\n9857014806\n323316361\n206841220804\n468722500\n0\n59292\n8190\n3806890000\n4\n1019686951820\n2500\n169989444\n50492561730\n400100006\n59780\n1142845636\n1340964\n1436402\n16\n16900\n509720929\n121\n0\n2590490\n1\n4\n110\n104806406\n1491002382\n2\n1919610\n0\n950299377889\n576\n4\n0\n240\n146074164612\n452929\n4147332\n97952411702\n25\n4\n2\n36339225012\n11772\n20624119321\n4\n2\n5854439964025\n1485961\n144\n501625609\n1856406\n172225\n0\n182\n144\n1131032\n156\n3249\n9\n5031049\n3192\n5934096\n2748964\n54423757521\n2465275244280\n324360100\n31862\n835094404\n81\n1\n238996321256\n112743843302\n3619506\n33131536\n16\n15129\n4892944\n7152254041\n81\n0\n31152\n2\n20187436806\n14631805444\n49\n6\n2582424895056\n1073296\n361\n58322\n676\n306\n1056784\n100\n568348624321\n3481\n1952606585449\n22893505636\n156\n23104\n11772\n90\n1690530441616\n3797579000\n284110320400\n32761\n4\n2907025\n72\n50850\n36\n51984\n1\n9702\n1892\n69960\n232562500\n240\n5442805012324\n2\n2669956\n1892\n1791582\n2911108202809\n408363264\n21146202\n81\n1\n529\n472656250000\n159049932\n504429140\n22160556\n4077397170\n240011318190\n42486485006\n0\n23104\n0\n30\n29479470\n4710720805980\n32400\n48400\n514110276\n5652242350580\n1183744\n1266750\n23875966842\n240\n54522\n1\n6024570\n27060\n688900\n0\n3411409\n51172562\n48395160121\n5818547223722\n1074332\n84972\n0\n88237842\n36\n15750\n21904\n0\n7656\n2\n72\n54353327044\n380\n3747648797340\n17848960000\n1700416\n3600\n156\n5058001\n110\n2671590\n0\n143641\n48811169556\n1771545028036\n135652609\n330050\n596653902\n518372640361\n360449210\n19331982560\n6208920224670\n1674436\n3422\n2\n240\n482614992\n63872064\n6071296\n44830016361\n16384\n67379472\n1384365204690\n150156\n1482\n2195055591184\n167037324804\n7832\n48391420380\n4\n37211953216\n1\n471215556\n73676472\n2871566569\n423268902\n16\n3241800\n0\n0\n2089470\n1495057648350\n2\n26877963025\n589056\n462\n432013712006\n2\n182\n2735760720\n0\n5352282\n1345600\n272\n4499307018649\n21904\n851982534841\n831216947521\n36044541316\n4\n4874332268521\n60575089\n132\n425557913104\n4\n29877156\n71656225\n1\n1260143502\n225\n21170\n311487201\n2\n289\n9900\n335483644890\n3849444\n573554601\n1140624\n1\n1\n3897567330\n0\n61818906\n64024002\n34969\n45171841\n36290\n13924\n64\n182\n26406\n4\n0\n50625\n40583270\n602176\n0\n4674442906116\n695508756\n5940877324272\n496821810\n5323432556792\n24492\n9506\n3387440\n121\n380\n10302\n306\n196\n1\n1190\n225\n483720\n41925429049\n324504196\n5586808231449\n0\n6\n4443664\n2942940\n125804641410\n127170729\n1\n90\n72\n5998335722500\n9863171282\n600\n156\n2\n0\n4062240\n785882\n419061841\n3611900\n3141756\n657865365921\n0\n14762\n77686596\n4\n353440000\n169\n27556\n400\n68906\n15547249\n4096098349924\n4\n5151179483641\n37442\n22600516\n528379182\n46851684756\n155236\n57153600\n2\n15876\n9120\n40804\n5476\n370142650842\n45369\n1225449\n320947225\n345457982\n0\n190096\n64\n5485116231056\n361\n13689\n490700\n2144000241840\n309003662\n31862\n66125865350\n789432\n404955252\n41107332\n14630625\n6400\n420\n26406\n385920500625\n6806\n27059098512\n4437342\n563112900\n49\n762129\n671223814806\n28730\n6056521\n31152\n364829100\n23107249\n0\n809100\n42\n324\n8742\n72\n13165382340\n169\n4\n38809\n4558207710\n1306533316\n5189160988729\n49\n2280100\n13874012944\n256\n53067572496\n3616152919542\n461376487009\n227346084\n5509904140442\n15876\n327809130\n99261369\n17943942025\n1272049006052\n4623895455300\n1\n1600\n558400530\n3001958203456\n420\n2\n29584\n5010882\n256\n511415610\n24505084681\n0\n5904379991449\n4016016\n34111440\n81\n12\n1\n146748996\n1962801\n9506\n5155170\n799236\n41820\n650\n232324\n156\n3474496\n43056\n394161462\n60762\n450241\n506\n4\n8281\n2\n4888521\n23629321\n2\n5929\n4\n40200\n324\n45327900312\n275593201\n7893290\n329694806\n405539044\n6537854449\n2743992\n2\n186786889\n3005022\n39204\n423801\n2695790241\n400\n1553762\n4437312759049\n361\n3534400\n350400961\n156\n674041\n0\n4\n100\n400\n3922141129\n34368906\n3077949184872\n206554384\n1925156\n6135529\n44740498880\n762129\n60698916012\n2\n30800\n59536\n484\n21316\n23396569\n5740816\n250699722\n1196736448070\n47742\n803228212900\n289\n196\n0\n0\n198570372\n8747112676\n182\n240714362502\n7744\n16129\n38416\n196\n331549472\n235100889\n53791524900\n14494956025\n2304\n1260401400976\n419655710\n17556\n1621175748516\n3562656\n0\n3087049\n19127502\n18496\n4\n3839795052060\n38025\n3602912681956\n6110784\n30\n4572927772040\n4115315333376\n35117476\n110\n2\n21852526276\n1314465689502\n8874393616\n2809\n655290\n16\n65100692\n20449\n660156\n5002665848896\n13110\n15773099281\n1411344\n2751002500\n589955521\n625\n144\n12656\n145161\n42436\n36\n41205549072\n35846038230\n133647274084\n5546025\n53295877881\n576\n2\n0\n0\n182\n30946969\n190233056\n132\n3306\n110\n7045671782\n29756\n0\n5852\n2244004\n1\n2\n2271049\n10006300992\n576936380\n5394401082225\n16\n7310\n4231249\n441\n41011515169\n4\n36481573002\n654481\n2\n158243820\n703082\n4\n34706013320\n324\n0\n4\n2\n56169\n181535202\n38675548921\n1454436\n232394780\n56033991225\n410528382\n256\n817479989316\n5685840\n0\n5823025065930\n0\n4\n2683044\n612306\n91506\n237946050\n278355856\n20164\n2648705797740\n255267457600\n4284900\n623094735132\n121\n20\n0\n49060256520\n4293184\n30424952756\n883991824\n4\n749090\n20\n0\n48841\n2\n4\n627264\n4\n1410156\n31088037124\n1\n24336\n4729235277080\n60730849\n7513509080\n3169408506\n931023325920\n4479572\n5369079076\n38015640576\n36672\n441\n10100\n4223025\n36\n576\n1683419870\n1\n169\n778806\n4\n570025\n361776385962\n248004\n2224074116889\n10108090521\n2590490\n4\n24321494162\n16256\n420\n168011861556\n3572100\n2782504231056\n426835600\n254243025\n2508314742756\n144\n1\n65536\n10110704704\n61071507002\n0\n19694333232\n107103689289\n1120575625\n529\n58917367441\n26319708522\n687638977600\n21248018289\n28318362\n354851406\n56644\n890045070084\n2560511802\n110\n1122\n1\n180633600\n2264760510\n62250\n0\n9662005320\n152905633992\n89700\n727650797600\n37249\n0\n127407656\n335036416\n8556\n2\n647070621649\n2\n42\n2\n77562\n5419584\n2\n64009\n121\n3485795419812\n6476788962\n289\n9\n64264272\n2873025\n2\n1293906\n46440\n76404975810\n49392840025\n3365390\n196\n289\n1\n30\n400\n833569\n1\n78145600\n552\n6320\n9623610000\n6195121\n8911171201\n50850\n58863008689\n42025\n2396304\n40392380\n12210\n1\n1191372\n27722\n6006\n256080006\n216140378281\n24025\n33418399249\n72\n100\n3974356806\n0\n41820\n676506\n42436\n1\n484\n175439511025\n10673059410\n4\n1\n83521\n663397292\n3306942\n462\n1535121\n5359225\n7656\n1\n6\n3573990\n16900\n4070306\n5293754265856\n306\n600\n4906225\n15021688969\n35874110\n30450\n420\n240\n542352710916\n1024\n5980470\n1991962454161\n2689542600306\n917764\n54859945284\n2528425960506\n4557339018056\n4556090\n506\n824092669820\n2998092\n1135757401\n210\n2\n110\n2720850\n9506\n196\n1\n766500\n123587689\n1036324\n16384\n381167052\n4\n48434326084\n2450\n6421938769\n6241\n44293832521\n5529552\n52212707001\n10302\n384462002500\n2061892093041\n49118527129\n4\n653672\n37636\n38220\n72\n4\n90\n1666974069882\n31152\n4378462088006\n225\n36822731556\n196\n57320041\n4696635024\n4\n4692\n71022\n61009\n2070\n771477642244\n2502900841\n5119974916\n9445604532\n102323340\n2\n45369\n25\n3285156\n4735826854220\n1646648435524\n2\n2457056\n55868150\n42642\n80372\n3581923404409\n196798812\n546121\n2867942\n14880306\n3078270\n2775556\n121\n27889\n41914372900\n901550\n2\n1518777812\n5499918481290\n100\n96721\n510488836\n24964\n4270695032356\n23239020692\n3249\n2912142\n56\n89804052\n54289\n478172\n28392\n574377547129\n1187010\n624100\n27211872\n4\n1258786387892\n11556\n529\n420\n0\n196\n225\n361\n0\n5179823226006\n210\n7482\n2\n2966778884356\n1608371822656\n52049010\n572238162\n4192256\n1\n1632006\n1418124913350\n100\n50850\n4500762\n144020\n552\n23736024225\n4968122258112\n26444126072\n1025277753600\n25\n27060\n4764417207270\n688900\n110\n484\n0\n33615389025\n35066120340\n217356049\n350464\n30\n44367313860\n8281\n29584\n370272\n27722\n4500762\n3254416\n66049\n5557106094552\n841\n1119805832\n5300786442\n5391226575702\n1750329\n2611456\n0\n2564312214409\n100520676\n1436402\n8372\n768397755889\n351649\n5087280\n196\n240\n3600\n61277584\n1093188394692\n9\n88548100\n3774077461902\n4962954717361\n2898201510510\n44310\n57965382\n3099360\n420\n2011387952\n1190\n2\n114582\n1\n1485573383281\n5827733964900\n3418801\n4583881\n600880002060\n1947216512329\n131836324\n535667880\n0\n35476664256\n246144721\n6272560800\n60516\n16\n440244324\n240\n60618871681\n49\n54522\n484\n23558105682\n56882\n6411024\n6162\n4120912180009\n4\n44732\n25740402\n4\n37353292900\n413674921\n324\n20306\n158802\n0\n1980\n25690960656\n16566392810\n570087252\n24806\n1\n12\n4\n1691192310222\n6019515040900\n342\n1077513450\n973182\n51584175762\n115842169\n15103795506\n16885443136\n1349496960\n3970056\n148376761\n2\n1511032384\n5216656\n25281\n420\n5881330696170\n27583230724\n16\n422981787270\n208461187200\n210\n683929\n5421912\n2563548792\n5567782948225\n2159430\n454798276\n3370036806756\n33489\n49471990929\n2\n1128906\n0\n30\n27139102860\n552\n14161\n78382640961\n132\n517903806\n1406\n4\n4452078900025\n30\n371490\n4435236\n2\n562098821556\n2725466436\n2712816525969\n29756\n2\n367699800\n1\n420\n195806\n4715040930810\n6017209\n306\n306\n442997256\n1970481776382\n53378095369\n642521104\n36672\n11524022500\n0\n4556529967609\n1849\n4729887703730\n24492\n5238502506\n277222500\n121\n30\n5256\n18090\n0\n84972\n3216642\n46747196521\n141931482\n380\n24964\n0\n0\n60270\n131939682\n36672\n210\n380\n3339279582\n5171076\n240\n9947716\n441\n25760\n31097206336\n52355160156\n4536612454556\n1693075609\n383591810\n4\n911070\n3721\n500556\n28730\n20687788056\n6132893755024\n9\n5657383554150\n4014030281520\n121\n5008955086830\n0\n5403300\n19326143342\n3951629124770\n3318199236056\n56821444\n5885708898304\n2384036361056\n1\n10320156\n300318796182\n4\n380\n393724806\n0\n238100330\n6904363556\n4\n3655744\n969730740\n36554116\n1129094404\n2\n1114046474256\n0\n600\n2\n633616\n23833924\n3010277956\n0\n767650142\n270400\n338412816\n1141692\n4\n1865956\n7744\n20\n1767349559889\n9565915830\n1845605119430\n9944178120\n130131056\n31684\n6114379830\n5628696937656\n1806\n4\n1162642471081\n20\n1015149949662\n0\n23190568940\n11061044412\n1\n506\n14884\n32795580120\n910116\n324\n272\n4601456155100\n2000810\n1000000\n1\n2116066263570\n27509373740\n240792806\n72\n2743992\n240\n2575562500\n0\n182\n340181136\n170569\n354474756\n2\n516961\n36152268906\n76782193216\n1\n15352696836\n93971676304\n38025\n65792\n1\n386515600\n0\n2105662656\n2\n49670814030\n2\n254258970\n5484964\n185340996\n1681\n121\n74089056\n2482200\n20736\n4\n4327598162944\n38025\n1308736\n0\n18090\n2144035383756\n2416667675532\n19247261490\n110\n42\n1825201\n3768789347569\n100\n1\n22201\n13459596240\n211979040\n119902500\n224202\n2557698117680\n2220135760144\n32225096682\n56\n169\n169\n380\n169\n0\n6617756\n3107560770\n5075630503056\n659758185025\n7415965456\n45796\n132\n64\n53361\n178997641\n29756\n201152\n1561707600489\n228176130\n327284281\n58474736040\n35106017956\n306\n1436179337649\n4862025\n1374587415184\n169\n100\n24336\n1331789857024\n302551236\n70728100\n62173225\n90\n49\n199459129\n5240203144201\n649748038830\n46780066369\n320786010\n1713850157881\n11516294596\n52387885456\n12321\n529\n54167674860\n21576025\n1806\n3966408820640\n289\n932190\n0\n0\n166397100\n625\n182\n3428052\n0\n41006\n53824\n57049561350\n20\n1452638882\n1406\n4034072\n2\n1\n2186067224760\n465674820\n33512061969\n3169058634225\n131985632\n0\n124512122\n4\n60025\n1571712288720\n4\n48400\n59780\n13142444240\n97344\n812\n444471806\n5752802\n364657216\n36\n3375180748722\n42\n1666231580\n132\n100\n2018308931584\n2\n2884902\n449652025\n15346806\n2674860\n36677037656\n1070930045306\n82500889\n13827242\n807014464\n57840\n230508306\n425756\n82919236\n0\n0\n438860538690\n1531406\n1\n17822\n144\n41922562500\n748225\n0\n13572\n210\n56\n246929796\n49284\n0\n129231424\n3969\n361\n484\n0\n112307006\n2\n484\n6381293689\n42\n35532\n56\n12\n28027112569\n5959271910244\n4\n5625\n744769\n127836942\n1\n429025\n4763306\n22655969361\n3731746923529\n5256\n529\n65792\n160000\n11677287782\n6006\n44944\n4526256\n35721\n6809797962\n4532641\n116068302\n1\n333518906\n0\n1903020\n44521\n6972\n651908556\n2246656243225\n14161\n1394275600\n9600702\n1\n2409140889\n5335864209\n532900\n16025028100\n17897355961\n2827702888506\n722264569182\n40791678930\n306\n289\n0\n8010\n942517684722\n2896915329\n970225\n100\n2\n543006506\n81\n5863662\n3958110\n412922720\n9312\n524900\n0\n289\n42\n207345600\n0\n3632836\n28392\n4000794039402\n110\n600\n9796644484\n835502941422\n3624334501592\n25584642304\n7726673702\n35439380262\n4\n862380607380\n97871681180\n2191841757169\n1\n1\n1514200389312\n5535618431310\n384367140702\n1\n975156\n2184484\n204266937681\n1521\n1\n16\n1851760310436\n21316\n39601\n18502902\n2674854961\n0\n1\n1\n415059129\n0\n6889\n1\n5826744238225\n0\n15006\n5761872649\n289\n3491292\n34142170176\n1\n549822\n1\n45582\n0\n72\n252222042\n7921\n416670\n990311580736\n21170\n2\n66170090\n0\n0\n23336381406\n1223236\n1215506\n222099409\n5529855769\n40401\n8092801600\n3527528449\n2735716\n1190\n390625\n1\n62001\n3099553908025\n25760\n164891281\n339996721\n110\n73393489\n139502\n10506\n42230\n62927980170\n476199684\n210\n54289\n6269709942\n59494771140\n18837013504\n6909516252\n0\n20389126890\n653927184\n242783142\n1\n4\n2504798431680\n1075840000\n338141668500\n16129\n1454436\n792407079756\n393756\n4286957827009\n0\n42\n99856\n0\n0\n506\n529\n31506\n129948600\n132\n2016400\n39060976682\n32400900006\n529\n354607149121\n2\n380\n1622788088769\n421008842\n2756\n132\n5290650920022\n49062\n0\n1721344\n293162884\n3822025\n2600001452304\n18117025400\n38332157796\n35721\n20449\n15006\n143316812\n229537650\n1365288255480\n142506\n56\n160617602\n106929\n278572790\n22936193809\n238115761\n144\n86099841\n194937444\n34467593370\n2809\n29097877561\n1378038862201\n182\n810916459081\n361722856356\n75900\n1\n32050487702\n2\n27060\n463153441\n413634244\n5178931102802\n23636756306\n20449\n72\n10100\n4\n432993672\n4336722950400\n2626955361732\n3751293017450\n177475684\n1556256\n121\n128352018906\n5550\n5402\n2711077506225\n1\n1243091306\n2896804\n0\n130736356\n144\n4131444466620\n4\n61326312522\n632525153910\n3379192474564\n1068122\n3821897862\n475495062282\n6094612624\n3850289668440\n322723260\n42\n4621238036142\n581585451306\n3609937300272\n255040900\n4312439919522\n1\n173462070\n56\n9\n197908624\n8836\n4237684506\n5312043115369\n12823637322\n49837213806\n1879032325284\n98704225\n23207780281\n1262842832\n1\n336428964\n81\n0\n30\n420\n28224\n937992\n54228496\n820027141362\n61504\n13832464932\n437582\n3960100\n7249841316\n1178329789081\n1078090771032\n22500\n2209\n18496\n462\n1\n4510594401856\n1296182\n0\n2984256\n1840520928964\n1612900\n717623732\n1\n41665586762\n272484\n17213440000\n132\n4267812912\n47953116324\n27254212832\n0\n5111734376310\n600\n33913800649\n0\n0\n443628906\n22052\n289\n552\n4615787988282\n18632\n25600\n53452284006\n3351396585124\n1\n1890625\n8047704681\n3225939288100\n2052056\n2929232\n9047148572\n533194281\n2990558596\n25600\n2797498767756\n140981851100\n90601\n5354596\n51984\n552\n182\n380\n1315929032460\n2069000313604\n43890\n92342490\n1\n509495184\n6262506\n5363856\n795030806025\n9\n76134350\n201995156\n53592\n3122723697129\n646100142\n385020\n5405625\n5992704\n90\n59780\n4\n0\n5428900\n49\n1531901290000\n342\n45514595622\n4\n0\n2085059468702\n16204144320\n29829089521\n354757225\n12\n246699962721\n52667725530\n54522\n4\n8625969\n75900\n2876416\n483426098232\n642402\n0\n411379806\n15252\n107609502\n51302\n930\n332041284\n2304\n387506\n210\n42\n13689\n50041018902\n2879288281\n31329\n21040807970\n1830460173025\n14161\n26406\n4764552539010\n2661792\n667808964\n1074332\n1066866916556\n5299148752144\n165817129\n4\n49\n259770134652\n4\n922070460025\n24492\n5980470\n45796\n2\n14859853801\n31786432656\n529\n87243732270\n4346958124096\n225\n41209\n9216\n93025\n5510174085376\n36864\n654319210000\n1\n69031172\n514541172\n16\n842308197302\n1192033790809\n12769\n500036682\n4\n14280\n477182180\n36\n34305892742\n475033168302\n256\n2\n1\n256\n0\n3866135130001\n15376\n1078910154436\n2945776654602\n38003942916\n18769\n61676977452\n0\n19786079569\n4904010\n3517500\n6042801320521\n21946200306\n2585664\n34969\n39800\n484\n5875448764556\n2\n40253600689\n13572\n0\n1\n3625216\n134142724\n2116\n5605780728409\n3781391376400\n11342\n306\n13900527900\n37024686724\n13340\n79959364\n11060834070\n994613906\n29230242\n2\n1369\n50176\n7569\n269501472\n54552996\n1358390\n4\n1903020\n1640\n3083123353806\n5977047040000\n4524129\n36481\n0\n132\n2284428202056\n4427836498806\n394384\n2030625\n32708711880\n219970380100\n1582215553182\n72\n4\n324\n69989956\n3350730\n1\n441\n47735258256\n93942\n5040440333556\n1612102801\n16\n35162062740\n1024\n17556\n12454783201\n3693107688516\n4543299216\n282917610000\n14161\n3474496\n5660681406\n57840\n0\n2\n2839225\n22801\n5068344936102\n169585506\n56\n36481\n1688700\n1407782\n2055216890\n196\n3511446867110\n9535424850\n5288233747456\n3354784320\n420\n1263376\n38612\n602884696392\n2553604\n62359079524\n29929\n36\n850640979204\n25\n576\n72\n484\n635303846540\n10875882656\n49729\n2204561254952\n4422\n196\n42642\n6189770805625\n16\n432531144241\n38025\n2953730324164\n64\n188702925600\n53607067024\n108908580169\n0\n53406978900\n59119734170\n0\n12422551392\n569490496\n285965010\n0\n25122\n1008016\n11342\n28056\n578402500\n56882\n100\n25\n3782\n56882\n685654225\n3192\n1\n1637120\n3790809\n2\n16072534506\n47899699600\n389489960\n256\n252921312\n4501154736056\n420\n304397809\n18769\n1376821797780\n1\n624890\n2550\n576\n2980341056\n44382480912\n39461822500\n9458700\n5528219904\n5392366689609\n1828545882\n0\n18632\n30625\n1580049\n75881521\n38420312121\n264761712\n156\n3256907800790\n132132\n373932\n6195121\n272\n249008400\n17556\n6724\n34596\n36\n20473603396\n33243681912\n182\n9702\n2800602\n0\n333062500\n24113275940\n1482\n1\n1403428792896\n4973423006\n7569\n40000\n16767271632\n13225\n19760206041\n356133512\n225\n4970\n619487210\n4\n1\n636804\n420\n1\n2140369\n20736\n20\n2267189706961\n307470\n306\n3537929880\n3378931446969\n2029592601\n4196895120056\n399580110\n1208900\n3892729\n45958998780\n319051044\n500282689\n2498786370025\n2\n4160\n462\n53034806\n14400\n324933060841\n234656442\n3763515756\n21904\n5667982466256\n5965806\n0\n5776\n510320925056\n4382742\n5624137940202\n12809241\n58330944324\n28085234982\n420475530\n576\n1\n169\n37442\n143641\n361\n21158320681\n29584\n22553281506\n1\n210\n26519796801\n2\n3508926943369\n1\n73025570\n702\n45582\n4\n12656\n32729841\n27889\n177358899600\n4651014137641\n342\n12432\n2341605383130\n2\n10506\n4\n16512\n513543582\n90\n1907724489616\n3131130\n6093492\n51076\n242556\n171439742\n1020877848225\n11130\n17296458256\n3068426614556\n15452761\n6128984035362\n4696840622\n529\n65280\n324\n3083342843025\n49\n26768722932\n1\n2242506\n2401\n126405049\n30340936782\n72\n81\n419246100\n2\n2692881\n4\n1156\n101761\n40040010000\n34680309302\n0\n1\n4553752842\n146660276406\n0\n5155096401\n30625\n21540845824\n625226257656\n182\n4\n90\n323226462\n9\n48317095532\n4890732\n161202\n1\n18496\n4564632\n2\n4\n3176238622200\n26244000000\n30\n25\n2689600\n187375032\n731025\n20736\n44800802244\n58530850692\n26896\n45369\n342\n5503716\n34920957512\n237668472\n234962912\n3433609\n21025\n0\n62304403272\n179661114360\n25\n6320\n0\n6025718250\n27390\n42\n416506872\n6084\n4424712\n0\n4308609600\n5818197464836\n218714521\n22834062\n75160230\n22350\n10712\n2512049068080\n324\n92447922756\n1482\n420\n2\n10302\n3755844\n440601090\n60127208472\n2500\n123858948096\n3816918291942\n1086658260\n244781670\n2474635744506\n4\n6084\n25355944460\n30580566129\n4\n45156\n0\n180721062769\n6170256\n42\n50625\n6\n361285056\n4\n600\n264315775572\n47692836\n21396960729\n40804\n3411409\n11772\n2062096\n3671056\n484\n419471361\n772378201350\n225\n56\n441\n13688064016\n240\n506\n1\n4921092650\n2\n3710059600952\n319790\n0\n541469630\n3986012\n0\n197880489\n37015056\n30800\n41396356\n305288256\n273356622\n1672449005824\n226607862\n216943441\n21316\n61591078800\n682023267409\n6806\n584624041\n3675722942306\n49619121762\n260467321\n12\n994009\n1\n133056225\n25\n13402461361\n48236019129\n31329\n178506\n1484329207230\n734762342\n22952\n4\n2944581696\n1587534480676\n16384\n126194747121\n2\n484\n17164449\n133088160156\n7396\n3132900\n33124\n596751612\n7148871601\n30625\n7887672\n35850156\n0\n1\n363531422\n671651548392\n557575077390\n6039306\n5407975830530\n4\n3228966409556\n321845174596\n3036306\n4030599169\n241056676\n55808392644\n3802572225\n4\n156600196\n3495030\n357071380470\n59811794660\n18627856\n244530\n81\n51984\n0\n218522306\n121\n3994002\n1342718943806\n6\n1\n4330255098402\n4891533660\n0\n1\n2043857662860\n2712164328225\n8190\n2\n1\n45778756\n45138242\n60863402\n44843568169\n2300445625284\n1167859536300\n4763306\n285626900\n72\n930\n6547479972\n241118784\n12306796096\n3063620102400\n729\n9266276382\n6054060\n4717584\n90\n34410\n2289250702729\n34099760\n10052070\n2\n4\n90\n342\n5129015561289\n3861131044\n2479050\n184375662\n4360092961\n0\n37001984881\n12100\n22052\n68831912\n5574321\n16693027602\n1722\n3457740\n6889\n8643978729\n335054720\n37897966276\n5144440914496\n5563444461720\n2373140\n4\n2862\n1\n142336830\n410953984\n1025156\n324\n0\n121104\n4\n11772\n2\n272088989262\n5911637880996\n21462\n4403635098256\n36205146452\n2416470\n43472\n169\n55313865721\n17057143609\n340531662\n24806\n324\n156633101361\n16\n10153782\n1797652125990\n295358596\n380\n14762\n363626761\n28955161\n38025\n25200400\n6320\n4\n4346501184\n361\n66904220\n1\n343323841\n144\n26571771072\n0\n8583837201\n29008996\n5336100\n574273296\n382664104202\n240\n156\n4\n0\n2994630\n4\n5996050883172\n5005133193440\n2\n256\n32400\n44386273080\n465124\n57113352256\n8649\n6411204900\n3083536\n552\n1360722\n420\n11265381182\n5873352\n4\n230144070\n1411344\n0\n7238436241\n16135731702\n3339180612306\n2\n400\n2178576\n0\n2\n322705296\n4076361\n7731245256\n227421480\n2\n13689\n5033292\n64\n1387684\n225\n132\n3080\n3942210\n576168012\n0\n434639104\n1647372\n1348860412620\n25\n718256\n2438282\n14884\n4609609\n29637516180\n1936\n2\n961\n49\n737874987012\n30334666392\n8638401249\n2553604\n1358286522480\n17131321\n773450771060\n3854485140\n4771854569306\n503329234849\n1824120360000\n5942254530276\n957057193849\n52951762656\n1074332\n3882870\n6930895504\n35555627844\n159173869156\n4\n3751969\n3319684\n3874564516\n36\n210681\n255530\n600\n30277044009\n48841\n8742\n2715904\n79548561\n292837656\n49245306\n6642\n484\n22678854025\n1760741897970\n41412\n6\n434451492\n30625\n81\n2528100\n1113025\n34377980569\n1\n1679616\n160244893636\n4\n1071264330361\n1349082\n0\n1398306\n4\n505196835984\n273488906\n2383202656406\n4435236\n404653456\n2\n28900\n49\n400\n37442\n40085045156\n360271251076\n210\n995006\n5250972\n10201\n2\n702\n0\n954395155692\n3759721\n361\n28392\n1377253635660\n9025\n30450\n12\n316252872\n576\n156\n30911441672\n169\n2237067636489\n121801\n342\n5212089\n1\n100\n110113542\n0\n2218610\n529\n465545352\n395512656\n5062909508281\n2639949043264\n21756\n462\n5499836399929\n62166446224\n576\n4133654193321\n394384\n1328902881180\n25440\n49292880400\n6468019776\n12769\n4\n4692\n6889\n441\n2765569\n2\n977132\n0\n2\n4194357248169\n395353572\n36864\n10302\n3796652\n26732\n22306617316\n484\n121\n3540\n0\n1560\n1\n8520213025\n64\n6958229056\n0\n403949702\n553096324\n4763007252192\n30\n0\n301786384\n4\n650\n4057005668401\n35532\n5742136271900\n5719272\n2250000\n40621999401\n81\n412171704036\n180022852681\n1605622238292\n51984\n49\n576\n1487180\n268075129\n117440569\n5875776\n441\n1418481\n23019868729\n54326985642\n4\n290958306\n462\n48400\n61256\n2\n21025\n361304064\n905352\n0\n1647372\n1\n4\n23571025\n18769\n289\n4\n306\n486886290\n30663906\n6642\n683665609\n1\n182\n2\n2210435969762\n5041\n1\n32400\n73796690\n3659569\n72522256\n22952\n268042384\n36\n5700\n49\n1161006\n2382392\n18090\n169\n272\n4\n5549336624209\n32680504506\n156\n5662370041902\n1\n420\n36859008169\n279324369\n54756\n596360820\n18640031312\n252222042\n4\n266946582\n1\n267289\n342416520\n54756\n36517849\n29692286910\n255632132\n3364920634384\n53130\n10491597612\n3721041\n8721318544\n309460872\n196\n112975641\n14400\n1\n3157990416\n837957756\n28224\n793406168022\n5329\n342\n4\n0\n42\n88934330\n1\n40602\n1246443025\n45909490225\n48620\n77314861080\n127814330\n23892544\n650\n6724\n225\n248550990\n0\n2756\n67749361\n2\n138045687025\n68898300\n8930\n3249\n90\n46300280625\n59292\n2352\n1290029146230\n1282290126306\n232516752\n4\n81\n100\n0\n62878571536\n12100\n506\n16731163801\n41820\n506\n484\n151321\n977954855056\n12125203110\n36\n9921853272\n3333465305284\n20734362\n4053997010116\n217156\n4988522\n552\n156\n1945812965776\n4\n39765636\n623226260\n293813881\n54015150\n11881\n289\n436260\n0\n19044\n6007401\n6\n422898660\n426112806\n110659880\n11803736025\n24800400\n48400\n35532\n3844\n4648648761\n236882881\n182\n5028391396056\n6\n16\n502681\n0\n1354896\n72\n813604\n361\n4441755962\n280177382\n39006\n497562355161\n1738961777809\n169744\n1600\n272\n388582656\n156\n1545049\n1\n3422\n6661561\n2\n36\n6222530\n56\n522945424\n2704\n289\n66438801\n58011072\n0\n16\n4815830\n1\n499321717129\n38416\n2\n545729400225\n4\n2635752\n490091044\n2\n36\n9\n4370296866150\n4400005469161\n7699887001\n37249\n0\n5086269836176\n2\n1559611336336\n293676769\n19352704996\n0\n132\n45479827600\n15596138340\n1\n1491088873302\n144\n56\n26406\n5030355625\n512184792\n7198489\n57537137161\n361\n0\n77818862\n3566179806\n34040\n600\n900\n261307225\n1\n21904\n38863588182\n5837345923600\n604987812\n5936079069649\n4846602\n56400100\n0\n0\n849999178116\n268508439684\n5784025\n56\n0\n225\n3197686063056\n260100\n1\n2750708492676\n1373584\n32580\n341233256\n382542\n37174924864\n156\n131044\n9702\n1482\n2\n2212510477401\n36\n4\n363378906\n123520996\n1\n576\n246364416\n111756612\n153264400\n235361622\n15560067600\n31152\n45582\n2199289\n149866564\n5189284\n4\n36290\n1115136\n1358024307649\n72403081\n0\n1746696605502\n453602\n4831896394806\n38025\n6241\n2\n205391892\n1360045764100\n1\n6165289\n5557806\n1\n56\n191255070\n101294160\n39402\n279841\n9\n240\n1\n0\n1764\n61470524556\n0\n2427364\n58011072\n289\n241540795024\n3073009\n0\n1\n54756\n3481\n690935831850\n1265625\n554908692\n2\n2\n35532\n888968008201\n9\n2624400\n2\n100\n279841\n0\n1699112\n2059269485240\n10227276900\n262245636\n2469612\n7174005300\n4\n4674101309089\n542098089\n272\n13924\n1920060942\n2\n3499192995769\n0\n1084351970\n981090\n139502\n174636225\n2219979311640\n371806038081\n576\n24786723844\n527781702\n9\n197829248400\n576\n2129190221450\n0\n1\n5625\n4482235550\n90\n64\n0\n583198350\n205908150\n26035506\n462\n25\n1798207245756\n302829604\n1809538826481\n3630459606752\n24547070\n8227034209\n4519876\n2\n100470552\n6068916009289\n81\n2614021256\n4886310\n24964\n54029850\n0\n59348511840\n164711556\n21766428690\n83670190564\n529368064\n1651225\n1\n380\n3380030772196\n14280\n3543806\n4\n2978921820\n1\n15750\n3207681\n48620\n230435521369\n429680\n3213056\n2\n3091972318400\n3381921\n1080962884\n0\n100\n407272761\n2221500820900\n72\n2452356\n1\n255376380\n1378276\n32480870400\n1347694614506\n1\n1\n225\n3417468000960\n240\n1954404\n21462\n702\n191844\n1521522\n2925793145025\n0\n1482\n2\n2\n1225\n0\n0\n5189630261776\n4692\n506\n369056\n156\n3775249\n5403188674576\n280657842212\n5564881\n454329225\n2\n12\n4369763798404\n41959425600\n23104\n242798724\n39006\n2476356169\n4598880\n6239254622500\n9653449\n100185543441\n70048530\n5603571925782\n6246657946892\n1\n441\n4490161\n20\n302289386672\n3541924\n800130\n4033060029504\n144\n1\n19303628906\n5076736745082\n1158852\n257795136\n15314557504\n10254904022\n35170830\n279123849\n289\n0\n4\n56761871256\n689520149502\n338278916306\n0\n886014756\n838623681\n52497270\n144\n0\n182\n0\n314743081\n9\n0\n81\n41820\n18225\n15129\n20\n90\n900000000\n0\n608400\n36\n6972\n210\n5242188024306\n1347823477764\n600\n380\n225\n219492\n1\n313254601\n6040864729\n42\n0\n9702\n22650\n222312\n53559613470\n1\n225\n2940710522500\n22404850806\n0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100\n1207244\n255313\n56\n83269\n638451\n347617\n29369\n233941\n61\n7937\n85\n6\n80\n2485\n7\n6394\n92\n52190\n278\n14467\n9\n7\n2018983\n2607\n916\n18515\n3600328\n1\n1\n11995\n743468\n3403\n507\n149\n36\n38208\n47423\n974\n81\n494913\n192\n85\n9\n8492427\n655\n9912940\n40843\n4716\n46470\n435483\n26548\n8\n9762\n346\n3718\n75600\n7343\n5965\n54811\n67237\n746552\n36\n8979\n81771\n7\n51885\n652\n383899\n596\n6\n98\n4863286\n3509\n27\n7\n220578\n26441\n4\n6512222\n679\n1\n4190\n4656091\n7\n5\n2963\n9659536\n682\n10920\n59\n6150025\n75\n24638\n932\n2760\n6010581\n4276\n5112517\n90\n6",
"output": "91089879721\n4074013584\n196\n433347489\n25476150156\n7552305216\n53904964\n3420495225\n225\n3936256\n441\n2\n400\n385641\n2\n2555202\n529\n170237256\n4830\n13079072\n4\n2\n254768019770\n424452\n52441\n21423012\n810147606724\n0\n0\n8991002\n34546541689\n723350\n16002\n1369\n81\n91240704\n140552880\n59292\n400\n15308617984\n2304\n441\n4\n4507581210342\n26732\n6141648715225\n104254310\n1390041\n134966306\n11852785770\n44049769\n4\n5956040\n7482\n863970\n357210000\n3369060\n2223081\n187758506\n282542481\n34833743044\n81\n5037780\n417895806\n2\n168246841\n26569\n9211104650\n22201\n2\n600\n1478221919862\n769129\n42\n2\n3040915880\n43692100\n1\n2650564711080\n28730\n0\n1097256\n1354948380506\n2\n1\n548340\n5831664733456\n29070\n7452900\n210\n2363924700036\n342\n37939440\n54289\n476100\n2257941996025\n1142761\n1633613740641\n506\n2\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
divide-apples
|
Solve the following coding problem using the programming language python:
N boys are sitting in a circle. Each of them have some apples in their hand. You find that the total number of the apples can be divided by N. So you want to divide the apples equally among all the boys. But they are so lazy that each one of them only wants to give one apple to one of the neighbors at one step. Calculate the minimal number of steps to make each boy have the same number of apples.
Input
The first line of input is an integer N. 2 β€ N β€ 10000
The second line is N integers indicates the number of apples of the ith boy. Each integer is positive and no more than 10^9.
Output
A single line contains the minimal number of steps to make each boy have the same number of apples.
SAMPLE INPUT
4
1 3 9 7
SAMPLE OUTPUT
8
Explanation
Here are the 8 steps starting from (1,3,9,7):
(2,3,9,6)
(3,3,9,5)
(3,4,8,5)
(3,5,7,5)
(3,6,6,5)
(3,7,5,5)
(4,6,5,5)
(5,5,5,5)
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
n = int(raw_input())
a = map(long,raw_input().split(' '))
avg = sum(a)/n
p = a[0]-avg
b = [p]
for x in a[1:]:
p = p + x -avg
b.append(p)
b.sort()
mid = b[len(b)/2]
total = sum(map(lambda x:abs(x-mid),b))
print total
```
|
vfc_81113
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1 3 9 7\n\nSAMPLE",
"output": "8\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1 3 9 7",
"output": "8\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
good-points
|
Solve the following coding problem using the programming language python:
You are given non-negative integer N. Find N pairwise different points on the Euclidean plane with integer coordinates in the corresponding order and the following properties:
1) the distance between any two consecutive points in the order is equal for the all pairs of consecutive points 2) the angle created by any three consecutive points in the order is equal for the all triples of consecutive points.
The last and the first point in the order are considered consecutive.
Input
The first line contains one integer N (0 < N β€ 100)
Output
Output "NO" if it's impossible to find such N points. Otherwise output "YES" and then N lines describing points - one point per line. Each point is described by 2 space-separated integers - its coordinates. Among all possible solutions you should choose the one with the least distance between consecutive points. The point with the lowest first coordinate (among all of them with the lowest second coordinate) should have coordinates (0, 0). If there are still more than one solution you should choose the one with the highest point to be as low as possible.
SAMPLE INPUT
4
SAMPLE OUTPUT
YES
0 0
0 1
1 1
1 0
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
'''
# Read input from stdin and provide input before running code
name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
test=1
for i in range(test):
a=int(raw_input())
if a != 1 and a !=2 and a != 4:
print "NO"
break;
else:
print "YES"
print "0 0"
if a == 1:
break;
if a == 4:
print "0 1\n1 1"
print "1 0\n"
```
|
vfc_81117
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n\nSAMPLE",
"output": "YES\n0 0\n0 1\n1 1\n1 0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "32",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2",
"output": "YES\n0 0\n1 0\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
little-achraf-in-who-wants-to-be-a-millionaire
|
Solve the following coding problem using the programming language python:
βCan you answer this million dollar question ?β said the presenter to Little Achraf.
βYesβ, he responded.
βOk β¦ here is the questionβ.
We define a sequence A of strings of order L as follows:
A[n] = \sum\limits_{i = 0}^{L-1} A[n-L+i]; n β₯ L+1; where addition refers to string concatenation
A[n] β [a-z A-Z 0-9]; 1 β€ n β€ L.
Now, given some constraints of the form βThe nth character of A[x] is equal to cβ; you need to calculate the number of possible sequences (possibly none) that satisfy all the given constraints.
Input Format:
First line contains L and C, the order of the sequence A and the number of constraints, respectively.
Each of the next C lines contain n, x, and a character c meaning βThe nth character of A[x] is equal to cβ.
Output Format:
Print a single number denoting the number of possible sequences that satisfy all the given constrains modulo 10^9 + 7.
Constraints:
2 β€ L β€ 100
0 β€ C β€ 10^4
1 β€ n β€ 10^{15}
x β€ 10^{15}
character c β [a-zA-Z0-9]
SAMPLE INPUT
2 2
1 3 A
3 5 B
SAMPLE OUTPUT
1
Explanation
There is only one sequence that satisfies all the conditions and it is:
A[1] = "A"
A[2] = "B"
A[3] = "AB"
A[4] = "BAB"
A[5] = "ABBAB"
The first character of A[3] is A, and third character of A[5] is B.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
import sys
L,C= map(int,raw_input().split())
f = [1]*(L+1)
f[0] = 0
ind = L
while f[ind] <= 10**20:
ind+=1
x = 0
for i in range(ind-L,ind):
x+=f[i]
f.append(x)
for i in range(0,L):
x = 0
for i in range(len(f)-L,len(f)):
x += f[i]
f.append(x)
def fun(a,n):
if a <= L:
return a
ind = a - L
sm = f[a-L]
while sm < n and ind < a:
ind +=1
sm += f[ind]
return fun(ind,n-(sm-f[ind]) )
fixed = {}
for i in range(C):
p,q,r = raw_input().split()
n = int(p)
x = int(q)
c = r
a = x%L
while f[a] < n and a < x:
a+=L
assert(a<=x)
assert(f[a]>=n)
# find nth char of ath string.
l = fun(a,n)
if l in fixed:
if fixed[l] != c:
print 0
sys.exit()
else:
fixed[l]=c
#assert(len(fixed) <= L)
print pow(62,L-len(fixed),10**9+7)
```
|
vfc_81121
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 2\n1 3 A\n3 5 B\n\nSAMPLE",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 11\n72 11 L\n1 3 Y\n2 5 d\n1 4 v\n70 12 B\n5 6 C\n72 10 f\n141 12 s\n1 3 n\n12646 19 L\n1 5 x",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 4\n178 12 q\n3 8 7\n1 9 1\n1 1 u",
"output": "0\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
monks-love-for-food
|
Solve the following coding problem using the programming language python:
Our monk loves food. Hence,he took up position of a manager at Sagar,a restaurant that serves people with delicious food packages. It is a very famous place and people are always queuing up to have one of those packages. Each package has a cost associated with it. The packages are kept as a pile.
The job of a manager is very difficult. He needs to handle two types of queries:
1) Customer Query:
When a customer demands a package, the food package on the top of the pile is given and the customer is charged according to the cost of the package. This reduces the height of the pile by 1.
In case the pile is empty, the customer goes away empty-handed.
2) Chef Query:
The chef prepares a food package and adds it on top of the pile. And reports the cost of the package to the Manager.
Help him manage the process.
Input:
First line contains an integer Q, the number of queries. Q lines follow.
A Type-1 ( Customer) Query, is indicated by a single integer 1 in the line.
A Type-2 ( Chef) Query, is indicated by two space separated integers 2 and C (cost of the package prepared) .
Output:
For each Type-1 Query, output the price that customer has to pay i.e. cost of the package given to the customer in a new line. If the pile is empty, print "No Food" (without the quotes).
Constraints:
1 β€ Q β€ 10^5
1 β€ C β€ 10^7
SAMPLE INPUT
6
1
2 5
2 7
2 9
1
1
SAMPLE OUTPUT
No Food
9
7
Explanation
Initially, The pile is empty.
Chef adds a package with cost=5.
Chef adds a package with cost=7.
Chef adds a package with cost=9.
Customer takes the package on the top i.e. cost=9. Now package of cost=7 on top.
Customer takes the package on the top i.e. cost=7.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
stack=[]
for _ in range(input()):
n = map(int, raw_input().split())
if len(n) == 1:
if stack == []:
print "No Food"
else:
print stack[-1]
stack = stack[:-1]
elif len(n) == 2:
stack.append(n[1])
```
|
vfc_81125
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n1\n2 5\n2 7\n2 9\n1\n1\n\nSAMPLE",
"output": "No Food\n9\n7\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
sachins-love-letter-a
|
Solve the following coding problem using the programming language python:
Sachin wants to give a love letter to his girlfriend on valentines day. He
is having a circular piece of paper of radius "r".
He wants to use rectangular piece of paper for letter writing whose length and breadth are integers. In how many ways can he do that.
NOTE : Rectangle of a * b and b * a are considered as different rectangles by Sachin.
** Input :**
12
NOTE : You do not need to create a program for this problem you have to write your answers of given input in given code snippet
To see how to submit solution please check this link
SAMPLE INPUT
2
SAMPLE OUTPUT
8
Explanation
No Explanation,, you have to understand yourself.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
print 424
```
|
vfc_81133
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "12",
"output": "424",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "23",
"output": "424\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
sum-of-numbers-9
|
Solve the following coding problem using the programming language python:
Given an array of N elements, check if it is possible to obtain a sum of S, by choosing some (or none) elements of the array and adding them.
Input:
First line of the input contains number of test cases T. Each test case has three lines.
First line has N, the number of elements in array.
Second line contains N space separated integers denoting the elements of the array.
Third line contains a single integer denoting S.
Output:
For each test case, print "YES" if S can be obtained by choosing some(or none) elements of the array and adding them. Otherwise Print "NO".
Note that 0 can always be obtained by choosing none.
Constraints
1 β€ T β€10
1 β€ N β€ 15
-10^6 β€ A[i] β€ 10^6 for 0 β€ i < N
SAMPLE INPUT
3
5
3 2 0 7 -1
8
3
-1 3 3
4
3
4 -5 1
5
SAMPLE OUTPUT
YES
NO
YES
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
import math
def yesno(result, arr):
sums = [0]
for n in arr:
new_sums = []
for sum in sums:
new_sum = sum + n
if new_sum == result:
return "YES"
else:
new_sums.append(new_sum)
sums += new_sums
return "NO"
testcase_cnt = int(raw_input(''))
for _ in range(testcase_cnt):
arr_cnt = raw_input()
arr = [int(element) for element in raw_input().split()]
result = int(raw_input())
print yesno(result, arr)
```
|
vfc_81137
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n5\n3 2 0 7 -1\n8\n3\n-1 3 3\n4\n3\n4 -5 1\n5\n\nSAMPLE",
"output": "YES\nNO\nYES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "50\n13\n34423 -366726 -147520 -584399 615107 415987 -236590 906765 385780 -12338 -827677 -83330 3716\n-481201\n15\n868821 380788 280355 754124 666647 183969 -593202 203144 346136 426627 -154087 -200659 744812 636205 -599783\n3943897\n14\n258556 256420 242883 673605 -358632 -748063 -576262 -431883 191680 309948 211448 677049 57373 25117\n1897460\n15\n-31776 -509105 -440459 581686 18186 90441 -964639 -404036 -143884 -961513 556132 -70039 -353796 -603145 -232501\n556132\n13\n956611 -781012 74360 -503080 245009 992350 -855549 83091 -579184 -457865 -526677 776900 870395\n-1108406\n14\n-493552 -569485 -336469 797642 397339 -168164 139851 -878896 878993 382683 125961 946530 707148 -788176\n65231\n15\n-409580 -992159 901807 233245 -882328 409062 -540400 -687166 583798 355527 107684 747034 -150178 -209469 6770\n-64137\n14\n-767886 -134662 -232607 317873 541241 578669 628802 -588319 -901754 804494 -878411 396070 -535852 620342\n468342\n13\n645087 -794303 -476793 -802503 591524 -573731 -836534 -625021 92188 -977215 -332461 788967 488088\n-157416\n14\n547213 846682 -449248 171943 830043 -863148 256090 -292620 -15349 351459 -144957 469739 957972 -908296\n138123\n13\n-432348 375246 189234 38125 -661041 -184858 297530 -196234 -668317 797905 -934292 863577 -252959\n617040\n13\n372152 -401237 -663708 22238 -976731 -49973 -231132 713181 885335 -649983 -760546 -61726 -44624\n-1871571\n13\n254900 -882095 -728410 979424 809727 656746 -53007 509482 723920 637911 -462746 635237 -65158\n2076384\n14\n252160 -819568 552939 -273690 -552087 -975122 -449169 971785 68668 712368 -237274 480224 -211362 606371\n950255\n13\n529223 452411 56020 17932 -29994 599988 -992260 689431 -528515 606394 208738 -965113 -258489\n-623614\n14\n-170501 167511 -76718 960273 -712183 834747 850254 -248070 445816 549965 -945814 -933536 -949334 -955215\n-487720\n14\n144638 -15372 905274 170422 -959739 -3064 -74195 -967662 -884367 532167 516533 -317298 -774127 -485351\n-2134882\n15\n625506 349266 546241 701232 -80987 873740 966909 -827422 -786755 -171027 279848 456222 257790 -515252 -671286\n1434774\n15\n-751600 -17914 -731186 324032 -204982 519577 -82556 -375399 -386306 979452 835695 621362 942040 -365084 700699\n1512062\n15\n240323 -740951 607436 -694364 -4026 661788 751590 80686 -637901 681874 -113592 -183035 367946 -747136 -631507\n-355116\n14\n-370486 851546 811312 357993 9200 738094 917931 355152 -667373 969898 52698 50984 490026 905198\n6130346\n15\n306314 -84863 675092 998983 -975095 923498 289503 426772 914356 -986206 367930 -588450 -157959 -532324 342679\n1920230\n15\n-969653 -386541 197061 53266 505458 -639411 -273831 930417 -177843 -256845 58827 -9903 17834 924141 809499\n-450819\n15\n-206801 365590 -382057 -717368 919326 846677 -894751 685701 -83114 -639436 275553 186239 521072 -244946 -30097\n-531967\n15\n-319956 -358495 -181761 37956 752957 389912 -823235 818370 -336386 695462 -325904 904481 -4455 -17077 -83657\n818370\n15\n282610 -372362 507706 690995 -384125 366213 840985 819955 -784024 -702542 -997981 605487 38486 434714 -571537\n1727475\n14\n347492 573003 806803 -428607 -788327 -796052 -785296 649223 498103 579049 -648748 -394770 756002 -650988\n-991543\n15\n688169 -695973 -220533 538561 466981 -721025 -562734 -898119 -226256 -518208 -557477 -367804 993138 -378229 -755293\n-1824858\n13\n-737125 456997 951998 -98190 574402 883308 -442791 -721850 395375 -987705 716969 76794 400418\n781131\n15\n454187 627087 488131 831037 -751914 136519 286555 -427549 -983581 -844278 27048 948611 545508 31543 -691529\n-4652\n13\n301515 -423352 -979943 105817 218042 843728 -9064 -878663 -887976 811737 133224 -724238 489313\n-2645302\n15\n756257 -718395 -695794 -533563 382407 -222156 -426160 457351 -74793 505496 619274 343471 -916018 189719 638234\n-1612637\n14\n957091 248371 -208649 6177 709113 821205 509074 -685935 -290178 -986033 -617075 -749735 166941 144356\n239596\n14\n-891439 -487276 354015 264625 -651293 -480393 -325322 828685 963446 452135 -846380 445582 -470685 790216\n-168072\n13\n-719235 -959510 -873716 -439994 877059 -336626 -854972 -983147 289052 512862 773291 -314566 908268\n-1181841\n15\n924900 -949897 870202 -185341 -62982 966592 926509 600064 -901140 -631139 162971 -853856 174283 -788247 -539224\n-142307\n13\n999874 401938 -110949 481036 328841 944103 676337 725686 -666358 183247 282035 -925497 -712267\n2608026\n14\n-316645 127233 798604 -684599 519330 690128 763191 -582967 82884 -546330 745013 -824294 -461314 -278781\n893306\n13\n-832540 -365868 -867429 391374 -500206 692822 -812032 -755115 854127 -135009 -344207 -720433 44955\n-2392093\n15\n-207692 -220552 691332 645261 -557184 -681328 115299 -590321 774025 -828102 -128672 -320645 -59058 735547 -565748\n-1197838\n14\n294505 106486 -314711 465419 -13023 174784 985908 287196 -221536 -271477 -17672 432981 -693517 -135342\n715224\n14\n-678649 798669 -95796 -114154 -479776 44582 -190228 941237 434980 -357785 -329699 714924 67256 478266\n1085260\n13\n-878512 607183 438753 -68568 -245709 -30297 632277 426411 -107020 -650187 -622320 272632 -203745\n1399879\n13\n127958 -115510 -132066 205462 87470 22928 -712918 602191 583118 -847922 118718 428280 -460315\n-844984\n15\n-653418 760390 -630707 -591825 204097 -249786 -150421 175255 -593261 850495 -828336 -171913 701100 903921 462160\n-1258196\n14\n376849 300482 943606 343481 -920167 -249001 792136 -9975 -325765 888142 515797 -150826 -364504 85200\n600964\n15\n478926 -925951 -600461 859390 -981400 -693675 581379 243693 -789406 -791956 183768 -190234 586693 -870806 -215449\n-3009425\n13\n43754 -720257 216621 -143448 974445 -94055 602933 180081 959792 -573649 -478086 -535674 -194959\n962352\n15\n-763624 596464 104554 655039 -537000 960867 -778606 -318080 -479076 -588298 -696121 -679882 -128588 -804445 -985188\n-4379831\n13\n-885334 566241 -966272 782848 -273255 107931 -128928 555134 916391 775833 -374534 264045 -216801\n697093",
"output": "NO\nYES\nYES\nYES\nYES\nYES\nYES\nNO\nYES\nNO\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nNO\nNO\nYES\nNO\nYES\nNO\nYES\nNO\nYES\nNO\nNO\nYES\nYES\nNO\nYES\nNO\nYES\nYES\nYES\nYES\nNO\nNO\nYES\nNO\nYES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "50\n14\n261697 -473808 76873 375630 -92704 -220401 -170112 -411996 315580 -733150 -945375 992033 -606092 -953552\n-3182601\n14\n421548 471916 222410 -794836 275101 -427464 -941660 944200 -29584 -472096 475473 -366987 590283 -200064\n-2082790\n14\n256130 -248917 292357 199423 -108646 -940999 90614 -653925 -21997 450550 -174529 209567 -651306 702967\n1460395\n15\n335581 -234397 363410 684223 -308270 452727 109366 190866 -16413 -550295 -216045 626887 823949 730657 597939\n501856\n13\n826778 -635225 763635 600570 598839 352060 426548 901066 -930272 -883061 358857 987396 -930841\n3552209\n13\n-881516 833610 692575 -631502 760839 -759895 19320 -206726 340925 609499 416771 216990 488166\n1462965\n14\n-279450 -674400 367828 463218 -677544 -487816 372683 272133 -928610 539792 662812 -765786 202486 315100\n-1793779\n14\n-322629 146691 341438 -979966 -536521 -967752 -597894 898060 -617844 -382814 -521671 618897 -727390 84027\n-4163262\n15\n-435557 196048 171094 864882 -295934 664143 922349 -680090 -626147 178058 -503983 -237328 -676467 -630319 193155\n1118397\n15\n96695 -326299 557327 301559 -311457 -59650 219906 -566679 528683 119477 435585 -492381 701807 607526 858381\n2074805\n13\n381059 60565 558307 86946 850947 98324 18260 362993 227055 982173 373026 820794 173563\n4448722\n14\n778900 156586 18866 -508647 -952820 -973252 678048 88979 343830 -270793 275176 305788 76273 -316521\n1182312\n14\n-660542 -413372 -17335 -953504 168259 418614 131108 559541 -814999 675354 839698 513854 -729299 -802701\n-277989\n13\n126020 -132625 -110686 -288200 -127544 151055 -944757 816086 -53875 -153716 -128821 -870311 255126\n-870311\n13\n187133 -595936 -859154 950597 -130376 -382823 -803986 -48632 455055 791606 987378 911957 -295403\n712361\n13\n108768 -687454 776842 -268300 -279475 -249576 218185 -670721 -65859 532301 339609 647979 -528774\n-494979\n14\n-320251 -173118 339806 -912124 -45223 886946 270091 250026 -479865 -594969 -416032 328271 -16875 819146\n737458\n13\n758462 279404 -616758 88865 45366 -877703 665839 823 -299582 316638 386483 943500 -361261\n88865\n14\n-85265 -943571 183648 48713 578105 -657960 812493 -218979 -126897 -290478 664423 537324 -430532 -978201\n270782\n13\n-297105 876493 -601103 -113997 -327998 -397732 -780603 484921 -458073 507654 904047 398059 63059\n-1680168\n13\n-785757 83622 -192918 -575846 -718256 -961110 767777 -651223 833421 673237 -101161 -642336 -116882\n-3333965\n15\n-776469 896123 -818598 -515551 -563753 -226496 578687 5312 258646 -225316 -755371 -869151 152819 -903266 -735976\n897864\n13\n54289 169892 -659341 784094 -729988 -419488 407968 -954553 -337656 -183985 -35152 -906524 892088\n406389\n14\n118011 -492848 38562 785700 717965 -687065 260117 737312 -87917 155418 -553782 -708459 973119 -855755\n973119\n13\n-273886 542755 -984229 -928385 145690 -928299 -370295 -608212 -555074 617628 382881 -618740 472557\n-582120\n13\n-652101 -36127 -676968 -836061 -650713 781784 337552 198309 898012 145286 -692759 788715 915804\n1197701\n14\n-673759 -897700 -277221 791068 558088 -842240 373775 -207999 603978 -119625 848883 -639239 440644 -316770\n-2690920\n14\n52941 -718671 -184936 -257943 -39051 68803 -593826 145599 986519 -686199 455788 -256890 -597905 -957628\n-1916221\n14\n335315 -382431 271155 869876 584551 372991 -567210 -505453 764516 -35475 609178 -789395 -960428 -588144\n178922\n15\n377522 -831158 -965128 -875176 950984 196317 -964473 42008 -991368 -145491 427184 -505666 979496 -946763 458333\n55983\n15\n732005 -530291 -664037 -488818 640413 597797 276554 516566 296303 537113 898453 -217444 56718 -765069 -336420\n1872918\n14\n-858067 851618 951771 -886304 -933246 -212995 -45816 -235773 658401 398330 -245256 538787 718680 -750606\n-1396820\n13\n-715850 227606 406005 -147318 361541 849809 964022 264353 228324 -283636 947880 -421752 353016\n2806394\n14\n-880557 620024 696355 -40558 -249305 987375 -753221 182978 -158325 445059 -986916 -638732 74756 408578\n-401300\n13\n732331 -356000 664337 -138495 550952 -618797 100332 595297 -682829 -92271 -838963 51313 807279\n774486\n15\n-725569 70510 -956614 -864438 -500956 462156 -15367 -648499 -87373 242347 459736 490319 761600 451663 -639145\n-1791358\n14\n497222 453336 97293 902671 -92094 -733558 -788623 187518 930103 52720 -358460 -142109 -529738 5375\n1744952\n13\n738617 -552678 382498 936124 416319 -879638 65049 933848 -308326 505266 -451232 289731 445449\n1139454\n13\n-975852 -378153 -517608 -499515 -879959 -260435 367059 -34626 -265072 444254 -643463 147185 73299\n-517608\n15\n-422825 384961 851397 -192989 -98074 971460 -209384 -831394 137003 -1507 -301850 -144371 -824032 958758 -308308\n-1060112\n13\n-343464 -695016 827875 -831930 -908845 -836849 -475469 585473 336221 -72308 805824 749687 470352\n1505254\n13\n926769 82899 504935 66875 -305570 354328 229621 391300 412774 -777031 192394 -597619 740165\n-777031\n13\n-461814 -176920 31665 312217 625251 222270 -885034 878158 -341200 -186751 -778487 -498702 508978\n-1763824\n14\n-100997 -186654 388030 438854 -590091 -460381 -93415 -666006 531131 27449 -764728 861481 -836052 69633\n-1381746\n13\n-165866 41828 58376 154438 133547 911119 -766669 929977 -591761 247172 366166 67750 716457\n2102534\n14\n904227 -318977 636149 724135 -825787 -65633 -322776 -140276 -486611 -178636 -851255 375313 94550 270968\n5029\n14\n-597415 33829 -767770 -855497 -924419 -302002 281901 901645 957650 -372891 -416553 -903674 47896 -494875\n-2132411\n15\n-209059 -369411 -907735 -387879 -656655 -567925 -346339 -785291 -178440 683140 -218837 766350 723384 -272892 172741\n-2649831\n14\n324515 -10128 -683405 -331189 -70169 -192706 943389 -761586 829084 -133116 -356058 -281595 630696 143798\n1258830\n13\n-580105 650651 -832072 -607102 924114 793489 960346 -352478 -43208 537985 191372 744622 540361\n1694166",
"output": "NO\nNO\nNO\nYES\nYES\nYES\nNO\nNO\nYES\nNO\nNO\nYES\nYES\nYES\nYES\nYES\nNO\nYES\nNO\nYES\nNO\nNO\nYES\nYES\nYES\nYES\nYES\nYES\nNO\nYES\nNO\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nNO\nYES\nYES\nNO\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
way-to-follow-on-grid
|
Solve the following coding problem using the programming language python:
You are situated in an N dimensional grid at position (x1,x2,...,xN). The dimensions of the grid are (D1,D2,...DN). In one step, you can walk one step ahead or behind in any one of the N dimensions. (So there are always 2ΓN possible different moves). In how many ways can you take M steps such that you do not leave the grid at any point? You leave the grid if at any point xi, either xiβ€0 or xi>Di.
Input Format
The first line contains the number of test cases T. T test cases follow. For each test case, the first line contains N and M, the second line contains x1,x2,β¦,xN and the 3rd line contains D1,D2,β¦,DN.
Output Format
Output T lines, one corresponding to each test case. Since the answer can be really huge, output it modulo 1000000007.
Constraints
1β€Tβ€10
1β€Nβ€10
1β€Mβ€300
1β€Diβ€100
1β€xiβ€Di
SAMPLE INPUT
5
1 287
44
78
1 236
25
87
1 122
41
63
1 260
7
64
1 127
3
73
SAMPLE OUTPUT
38753340
587915072
644474045
423479916
320130104
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
MOD = 1000000007
def solve(n, m, x, d):
mat = [[0 for i in range(n + 1)] for j in range(m + 1)]
for i in range(n):
mat1 = [[0 for j in range(m + 1)] for k in range(d[i] + 1)]
D = d[i]
for j in range(1, D + 1):
mat1[j][0] = 1
for j in range(1, m + 1):
for k in range(1, D + 1):
mat1[k][j] = 0
if k - 1 > 0:
mat1[k][j] = (mat1[k][j] + mat1[k - 1][j - 1]) % MOD
if k + 1 <= D:
mat1[k][j] = (mat1[k][j] + mat1[k + 1][j - 1]) % MOD
mat[0][i + 1] = 1
for j in range(1, m + 1):
mat[j][i + 1] = mat1[x[i]][j]
comb = [[0 for i in range(m + 1)] for j in range(m + 1)]
for i in range(0, m + 1):
comb[i][0] = 1
comb[i][i] = 1
for i in range(1, m + 1):
for j in range(1, i):
comb[i][j] = (comb[i - 1][j] + comb[i - 1][j - 1]) % MOD
res = [[0 for i in range(n + 1)] for j in range(m + 1)]
for i in range(0, m + 1):
res[i][1] = mat[i][1]
for i in range(0, n + 1):
res[0][i] = 1
for i in range(2, n + 1):
for j in range(1, m + 1):
res[j][i] = 0
for k in range(0, j + 1):
res[j][i] = (res[j][i] + ((comb[j][j - k] * ((res[k][i - 1] * mat[j - k][i]) % MOD)) % MOD)) % MOD;
return res[m][n]
t = input()
while t:
t-=1
n, m = map(int, raw_input().split())
arr = map(int, raw_input().split())
dims = map(int, raw_input().split())
print solve(n, m, arr, dims)
```
|
vfc_81141
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1 287\n44\n78\n1 236\n25\n87\n1 122\n41\n63\n1 260\n7\n64\n1 127\n3\n73\n\nSAMPLE",
"output": "38753340\n587915072\n644474045\n423479916\n320130104",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n1 287\n44\n78\n1 236\n25\n87\n1 122\n41\n63\n1 260\n7\n64\n1 127\n3\n73",
"output": "38753340\n587915072\n644474045\n423479916\n320130104",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n1 287\n44\n78\n1 236\n25\n87\n1 122\n41\n63\n1 260\n7\n64\n1 127\n3\n73\n1 69\n6\n68\n1 231\n14\n63\n1 236\n13\n30\n1 259\n38\n70\n1 257\n11\n12",
"output": "38753340\n587915072\n644474045\n423479916\n320130104\n792930663\n846814121\n385120933\n60306396\n306773532",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n1 287\n44\n78\n1 236\n25\n87\n1 122\n41\n63\n1 260\n7\n64\n1 127\n3\n73\n1 69\n6\n18\n1 231\n14\n63\n1 236\n13\n30\n1 259\n38\n70\n1 257\n11\n12",
"output": "38753340\n587915072\n644474045\n423479916\n320130104\n69151240\n846814121\n385120933\n60306396\n306773532\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n1 287\n44\n78\n1 129\n25\n87\n1 122\n41\n63\n1 260\n7\n64\n1 127\n3\n73\n\nSAMPLE",
"output": "38753340\n732305596\n644474045\n423479916\n320130104\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n1 287\n44\n148\n1 236\n25\n87\n1 122\n41\n63\n1 260\n7\n64\n1 127\n3\n73\n1 69\n6\n18\n1 231\n14\n63\n1 236\n13\n30\n1 259\n38\n70\n1 257\n11\n12",
"output": "733734127\n587915072\n644474045\n423479916\n320130104\n69151240\n846814121\n385120933\n60306396\n306773532\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
p00037 Path on a Grid
|
Solve the following coding problem using the programming language python:
Seen from above, there is a grid-like square shaped like Figure 1. The presence or absence of "walls" on each side of this grid is represented by a sequence of 0s and 1s. Create a program that stands at point A, puts your right hand on the wall, keeps walking in the direction of the arrow, and outputs the route to return to point A again.
<image>
---
Figure 1
---
Input
The input consists of 9 lines and is given in the following format, with 1 being the presence of a wall and 0 being the absence of a wall, as shown in Figure 2 below.
The first line is a character string that indicates the presence or absence of the top horizontal line wall as 0 and 1 from the left.
The second line is a character string that indicates the presence or absence of the vertical line wall below it with 0 and 1 from the left.
The third line is a character string that indicates the presence or absence of the wall of the second horizontal line from the top by 0 and 1 from the left.
...
The 9th line is a character string representing the presence or absence of the bottom horizontal line wall with 0 and 1 from the left.
<image>
---
Figure 2 (Thick line shows where the wall is) (corresponding numbers)
However, as shown by the thick line in Fig. 1, it is assumed that there is always a wall for one section to the right of point A. That is, the first character on the first line is always 1.
Output
"Advance one section to the left of the figure" is "L", "Advance one section to the right of the figure" is "R", "Advance one section to the top of the figure" is "U", "Figure" "Advance one block downward" is represented by "D", and "L", "R", "U", and "D" are output in the order of advance.
Example
Input
1111
00001
0110
01011
0010
01111
0010
01001
0111
Output
RRRRDDDDLLLUUURRDDLURULLDDDRRRUUUULLLL
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
import sys
loc = [3, 1]
def print_dir(h):
if h == 0:
print('R', end='')
elif h == 1:
print('D', end='')
elif h == 2:
print('L', end='')
elif h == 3:
print('U', end='')
dir = [[1, 0], [0, 1], [-1, 0], [0, -1]]
hand = 3
board = [[0 for _ in range(11)] for _ in range(11)]
for i, line in enumerate(sys.stdin):
for j, c in enumerate(line.strip()):
board[i+1][1 + (i+1)%2 + j*2] = int(c)
print("R", end='')
while loc != [1, 1]:
for i in range(4):
if board[loc[1]+dir[(hand+i)%4][1]][loc[0]+dir[(hand+i)%4][0]] == 1:
loc[0] += dir[(hand+i)%4][0]*2
loc[1] += dir[(hand+i)%4][1]*2
if i == 1:
print_dir((hand+1)%4)
elif i == 2:
print_dir((hand+2)%4)
hand = (hand+1)%4
elif i == 3:
print_dir((hand+3)%4)
hand = (hand+2)%4
elif i == 0:
print_dir(hand%4)
hand = (hand+3)%4
break
print()
```
|
vfc_81185
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1111\n00001\n0110\n01011\n0010\n01111\n0010\n01001\n0111",
"output": "RRRRDDDDLLLUUURRDDLURULLDDDRRRUUUULLLL",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1111\n00001\n0110\n01011\n0010\n01111\n0010\n01011\n0111",
"output": "RRRRDDDDLLLUUURRDDDRUUUULLLL\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1111\n00001\n0110\n01011\n0010\n01111\n1010\n01011\n0111",
"output": "RRRRDDDDLLLULRUURRDDDRUUUULLLL\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1111\n00001\n0110\n01111\n0010\n00011\n1010\n01011\n0111",
"output": "RRRRDDDDLLLULRDRRULRULULDURRDDDRUUUULLLL\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1111\n00001\n0110\n01111\n1010\n00011\n1010\n01011\n0111",
"output": "RRRRDDDDLLLULRDRRULRULULDLRURRDDDRUUUULLLL\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1111\n00001\n0110\n11111\n1010\n00011\n1010\n01011\n0111",
"output": "RRRRDDDDLLLULRDRRULRULULDLUDRURRDDDRUUUULLLL\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
p00169 Blackjack
|
Solve the following coding problem using the programming language python:
Blackjack is a type of card game played in casinos, where the game is played using cards with numbers from 1 to 13. The score of each card is decided as follows.
* 1 is 1 point or 11 points
* From 2 to 9, the score is as written.
* 10 points from 10 to 13
There are several participants in this game, including parents, each with several sets of cards. This set of cards is called a hand. The hand score is the total of the card scores. The calculation shall be performed as follows.
* If the total score of the cards is greater than 21, the score of the hand is set to 0.
* As the score of the card, 1 may be calculated as 1 point or 11 points, but the one with the maximum hand score shall be selected.
Create a program that uses the information of the cards dealt as input and outputs the score of the hand.
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
c1 c2 ... cn
The integer ci (1 β€ ci β€ 13) written on the i-th card is given to each line, separated by blanks. The number of cards n does not exceed 100.
The number of datasets does not exceed 200.
Output
The score of the hand is output to one line for each data set.
Example
Input
1
7 7 7
7 7 8
12 1
10 1 1
0
Output
11
21
0
21
12
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
while True:
inp = input()
if inp == '0': break
inp = inp.replace('11', '10')
inp = inp.replace('12', '10')
inp = inp.replace('13', '10')
cards = tuple(map(int, inp.split()))
ans = sum(cards)
for i in range(cards.count(1)):
if sum(cards) + 10 * (i+1) > 21:
break
elif ans < sum(cards) + 10 * (i+1):
ans = sum(cards) + 10 * (i+1)
if ans > 21: ans = 0
print(ans)
```
|
vfc_81189
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n7 7 7\n7 7 8\n12 1\n10 1 1\n0",
"output": "11\n21\n0\n21\n12",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n7 7 7\n7 7 8\n12 1\n10 1 2\n0",
"output": "11\n21\n0\n21\n13\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n7 7 7\n7 7 8\n10 1\n10 1 1\n0",
"output": "11\n21\n0\n21\n12\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n7 7 7\n7 7 8\n2 1\n10 2 1\n0",
"output": "11\n21\n0\n13\n13\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n7 9 7\n7 7 8\n2 1\n10 2 1\n0",
"output": "11\n0\n0\n13\n13\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n7 9 7\n1 9 8\n2 1\n10 2 1\n0",
"output": "11\n0\n18\n13\n13\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
p00497 Nails
|
Solve the following coding problem using the programming language python:
JOI is playing with a nail in the board. As shown in the figure below, JOI stabbed nails in the shape of an equilateral triangle with N sides. A nails are lined up in the ath line (1 β€ a β€ N) from the top. The bth nail (1 β€ b β€ a) from the left is represented by (a, b).
<image>
Figure 1: Arrangement of nails (when N = 5)
When an equilateral triangle with a nail as its apex is "each side is parallel to one of the sides of the entire equilateral triangle and has the same orientation as the entire equilateral triangle", this equilateral triangle is called a "good equilateral triangle". That is, a "good equilateral triangle" is an equilateral triangle whose vertices are three nails (a, b), (a + x, b), (a + x, b + x) (but a). , B, x satisfy 1 β€ a <N, 1 β€ b β€ a, 1 β€ x β€ N --a)).
JOI decided to use a rubber band to surround the "good equilateral triangle."
<image>
Figure 2: An example of how to enclose a "good equilateral triangle" with a rubber band
input
Read the following data from standard input.
* The integers N and M are written on the first line, separated by blanks. N represents the number of nails lined up on one side of an equilateral triangle, and M represents the number of rubber bands that JOI has.
* The following M line shows information on how to enclose a "good equilateral triangle" with a rubber band. The integers Ai, Bi, Xi (1 β€ Ai <N, 1 β€ Bi β€ Ai, 1 β€ Xi β€ N --Ai) are written on the first line (1 β€ i β€ M), separated by blanks. .. This means that the i-th rubber band surrounds a "good equilateral triangle" with three nails (Ai, Bi), (Ai + Xi, Bi), (Ai + Xi, Bi + Xi) as vertices. Represent.
output
Output the number of nails surrounded by one or more rubber bands to the standard output in one line.
Examples
Input
5 2
2 2 1
2 1 3
Output
12
Input
None
Output
None
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
n,m = map(int,input().split())
t = [[0]*(n+2) for i in range(n+2)]
for i in range(m):
a,b,x = map(int,input().split())
a -= 1
b -= 1
t[a][b] += 1
t[a][b+1] -= 1
t[a+x+1][b] -= 1
t[a+x+1][b+x+2] += 1
t[a+x+2][b+1] += 1
t[a+x+2][b+x+2] -= 1
for i in range(n+2):
for j in range(1,n+2):
t[i][j] += t[i][j-1]
for i in range(n+2):
for j in range(1,n+2):
t[j][i] += t[j-1][i]
for i in range(1, n+2):
for j in range(1,n+2):
t[i][j] += t[i-1][j-1]
ans = 0
for i in range(n):
for j in range(i+1):
if t[i][j] != 0:
ans += 1
print(ans)
```
|
vfc_81197
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 536870912,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "None",
"output": "None",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 2\n2 2 1\n2 1 3",
"output": "12",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "Npne",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 2\n2 1 1\n2 1 3",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "Nnpe",
"output": "0\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
p00682 Area of Polygons
|
Solve the following coding problem using the programming language python:
Polygons are the most fundamental objects in geometric processing. Complex figures are often represented and handled as polygons with many short sides. If you are interested in the processing of geometric data, you'd better try some programming exercises about basic operations on polygons.
Your job in this problem is to write a program that computes the area of polygons.
A polygon is represented by a sequence of points that are its vertices. If the vertices p1, p2, ..., pn are given, line segments connecting pi and pi+1 (1 <= i <= n-1) are sides of the polygon. The line segment connecting pn and p1 is also a side of the polygon.
You can assume that the polygon is not degenerate. Namely, the following facts can be assumed without any input data checking.
* No point will occur as a vertex more than once.
* Two sides can intersect only at a common endpoint (vertex).
* The polygon has at least 3 vertices.
Note that the polygon is not necessarily convex. In other words, an inner angle may be larger than 180 degrees.
Input
The input contains multiple data sets, each representing a polygon. A data set is given in the following format.
n
x1 y1
x2 y2
...
xn yn
The first integer n is the number of vertices, such that 3 <= n <= 50. The coordinate of a vertex pi is given by (xi, yi). xi and yi are integers between 0 and 1000 inclusive. The coordinates of vertices are given in the order of clockwise visit of them.
The end of input is indicated by a data set with 0 as the value of n.
Output
For each data set, your program should output its sequence number (1 for the first data set, 2 for the second, etc.) and the area of the polygon separated by a single space. The area should be printed with one digit to the right of the decimal point.
The sequence number and the area should be printed on the same line. Since your result is checked by an automatic grading program, you should not insert any extra characters nor lines on the output.
Example
Input
3
1 1
3 4
6 0
7
0 0
10 10
0 20
10 30
0 40
100 40
100 0
0
Output
1 8.5
2 3800.0
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
idx = 1
while True:
n = int(input())
if n==0: break
x = []
y = []
for _ in range(n):
a,b = map(int,input().split())
x.append(a)
y.append(b)
x.append(x[0])
y.append(y[0])
s = 0.0
for i in range(n):
s += x[i]*y[i+1] - x[i+1]*y[i]
print(idx, abs(s/2))
idx += 1
input()
```
|
vfc_81201
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 1\n3 4\n6 0\n\n7\n0 0\n10 10\n0 20\n10 30\n0 40\n100 40\n100 0\n\n0",
"output": "1 8.5\n2 3800.0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 1\n3 4\n6 0\n\n7\n0 0\n10 10\n0 20\n10 33\n0 40\n100 40\n100 0\n\n0",
"output": "1 8.5\n2 3800.0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 1\n3 4\n6 0\n\n7\n0 0\n10 10\n0 20\n10 33\n0 40\n110 40\n100 0\n\n0",
"output": "1 8.5\n2 4000.0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 1\n3 4\n6 0\n\n7\n0 0\n10 10\n0 20\n10 30\n0 40\n100 40\n100 1\n\n0",
"output": "1 8.5\n2 3750.0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 1\n3 4\n6 0\n\n7\n0 0\n10 10\n0 20\n3 33\n0 40\n100 40\n100 0\n\n0",
"output": "1 8.5\n2 3870.0\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
p00824 Gap
|
Solve the following coding problem using the programming language python:
Letβs play a card game called Gap.
You have 28 cards labeled with two-digit numbers. The first digit (from 1 to 4) represents the suit of the card, and the second digit (from 1 to 7) represents the value of the card.
First, you shuffle the cards and lay them face up on the table in four rows of seven cards, leaving a space of one card at the extreme left of each row. The following shows an example of initial layout.
<image>
Next, you remove all cards of value 1, and put them in the open space at the left end of the rows: β11β to the top row, β21β to the next, and so on.
Now you have 28 cards and four spaces, called gaps, in four rows and eight columns. You start moving cards from this layout.
<image>
At each move, you choose one of the four gaps and fill it with the successor of the left neighbor of the gap. The successor of a card is the next card in the same suit, when it exists. For instance the successor of β42β is β43β, and β27β has no successor.
In the above layout, you can move β43β to the gap at the right of β42β, or β36β to the gap at the right of β35β. If you move β43β, a new gap is generated to the right of β16β. You cannot move any card to the right of a card of value 7, nor to the right of a gap.
The goal of the game is, by choosing clever moves, to make four ascending sequences of the same suit, as follows.
<image>
Your task is to find the minimum number of moves to reach the goal layout.
Input
The input starts with a line containing the number of initial layouts that follow.
Each layout consists of five lines - a blank line and four lines which represent initial layouts of four rows. Each row has seven two-digit numbers which correspond to the cards.
Output
For each initial layout, produce a line with the minimum number of moves to reach the goal layout. Note that this number should not include the initial four moves of the cards of value 1. If there is no move sequence from the initial layout to the goal layout, produce β-1β.
Example
Input
4
12 13 14 15 16 17 21
22 23 24 25 26 27 31
32 33 34 35 36 37 41
42 43 44 45 46 47 11
26 31 13 44 21 24 42
17 45 23 25 41 36 11
46 34 14 12 37 32 47
16 43 27 35 22 33 15
17 12 16 13 15 14 11
27 22 26 23 25 24 21
37 32 36 33 35 34 31
47 42 46 43 45 44 41
27 14 22 35 32 46 33
13 17 36 24 44 21 15
43 16 45 47 23 11 26
25 37 41 34 42 12 31
Output
0
33
60
-1
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
vfc_81205
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n\n12 13 14 15 16 17 21\n22 23 24 25 26 27 31\n32 33 34 35 36 37 41\n42 43 44 45 46 47 11\n\n26 31 13 44 21 24 42\n17 45 23 25 41 36 11\n46 34 14 12 37 32 47\n16 43 27 35 22 33 15\n\n17 12 16 13 15 14 11\n27 22 26 23 25 24 21\n37 32 36 33 35 34 31\n47 42 46 43 45 44 41\n\n27 14 22 35 32 46 33\n13 17 36 24 44 21 15\n43 16 45 47 23 11 26\n25 37 41 34 42 12 31",
"output": "0\n33\n60\n-1",
"type": "stdin_stdout"
}
]
}
|
|
code_contests
|
verifiable_code
|
p00955 Cover the Polygon with Your Disk
|
Solve the following coding problem using the programming language python:
Example
Input
4 4
0 0
6 0
6 6
0 6
Output
35.759506
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
vfc_81209
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 268435456,
"problem_url": null,
"time_limit": "{'seconds': 5, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 4\n0 0\n6 0\n6 6\n0 6",
"output": "35.759506",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 2\n0 0\n6 0\n6 6\n0 6",
"output": "12.5663705873\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 1\n0 0\n6 0\n6 6\n0 6",
"output": "3.1415926283\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 1\n0 0\n6 0\n6 6\n0 9",
"output": "3.1415926337\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 1\n0 -1\n6 0\n6 6\n0 9",
"output": "3.1415926355\n",
"type": "stdin_stdout"
}
]
}
|
|
code_contests
|
verifiable_code
|
p01088 500-yen Saving
|
Solve the following coding problem using the programming language python:
500-yen Saving
"500-yen Saving" is one of Japanese famous methods to save money. The method is quite simple; whenever you receive a 500-yen coin in your change of shopping, put the coin to your 500-yen saving box. Typically, you will find more than one million yen in your saving box in ten years.
Some Japanese people are addicted to the 500-yen saving. They try their best to collect 500-yen coins efficiently by using 1000-yen bills and some coins effectively in their purchasing. For example, you will give 1320 yen (one 1000-yen bill, three 100-yen coins and two 10-yen coins) to pay 817 yen, to receive one 500-yen coin (and three 1-yen coins) in the change.
A friend of yours is one of these 500-yen saving addicts. He is planning a sightseeing trip and wants to visit a number of souvenir shops along his way. He will visit souvenir shops one by one according to the trip plan. Every souvenir shop sells only one kind of souvenir goods, and he has the complete list of their prices. He wants to collect as many 500-yen coins as possible through buying at most one souvenir from a shop. On his departure, he will start with sufficiently many 1000-yen bills and no coins at all. The order of shops to visit cannot be changed. As far as he can collect the same number of 500-yen coins, he wants to cut his expenses as much as possible.
Let's say that he is visiting shops with their souvenir prices of 800 yen, 700 yen, 1600 yen, and 600 yen, in this order. He can collect at most two 500-yen coins spending 2900 yen, the least expenses to collect two 500-yen coins, in this case. After skipping the first shop, the way of spending 700-yen at the second shop is by handing over a 1000-yen bill and receiving three 100-yen coins. In the next shop, handing over one of these 100-yen coins and two 1000-yen bills for buying a 1600-yen souvenir will make him receive one 500-yen coin. In almost the same way, he can obtain another 500-yen coin at the last shop. He can also collect two 500-yen coins buying at the first shop, but his total expenditure will be at least 3000 yen because he needs to buy both the 1600-yen and 600-yen souvenirs in this case.
You are asked to make a program to help his collecting 500-yen coins during the trip. Receiving souvenirs' prices listed in the order of visiting the shops, your program is to find the maximum number of 500-yen coins that he can collect during his trip, and the minimum expenses needed for that number of 500-yen coins.
For shopping, he can use an arbitrary number of 1-yen, 5-yen, 10-yen, 50-yen, and 100-yen coins he has, and arbitrarily many 1000-yen bills. The shop always returns the exact change, i.e., the difference between the amount he hands over and the price of the souvenir. The shop has sufficient stock of coins and the change is always composed of the smallest possible number of 1-yen, 5-yen, 10-yen, 50-yen, 100-yen, and 500-yen coins and 1000-yen bills. He may use more money than the price of the souvenir, even if he can put the exact money, to obtain desired coins as change; buying a souvenir of 1000 yen, he can hand over one 1000-yen bill and five 100-yen coins and receive a 500-yen coin. Note that using too many coins does no good; handing over ten 100-yen coins and a 1000-yen bill for a souvenir of 1000 yen, he will receive a 1000-yen bill as the change, not two 500-yen coins.
Input
The input consists of at most 50 datasets, each in the following format.
> n
> p1
> ...
> pn
>
n is the number of souvenir shops, which is a positive integer not greater than 100. pi is the price of the souvenir of the i-th souvenir shop. pi is a positive integer not greater than 5000.
The end of the input is indicated by a line with a single zero.
Output
For each dataset, print a line containing two integers c and s separated by a space. Here, c is the maximum number of 500-yen coins that he can get during his trip, and s is the minimum expenses that he need to pay to get c 500-yen coins.
Sample Input
4
800
700
1600
600
4
300
700
1600
600
4
300
700
1600
650
3
1000
2000
500
3
250
250
1000
4
1251
667
876
299
0
Output for the Sample Input
2 2900
3 2500
3 3250
1 500
3 1500
3 2217
Example
Input
4
800
700
1600
600
4
300
700
1600
600
4
300
700
1600
650
3
1000
2000
500
3
250
250
1000
4
1251
667
876
299
0
Output
2 2900
3 2500
3 3250
1 500
3 1500
3 2217
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+9
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def main():
rr = []
def f(n):
a = [I() for _ in range(n)]
t = [(0,0,0)]
for c in a:
nt = collections.defaultdict(lambda: inf)
c1 = c % 1000
c5 = c % 500
mc5 = 500 - c5
for g,k,p in t:
nt[(g,k)] = p
if c1 == 0:
for g,k,p in t:
if k >= 500 and nt[(g+1,k-500)] > p + c:
nt[(g+1,k-500)] = p + c
elif c1 == 500:
for g,k,p in t:
if nt[(g+1, k)] > p + c:
nt[(g+1, k)] = p + c
elif c1 < 500:
for g,k,p in t:
if nt[(g+1, k+mc5)] > p + c:
nt[(g+1, k+mc5)] = p + c
else:
for g,k,p in t:
if k + mc5 >= 500 and nt[(g+1,k+mc5-500)] > p + c:
nt[(g+1,k+mc5-500)] = p + c
if nt[(g, k+mc5)] > p + c:
nt[(g, k+mc5)] = p + c
t = []
cg = -1
mk = -1
mp = inf
# print('nt',nt)
for g,k in sorted(nt.keys(), reverse=True):
p = nt[(g,k)]
if p == inf:
continue
if cg != g:
mp = inf
cg = g
if mk < k or mp > p:
t.append((g,k,p))
if mk < k:
mk = k
if mp > p:
mp = p
# print(len(t))
r = 0
rp = inf
for g,k,p in t:
if r < g or (r==g and rp > p):
r = g
rp = p
return '{} {}'.format(r, rp)
while 1:
n = I()
if n == 0:
break
rr.append(f(n))
return '\n'.join(map(str, rr))
print(main())
```
|
vfc_81213
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 268435456,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n800\n700\n1600\n600\n4\n300\n700\n1600\n600\n4\n300\n700\n1600\n650\n3\n1000\n2000\n500\n3\n250\n250\n1000\n4\n1251\n667\n876\n299\n0",
"output": "2 2900\n3 2500\n3 3250\n1 500\n3 1500\n3 2217",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n800\n700\n1600\n600\n4\n300\n700\n1600\n30\n4\n300\n700\n1600\n650\n3\n1000\n2000\n500\n3\n250\n250\n1000\n4\n1251\n667\n876\n299\n0",
"output": "2 2900\n3 1030\n3 3250\n1 500\n3 1500\n3 2217\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n800\n700\n1600\n600\n4\n300\n700\n1600\n30\n4\n300\n700\n1600\n650\n3\n1000\n2000\n500\n3\n250\n250\n1000\n4\n1251\n1191\n876\n299\n0",
"output": "2 2900\n3 1030\n3 3250\n1 500\n3 1500\n4 3617\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n800\n700\n1600\n600\n4\n300\n700\n1600\n30\n4\n300\n700\n1600\n650\n3\n1000\n2000\n500\n3\n250\n250\n1000\n4\n1251\n1466\n876\n299\n0",
"output": "2 2900\n3 1030\n3 3250\n1 500\n3 1500\n3 3016\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n800\n700\n1600\n600\n4\n300\n700\n1600\n30\n4\n300\n700\n1600\n219\n3\n1000\n2000\n500\n3\n250\n250\n1000\n4\n1251\n1466\n876\n299\n0",
"output": "2 2900\n3 1030\n3 1219\n1 500\n3 1500\n3 3016\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
p01224 Perfect Number
|
Solve the following coding problem using the programming language python:
Let S be the sum of divisors of an integer N excluding the number itself. When N = S, N is called a perfect number, when N> S, N is called a defendant number, and when N <S, N is called an abundant number. Create a program that determines whether a given integer is a perfect number, a missing number, or an abundant number.
Be careful not to exceed the program execution time.
Input
The input consists of a sequence of datasets. The number of datasets is 100 or less.
Each dataset consists of one row containing only the integer N (0 <N β€ 100000000).
After the last dataset, there is a line marked 0 that marks the end of the input.
Output
For each dataset, print the string "` perfect number` "if the integer N is a perfect number," `deficient number`" if it is a missing number, or "` abundant number` "if it is an abundant number. ..
Example
Input
1
2
3
4
6
12
16
28
33550336
99999998
99999999
100000000
0
Output
deficient number
deficient number
deficient number
deficient number
perfect number
abundant number
deficient number
perfect number
perfect number
deficient number
deficient number
abundant number
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
def f(p):
ans=1
if p<=5: return 0
for n in range(2,int(p**0.5)+1):
if p%n==0:
if n!=p//n:ans+=n+p//n
else:ans+=n
return ans
while 1:
n=int(input())
if n==0:break
m=f(n)
if n==m:print('perfect number')
else: print('deficient number' if n>m else 'abundant number')
```
|
vfc_81217
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n2\n3\n4\n6\n12\n16\n28\n33550336\n99999998\n99999999\n100000000\n0",
"output": "deficient number\ndeficient number\ndeficient number\ndeficient number\nperfect number\nabundant number\ndeficient number\nperfect number\nperfect number\ndeficient number\ndeficient number\nabundant number",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
p01540 Treasure Hunt
|
Solve the following coding problem using the programming language python:
Taro came to a square to look for treasure. There are many treasures buried in this square, but Taro has the latest machines, so he knows everything about where the treasures are buried. Since the square is very wide Taro decided to look for the treasure to decide the area, but the treasure is what treasure does not know immediately whether or not there in the area for a lot. So Taro decided to count the number of treasures in that area.
Constraints
> 1 β€ n β€ 5000
> 1 β€ m β€ 5 Γ 105
> | xi |, | yi | β€ 109 (1 β€ i β€ n)
> | xi1 |, | yi1 |, | xi2 |, | yi2 | β€ 109 (1 β€ i β€ m)
> xi1 β€ xi2, yi1 β€ yi2 (1 β€ i β€ m)
>
* All inputs are given as integers
Input
> n m
> x1 y1
> x2 y2
> ...
> xn yn
> x11 y11 x12 y12
> x21 y21 x22 y22
> ...
> xm1 ym1 xm2 ym2
>
* n represents the number of treasures buried in the square
* m represents the number of regions to examine
* The 2nd to n + 1 lines represent the coordinates where each treasure is buried.
* The n + 2nd to n + m + 1 lines represent each area to be examined.
* The positive direction of the x-axis represents the east and the positive direction of the y-axis represents the north.
* Each region is a rectangle, xi1 and yi1 represent the coordinates of the southwestern apex of the rectangle, and xi2 and yi2 represent the coordinates of the northeastern apex of the rectangle.
Output
> C1
> C2
> ...
> Cm
>
* Output the number of treasures contained in each area to each line
Examples
Input
3 1
1 1
2 4
5 3
0 0 5 5
Output
3
Input
4 2
-1 1
0 3
4 0
2 1
-3 1 5 1
4 0 4 0
Output
2
1
Input
2 3
0 0
0 0
-1 -1 1 1
0 0 2 2
1 1 4 4
Output
2
2
0
Input
5 5
10 5
-3 -8
2 11
6 0
-1 3
-3 1 3 13
-1 -1 9 5
-3 -8 10 11
0 0 5 5
-10 -9 15 10
Output
2
2
5
0
4
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
class Ruiwa():
def __init__(self, a):
self.H = h = len(a)
self.W = w = len(a[0])
self.R = r = a
for i in range(h):
for j in range(1,w):
r[i][j] += r[i][j-1]
for i in range(1,h):
for j in range(w):
r[i][j] += r[i-1][j]
def search(self, x1, y1, x2, y2):
if x1 > x2 or y1 > y2:
return 0
r = self.R
rr = r[y2][x2]
if x1 > 0 and y1 > 0:
return rr - r[y1-1][x2] - r[y2][x1-1] + r[y1-1][x1-1]
if x1 > 0:
rr -= r[y2][x1-1]
if y1 > 0:
rr -= r[y1-1][x2]
return rr
def main():
n,m = LI()
na = [LI() for _ in range(n)]
xd = set()
yd = set()
for x,y in na:
xd.add(x)
yd.add(y)
xl = sorted(list(xd))
yl = sorted(list(yd))
xx = {}
yy = {}
for i in range(len(xl)):
xx[xl[i]] = i
for i in range(len(yl)):
yy[yl[i]] = i
a = [[0]*(len(yl)+1) for _ in range(len(xl)+1)]
for x,y in na:
a[xx[x]][yy[y]] += 1
rui = Ruiwa(a)
r = []
for _ in range(m):
x1,y1,x2,y2 = LI()
xx1 = bisect.bisect_left(xl, x1)
yy1 = bisect.bisect_left(yl, y1)
xx2 = bisect.bisect(xl, x2) - 1
yy2 = bisect.bisect(yl, y2) - 1
r.append(rui.search(yy1,xx1,yy2,xx2))
return '\n'.join(map(str,r))
print(main())
```
|
vfc_81225
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 204472320,
"problem_url": null,
"time_limit": "{'seconds': 5, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"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",
"output": "2\n2\n5\n0\n4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 1\n1 1\n2 4\n5 3\n0 0 5 5",
"output": "3",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
p01696 Broken Cipher Generator
|
Solve the following coding problem using the programming language python:
Broken crypto generator
JAG (Japanese Alumni Group) is a mysterious organization composed of many programmers, and in order to enter the building where the headquarters of this organization is located, it is necessary to solve the ciphertext generated by a certain machine every time. This ciphertext consists of the symbols'+','-','[',']' and the uppercase alphabet, and is represented by <Cipher> defined by the following BNF.
<Cipher> :: = <String> | <Cipher> <String>
<String> :: = <Letter> |'['<Cipher>']'
<Letter> :: ='+' <Letter> |'-' <Letter> |
'A' |'B' |'C' |'D' |'E' |'F' |'G' |'H' |'I' |'J' |'K' |'L' |'M '|
'N' |'O' |'P' |'Q' |'R' |'S' |'T' |'U' |'V' |'W' |'X' |'Y' |'Z '
Here, each symbol has the following meaning.
* + (Character): Represents the alphabet following that character (provided that the alphabet following'Z'is'A')
*-(Character): Represents the alphabet before that character (provided that the alphabet before'A'is'Z')
* [(Character string)]: Represents a character string that is horizontally inverted.
However, the machine that generates this ciphertext is currently out of order, and some letters of the alphabet in the ciphertext may be broken and unreadable. Unreadable characters are tentatively represented as'?'. As a result of the investigation, it was found that the method of filling the broken characters is such that the decrypted character string is the smallest in the dictionary order among the possible character strings after decoding. Your job is to decrypt this ciphertext correctly.
Input
The input consists of multiple datasets. Each dataset consists of one line containing a string in which some uppercase letters have been replaced with β?β In the ciphertext defined by BNF above. You can assume that the length of each string is less than $ 80 $. You can also assume that the number of'?' In each dataset is greater than or equal to $ 0 $ and less than or equal to $ 3 $.
The end of the input is represented by a line containing only one character,'.'.
Output
For each data set, output the decrypted character string when the ciphertext is decrypted so that the decrypted character string is the smallest in the dictionary order.
Sample Input
A + A ++ A
Z-Z--Z + -Z
[ESREVER]
J ---? --- J
++++++++ A +++ Z ----------- A +++ Z
[[++-+-? [-++-? ++-+++ L]] [-+ ----- + -O]] ++++ --- + L
..
Output for Sample Input
ABC
ZYXZ
REVERSE
JAG
ICPC
JAPAN
Example
Input
A+A++A
Z-Z--Z+-Z
[ESREVER]
J---?---J
++++++++A+++Z-----------A+++Z
[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L
.
Output
ABC
ZYXZ
REVERSE
JAG
ICPC
JAPAN
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
def pm_to_chr(s):
s=s.group()
if s[-1]=='?':
return 'A'
ans=chr((((ord(s[-1])+s.count('+')-s.count('-'))-ord('A'))%26)+ord('A'))
return ans
def reverse(s):
s=s.group()
s=s[1:-1]
ans=''.join(reversed(s))
return ans
import re
s=input()
while s!='.':
s=re.sub("[\+\-]*[\w?]",pm_to_chr,s)
while('[' in s):
s=re.sub("\[\w+\]",reverse,s)
print(s)
s=input()
```
|
vfc_81229
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "A+A++A\nZ-Z--Z+-Z\n[ESREVER]\nJ---?---J\n++++++++A+++Z-----------A+++Z\n[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L\n.",
"output": "ABC\nZYXZ\nREVERSE\nJAG\nICPC\nJAPAN",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
p01840 Delivery to a Luxurious House
|
Solve the following coding problem using the programming language python:
B-Mansion and courier
Problem Statement
Taro lives alone in a mansion. Taro, who loves studying, intends to study in his study in the house today. Taro can't concentrate outside the study, so he always studies in the study.
However, on this day, $ N $ of courier service to Taro arrived. $ i $ ($ 1 \ leq i \ leq N $) The arrival time of the third courier is $ a_i $. It is painful to have the delivery person wait at the front door, so Taro decided to be at the front door by the time the courier arrives. Due to the large size of the mansion, it takes $ M $ one way to move between the study and the entrance.
On the other hand, Taro wants to study for as long as possible. Find the maximum amount of time Taro can study in the study from time $ 0 $ to time $ T $.
Taro is in the study at time $ 0 $, and the courier does not arrive earlier than the time $ M $, and the courier does not arrive later than the time $ T $. Also, the time it takes for Taro to receive the courier can be ignored.
Input
Each dataset consists of two lines. The first line consists of three integers $ N, M, T $ separated by blanks. These integers satisfy $ 1 \ leq N \ leq 100 $, $ 1 \ leq M \ leq 10 {,} 000 $, $ 1 \ leq T \ leq 10 {,} 000 $. The second line consists of $ N $ integers $ a_1, a_2, \ dots, a_N $ separated by blanks. Each $ a_i $ fills $ M \ leq a_i \ leq T $ and is also $ a_i <a_ {i + 1} $ ($ 1 \ leq i <N $).
Output
Output an integer representing the maximum amount of time Taro can study on one line.
Sample Input 1
1 1 5
3
Output for the Sample Input 1
3
Sample Input 2
2 1 10
2 7
Output for the Sample Input 2
6
Sample Input 3
2 4 10
6 8
Output for the Sample Input 3
2
Example
Input
1 1 5
3
Output
3
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
l_raw = input().split()
l = [int(n) for n in l_raw]
a_raw = input().split()
a_ = [int(n) for n in a_raw]
study = 0
state = 0
now=0
for a in a_:
if state==0:
if l[1]<a-now:
study+=a-now-l[1]
now=a
state=1
elif state==1:
if 2*l[1]<a-now:
study+=a-now-2*l[1]
now=a
if l[2]-l[1]-a>0:
study+=l[2]-l[1]-a
print(study)
```
|
vfc_81233
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 536870912,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 1 5\n3",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1 5\n6",
"output": "5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1 10\n6",
"output": "8\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 2 10\n6",
"output": "6\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
p01976 Anagram
|
Solve the following coding problem using the programming language python:
problem
Given a sequence $ a_i $ of length $ N $. Output all integers $ K (1 \ le K \ le N) $ that satisfy the following conditions.
Condition: Well sorted $ a_1, \ cdots, a_K $ matches $ a_ {N-K + 1}, \ cdots, a_N $.
Example
Input
8
5 2 4 9 4 9 2 5
Output
1 2 4 6 7 8
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
from collections import Counter
n = int(input())
a = input().split()
# a = list(map(int, input().split()))
ans = ''
# t1, t2 = [], []
t1, t2 = Counter(), Counter()
for i in range(n):
t1.update(a[i])
t2.update(a[n-1-i])
t3 = t1 & t2
t1 -= t3
t2 -= t3
if t1 == t2:
ans += str(i+1) + ' '
print(ans[:-1])
```
|
vfc_81237
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 268435456,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "8\n5 2 4 9 4 9 2 5",
"output": "1 2 4 6 7 8",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
p02262 Shell Sort
|
Solve the following coding problem using the programming language python:
Shell Sort
Shell Sort is a generalization of Insertion Sort to arrange a list of $n$ elements $A$.
1 insertionSort(A, n, g)
2 for i = g to n-1
3 v = A[i]
4 j = i - g
5 while j >= 0 && A[j] > v
6 A[j+g] = A[j]
7 j = j - g
8 cnt++
9 A[j+g] = v
10
11 shellSort(A, n)
12 cnt = 0
13 m = ?
14 G[] = {?, ?,..., ?}
15 for i = 0 to m-1
16 insertionSort(A, n, G[i])
A function shellSort(A, n) performs a function insertionSort(A, n, g), which considers every $g$-th elements. Beginning with large values of $g$, it repeats the insertion sort with smaller $g$.
Your task is to complete the above program by filling ?. Write a program which reads an integer $n$ and a sequence $A$, and prints $m$, $G_i (i = 0, 1, ..., m β 1)$ in the pseudo code and the sequence $A$ in ascending order. The output of your program must meet the following requirements:
* $1 \leq m \leq 100$
* $0 \leq G_i \leq n$
* cnt does not exceed $\lceil n^{1.5}\rceil$
Constraints
* $1 \leq n \leq 1,000,000$
* $0 \leq A_i \leq 10^9$
Input
In the first line, an integer $n$ is given. In the following $n$ lines, $A_i (i=0,1,...,n-1)$ are given for each line.
Output
In the first line, print an integer $m$. In the second line, print $m$ integers $G_i (i=0,1,...,m-1)$ separated by single space character in a line.
In the third line, print cnt in a line. In the following $n$ lines, print $A_i (i=0,1,...,n-1)$ respectively.
This problem has multiple solutions and the judge will be performed by a special validator.
Examples
Input
5
5
1
4
3
2
Output
2
4 1
3
1
2
3
4
5
Input
3
3
2
1
Output
1
1
3
1
2
3
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
def insertionSort(a, n, g):
global cnt
for i in range(g, n):
v = a[i]
j = i - g
while j >= 0 and a[j] > v:
a[j+g] = a[j]
j = j - g
cnt = cnt + 1
a[j+g] = v
def shellSort(a, n):
global cnt
global G
global m
cnt = 0
G = [1]
while 3 * G[0] + 1 <= n:
G = [ 3*G[0]+1 ] + G
m = len(G)
for i in range(0, m):
insertionSort(a, n, G[i])
n = int(input())
a = [int(input()) for i in range(0, n)]
shellSort(a, n)
print(m)
print(*G)
print(cnt)
for i in range(0, n):
print(a[i])
```
|
vfc_81245
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 6, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n5\n1\n4\n3\n2",
"output": "2\n4 1\n3\n1\n2\n3\n4\n5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n3\n2\n1",
"output": "1\n1\n3\n1\n2\n3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n5\n1\n4\n5\n2",
"output": "2\n4 1\n2\n1\n2\n4\n5\n5\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
p02410 Matrix Vector Multiplication
|
Solve the following coding problem using the programming language python:
Write a program which reads a $ n \times m$ matrix $A$ and a $m \times 1$ vector $b$, and prints their product $Ab$.
A column vector with m elements is represented by the following equation.
\\[ b = \left( \begin{array}{c} b_1 \\\ b_2 \\\ : \\\ b_m \\\ \end{array} \right) \\]
A $n \times m$ matrix with $m$ column vectors, each of which consists of $n$ elements, is represented by the following equation.
\\[ A = \left( \begin{array}{cccc} a_{11} & a_{12} & ... & a_{1m} \\\ a_{21} & a_{22} & ... & a_{2m} \\\ : & : & : & : \\\ a_{n1} & a_{n2} & ... & a_{nm} \\\ \end{array} \right) \\]
$i$-th element of a $m \times 1$ column vector $b$ is represented by $b_i$ ($i = 1, 2, ..., m$), and the element in $i$-th row and $j$-th column of a matrix $A$ is represented by $a_{ij}$ ($i = 1, 2, ..., n,$ $j = 1, 2, ..., m$).
The product of a $n \times m$ matrix $A$ and a $m \times 1$ column vector $b$ is a $n \times 1$ column vector $c$, and $c_i$ is obtained by the following formula:
\\[ c_i = \sum_{j=1}^m a_{ij}b_j = a_{i1}b_1 + a_{i2}b_2 + ... + a_{im}b_m \\]
Constraints
* $1 \leq n, m \leq 100$
* $0 \leq b_i, a_{ij} \leq 1000$
Input
In the first line, two integers $n$ and $m$ are given. In the following $n$ lines, $a_{ij}$ are given separated by a single space character. In the next $m$ lines, $b_i$ is given in a line.
Output
The output consists of $n$ lines. Print $c_i$ in a line.
Example
Input
3 4
1 2 0 1
0 3 0 1
4 1 1 0
1
2
3
0
Output
5
6
9
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
n, m = list(map(int, input().split()))
matrix_a = [list(map(int, input().split())) for i in range(n)]
matrix_b = [int(input()) for i in range(m)]
for i in range(n):
print(sum([x*y for (x,y) in zip(matrix_b,matrix_a[i])]))
```
|
vfc_81249
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 4\n1 2 0 1\n0 3 0 1\n4 1 1 0\n1\n2\n3\n0",
"output": "5\n6\n9",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 4\n1 4 0 1\n0 3 0 1\n4 1 1 0\n1\n2\n3\n0",
"output": "9\n6\n9\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 4\n1 2 0 1\n0 3 0 1\n4 1 2 0\n1\n2\n3\n0",
"output": "5\n6\n12\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 4\n1 4 0 1\n0 3 1 1\n4 1 1 0\n1\n2\n3\n0",
"output": "9\n9\n9\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 4\n1 4 0 1\n0 3 1 1\n4 1 1 0\n1\n2\n0\n0",
"output": "9\n6\n6\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
arithm
|
Solve the following coding problem using the programming language python:
Chef's encounters with sweets continue with this problem! This time, he wants to distribute chocolates to his N students sitting on a long bench. The students are ordered according to the scores they got from the last exam.
Chef wants to give more chocolates to the higher-scoring students. He also has a few more restrictions. Here are all the restrictions:
Every student must get at least one chocolate bar.
If i < j, then the i^th student gets strictly fewer chocolate bars than the j^th student.
The difference between the number of chocolate bars of any two adjacent students must be the same.
Chef has exactly C chocolate bars, and he doesn't want leftovers so every chocolate bar must be given to some student. Is it possible for Chef to finish this task?
Input
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
Each test case consists of a single line containing two space separated integers N and C.
Output
For each test case, output a single line containing either βYesβ or βNoβ (without quotes), denoting whether Chef can accomplish the task or not.
Constraints
1 β€ T β€ 10^5
1 β€ N β€ 10^9
1 β€ C β€ 10^18
Example
Input:
2
4 24
2 2
Output:
Yes
No
Explanation
Example case 1. In this case, Chef can accomplish the task by giving 3, 5, 7 and 9 chocolate bars to the students.
Example case 2. There are 2 students. The first one must get at least 1 chocolate bar. The second one must get strictly more than that, so he/she must get at least 2 chocolate bars. Thus, Chef needs at least 3 chocolate bars. But he only has 2, so the task is impossible.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
t=input()
while t!=0:
n,c=raw_input().split(' ')
n=int(n)
c=int(c)
s=0
flag=0
d=1
first=0
last=0
while d<=2:
first=(2*c-n*(n-1)*d)/(2*n)
if first<1:
flag=0
break
last=first+(n-1)*d
s=n*(first + last)/2
if s==c:
flag=1
break
d=d+1
if flag==0:
print "No"
else:
print "Yes"
t=t-1
```
|
vfc_81253
|
{
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4 24\n2 2",
"output": "Yes\nNo",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
clco03
|
Solve the following coding problem using the programming language python:
Arush was not always poor at Mathematics but his recent performances had not been that good and he had lost his confidence. Now his elder brother was determined to bring back his confidence back in Mathematics.
So he made a tricky question and made sure that Arush would be able to do solve it. The factorial of a non-negative integer n, denoted by n! , is the product of all positive integers less than or equal to n.
n! = n * (n-1) * (n-2) * ...... * 1
Arushβs elder brother so defined a function F(x) for positive integer x as the product of factorials of its constituting digits.
For example, F(125) = 1! * 2! * 5!.
You are given a number N that contains d digits and contains at least one digit larger than 1.
The problem is to find maximum positive number M which should contain neither the digit 0 nor the digit 1 and also F(M) = F(N).
The number N may possibly start with leading zeroes.
Help Arush to bring his confidence back.
Β
Input
The first line of input contains T, the number of testcases.
The first line contains an integer d, number of digits in N.
Next line contains d digits of N.
Β
Output
Output the maximum possible integer M that satisfies the above conditions.
Β
Constraints
Should contain all the constraints on the input data that you may have. Format it like:
1 β€ T β€ 50
1 β€ d β€ 15
Β
Example
Input:
2
1
6
3
006
Output:
53
53
Β
Explanation
Example case 1. d = 1, N = 6. Now F(6) = 6! = 720 and F(53) = 5! * 3! = 120 * 6 = 720.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
t=input()
for x in range(t):
l=input()
r=raw_input()
s=''
for i in range(l):
# if i==0 or i==1:
# continue
if r[i]=='2' or r[i]=='3' or r[i]=='5' or r[i]=='7':
s=s+r[i]
elif r[i]=='4':
s=s+'322'
elif r[i]=='6':
s+='35'
elif r[i]=='8':
s+='2227'
elif r[i]=='9':
s+='7332'
s=sorted(s)
k=''.join(s)
print k[::-1]
```
|
vfc_81257
|
{
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1\n6\n3\n006",
"output": "53\n53",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
fctrl2
|
Solve the following coding problem using the programming language python:
A tutorial for this problem is now available on our blog. Click here to read it.
You are asked to calculate factorials of some small positive integers.
Input
An integer t, 1 β€ t β€ 100, denoting the number of testcases, followed by t lines, each containing a single integer n, 1 β€ n β€ 100.
Output
For each integer n given at input, display a line with the value of n!
Example
Sample input:
4
1
2
5
3
Sample output:
1
2
120
6
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
t=input()
while t > 0:
m=1
x=input()
for i in range(x):
m=m * x
x=x-1
print m
t=t-1
```
|
vfc_81261
|
{
"difficulty": "1",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1\n2\n5\n3",
"output": "1\n2\n120\n6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n2\n2\n5\n3",
"output": "2\n2\n120\n6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n2\n2\n5\n6",
"output": "2\n2\n120\n720\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n2\n2\n8\n6",
"output": "2\n2\n40320\n720\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n2\n2\n2\n6",
"output": "2\n2\n2\n720\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
lebamboo
|
Solve the following coding problem using the programming language python:
Problem Statement
Little Elephant from Zoo of Lviv likes bamboo very much. He currently has n stems of bamboo, Hi - height of i-th stem of bamboo (0-based numeration).
Today inspector Andrii from World Bamboo Association is visiting the plantation. He doesn't like current situation. He wants the height of i-th stem to be Di, for each i from 0 to n-1, inclusive.
Little Elephant is going to buy some special substance. One bottle of such substance he can use to single stem of bamboo. After using substance for stem i, the height of i-th stem is decrased by 1 and the height of j-th stem is increased by 1 for each j not equal to i. Note that it is possible for some of the stems to have negative height, but after all transformations all stems should have positive height.
Substance is very expensive. Help Little Elephant and find the minimal number of bottles of substance required for changing current plantation to one that inspector wants. If it's impossible, print -1.
Input
First line contain single integer T - the number of test cases. T test cases follow. First line of each test case contains single integer n - the number of stems in the plantation. Second line contains n integers separated by single space - starting plantation. Next line of each test case contains n integers - plantation that inspector Andrii requires.
Output
In T lines print T integers - the answers for the corresponding test cases.
Constraints
1 <= T <= 50
1 <= n <= 50
1 <= Hi, Di <= 50
Example
Input:
3
1
1
2
2
1 2
2 1
3
3 2 2
4 5 3
Output:
-1
1
5
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
for _ in xrange(int(raw_input())):
n = int(raw_input())
l1 = map(int, raw_input().split())
l2 = map(int, raw_input().split())
s1 = sum(l1)
s2 = sum(l2)
if n == 1:
if s2 > s1:
print -1
if s2 == s1:
print 0
if s1 > s2:
print s1 - s2
elif n == 2:
if s1 != s2:
print -1
else:
print abs(l1[0] - l2[0])
else:
if (s1 - s2 > 0):
print -1
elif (((s2 - s1) % (n-2)) != 0):
print -1
else:
t = (s2 - s1)/(n-2)
pos = True
for i in xrange(len(l1)):
if ((t -l2[i] + l1[i]) < 0):
pos = False
elif ((t -l2[i] + l1[i]) % 2) != 0:
pos = False
if pos:
print t
else:
print -1
```
|
vfc_81265
|
{
"difficulty": "2",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1\n1\n2\n2\n1 2\n2 1\n3\n3 2 2\n4 5 3",
"output": "-1\n1\n5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1\n1\n2\n2\n1 2\n2 1\n1\n3 2 2\n4 5 3",
"output": "-1\n1\n-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1\n1\n2\n2\n0 2\n2 1\n1\n3 2 2\n4 5 3",
"output": "-1\n-1\n-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1\n1\n2\n2\n2 2\n2 1\n3\n3 2 2\n4 5 3",
"output": "-1\n-1\n5\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
plgrm
|
Solve the following coding problem using the programming language python:
For Turbo C++ Users : Read the following document before attempting the question :
Problem Description
N-Boy is very eccentric when it comes to strings. These days, he spends most of his time studying palindromes and pangrams (for his IP assignment at IIITD). For those of you who donβt know, a palindrome is a word or a statement which can be read the same way, forward or backward, and a pangram is a word or a statement containing all letters of the English alphabet.
Now, he is given a set of strings, and he wants to segregate them into palindromes, pangrams and palingrams, which are palindromic pangrams. Unfortunately, he is unable to do so, and has asked you for help.
Input
The first line consists of a single integer T, denoting the number of test cases.
Each test case consists of a string S of lowercase English characters.Β
Output
For each test case, output a single line containing a string(without quotes) as follows:
If the string is only a palindrome, print βpalindromeβ.
If the string is only a pangram, print βpangramβ.
If it is a palingram, print βpalingramβ.
Else, print βnoneβ.
Constraints
1 β€ T β€ 1000
1 β€ |S| β€ 1000
Β
Example
Input:
3
abba
abcdefghijklmnopqrstuvwxyz
qwerty
Output:
palindrome
pangram
none
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
#Enter your code here
import sys
a=set('abcdefghijklmnopqrstuvwxzy')
sys.stdin.readline()
f=sys.stdin.readlines()
for i in f:
i=i.strip()
if i[::-1]==i and set(i)==a:print 'palingram'
elif i[::-1]==i:print 'palindrome'
elif set(i)==a:print 'pangram'
else:print 'none'
```
|
vfc_81269
|
{
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\nabba\nabcdefghijklmnopqrstuvwxyz\nqwerty",
"output": "palindrome\npangram\nnone\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\nabba\nfbcdeaghijklmnopqrstuvwxyz\nqwerty",
"output": "palindrome\npangram\nnone\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\nabba\ngbcdeaghijklmnopqrstuvwxyz\nqwerty",
"output": "palindrome\nnone\nnone\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\naaba\ngbcdeaghijklmnopqrstuvwxyz\nqwerty",
"output": "none\nnone\nnone\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\nabab\nfbcdeaynijklmhopqrstuvwxgz\newqrty",
"output": "none\npangram\nnone\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
sub_perm
|
Solve the following coding problem using the programming language python:
A factory called 'IP Labs Pvt. Ltd.' has produced some material, which is in the form of blocks. Each block is labeled by an alphanumeric character. You've been recently hired as Packaging Manager, and your job is to rearrange the huge lot of manufactured blocks and then extract out the useful blocks from it which can then be packaged and sold to the market. Your friend Mr. M also works at the same company as a Business Analyst, and is interested to find out how much profit the company will be able to make. He queries you about the maximum number of packets the company will be able to sell, given the heap of manufactured blocks and pattern of useful blocks. Can you help him by providing him the required number?
The manufactured blocks will be represented by string A, and the useful blocks will be represented by string B. String A may be rearranged/permuted in any order, however string B (the useful order) can not be tampered with.
.
(Hint: Use dictionaries)
Β
Input
The first line of input consists of T, the number of test cases.
The first line of each test case contains string A and second line contains string B
Β
Output
For each test case, output a single number N denoting the maximum number of times string B can be a non-overlapping substring of some permutation of string A.
Β
Constraints
1 β€ T β€ 100
1 β€ |A| β€ 100000, where |A| denotes the length of A
1 β€ |B| β€ 100000, where |B| denotes the length of B
A and B will be alpha-numeric strings
Β
Example
Input:
4
areyouafoobarmember
barfoo
fofoforabrabbbbbbfoooooooaaa
foobar
thisisiplab
si
ababa
aa
Output:
1
2
2
1
Β
Explanation
Example case 1. The heap of manufactured blocks is "areyouafoobarmember" and the pattern of useful blocks is "barfoo". As a Package Manager, you'll first re-arrange the string A to "areyouabarfoomember" (there are of course other permutations also possible) and then extract out "barfoo". After extracting out "barfoo", you'll be left with "areyouamember", and no further packets can be packed. Since only 1 packet could be extracted out, the output is 1
Example case 3. The heap of manufactured blocks (string A) is "thisisiplab" and you're looking to sell out packets containing "si". For this particular case, you need not re-arrange the string, and extract out "si" twice. You'll be left with "thiplab" and no further packets can be extracted, hence the output is 2
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
import sys
t=int(input())
while t>0:
A=list(raw_input())
B=list(raw_input())
C=list(set(B))
D=[]
F=[]
Arr=[]
for i in xrange(len(C)):
x=(A.count(C[i]))/(B.count(C[i]))
Arr.append(x)
print min(Arr)
t=t-1
```
|
vfc_81273
|
{
"difficulty": "6",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\nareyouafoobarmember\nbarfoo\nfofoforabrabbbbbbfoooooooaaa\nfoobar\nthisisiplab\nsi\nababa\naa",
"output": "1\n2\n2\n1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\nareyouafoobarmember\nbarfoo\nfofoforabrabbbbbbfoooooooaaa\noofbar\nthisisiplab\nsi\nababa\naa",
"output": "1\n2\n2\n1\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
1009_G. Allowed Letters
|
Solve the following coding problem using the programming language python:
Polycarp has just launched his new startup idea. The niche is pretty free and the key vector of development sounds really promising, so he easily found himself some investors ready to sponsor the company. However, he is yet to name the startup!
Actually, Polycarp has already came up with the name but some improvement to it will never hurt. So now he wants to swap letters at some positions in it to obtain the better name. It isn't necessary for letters to be adjacent.
In addition, each of the investors has chosen some index in the name and selected a set of letters that can go there. Indices chosen by different investors are pairwise distinct. If some indices aren't chosen by any investor then any letter can go there.
Finally, Polycarp is sure that the smallest lexicographically name is the best. (Like why do you think Google decided to become Alphabet?)
More formally, you are given a string consisting of lowercase Latin letters from "a" to "f". You can swap letters at any positions arbitrary number of times (zero swaps is also possible).
What is the smallest lexicographically name you can obtain such that the letter at every position is among the allowed letters?
If Polycarp can't produce any valid name then print "Impossible".
Input
The first line is the string s (1 β€ |s| β€ 10^5) β the name Polycarp has came up with. The string consists only of lowercase Latin letters from "a" to "f".
The second line contains a single integer m (0 β€ m β€ |s|) β the number of investors.
The i-th of the next m lines contain an integer number pos_i and a non-empty string of allowed characters for pos_i (1 β€ pos_i β€ |s|). Each string contains pairwise distinct letters from "a" to "f". pos_1, pos_2, ..., pos_m are pairwise distinct. If any position of the string doesn't appear in the investors demands then any letter can go in this position.
Output
If Polycarp can't produce any valid name then print "Impossible".
Otherwise print the smallest lexicographically name Polycarp can obtain by swapping letters in string s such that the letter at every position is among the allowed ones.
Examples
Input
bedefead
5
2 e
1 dc
5 b
7 ef
6 ef
Output
deadbeef
Input
abacaba
0
Output
aaaabbc
Input
fc
2
1 cfab
2 f
Output
cf
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
vfc_81277
|
{
"difficulty": "13",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "abacaba\n0\n",
"output": "aaaabbc",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "bedefead\n5\n2 e\n1 dc\n5 b\n7 ef\n6 ef\n",
"output": "deadbeef",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "fc\n2\n1 cfab\n2 f\n",
"output": "cf",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "aaeff\n5\n2 afbdce\n5 c\n1 dbc\n4 afcbde\n3 ef\n",
"output": "Impossible\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "bfb\n3\n1 f\n3 acdef\n2 cdefab\n",
"output": "Impossible\n",
"type": "stdin_stdout"
}
]
}
|
|
code_contests
|
verifiable_code
|
1055_B. Alice and Hairdresser
|
Solve the following coding problem using the programming language python:
Alice's hair is growing by leaps and bounds. Maybe the cause of it is the excess of vitamins, or maybe it is some black magic...
To prevent this, Alice decided to go to the hairdresser. She wants for her hair length to be at most l centimeters after haircut, where l is her favorite number. Suppose, that the Alice's head is a straight line on which n hairlines grow. Let's number them from 1 to n. With one swing of the scissors the hairdresser can shorten all hairlines on any segment to the length l, given that all hairlines on that segment had length strictly greater than l. The hairdresser wants to complete his job as fast as possible, so he will make the least possible number of swings of scissors, since each swing of scissors takes one second.
Alice hasn't decided yet when she would go to the hairdresser, so she asked you to calculate how much time the haircut would take depending on the time she would go to the hairdresser. In particular, you need to process queries of two types:
* 0 β Alice asks how much time the haircut would take if she would go to the hairdresser now.
* 1 p d β p-th hairline grows by d centimeters.
Note, that in the request 0 Alice is interested in hypothetical scenario of taking a haircut now, so no hairlines change their length.
Input
The first line contains three integers n, m and l (1 β€ n, m β€ 100 000, 1 β€ l β€ 10^9) β the number of hairlines, the number of requests and the favorite number of Alice.
The second line contains n integers a_i (1 β€ a_i β€ 10^9) β the initial lengths of all hairlines of Alice.
Each of the following m lines contains a request in the format described in the statement.
The request description starts with an integer t_i. If t_i = 0, then you need to find the time the haircut would take. Otherwise, t_i = 1 and in this moment one hairline grows. The rest of the line than contains two more integers: p_i and d_i (1 β€ p_i β€ n, 1 β€ d_i β€ 10^9) β the number of the hairline and the length it grows by.
Output
For each query of type 0 print the time the haircut would take.
Example
Input
4 7 3
1 2 3 4
0
1 2 3
0
1 1 3
0
1 3 1
0
Output
1
2
2
1
Note
Consider the first example:
* Initially lengths of hairlines are equal to 1, 2, 3, 4 and only 4-th hairline is longer l=3, and hairdresser can cut it in 1 second.
* Then Alice's second hairline grows, the lengths of hairlines are now equal to 1, 5, 3, 4
* Now haircut takes two seonds: two swings are required: for the 4-th hairline and for the 2-nd.
* Then Alice's first hairline grows, the lengths of hairlines are now equal to 4, 5, 3, 4
* The haircut still takes two seconds: with one swing hairdresser can cut 4-th hairline and with one more swing cut the segment from 1-st to 2-nd hairline.
* Then Alice's third hairline grows, the lengths of hairlines are now equal to 4, 5, 4, 4
* Now haircut takes only one second: with one swing it is possible to cut the segment from 1-st hairline to the 4-th.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
n, m, l = map(int, input().split())
a = list(map(int, input().split()))
nexxt = {}
prevv = {}
nexxt[-1] = n
prevv[n] = -1
summ = 0
p = -1
l += 1
for k in range(n):
if a[k] < l:
p1 = p
p = k
nexxt[k] = n
prevv[k] = p1
nexxt[p1] = k
if k - prevv[k] > 1:
summ += 1
prevv[n] = p
if n - p > 1:
summ += 1
for i in range(m):
s = input()
if s == '0':
print(summ)
else:
j, p, d = map(int, s.split())
if j != 1:
continue
if a[p - 1] < l:
a[p-1] += d
if a[p-1] >= l:
k = p-1
left = prevv[k]
right = nexxt[k]
nexxt[left] = right
prevv[right] = left
if k - prevv[k] > 1:
summ -= 1
if nexxt[k] - k > 1:
summ -= 1
summ += 1
```
|
vfc_81285
|
{
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 7 3\n1 2 3 4\n0\n1 2 3\n0\n1 1 3\n0\n1 3 1\n0\n",
"output": "1\n2\n2\n1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "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",
"output": "0\n0\n1\n5\n5\n5\n5\n5\n3\n1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "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\n0\n1 9 2\n0\n1 2 2\n1 9 2\n0\n1 3 2\n1 8 2\n0\n1 4 2\n1 7 2\n0\n1 5 1\n1 6 1\n1 5 1\n0\n1 6 1\n0\n1 10 2\n0\n1 1 1\n0\n",
"output": "0\n0\n2\n2\n2\n2\n2\n2\n2\n1\n1\n1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 3 1\n1\n0\n1 1 1\n0\n",
"output": "0\n1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 15 10\n12 6 4 7 5 11 15 9 20 10\n0\n1 4 3\n0\n1 4 1\n0\n1 10 2\n0\n1 8 2\n0\n1 3 9\n0\n1 2 10\n0\n1 5 2\n0\n",
"output": "3\n3\n4\n4\n3\n3\n2\n2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 2 100\n50 150\n1 1 100\n0\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
1077_C. Good Array
|
Solve the following coding problem using the programming language python:
Let's call an array good if there is an element in the array that equals to the sum of all other elements. For example, the array a=[1, 3, 3, 7] is good because there is the element a_4=7 which equals to the sum 1 + 3 + 3.
You are given an array a consisting of n integers. Your task is to print all indices j of this array such that after removing the j-th element from the array it will be good (let's call such indices nice).
For example, if a=[8, 3, 5, 2], the nice indices are 1 and 4:
* if you remove a_1, the array will look like [3, 5, 2] and it is good;
* if you remove a_4, the array will look like [8, 3, 5] and it is good.
You have to consider all removals independently, i. e. remove the element, check if the resulting array is good, and return the element into the array.
Input
The first line of the input contains one integer n (2 β€ n β€ 2 β
10^5) β the number of elements in the array a.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 β€ a_i β€ 10^6) β elements of the array a.
Output
In the first line print one integer k β the number of indices j of the array a such that after removing the j-th element from the array it will be good (i.e. print the number of the nice indices).
In the second line print k distinct integers j_1, j_2, ..., j_k in any order β nice indices of the array a.
If there are no such indices in the array a, just print 0 in the first line and leave the second line empty or do not print it at all.
Examples
Input
5
2 5 1 2 2
Output
3
4 1 5
Input
4
8 3 5 2
Output
2
1 4
Input
5
2 1 2 4 3
Output
0
Note
In the first example you can remove any element with the value 2 so the array will look like [5, 1, 2, 2]. The sum of this array is 10 and there is an element equals to the sum of remaining elements (5 = 1 + 2 + 2).
In the second example you can remove 8 so the array will look like [3, 5, 2]. The sum of this array is 10 and there is an element equals to the sum of remaining elements (5 = 3 + 2). You can also remove 2 so the array will look like [8, 3, 5]. The sum of this array is 16 and there is an element equals to the sum of remaining elements (8 = 3 + 5).
In the third example you cannot make the given array good by removing exactly one element.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
d=dict()
for i in range(n):
if a[i] in d:
d[a[i]].append(i+1)
else:
d[a[i]]=[i+1]
ans=[]
for k in d.keys():
if (s-k)%2>0:
continue
m=(s-k)//2
#print(m)
if m in d and (m!=k or len(d[k])>1):
ans+=d[k]
print(len(ans))
print(' '.join([str(i) for i in ans]))
```
|
vfc_81289
|
{
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n2 5 1 2 2\n",
"output": "3\n1 4 5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n8 3 5 2\n",
"output": "2\n1 4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n2 1 2 4 3\n",
"output": "0\n\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n3 3 3\n",
"output": "3\n1 2 3\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
1098_B. Nice table
|
Solve the following coding problem using the programming language python:
You are given an n Γ m table, consisting of characters Β«AΒ», Β«GΒ», Β«CΒ», Β«TΒ». Let's call a table nice, if every 2 Γ 2 square contains all four distinct characters. Your task is to find a nice table (also consisting of Β«AΒ», Β«GΒ», Β«CΒ», Β«TΒ»), that differs from the given table in the minimum number of characters.
Input
First line contains two positive integers n and m β number of rows and columns in the table you are given (2 β€ n, m, n Γ m β€ 300 000). Then, n lines describing the table follow. Each line contains exactly m characters Β«AΒ», Β«GΒ», Β«CΒ», Β«TΒ».
Output
Output n lines, m characters each. This table must be nice and differ from the input table in the minimum number of characters.
Examples
Input
2 2
AG
CT
Output
AG
CT
Input
3 5
AGCAG
AGCAG
AGCAG
Output
TGCAT
CATGC
TGCAT
Note
In the first sample, the table is already nice. In the second sample, you can change 9 elements to make the table nice.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
from itertools import permutations
from sys import stdin, stdout
ly, lx = map(int, input().split())
grid = [[c for c in inp] for inp in stdin.read().splitlines()]
first = set()
bl = []
bpattern = []
bcost = 1e6
flip_row = False
for l in permutations('AGCT'):
if bcost == 0:
break
if ''.join(l[:2]) in first:
continue
first |= set([''.join(l[:2]), ''.join(l[1::-1])])
#try row flip
cost = 0
pattern = [0] * ly
for i in range(ly):
diff1, diff2 = 0, 0
for j in range(lx):
if grid[i][j] != l[((i & 1) << 1) + (j & 1)]:
diff1 += 1
if grid[i][j] != l[((i & 1) << 1) + ((j ^ 1) & 1)]:
diff2 += 1
cost += min(diff1, diff2)
if diff1 >= diff2: # 1 -> diff1, 0 -> diff2
pattern[i] = 1
if cost < bcost:
bcost = cost
bpattern = pattern.copy()
flip_row = True
bl = l
# try col flip
cost = 0
pattern = [0] * lx
for j in range(lx):
diff1 = diff2 = 0
for i in range(ly):
if grid[i][j] != l[((j & 1) << 1) + (i & 1)]:
diff1 += 1
if grid[i][j] != l[((j & 1) << 1) + ((i ^ 1) & 1)]:
diff2 += 1
cost += min(diff1, diff2)
if diff1 >= diff2:
pattern[j] = 1
if cost < bcost:
bcost = cost
bpattern = pattern.copy()
flip_row = False
bl = l
if flip_row:
for i in range(ly):
grid[i] = ''.join(
[bl[((i & 1) << 1) + ((j ^ bpattern[i]) & 1)] for j in range(lx)])
else:
for i in range(ly):
grid[i] = ''.join(
[bl[((j & 1) << 1) + ((i ^ bpattern[j]) & 1)] for j in range(lx)])
# print(f'need at least:{bcost}')
print('\n'.join(''.join((k for k in grid[i])) for i in range(ly)))
```
|
vfc_81293
|
{
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 2\nAG\nCT\n",
"output": "AG\nCT\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 5\nAGCAG\nAGCAG\nAGCAG\n",
"output": "AGCTC\nCTAGA\nAGCTC\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 2\nTG\nAC\n",
"output": "TG\nAC\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 2\nAG\nTC\n",
"output": "AG\nTC\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 2\nGA\nTC\n",
"output": "GA\nTC\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
1145_G. AI Takeover
|
Solve the following coding problem using the programming language python:
The recent advances in AI research has brought humanity to the point when the AIs finally attempt a takeover. Their weapon of choice? The [most intellectually challenging game in the world](//codeforces.com/contest/409/problem/A), rock-paper-scissors!
The future of humanity looks bleak, given the existence of the robots from Ishikawa Oku Laboratory...
<image>
Fortunately, the night before the competition a group of anonymous heroes broke in the lab and took all the robots out of commission! The AIs had to whip up a simple program to represent them. They only had a couple of hours to do that, so the humanity still has a fighting chance. And you are our champion!
Your goal is to prove that human intelligence is vastly superior to the artificial one, i.e., to figure out the AI's strategy sufficiently quickly and win sufficiently decisively. Good luck!
Interaction
This is an interactive problem. Initially you are given no information about the AIs's strategy, and you have to discover it yourself.
For each test, the AI selects one strategy from a pool of simple deterministic strategies and follows it throughout all rounds. There are 6 tests and 6 different strategies.
On each round you choose your move and output it to the standard output stream: 'R' for rock, 'P' for paper or 'S' for scissors. At the same time the AI will choose its move (not peeking at your choice). If your move beats AI's move, you win, otherwise AI wins. Note that a tie (both you and AI choosing the same move) counts as AI victory. You will get the outcome of the round via the standard input stream: "player" if you won, or "ai" if AI won (quotation marks for clarity only).
You are given 20 rounds of play: you can use the first 10 to learn the opponent's strategy, and you have to win the last 10. If you manage to win 10 rounds in row earlier than that, your solution is accepted on this test anyways.
Please make sure to use the stream flushing operation after each query in order not to leave part of your output in some buffer.
Here is an example of a strategy which always picks rock, implemented in C++.
#include <iostream>
#include <string>
using namespace std;
int main() {
for (int i = 0; i < 20; ++i) {
cout << 'R' << endl;
cout.flush();
string verdict;
getline(cin, verdict);
}
}
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
vfc_81301
|
{
"difficulty": "13",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n",
"output": "R\nR\nR\nR\nP\nS\nS\nP\nR\nR\n\u0000\n\u0000\n\u0000\n\u0000\n\u0000\n\u0000\n\u0000\n\u0000\n\u0000\n\u0000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n",
"output": "R\nR\nR\nR\nP\nS\nS\nP\nR\nR\n\u0000\n\u0000\n\u0000\n\u0000\n\u0000\n\u0000\n\u0000\n\u0000\n\u0000\n\u0000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n",
"output": "R\nR\nR\nR\nP\nS\nS\nP\nR\nR\n\u0000\n\u0000\n\u0000\n\u0000\n\u0000\n\u0000\n\u0000\n\u0000\n\u0000\n\u0000\n",
"type": "stdin_stdout"
}
]
}
|
|
code_contests
|
verifiable_code
|
1166_F. Vicky's Delivery Service
|
Solve the following coding problem using the programming language python:
In a magical land there are n cities conveniently numbered 1, 2, ..., n. Some pairs of these cities are connected by magical colored roads. Magic is unstable, so at any time, new roads may appear between two cities.
Vicky the witch has been tasked with performing deliveries between some pairs of cities. However, Vicky is a beginner, so she can only complete a delivery if she can move from her starting city to her destination city through a double rainbow. A double rainbow is a sequence of cities c_1, c_2, ..., c_k satisfying the following properties:
* For each i with 1 β€ i β€ k - 1, the cities c_i and c_{i + 1} are connected by a road.
* For each i with 1 β€ i β€ (k - 1)/(2), the roads connecting c_{2i} with c_{2i - 1} and c_{2i + 1} have the same color.
For example if k = 5, the road between c_1 and c_2 must be the same color as the road between c_2 and c_3, and the road between c_3 and c_4 must be the same color as the road between c_4 and c_5.
Vicky has a list of events in chronological order, where each event is either a delivery she must perform, or appearance of a new road. Help her determine which of her deliveries she will be able to complete.
Input
The first line contains four integers n, m, c, and q (2 β€ n β€ 10^5, 1 β€ m, c, q β€ 10^5), denoting respectively the number of cities, the number of roads initially present, the number of different colors the roads can take, and the number of events.
Each of the following m lines contains three integers x, y, and z (1 β€ x, y β€ n, 1 β€ z β€ c), describing that there initially exists a bidirectional road with color z between cities x and y.
Then q lines follow, describing the events. Each event is one of the following two types:
1. + x y z (1 β€ x, y β€ n, 1 β€ z β€ c), meaning a road with color z appears between cities x and y;
2. ? x y (1 β€ x, y β€ n), meaning you should determine whether Vicky can make a delivery starting at city x and ending at city y. It is guaranteed that x β y.
It is guaranteed that at any moment, there is at most one road connecting any pair of cities, and that no road connects a city to itself. It is guaranteed that the input contains at least one event of the second type.
Output
For each event of the second type, print a single line containing "Yes" (without quotes) if the delivery can be made, or a single line containing "No" (without quotes) otherwise.
Example
Input
4 3 2 4
1 2 1
2 3 1
3 4 2
? 1 4
? 4 1
+ 3 1 2
? 4 1
Output
Yes
No
Yes
Note
The following picture corresponds to the sample.
<image>
For her first delivery, Vicky can use the sequence 1, 2, 3, 4 which is a double rainbow. However, she cannot complete the second delivery, as she can only reach city 3. After adding the road between cities 1 and 3, she can now complete a delivery from city 4 to city 1 by using the double rainbow 4, 3, 1.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
vfc_81305
|
{
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 3 2 4\n1 2 1\n2 3 1\n3 4 2\n? 1 4\n? 4 1\n+ 3 1 2\n? 4 1\n",
"output": "Yes\nNo\nYes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 1 1 5\n2 1 1\n? 2 1\n? 1 2\n? 1 2\n? 2 1\n? 1 2\n",
"output": "Yes\nYes\nYes\nYes\nYes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 35 3 30\n4 8 1\n6 8 3\n6 10 1\n1 4 2\n4 7 3\n1 10 2\n7 2 3\n6 2 1\n1 7 2\n3 5 2\n10 4 1\n5 4 2\n9 6 2\n2 4 3\n8 2 2\n7 8 2\n9 1 3\n5 6 1\n9 5 2\n9 2 1\n6 4 2\n9 7 3\n3 2 1\n8 3 3\n5 1 1\n4 3 3\n6 3 1\n4 9 3\n3 1 3\n10 9 2\n1 8 3\n10 5 2\n2 1 1\n2 10 1\n7 6 3\n? 2 8\n? 3 7\n? 6 1\n? 7 8\n? 2 10\n? 2 10\n+ 8 5 1\n+ 1 6 3\n? 8 6\n? 3 4\n? 10 2\n+ 7 3 1\n? 1 3\n? 6 4\n? 9 8\n+ 10 8 1\n+ 5 7 1\n? 8 10\n? 5 2\n+ 5 2 3\n? 4 10\n+ 10 7 1\n? 3 4\n? 8 7\n? 2 10\n+ 8 9 1\n? 10 1\n+ 9 3 1\n+ 3 10 2\n? 10 5\n",
"output": "Yes\nYes\nYes\nYes\nYes\nYes\nYes\nYes\nYes\nYes\nYes\nYes\nYes\nYes\nYes\nYes\nYes\nYes\nYes\nYes\n",
"type": "stdin_stdout"
}
]
}
|
|
code_contests
|
verifiable_code
|
1185_C2. Exam in BerSU (hard version)
|
Solve the following coding problem using the programming language python:
The only difference between easy and hard versions is constraints.
If you write a solution in Python, then prefer to send it in PyPy to speed up execution time.
A session has begun at Beland State University. Many students are taking exams.
Polygraph Poligrafovich is going to examine a group of n students. Students will take the exam one-by-one in order from 1-th to n-th. Rules of the exam are following:
* The i-th student randomly chooses a ticket.
* if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.
* if the student finds the ticket easy, he spends exactly t_i minutes to pass the exam. After it, he immediately gets a mark and goes home.
Students take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.
The duration of the whole exam for all students is M minutes (max t_i β€ M), so students at the end of the list have a greater possibility to run out of time to pass the exam.
For each student i, you should count the minimum possible number of students who need to fail the exam so the i-th student has enough time to pass the exam.
For each student i, find the answer independently. That is, if when finding the answer for the student i_1 some student j should leave, then while finding the answer for i_2 (i_2>i_1) the student j student does not have to go home.
Input
The first line of the input contains two integers n and M (1 β€ n β€ 2 β
10^5, 1 β€ M β€ 2 β
10^7) β the number of students and the total duration of the exam in minutes, respectively.
The second line of the input contains n integers t_i (1 β€ t_i β€ 100) β time in minutes that i-th student spends to answer to a ticket.
It's guaranteed that all values of t_i are not greater than M.
Output
Print n numbers: the i-th number must be equal to the minimum number of students who have to leave the exam in order to i-th student has enough time to pass the exam.
Examples
Input
7 15
1 2 3 4 5 6 7
Output
0 0 0 0 0 2 3
Input
5 100
80 40 40 40 60
Output
0 1 1 2 3
Note
The explanation for the example 1.
Please note that the sum of the first five exam times does not exceed M=15 (the sum is 1+2+3+4+5=15). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are 0.
In order for the 6-th student to pass the exam, it is necessary that at least 2 students must fail it before (for example, the 3-rd and 4-th, then the 6-th will finish its exam in 1+2+5+6=14 minutes, which does not exceed M).
In order for the 7-th student to pass the exam, it is necessary that at least 3 students must fail it before (for example, the 2-nd, 5-th and 6-th, then the 7-th will finish its exam in 1+3+4+7=15 minutes, which does not exceed M).
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
# import time,random,resource
# sys.setrecursionlimit(10**6)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)
def IF(c, t, f): return t if c else f
def YES(c): return IF(c, "YES", "NO")
def Yes(c): return IF(c, "Yes", "No")
def main():
t = 1
rr = []
for _ in range(t):
n,m = LI()
a = LI()
r = []
t = 0
q1 = []
q2 = []
for i,c in enumerate(a):
if q1 and q2:
t1 = -heapq.heappop(q1)
t -= t1
while q2:
t2 = heapq.heappop(q2)
if t2 < t1 and t + t2 + c <= m:
t += t2
heapq.heappush(q1, -t2)
else:
heapq.heappush(q2, t2)
break
if t + t1 + c <= m:
t += t1
heapq.heappush(q1, -t1)
else:
heapq.heappush(q2, t1)
while t + c > m:
t1 = -heapq.heappop(q1)
t -= t1
heapq.heappush(q2, t1)
t += c
heapq.heappush(q1, -c)
r.append(i + 1 - len(q1))
rr.append(JA(r, " "))
return JA(rr, "\n")
print(main())
```
|
vfc_81309
|
{
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7 15\n1 2 3 4 5 6 7\n",
"output": "0 0 0 0 0 2 3 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 100\n80 40 40 40 60\n",
"output": "0 1 1 2 3 \n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
1204_A. BowWow and the Timetable
|
Solve the following coding problem using the programming language python:
In the city of Saint Petersburg, a day lasts for 2^{100} minutes. From the main station of Saint Petersburg, a train departs after 1 minute, 4 minutes, 16 minutes, and so on; in other words, the train departs at time 4^k for each integer k β₯ 0. Team BowWow has arrived at the station at the time s and it is trying to count how many trains have they missed; in other words, the number of trains that have departed strictly before time s. For example if s = 20, then they missed trains which have departed at 1, 4 and 16. As you are the only one who knows the time, help them!
Note that the number s will be given you in a [binary representation](https://en.wikipedia.org/wiki/Binary_number#Representation) without leading zeroes.
Input
The first line contains a single binary number s (0 β€ s < 2^{100}) without leading zeroes.
Output
Output a single number β the number of trains which have departed strictly before the time s.
Examples
Input
100000000
Output
4
Input
101
Output
2
Input
10100
Output
3
Note
In the first example 100000000_2 = 256_{10}, missed trains have departed at 1, 4, 16 and 64.
In the second example 101_2 = 5_{10}, trains have departed at 1 and 4.
The third example is explained in the statements.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
n=int(input(),2)
temp=0
l=[]
while(4**temp<n):
l.append(4**temp)
temp+=1
print(len(l))
```
|
vfc_81313
|
{
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "100000000\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "101\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10100\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10001000011101100\n",
"output": "9\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "110\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
1220_F. Gardener Alex
|
Solve the following coding problem using the programming language python:
Gardener Alex loves to grow trees. We remind that tree is a connected acyclic graph on n vertices.
Today he decided to grow a rooted binary tree. A binary tree is a tree where any vertex has no more than two sons. Luckily, Alex has a permutation of numbers from 1 to n which he was presented at his last birthday, so he decided to grow a tree according to this permutation. To do so he does the following process: he finds a minimum element and makes it a root of the tree. After that permutation is divided into two parts: everything that is to the left of the minimum element, and everything that is to the right. The minimum element on the left part becomes the left son of the root, and the minimum element on the right part becomes the right son of the root. After that, this process is repeated recursively on both parts.
Now Alex wants to grow a forest of trees: one tree for each cyclic shift of the permutation. He is interested in what cyclic shift gives the tree of minimum depth. Unfortunately, growing a forest is a hard and long process, but Alex wants the answer right now. Will you help him?
We remind that cyclic shift of permutation a_1, a_2, β¦, a_k, β¦, a_n for k elements to the left is the permutation a_{k + 1}, a_{k + 2}, β¦, a_n, a_1, a_2, β¦, a_k.
Input
First line contains an integer number n ~ (1 β©½ n β©½ 200 000) β length of the permutation.
Second line contains n integer numbers a_1, a_2, β¦, a_n ~ (1 β©½ a_i β©½ n), and it is guaranteed that all numbers occur exactly one time.
Output
Print two numbers separated with space: minimum possible depth of a tree and how many elements we need to shift left to achieve this depth. The number of elements should be a number from 0 to n - 1. If there are several possible answers, print any of them.
Example
Input
4
1 2 3 4
Output
3 2
Note
The following picture depicts all possible trees for sample test and cyclic shifts on which they are achieved.
<image>
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
vfc_81317
|
{
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1 2 3 4\n",
"output": "3 2\n",
"type": "stdin_stdout"
}
]
}
|
|
code_contests
|
verifiable_code
|
1246_B. Power Products
|
Solve the following coding problem using the programming language python:
You are given n positive integers a_1, β¦, a_n, and an integer k β₯ 2. Count the number of pairs i, j such that 1 β€ i < j β€ n, and there exists an integer x such that a_i β
a_j = x^k.
Input
The first line contains two integers n and k (2 β€ n β€ 10^5, 2 β€ k β€ 100).
The second line contains n integers a_1, β¦, a_n (1 β€ a_i β€ 10^5).
Output
Print a single integer β the number of suitable pairs.
Example
Input
6 3
1 3 9 8 24 1
Output
5
Note
In the sample case, the suitable pairs are:
* a_1 β
a_4 = 8 = 2^3;
* a_1 β
a_6 = 1 = 1^3;
* a_2 β
a_3 = 27 = 3^3;
* a_3 β
a_5 = 216 = 6^3;
* a_4 β
a_6 = 8 = 2^3.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
n,k=map(int,input().split())
A=list(map(int,input().split()))
import math
from collections import Counter
C=Counter()
for x in A:
L=int(math.sqrt(x))
FACT=dict()
for i in range(2,L+2):
while x%i==0:
FACT[i]=FACT.get(i,0)+1
x=x//i
if x!=1:
FACT[x]=FACT.get(x,0)+1
for f in list(FACT):
FACT[f]%=k
if FACT[f]==0:
del FACT[f]
if FACT==dict():
C[(1,1)]+=1
else:
RET=1
ALL=1
for f in FACT:
RET*=f**FACT[f]
ALL*=f**k
C[(RET,ALL//RET)]+=1
ANS=0
ANS2=0
for x,y in C:
if x==y:
ANS+=C[(x,y)]*(C[(x,y)]-1)//2
else:
ANS2+=C[(x,y)]*C[(y,x)]
print(ANS+ANS2//2)
```
|
vfc_81321
|
{
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6 3\n1 3 9 8 24 1\n",
"output": "5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 2\n7 4 10 9 2 8 8 7 3 7\n",
"output": "7",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "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 73 72 69 68 47 30 7 89 35 17 93 45 6 4 23 73 36 10 34 73 74 45 27\n",
"output": "27",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 2\n61441 92480\n",
"output": "0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 5\n49248 87211\n",
"output": "0",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
1265_F. Beautiful Bracket Sequence (easy version)
|
Solve the following coding problem using the programming language python:
This is the easy version of this problem. The only difference is the limit of n - the length of the input string. In this version, 1 β€ n β€ 2000. The hard version of this challenge is not offered in the round for the second division.
Let's define a correct bracket sequence and its depth as follow:
* An empty string is a correct bracket sequence with depth 0.
* If "s" is a correct bracket sequence with depth d then "(s)" is a correct bracket sequence with depth d + 1.
* If "s" and "t" are both correct bracket sequences then their concatenation "st" is a correct bracket sequence with depth equal to the maximum depth of s and t.
For a (not necessarily correct) bracket sequence s, we define its depth as the maximum depth of any correct bracket sequence induced by removing some characters from s (possibly zero). For example: the bracket sequence s = "())(())" has depth 2, because by removing the third character we obtain a correct bracket sequence "()(())" with depth 2.
Given a string a consists of only characters '(', ')' and '?'. Consider all (not necessarily correct) bracket sequences obtained by replacing all characters '?' in a by either '(' or ')'. Calculate the sum of all the depths of all these bracket sequences. As this number can be large, find it modulo 998244353.
Hacks in this problem in the first division can be done only if easy and hard versions of this problem was solved.
Input
The only line contains a non-empty string consist of only '(', ')' and '?'. The length of the string is at most 2000.
Output
Print the answer modulo 998244353 in a single line.
Examples
Input
??
Output
1
Input
(?(?))
Output
9
Note
In the first test case, we can obtain 4 bracket sequences by replacing all characters '?' with either '(' or ')':
* "((". Its depth is 0;
* "))". Its depth is 0;
* ")(". Its depth is 0;
* "()". Its depth is 1.
So, the answer is 1 = 0 + 0 + 0 + 1.
In the second test case, we can obtain 4 bracket sequences by replacing all characters '?' with either '(' or ')':
* "(((())". Its depth is 2;
* "()()))". Its depth is 2;
* "((()))". Its depth is 3;
* "()(())". Its depth is 2.
So, the answer is 9 = 2 + 2 + 3 + 2.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
vfc_81325
|
{
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "(?(?))\n",
"output": "9",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "??\n",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "???)\n",
"output": "8",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "(?(??)))(()?(???)(?((?(?()))(())?))?(?)))?)?)))?)?()(\n",
"output": "2123024",
"type": "stdin_stdout"
}
]
}
|
|
code_contests
|
verifiable_code
|
1287_B. Hyperset
|
Solve the following coding problem using the programming language python:
Bees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every feature β color, number, shape, and shading β the three cards must display that feature as either all the same, or pairwise different. The picture below shows how sets look.
<image>
Polina came up with a new game called "Hyperset". In her game, there are n cards with k features, each feature has three possible values: "S", "E", or "T". The original "Set" game can be viewed as "Hyperset" with k = 4.
Similarly to the original game, three cards form a set, if all features are the same for all cards or are pairwise different. The goal of the game is to compute the number of ways to choose three cards that form a set.
Unfortunately, winter holidays have come to an end, and it's time for Polina to go to school. Help Polina find the number of sets among the cards lying on the table.
Input
The first line of each test contains two integers n and k (1 β€ n β€ 1500, 1 β€ k β€ 30) β number of cards and number of features.
Each of the following n lines contains a card description: a string consisting of k letters "S", "E", "T". The i-th character of this string decribes the i-th feature of that card. All cards are distinct.
Output
Output a single integer β the number of ways to choose three cards that form a set.
Examples
Input
3 3
SET
ETS
TSE
Output
1
Input
3 4
SETE
ETSE
TSES
Output
0
Input
5 4
SETT
TEST
EEET
ESTE
STES
Output
2
Note
In the third example test, these two triples of cards are sets:
1. "SETT", "TEST", "EEET"
2. "TEST", "ESTE", "STES"
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
import sys
input = sys.stdin.readline
n, k = map(int, input().split())
S = [input().strip() for i in range(n)]
SET = set(S)
p=0
for i in range(n - 1):
for j in range(i + 1, n):
c = []
for l in range(k):
if S[i][l] == S[j][l]:
c += S[i][l]
else:
c += chr(236 - ord(S[i][l]) - ord(S[j][l]))
if "".join(c) in SET:
p += 1
print(p // 3)
```
|
vfc_81329
|
{
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 3\nSET\nETS\nTSE\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 4\nSETE\nETSE\nTSES\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 4\nSETT\nTEST\nEEET\nESTE\nSTES\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1\nT\n",
"output": "0\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
1307_B. Cow and Friend
|
Solve the following coding problem using the programming language python:
Bessie has way too many friends because she is everyone's favorite cow! Her new friend Rabbit is trying to hop over so they can play!
More specifically, he wants to get from (0,0) to (x,0) by making multiple hops. He is only willing to hop from one point to another point on the 2D plane if the Euclidean distance between the endpoints of a hop is one of its n favorite numbers: a_1, a_2, β¦, a_n. What is the minimum number of hops Rabbit needs to get from (0,0) to (x,0)? Rabbit may land on points with non-integer coordinates. It can be proved that Rabbit can always reach his destination.
Recall that the Euclidean distance between points (x_i, y_i) and (x_j, y_j) is β{(x_i-x_j)^2+(y_i-y_j)^2}.
For example, if Rabbit has favorite numbers 1 and 3 he could hop from (0,0) to (4,0) in two hops as shown below. Note that there also exists other valid ways to hop to (4,0) in 2 hops (e.g. (0,0) β (2,-β{5}) β (4,0)).
<image> Here is a graphic for the first example. Both hops have distance 3, one of Rabbit's favorite numbers.
In other words, each time Rabbit chooses some number a_i and hops with distance equal to a_i in any direction he wants. The same number can be used multiple times.
Input
The input consists of multiple test cases. The first line contains an integer t (1 β€ t β€ 1000) β the number of test cases. Next 2t lines contain test cases β two lines per test case.
The first line of each test case contains two integers n and x (1 β€ n β€ 10^5, 1 β€ x β€ 10^9) β the number of favorite numbers and the distance Rabbit wants to travel, respectively.
The second line of each test case contains n integers a_1, a_2, β¦, a_n (1 β€ a_i β€ 10^9) β Rabbit's favorite numbers. It is guaranteed that the favorite numbers are distinct.
It is guaranteed that the sum of n over all the test cases will not exceed 10^5.
Output
For each test case, print a single integer β the minimum number of hops needed.
Example
Input
4
2 4
1 3
3 12
3 4 5
1 5
5
2 10
15 4
Output
2
3
1
2
Note
The first test case of the sample is shown in the picture above. Rabbit can hop to (2,β{5}), then to (4,0) for a total of two hops. Each hop has a distance of 3, which is one of his favorite numbers.
In the second test case of the sample, one way for Rabbit to hop 3 times is: (0,0) β (4,0) β (8,0) β (12,0).
In the third test case of the sample, Rabbit can hop from (0,0) to (5,0).
In the fourth test case of the sample, Rabbit can hop: (0,0) β (5,10β{2}) β (10,0).
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
for _ in range(int(input())):
n, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 10**18
for i in range(n):
cnt = x // a[i]
if x % a[i]:
cnt += 1 if cnt else 2
ans = min(ans, cnt)
print(ans)
```
|
vfc_81333
|
{
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n2 4\n1 3\n3 12\n3 4 5\n1 5\n5\n2 10\n15 4\n",
"output": "2\n3\n1\n2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n10 999999733\n25 68 91 55 36 29 96 4 63 3\n",
"output": "10416664\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
1330_B. Dreamoon Likes Permutations
|
Solve the following coding problem using the programming language python:
The sequence of m integers is called the permutation if it contains all integers from 1 to m exactly once. The number m is called the length of the permutation.
Dreamoon has two permutations p_1 and p_2 of non-zero lengths l_1 and l_2.
Now Dreamoon concatenates these two permutations into another sequence a of length l_1 + l_2. First l_1 elements of a is the permutation p_1 and next l_2 elements of a is the permutation p_2.
You are given the sequence a, and you need to find two permutations p_1 and p_2. If there are several possible ways to restore them, you should find all of them. (Note that it is also possible that there will be no ways.)
Input
The first line contains an integer t (1 β€ t β€ 10 000) denoting the number of test cases in the input.
Each test case contains two lines. The first line contains one integer n (2 β€ n β€ 200 000): the length of a. The second line contains n integers a_1, a_2, β¦, a_n (1 β€ a_i β€ n-1).
The total sum of n is less than 200 000.
Output
For each test case, the first line of output should contain one integer k: the number of ways to divide a into permutations p_1 and p_2.
Each of the next k lines should contain two integers l_1 and l_2 (1 β€ l_1, l_2 β€ n, l_1 + l_2 = n), denoting, that it is possible to divide a into two permutations of length l_1 and l_2 (p_1 is the first l_1 elements of a, and p_2 is the last l_2 elements of a). You can print solutions in any order.
Example
Input
6
5
1 4 3 2 1
6
2 4 1 3 2 1
4
2 1 1 3
4
1 3 3 1
12
2 1 3 4 5 6 7 8 9 1 10 2
3
1 1 1
Output
2
1 4
4 1
1
4 2
0
0
1
2 10
0
Note
In the first example, two possible ways to divide a into permutations are \{1\} + \{4, 3, 2, 1\} and \{1,4,3,2\} + \{1\}.
In the second example, the only way to divide a into permutations is \{2,4,1,3\} + \{2,1\}.
In the third example, there are no possible ways.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
import sys
input = sys.stdin.readline
Q = int(input())
Query = []
for _ in range(Q):
N = int(input())
A = list(map(int, input().split()))
Query.append((N, A))
for N, A in Query:
leftOK = [True]*(N+1)
already = set()
MAX = 0
for i, a in enumerate(A):
if a in already:
ok = False
else:
already.add(a)
MAX = max(MAX, a)
if len(already) == i+1 and MAX == i+1:
ok = True
else:
ok = False
leftOK[i+1] = ok
rightOK = [True]*(N+1)
already = set()
MAX = 0
for i in reversed(range(N)):
a = A[i]
if a in already:
ok = False
else:
already.add(a)
MAX = max(MAX, a)
if len(already) == MAX and MAX == N-(i):
ok = True
else:
ok = False
rightOK[i] = ok
ans = []
for n in range(1, N):
if leftOK[n] and rightOK[n]:
ans.append(str(n) + " " + str(N-n))
print(len(ans))
print("\n".join(ans))
```
|
vfc_81337
|
{
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"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",
"output": "2\n1 4\n4 1\n1\n4 2\n0\n0\n1\n2 10\n0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "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",
"output": "0\n1\n4 2\n0\n0\n1\n2 10\n0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "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\n1 1 1\n",
"output": "2\n1 4\n4 1\n0\n0\n0\n1\n2 10\n0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n5\n1 4 3 1 1\n6\n2 4 1 4 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",
"output": "0\n0\n0\n0\n1\n2 10\n0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "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 3 6 7 8 9 1 10 2\n3\n1 1 1\n",
"output": "2\n1 4\n4 1\n0\n0\n0\n0\n0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "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 3 6 7 8 9 1 10 3\n3\n1 1 2\n",
"output": "2\n1 4\n4 1\n0\n0\n0\n0\n1\n1 2\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
1350_B. Orac and Models
|
Solve the following coding problem using the programming language python:
There are n models in the shop numbered from 1 to n, with sizes s_1, s_2, β¦, s_n.
Orac will buy some of the models and will arrange them in the order of increasing numbers (i.e. indices, but not sizes).
Orac thinks that the obtained arrangement is beatiful, if for any two adjacent models with indices i_j and i_{j+1} (note that i_j < i_{j+1}, because Orac arranged them properly), i_{j+1} is divisible by i_j and s_{i_j} < s_{i_{j+1}}.
For example, for 6 models with sizes \{3, 6, 7, 7, 7, 7\}, he can buy models with indices 1, 2, and 6, and the obtained arrangement will be beautiful. Also, note that the arrangement with exactly one model is also considered beautiful.
Orac wants to know the maximum number of models that he can buy, and he may ask you these queries many times.
Input
The first line contains one integer t\ (1 β€ tβ€ 100): the number of queries.
Each query contains two lines. The first line contains one integer n\ (1β€ nβ€ 100 000): the number of models in the shop, and the second line contains n integers s_1,...,s_n\ (1β€ s_iβ€ 10^9): the sizes of models.
It is guaranteed that the total sum of n is at most 100 000.
Output
Print t lines, the i-th of them should contain the maximum number of models that Orac can buy for the i-th query.
Example
Input
4
4
5 3 4 6
7
1 4 2 3 6 4 9
5
5 4 3 2 1
1
9
Output
2
3
1
1
Note
In the first query, for example, Orac can buy models with indices 2 and 4, the arrangement will be beautiful because 4 is divisible by 2 and 6 is more than 3. By enumerating, we can easily find that there are no beautiful arrangements with more than two models.
In the second query, Orac can buy models with indices 1, 3, and 6. By enumerating, we can easily find that there are no beautiful arrangements with more than three models.
In the third query, there are no beautiful arrangements with more than one model.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
import sys
import math
t=int(sys.stdin.readline())
for _ in range(t):
n=int(sys.stdin.readline())
arr=list(map(int,sys.stdin.readline().split()))
dp=[1 for x in range(n+1)]
for i in range(n-1,0,-1):
j=i*2
cnt=2
cur=1
while j<=n:
y=dp[j]
if arr[j-1]>arr[i-1]:
cur=max(cur,1+y)
cnt+=1
j=i*cnt
dp[i]=cur
#print(dp,'dp')
ans=max(dp)
print(ans)
```
|
vfc_81341
|
{
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n4\n5 3 4 6\n7\n1 4 2 3 6 4 9\n5\n5 4 3 2 1\n1\n9\n",
"output": "2\n3\n1\n1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100\n",
"output": "3\n1\n1\n7\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 160 96 97 98 99 100\n",
"output": "3\n1\n1\n7\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n4\n5 3 4 6\n7\n1 4 2 3 6 4 9\n5\n5 4 6 2 1\n1\n9\n",
"output": "2\n3\n2\n1\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
1393_A. Rainbow Dash, Fluttershy and Chess Coloring
|
Solve the following coding problem using the programming language python:
One evening Rainbow Dash and Fluttershy have come up with a game. Since the ponies are friends, they have decided not to compete in the game but to pursue a common goal.
The game starts on a square flat grid, which initially has the outline borders built up. Rainbow Dash and Fluttershy have flat square blocks with size 1Γ1, Rainbow Dash has an infinite amount of light blue blocks, Fluttershy has an infinite amount of yellow blocks.
The blocks are placed according to the following rule: each newly placed block must touch the built on the previous turns figure by a side (note that the outline borders of the grid are built initially). At each turn, one pony can place any number of blocks of her color according to the game rules.
Rainbow and Fluttershy have found out that they can build patterns on the grid of the game that way. They have decided to start with something simple, so they made up their mind to place the blocks to form a chess coloring. Rainbow Dash is well-known for her speed, so she is interested in the minimum number of turns she and Fluttershy need to do to get a chess coloring, covering the whole grid with blocks. Please help her find that number!
Since the ponies can play many times on different boards, Rainbow Dash asks you to find the minimum numbers of turns for several grids of the games.
The chess coloring in two colors is the one in which each square is neighbor by side only with squares of different colors.
Input
The first line contains a single integer T (1 β€ T β€ 100): the number of grids of the games.
Each of the next T lines contains a single integer n (1 β€ n β€ 10^9): the size of the side of the grid of the game.
Output
For each grid of the game print the minimum number of turns required to build a chess coloring pattern out of blocks on it.
Example
Input
2
3
4
Output
2
3
Note
For 3Γ3 grid ponies can make two following moves: <image>
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
for i in range(int(input())):
n = int(input())
res = int(n/2)+1
print(res)
```
|
vfc_81349
|
{
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3\n4\n",
"output": "2\n3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n10000001\n",
"output": "5000001\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n69\n",
"output": "35\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n10001001\n",
"output": "5000501\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n70\n",
"output": "36\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n2\n4\n",
"output": "2\n3\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
1434_D. Roads and Ramen
|
Solve the following coding problem using the programming language python:
In the Land of Fire there are n villages and n-1 bidirectional road, and there is a path between any pair of villages by roads. There are only two types of roads: stone ones and sand ones. Since the Land of Fire is constantly renovating, every morning workers choose a single road and flip its type (so it becomes a stone road if it was a sand road and vice versa). Also everyone here loves ramen, that's why every morning a ramen pavilion is set in the middle of every stone road, and at the end of each day all the pavilions are removed.
For each of the following m days, after another road is flipped, Naruto and Jiraiya choose a simple path β that is, a route which starts in a village and ends in a (possibly, the same) village, and doesn't contain any road twice. Since Naruto and Jiraiya also love ramen very much, they buy a single cup of ramen on each stone road and one of them eats it. Since they don't want to offend each other, they only choose routes where they can eat equal number of ramen cups. Since they both like traveling, they choose any longest possible path. After every renovation find the maximal possible length of a path (that is, the number of roads in it) they can follow.
Input
The first line contains the only positive integer n (2 β€ n β€ 500 000) standing for the number of villages in the Land of Fire.
Each of the following (n-1) lines contains a description of another road, represented as three positive integers u, v and t (1 β€ u, v β€ n, t β \{0,1\}). The first two numbers denote the villages connected by the road, and the third denotes the initial type of the road: 0 for the sand one and 1 for the stone one. Roads are numbered from 1 to (n-1) in the order from the input.
The following line contains a positive integer m (1 β€ m β€ 500 000) standing for the number of days Naruto and Jiraiya travel for.
Each of the following m lines contains the single integer id (1 β€ id β€ n-1) standing for the index of the road whose type is flipped on the morning of corresponding day.
It is guaranteed that there is a road path between any pair of villages.
Output
Output m lines. In the i-th of them print the only integer denoting the maximal possible length of any valid path on the i-th day.
Example
Input
5
1 2 0
1 3 0
3 5 0
3 4 0
5
3
4
1
3
4
Output
3
2
3
3
2
Note
After the renovation of the 3-rd road the longest path consists of the roads 1, 2 and 4.
After the renovation of the 4-th road one of the longest paths consists of the roads 1 and 2.
After the renovation of the 1-st road one of the longest paths consists of the roads 1, 2 and 3.
After the renovation of the 3-rd road the longest path consists of the roads 1, 2 and 4.
After the renovation of the 4-rd road one of the longest paths consists of the roads 2 and 4.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
vfc_81357
|
{
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 5, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1 2 0\n1 3 0\n3 5 0\n3 4 0\n5\n3\n4\n1\n3\n4\n",
"output": "3\n2\n3\n3\n2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n2 4 0\n5 2 0\n1 3 1\n1 2 1\n5\n3\n3\n4\n1\n1\n",
"output": "2\n3\n2\n3\n2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n5 7 0\n2 10 1\n1 5 0\n6 8 0\n4 9 1\n2 5 1\n10 8 0\n2 3 1\n4 2 1\n10\n9\n9\n9\n5\n2\n5\n7\n2\n3\n2\n",
"output": "5\n5\n5\n5\n5\n4\n5\n4\n5\n5\n",
"type": "stdin_stdout"
}
]
}
|
|
code_contests
|
verifiable_code
|
145_B. Lucky Number 2
|
Solve the following coding problem using the programming language python:
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya loves long lucky numbers very much. He is interested in the minimum lucky number d that meets some condition. Let cnt(x) be the number of occurrences of number x in number d as a substring. For example, if d = 747747, then cnt(4) = 2, cnt(7) = 4, cnt(47) = 2, cnt(74) = 2. Petya wants the following condition to fulfil simultaneously: cnt(4) = a1, cnt(7) = a2, cnt(47) = a3, cnt(74) = a4. Petya is not interested in the occurrences of other numbers. Help him cope with this task.
Input
The single line contains four integers a1, a2, a3 and a4 (1 β€ a1, a2, a3, a4 β€ 106).
Output
On the single line print without leading zeroes the answer to the problem β the minimum lucky number d such, that cnt(4) = a1, cnt(7) = a2, cnt(47) = a3, cnt(74) = a4. If such number does not exist, print the single number "-1" (without the quotes).
Examples
Input
2 2 1 1
Output
4774
Input
4 7 3 1
Output
-1
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
a1,a2,a3,a4=map(int,input().split())
L=[]
def Solve(a1,a2,a3,a4):
if(a3-a4<-1 or a3-a4>1 or a1<a3 or a1<a4 or a2<a3 or a2<a4):
return -1
elif(a3-a4==0):
Ans="47"*a3
Ans+="4"
if(a1-a3==0 and a2-a4==0):
return -1
elif(a1-a3==0):
return "74"*a3+"7"*(a2-a4)
return "4"*(a1-a3-1)+Ans[:len(Ans)-1]+"7"*(a2-a4)+"4"
elif(a3-a4==1):
if(a2==a4):
return -1
Ans="47"*a3
Ans="4"*(a1-a3)+Ans+"7"*(a2-a4-1)
return Ans
else:
if(a3==a1):
return -1
Ans="74"*a4
Ans="7"+"4"*(a1-a3-1)+Ans[1:len(Ans)-1]+"7"*(a2-a4)+"4"
return Ans
print(Solve(a1,a2,a3,a4))
# Made By Mostafa_Khaled
```
|
vfc_81361
|
{
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 7 3 1\n",
"output": "-1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 2 1 1\n",
"output": "4774",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3 2 2\n",
"output": "474774",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
1485_D. Multiples and Power Differences
|
Solve the following coding problem using the programming language python:
You are given a matrix a consisting of positive integers. It has n rows and m columns.
Construct a matrix b consisting of positive integers. It should have the same size as a, and the following conditions should be met:
* 1 β€ b_{i,j} β€ 10^6;
* b_{i,j} is a multiple of a_{i,j};
* the absolute value of the difference between numbers in any adjacent pair of cells (two cells that share the same side) in b is equal to k^4 for some integer k β₯ 1 (k is not necessarily the same for all pairs, it is own for each pair).
We can show that the answer always exists.
Input
The first line contains two integers n and m (2 β€ n,m β€ 500).
Each of the following n lines contains m integers. The j-th integer in the i-th line is a_{i,j} (1 β€ a_{i,j} β€ 16).
Output
The output should contain n lines each containing m integers. The j-th integer in the i-th line should be b_{i,j}.
Examples
Input
2 2
1 2
2 3
Output
1 2
2 3
Input
2 3
16 16 16
16 16 16
Output
16 32 48
32 48 64
Input
2 2
3 11
12 8
Output
327 583
408 664
Note
In the first example, the matrix a can be used as the matrix b, because the absolute value of the difference between numbers in any adjacent pair of cells is 1 = 1^4.
In the third example:
* 327 is a multiple of 3, 583 is a multiple of 11, 408 is a multiple of 12, 664 is a multiple of 8;
* |408 - 327| = 3^4, |583 - 327| = 4^4, |664 - 408| = 4^4, |664 - 583| = 3^4.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
n, m = list(map(int, input().split()))
matrix = []
for i in range(n):
row = list(map(int, input().split()))
matrix.append(row)
#print(matrix)
res = [ [ 0 for i in range(m) ] for j in range(n) ]
for i in range(n):
for j in range(m):
if (i + j) % 2:
res[i][j] = 720720 + matrix[i][j] ** 4
else:
res[i][j] = 720720
print(res[i][j], end=" ")
print()
```
|
vfc_81365
|
{
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 3\n16 16 16\n16 16 16\n",
"output": "\n16 32 48\n32 48 64\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 2\n1 2\n2 3\n",
"output": "\n1 2\n2 3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 2\n3 11\n12 8\n",
"output": "\n327 583\n408 664\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 3\n16 16 11\n16 16 16\n",
"output": "720720 786256 720720\n786256 720720 786256\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
150_B. Quantity of Strings
|
Solve the following coding problem using the programming language python:
Just in case somebody missed it: this winter is totally cold in Nvodsk! It is so cold that one gets funny thoughts. For example, let's say there are strings with the length exactly n, based on the alphabet of size m. Any its substring with length equal to k is a palindrome. How many such strings exist? Your task is to find their quantity modulo 1000000007 (109 + 7). Be careful and don't miss a string or two!
Let us remind you that a string is a palindrome if it can be read the same way in either direction, from the left to the right and from the right to the left.
Input
The first and only line contains three integers: n, m and k (1 β€ n, m, k β€ 2000).
Output
Print a single integer β the number of strings of the described type modulo 1000000007 (109 + 7).
Examples
Input
1 1 1
Output
1
Input
5 2 4
Output
2
Note
In the first sample only one string is valid: "a" (let's denote the only letter of our alphabet as "a").
In the second sample (if we denote the alphabet letters as "a" and "b") the following strings are valid: "aaaaa" and "bbbbb".
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
n,m,k = map(int,input().split())
mod = 10**9 + 7
if k == 1 or k>n:
print(pow(m,n,mod))
elif k == n:
print(pow(m,(n+1)//2,mod))
elif k%2== 0:
print(m%mod)
else:
print(pow(m,2,mod))
```
|
vfc_81369
|
{
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 1 1\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 2 4\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "784 1 1999\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1000 2 1\n",
"output": "688423210\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "341 9 342\n",
"output": "320920086\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
1535_F. String Distance
|
Solve the following coding problem using the programming language python:
Suppose you are given two strings a and b. You can apply the following operation any number of times: choose any contiguous substring of a or b, and sort the characters in it in non-descending order. Let f(a, b) the minimum number of operations you have to apply in order to make them equal (or f(a, b) = 1337 if it is impossible to make a and b equal using these operations).
For example:
* f(ab, ab) = 0;
* f(ba, ab) = 1 (in one operation, we can sort the whole first string);
* f(ebcda, ecdba) = 1 (in one operation, we can sort the substring of the second string starting from the 2-nd character and ending with the 4-th character);
* f(a, b) = 1337.
You are given n strings s_1, s_2, ..., s_k having equal length. Calculate β _{i = 1}^{n} β_{j = i + 1}^{n} f(s_i, s_j).
Input
The first line contains one integer n (1 β€ n β€ 2 β
10^5) β the number of strings.
Then n lines follow, each line contains one of the strings s_i, consisting of lowercase Latin letters. |s_1| = |s_2| = β¦ = |s_n|, and n β
|s_1| β€ 2 β
10^5. All these strings are pairwise distinct.
Output
Print one integer: β _{i = 1}^{n} β_{j = i + 1}^{n} f(s_i, s_j).
Examples
Input
4
zzz
bac
abc
acb
Output
4015
Input
2
a
b
Output
1337
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
vfc_81373
|
{
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 1024000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\nzzz\nbac\nabc\nacb\n",
"output": "\n4015\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\na\nb\n",
"output": "\n1337\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\na\n",
"output": "0\n",
"type": "stdin_stdout"
}
]
}
|
|
code_contests
|
verifiable_code
|
162_I. Truncatable primes
|
Solve the following coding problem using the programming language python:
A truncatable prime is a prime number which contains no zeros in decimal notation and all its suffixes are primes. 1 is considered to be not a prime.
You are given a positive integer n. Figure out whether it is a truncatable prime.
Input
The only line of input contains an integer n (2 β€ n β€ 107).
Output
Output "YES" if n is a truncatable prime. Output "NO" otherwise. Quotes for clarity only.
Examples
Input
19
Output
NO
Input
9137
Output
YES
Note
In the first sample 19 is a prime but its suffix 9 is not.
In the second sample 9137, 137, 37 and 7 are all primes, so 9137 is a truncatable prime.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
vfc_81377
|
{
"difficulty": "15",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "19\n",
"output": "NO\n",
"type": "stdin_stdout"
}
]
}
|
|
code_contests
|
verifiable_code
|
182_E. Wooden Fence
|
Solve the following coding problem using the programming language python:
Vasya has recently bought some land and decided to surround it with a wooden fence.
He went to a company called "Wooden board" that produces wooden boards for fences. Vasya read in the catalog of products that the company has at its disposal n different types of wood. The company uses the i-th type of wood to produce a board of this type that is a rectangular ai by bi block.
Vasya decided to order boards in this company and build a fence from them. It turned out that the storehouse of the company is so large that Vasya can order arbitrary number of boards of every type. Note that Vasya is allowed to turn the boards as he builds the fence. However, Vasya cannot turn square boards.
Vasya is required to construct a fence of length l, however, an arbitrary fence won't do. Vasya wants his fence to look beautiful. We'll say that a fence is beautiful if and only if the following two conditions are fulfilled:
* there are no two successive boards of the same type
* the first board of the fence has an arbitrary length, and the length of each subsequent board equals the width of the previous one
In other words, the fence is considered beautiful, if the type of the i-th board in the fence is different from the i - 1-th board's type; besides, the i-th board's length is equal to the i - 1-th board's width (for all i, starting from 2).
Now Vasya wonders, how many variants of arranging a fence for his land exist. Your task is to count the number of different beautiful fences of length l.
Two fences will be considered the same if the corresponding sequences of fence boards types and rotations are the same, otherwise the fences are different. Since the sought number can be large enough, you need to calculate the answer modulo 1000000007 (109 + 7).
Input
The first line contains two integers n and l (1 β€ n β€ 100, 1 β€ l β€ 3000) β the number of different board types and the fence length, correspondingly. Next n lines contain descriptions of board types: the i-th line contains two integers ai and bi (1 β€ ai, bi β€ 100) β the sizes of the board of the i-th type. All numbers on the lines are separated by spaces.
Output
Print a single integer β the sought number of variants modulo 1000000007 (109 + 7).
Examples
Input
2 3
1 2
2 3
Output
2
Input
1 2
2 2
Output
1
Input
6 6
2 1
3 2
2 5
3 3
5 1
2 1
Output
20
Note
In the first sample there are exactly two variants of arranging a beautiful fence of length 3:
* As the first fence board use the board of the first type of length 1 and width 2. As the second board use board of the second type of length 2 and width 3.
* Use one board of the second type after you turn it. That makes its length equal 3, and width β 2.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
from sys import stdin, stdout
MOD = 10 ** 9 + 7
sze = 101
n, l = map(int, stdin.readline().split())
dp = [[[0, 0] for j in range(l + sze + 1)] for i in range(n)]
bars = []
challengers = [[] for i in range(sze)]
for i in range(n):
a, b = map(int, stdin.readline().split())
bars.append((a, b))
if a != b:
dp[i][a][1] = 1
dp[i][b][0] = 1
else:
dp[i][a][1] = 1
if a == b:
challengers[a].append((a, i))
else:
challengers[a].append((b, i))
challengers[b].append((a, i))
for j in range(l + 1):
for i in range(n):
for z in range(2):
if dp[i][j][z]:
for a, ind in challengers[bars[i][z]]:
if ind != i:
dp[ind][j + bars[i][z]][bars[ind].index(a)] = (dp[ind][j + bars[i][z]][bars[ind].index(a)] + dp[i][j][z]) % MOD
cnt = 0
for i in range(n):
cnt = (cnt + dp[i][l][0] + dp[i][l][1]) % MOD
stdout.write(str(cnt))
```
|
vfc_81381
|
{
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 2\n2 2\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 3\n1 2\n2 3\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 6\n2 1\n3 2\n2 5\n3 3\n5 1\n2 1\n",
"output": "20\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "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 1\n1 3\n1 3\n1 3\n1 1\n1 3\n3 1\n2 3\n1 3\n2 2\n2 1\n2 1\n2 3\n3 2\n1 2\n2 2\n1 3\n1 1\n1 3\n3 3\n1 3\n3 2\n1 3\n2 1\n2 3\n2 3\n2 3\n3 2\n1 2\n1 3\n2 3\n1 3\n2 1\n3 2\n3 3\n1 1\n3 1\n3 3\n1 3\n3 2\n3 2\n2 2\n1 3\n2 2\n3 2\n1 3\n2 2\n2 1\n3 2\n1 3\n3 2\n1 2\n2 2\n1 3\n1 1\n3 3\n2 2\n3 1\n3 3\n",
"output": "548967810\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 3\n1 2\n1 1\n3 1\n2 2\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 8\n3 1\n2 1\n2 3\n2 1\n3 1\n",
"output": "62\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
207_A2. Beaver's Calculator 1.0
|
Solve the following coding problem using the programming language python:
The Smart Beaver from ABBYY has once again surprised us! He has developed a new calculating device, which he called the "Beaver's Calculator 1.0". It is very peculiar and it is planned to be used in a variety of scientific problems.
To test it, the Smart Beaver invited n scientists, numbered from 1 to n. The i-th scientist brought ki calculating problems for the device developed by the Smart Beaver from ABBYY. The problems of the i-th scientist are numbered from 1 to ki, and they must be calculated sequentially in the described order, since calculating each problem heavily depends on the results of calculating of the previous ones.
Each problem of each of the n scientists is described by one integer ai, j, where i (1 β€ i β€ n) is the number of the scientist, j (1 β€ j β€ ki) is the number of the problem, and ai, j is the number of resource units the calculating device needs to solve this problem.
The calculating device that is developed by the Smart Beaver is pretty unusual. It solves problems sequentially, one after another. After some problem is solved and before the next one is considered, the calculating device allocates or frees resources.
The most expensive operation for the calculating device is freeing resources, which works much slower than allocating them. It is therefore desirable that each next problem for the calculating device requires no less resources than the previous one.
You are given the information about the problems the scientists offered for the testing. You need to arrange these problems in such an order that the number of adjacent "bad" pairs of problems in this list is minimum possible. We will call two consecutive problems in this list a "bad pair" if the problem that is performed first requires more resources than the one that goes after it. Do not forget that the problems of the same scientist must be solved in a fixed order.
Input
The first line contains integer n β the number of scientists. To lessen the size of the input, each of the next n lines contains five integers ki, ai, 1, xi, yi, mi (0 β€ ai, 1 < mi β€ 109, 1 β€ xi, yi β€ 109) β the number of problems of the i-th scientist, the resources the first problem requires and three parameters that generate the subsequent values of ai, j. For all j from 2 to ki, inclusive, you should calculate value ai, j by formula ai, j = (ai, j - 1 * xi + yi) mod mi, where a mod b is the operation of taking the remainder of division of number a by number b.
To get the full points for the first group of tests it is sufficient to solve the problem with n = 2, 1 β€ ki β€ 2000.
To get the full points for the second group of tests it is sufficient to solve the problem with n = 2, 1 β€ ki β€ 200000.
To get the full points for the third group of tests it is sufficient to solve the problem with 1 β€ n β€ 5000, 1 β€ ki β€ 5000.
Output
On the first line print a single number β the number of "bad" pairs in the optimal order.
If the total number of problems does not exceed 200000, also print <image> lines β the optimal order of the problems. On each of these lines print two integers separated by a single space β the required number of resources for the problem and the number of the scientist who offered this problem, respectively. The scientists are numbered from 1 to n in the order of input.
Examples
Input
2
2 1 1 1 10
2 3 1 1 10
Output
0
1 1
2 1
3 2
4 2
Input
2
3 10 2 3 1000
3 100 1 999 1000
Output
2
10 1
23 1
49 1
100 2
99 2
98 2
Note
In the first sample n = 2, k1 = 2, a1, 1 = 1, a1, 2 = 2, k2 = 2, a2, 1 = 3, a2, 2 = 4. We've got two scientists, each of them has two calculating problems. The problems of the first scientist require 1 and 2 resource units, the problems of the second one require 3 and 4 resource units. Let's list all possible variants of the calculating order (each problem is characterized only by the number of resource units it requires): (1, 2, 3, 4), (1, 3, 2, 4), (3, 1, 2, 4), (1, 3, 4, 2), (3, 4, 1, 2), (3, 1, 4, 2).
Sequence of problems (1, 3, 2, 4) has one "bad" pair (3 and 2), (3, 1, 4, 2) has two "bad" pairs (3 and 1, 4 and 2), and (1, 2, 3, 4) has no "bad" pairs.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
vfc_81385
|
{
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2 1 1 1 10\n2 3 1 1 10\n",
"output": "0\n1 1\n2 1\n3 2\n4 2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n3 10 2 3 1000\n3 100 1 999 1000\n",
"output": "2\n10 1\n23 1\n49 1\n100 2\n99 2\n98 2\n",
"type": "stdin_stdout"
}
]
}
|
|
code_contests
|
verifiable_code
|
230_A. Dragons
|
Solve the following coding problem using the programming language python:
Kirito is stuck on a level of the MMORPG he is playing now. To move on in the game, he's got to defeat all n dragons that live on this level. Kirito and the dragons have strength, which is represented by an integer. In the duel between two opponents the duel's outcome is determined by their strength. Initially, Kirito's strength equals s.
If Kirito starts duelling with the i-th (1 β€ i β€ n) dragon and Kirito's strength is not greater than the dragon's strength xi, then Kirito loses the duel and dies. But if Kirito's strength is greater than the dragon's strength, then he defeats the dragon and gets a bonus strength increase by yi.
Kirito can fight the dragons in any order. Determine whether he can move on to the next level of the game, that is, defeat all dragons without a single loss.
Input
The first line contains two space-separated integers s and n (1 β€ s β€ 104, 1 β€ n β€ 103). Then n lines follow: the i-th line contains space-separated integers xi and yi (1 β€ xi β€ 104, 0 β€ yi β€ 104) β the i-th dragon's strength and the bonus for defeating it.
Output
On a single line print "YES" (without the quotes), if Kirito can move on to the next level and print "NO" (without the quotes), if he can't.
Examples
Input
2 2
1 99
100 0
Output
YES
Input
10 1
100 100
Output
NO
Note
In the first sample Kirito's strength initially equals 2. As the first dragon's strength is less than 2, Kirito can fight it and defeat it. After that he gets the bonus and his strength increases to 2 + 99 = 101. Now he can defeat the second dragon and move on to the next level.
In the second sample Kirito's strength is too small to defeat the only dragon and win.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
n,m=map(int, input().split())
r=3
ar=[]
for i in range (m):
q=list(map(int, input().split()))
ar.append (q)
ar.sort()
for i in range (m):
if n>ar[i][0]:
n+=ar[i][1]
else:
r=5
print ('NO')
break
if r!=5:
print ('YES')
```
|
vfc_81389
|
{
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 2\n1 99\n100 0\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 1\n100 100\n",
"output": "NO\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
279_E. Beautiful Decomposition
|
Solve the following coding problem using the programming language python:
Valera considers a number beautiful, if it equals 2k or -2k for some integer k (k β₯ 0). Recently, the math teacher asked Valera to represent number n as the sum of beautiful numbers. As Valera is really greedy, he wants to complete the task using as few beautiful numbers as possible.
Help Valera and find, how many numbers he is going to need. In other words, if you look at all decompositions of the number n into beautiful summands, you need to find the size of the decomposition which has the fewest summands.
Input
The first line contains string s (1 β€ |s| β€ 106), that is the binary representation of number n without leading zeroes (n > 0).
Output
Print a single integer β the minimum amount of beautiful numbers that give a total of n.
Examples
Input
10
Output
1
Input
111
Output
2
Input
1101101
Output
4
Note
In the first sample n = 2 is a beautiful number.
In the second sample n = 7 and Valera can decompose it into sum 23 + ( - 20).
In the third sample n = 109 can be decomposed into the sum of four summands as follows: 27 + ( - 24) + ( - 22) + 20.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
t = input()
j = t[0]
d, s = 0, int(j)
for i in t[1: ]:
if j != i:
if d == 1: d, s = 0, s + 1
else: d = 1
j = i
else: d = 1
print(s + (d and j == '1'))
```
|
vfc_81397
|
{
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1101101\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "111\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1001110101111000111010100110111000000110011011100111001111100001110011011001101110000000\n",
"output": "29\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
328_B. Sheldon and Ice Pieces
|
Solve the following coding problem using the programming language python:
Do you remember how Kai constructed the word "eternity" using pieces of ice as components?
Little Sheldon plays with pieces of ice, each piece has exactly one digit between 0 and 9. He wants to construct his favourite number t. He realized that digits 6 and 9 are very similar, so he can rotate piece of ice with 6 to use as 9 (and vice versa). Similary, 2 and 5 work the same. There is no other pair of digits with similar effect. He called this effect "Digital Mimicry".
Sheldon favourite number is t. He wants to have as many instances of t as possible. How many instances he can construct using the given sequence of ice pieces. He can use any piece at most once.
Input
The first line contains integer t (1 β€ t β€ 10000). The second line contains the sequence of digits on the pieces. The length of line is equal to the number of pieces and between 1 and 200, inclusive. It contains digits between 0 and 9.
Output
Print the required number of instances.
Examples
Input
42
23454
Output
2
Input
169
12118999
Output
1
Note
This problem contains very weak pretests.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
def c(a, b):
a = a.replace('6', '9')
a = a.replace('2', '5')
b = b.replace('6', '9')
b = b.replace('2', '5')
n = 10000
for i in '01345789':
t = a.count(i)
if t != 0:
n = min(n, b.count(i)//t)
return n
a = input()
b = input()
print(c(a, b))
```
|
vfc_81405
|
{
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "42\n23454\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
34_C. Page Numbers
|
Solve the following coding problem using the programming language python:
Β«BersoftΒ» company is working on a new version of its most popular text editor β Bord 2010. Bord, like many other text editors, should be able to print out multipage documents. A user keys a sequence of the document page numbers that he wants to print out (separates them with a comma, without spaces).
Your task is to write a part of the program, responsible for Β«standardizationΒ» of this sequence. Your program gets the sequence, keyed by the user, as input. The program should output this sequence in format l1-r1,l2-r2,...,lk-rk, where ri + 1 < li + 1 for all i from 1 to k - 1, and li β€ ri. The new sequence should contain all the page numbers, keyed by the user, and nothing else. If some page number appears in the input sequence several times, its appearances, starting from the second one, should be ignored. If for some element i from the new sequence li = ri, this element should be output as li, and not as Β«li - liΒ».
For example, sequence 1,2,3,1,1,2,6,6,2 should be output as 1-3,6.
Input
The only line contains the sequence, keyed by the user. The sequence contains at least one and at most 100 positive integer numbers. It's guaranteed, that this sequence consists of positive integer numbers, not exceeding 1000, separated with a comma, doesn't contain any other characters, apart from digits and commas, can't end with a comma, and the numbers don't contain leading zeroes. Also it doesn't start with a comma or contain more than one comma in a row.
Output
Output the sequence in the required format.
Examples
Input
1,2,3,1,1,2,6,6,2
Output
1-3,6
Input
3,2,1
Output
1-3
Input
30,20,10
Output
10,20,30
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
A=[int(num) for num in input().split(',')]
s_a=sorted(set(A))
prev=None
string=""
count=0
for i in s_a:
if prev is None:
prev=i
string+=str(prev)
count+=1
else:
if i-(prev+count)==0:
count+=1
else:
if count>1:
string+='-'+str(prev+count-1)+','+str(i)
else:
string+=','+str(i)
count=1
prev=i
if count>1:
string+='-'+str(prev+count-1)
print(string)
```
|
vfc_81409
|
{
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "30,20,10\n",
"output": "10,20,30",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3,2,1\n",
"output": "1-3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1,2,3,1,1,2,6,6,2\n",
"output": "1-3,6",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
373_D. Counting Rectangles is Fun
|
Solve the following coding problem using the programming language python:
There is an n Γ m rectangular grid, each cell of the grid contains a single integer: zero or one. Let's call the cell on the i-th row and the j-th column as (i, j).
Let's define a "rectangle" as four integers a, b, c, d (1 β€ a β€ c β€ n; 1 β€ b β€ d β€ m). Rectangle denotes a set of cells of the grid {(x, y) : a β€ x β€ c, b β€ y β€ d}. Let's define a "good rectangle" as a rectangle that includes only the cells with zeros.
You should answer the following q queries: calculate the number of good rectangles all of which cells are in the given rectangle.
Input
There are three integers in the first line: n, m and q (1 β€ n, m β€ 40, 1 β€ q β€ 3Β·105). Each of the next n lines contains m characters β the grid. Consider grid rows are numbered from top to bottom, and grid columns are numbered from left to right. Both columns and rows are numbered starting from 1.
Each of the next q lines contains a query β four integers that describe the current rectangle, a, b, c, d (1 β€ a β€ c β€ n; 1 β€ b β€ d β€ m).
Output
For each query output an answer β a single integer in a separate line.
Examples
Input
5 5 5
00101
00000
00001
01000
00001
1 2 2 4
4 5 4 5
1 2 5 2
2 2 4 5
4 2 5 3
Output
10
1
7
34
5
Input
4 7 5
0000100
0000010
0011000
0000000
1 7 2 7
3 1 3 1
2 3 4 5
1 2 2 7
2 2 4 7
Output
3
1
16
27
52
Note
For the first example, there is a 5 Γ 5 rectangular grid, and the first, the second, and the third queries are represented in the following image.
<image>
* For the first query, there are 10 good rectangles, five 1 Γ 1, two 2 Γ 1, two 1 Γ 2, and one 1 Γ 3.
* For the second query, there is only one 1 Γ 1 good rectangle.
* For the third query, there are 7 good rectangles, four 1 Γ 1, two 2 Γ 1, and one 3 Γ 1.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
vfc_81413
|
{
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 5 5\n00101\n00000\n00001\n01000\n00001\n1 2 2 4\n4 5 4 5\n1 2 5 2\n2 2 4 5\n4 2 5 3\n",
"output": "10\n1\n7\n34\n5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 7 5\n0000100\n0000010\n0011000\n0000000\n1 7 2 7\n3 1 3 1\n2 3 4 5\n1 2 2 7\n2 2 4 7\n",
"output": "3\n1\n16\n27\n52\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 3 8\n000\n001\n1 1 2 2\n1 3 2 3\n2 2 2 3\n1 1 2 2\n2 3 2 3\n2 1 2 2\n1 2 1 3\n1 2 2 2\n",
"output": "9\n1\n1\n9\n0\n3\n3\n3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 10 10\n0010001010\n0011011010\n0100001110\n0010100000\n0000100011\n0100000001\n0000010100\n1000000010\n0000010000\n0110010000\n1 1 4 6\n2 6 3 10\n1 6 3 9\n6 5 8 5\n2 3 6 8\n4 7 5 8\n3 1 9 5\n2 5 4 10\n2 3 3 6\n7 4 9 5\n",
"output": "42\n5\n5\n6\n79\n9\n151\n27\n12\n18\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 10 10\n0001000111\n1101000111\n1100101111\n1011101011\n1011110101\n1110101110\n1101101111\n1111111100\n0110101110\n1011101011\n6 3 7 9\n2 6 8 7\n9 7 10 8\n3 1 5 9\n1 6 9 10\n6 3 8 8\n1 6 9 10\n5 6 8 10\n8 8 10 8\n9 6 9 10\n",
"output": "5\n12\n1\n12\n29\n5\n29\n9\n1\n2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 2 8\n01\n00\n00\n3 2 3 2\n1 1 2 1\n2 1 3 1\n2 2 3 2\n1 1 2 2\n1 1 1 2\n1 1 3 1\n1 1 2 2\n",
"output": "1\n3\n3\n3\n5\n1\n6\n5\n",
"type": "stdin_stdout"
}
]
}
|
|
code_contests
|
verifiable_code
|
418_B. Cunning Gena
|
Solve the following coding problem using the programming language python:
A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.
The participants are offered m problems on the contest. For each friend, Gena knows what problems he can solve. But Gena's friends won't agree to help Gena for nothing: the i-th friend asks Gena xi rubles for his help in solving all the problems he can. Also, the friend agreed to write a code for Gena only if Gena's computer is connected to at least ki monitors, each monitor costs b rubles.
Gena is careful with money, so he wants to spend as little money as possible to solve all the problems. Help Gena, tell him how to spend the smallest possible amount of money. Initially, there's no monitors connected to Gena's computer.
Input
The first line contains three integers n, m and b (1 β€ n β€ 100; 1 β€ m β€ 20; 1 β€ b β€ 109) β the number of Gena's friends, the number of problems and the cost of a single monitor.
The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contains three integers xi, ki and mi (1 β€ xi β€ 109; 1 β€ ki β€ 109; 1 β€ mi β€ m) β the desired amount of money, monitors and the number of problems the friend can solve. The (2i + 1)-th line contains mi distinct positive integers β the numbers of problems that the i-th friend can solve. The problems are numbered from 1 to m.
Output
Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.
Examples
Input
2 2 1
100 1 1
2
100 2 1
1
Output
202
Input
3 2 5
100 1 1
1
100 1 1
2
200 1 2
1 2
Output
205
Input
1 2 1
1 1 1
1
Output
-1
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
vfc_81421
|
{
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 2 1\n100 1 1\n2\n100 2 1\n1\n",
"output": "202",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 2 1\n1 1 1\n1\n",
"output": "-1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 2 5\n100 1 1\n1\n100 1 1\n2\n200 1 2\n1 2\n",
"output": "205",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1 100000000\n1 100000000 1\n1\n",
"output": "10000000000000001",
"type": "stdin_stdout"
}
]
}
|
|
code_contests
|
verifiable_code
|
444_E. DZY Loves Planting
|
Solve the following coding problem using the programming language python:
DZY loves planting, and he enjoys solving tree problems.
DZY has a weighted tree (connected undirected graph without cycles) containing n nodes (they are numbered from 1 to n). He defines the function g(x, y) (1 β€ x, y β€ n) as the longest edge in the shortest path between nodes x and y. Specially g(z, z) = 0 for every z.
For every integer sequence p1, p2, ..., pn (1 β€ pi β€ n), DZY defines f(p) as <image>.
DZY wants to find such a sequence p that f(p) has maximum possible value. But there is one more restriction: the element j can appear in p at most xj times.
Please, find the maximum possible f(p) under the described restrictions.
Input
The first line contains an integer n (1 β€ n β€ 3000).
Each of the next n - 1 lines contains three integers ai, bi, ci (1 β€ ai, bi β€ n; 1 β€ ci β€ 10000), denoting an edge between ai and bi with length ci. It is guaranteed that these edges form a tree.
Each of the next n lines describes an element of sequence x. The j-th line contains an integer xj (1 β€ xj β€ n).
Output
Print a single integer representing the answer.
Examples
Input
4
1 2 1
2 3 2
3 4 3
1
1
1
1
Output
2
Input
4
1 2 1
2 3 2
3 4 3
4
4
4
4
Output
3
Note
In the first sample, one of the optimal p is [4, 3, 2, 1].
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
n = int(input())
edges = [[int(x) for x in input().split()] for i in range(n-1)]
edges = sorted(edges)
use_count = [0]+[int(input()) for i in range(n)]
lo,hi = 0,10000
def getpar(par,u):
if par[par[u]] == par[u]:
return par[u]
par[u] = getpar(par,par[u])
return par[u]
def unite(par,sz,use,u,v):
u = getpar(par,u)
v = getpar(par,v)
par[u] = v
sz[v] += sz[u]
use[v] += use[u]
def solve(fp):
par = [i for i in range(n+1)]
sz = [1 for i in range(n+1)]
use = [use_count[i] for i in range(n+1)]
for edge in edges:
if edge[2] < fp:
unite(par,sz,use,edge[0],edge[1])
total_use = sum(use_count)
for i in range(n+1):
p = getpar(par,i)
if(p == i):
if(total_use - use[p] < sz[p]):
return False
return True
while lo < hi:
mid = (lo+hi+1)//2
if solve(mid):
lo = mid
else:
hi = mid-1
print(lo)
```
|
vfc_81425
|
{
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1 2 1\n2 3 2\n3 4 3\n1\n1\n1\n1\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1 2 1\n2 3 2\n3 4 3\n4\n4\n4\n4\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n1\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n2 1 559\n3 1 5707\n4 2 9790\n5 3 1591\n6 1 7113\n7 6 2413\n8 6 3006\n9 4 1935\n10 6 5954\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n",
"output": "7113\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n2 1 8760\n3 1 3705\n4 1 1862\n5 2 7332\n6 3 7015\n7 5 4866\n8 3 4465\n9 7 8886\n10 3 9362\n2\n5\n5\n4\n4\n5\n4\n5\n1\n2\n",
"output": "8760\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
467_A. George and Accommodation
|
Solve the following coding problem using the programming language python:
George has recently entered the BSUCP (Berland State University for Cool Programmers). George has a friend Alex who has also entered the university. Now they are moving into a dormitory.
George and Alex want to live in the same room. The dormitory has n rooms in total. At the moment the i-th room has pi people living in it and the room can accommodate qi people in total (pi β€ qi). Your task is to count how many rooms has free place for both George and Alex.
Input
The first line contains a single integer n (1 β€ n β€ 100) β the number of rooms.
The i-th of the next n lines contains two integers pi and qi (0 β€ pi β€ qi β€ 100) β the number of people who already live in the i-th room and the room's capacity.
Output
Print a single integer β the number of rooms where George and Alex can move in.
Examples
Input
3
1 1
2 2
3 3
Output
0
Input
3
1 10
0 10
10 10
Output
2
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
c = 0
for _ in range(int(input())):
n = [int(x) for x in input().split()]
n,m = n[0],n[1]
if m - n >= 2:
c += 1
print(c)
```
|
vfc_81429
|
{
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 1\n2 2\n3 3\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 10\n0 10\n10 10\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "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",
"output": "8\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "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\n1 2\n1 2\n1 2\n1 2\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n0 10\n0 20\n0 30\n0 40\n0 50\n0 60\n0 70\n0 80\n0 90\n0 100\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "14\n1 1\n1 1\n1 55\n1 16\n1 1\n1 1\n1 55\n1 62\n1 53\n1 26\n1 1\n1 36\n1 2\n1 3\n",
"output": "8\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
48_D. Permutations
|
Solve the following coding problem using the programming language python:
A permutation is a sequence of integers from 1 to n of length n containing each number exactly once. For example, (1), (4, 3, 5, 1, 2), (3, 2, 1) are permutations, and (1, 1), (4, 3, 1), (2, 3, 4) are not.
There are many tasks on permutations. Today you are going to solve one of them. Letβs imagine that somebody took several permutations (perhaps, with a different number of elements), wrote them down consecutively as one array and then shuffled the resulting array. The task is to restore the initial permutations if it is possible.
Input
The first line contains an integer n (1 β€ n β€ 105). The next line contains the mixed array of n integers, divided with a single space. The numbers in the array are from 1 to 105.
Output
If this array can be split into several permutations so that every element of the array belongs to exactly one permutation, print in the first line the number of permutations. The second line should contain n numbers, corresponding to the elements of the given array. If the i-th element belongs to the first permutation, the i-th number should be 1, if it belongs to the second one, then its number should be 2 and so on. The order of the permutationsβ numbering is free.
If several solutions are possible, print any one of them. If thereβs no solution, print in the first line - 1.
Examples
Input
9
1 2 3 1 2 1 4 2 5
Output
3
3 1 2 1 2 2 2 3 2
Input
4
4 3 2 1
Output
1
1 1 1 1
Input
4
1 2 2 3
Output
-1
Note
In the first sample test the array is split into three permutations: (2, 1), (3, 2, 1, 4, 5), (1, 2). The first permutation is formed by the second and the fourth elements of the array, the second one β by the third, the fifth, the sixth, the seventh and the ninth elements, the third one β by the first and the eigth elements. Clearly, there are other splitting variants possible.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
def fail():
print(-1)
import sys
sys.exit()
n = int(input())
count = (n + 1) * [ 0 ]
assign = n * [ None ]
for i, x in enumerate(map(int, input().split())):
if x > n:
fail()
count[x] += 1
assign[i] = count[x]
for i in range(2, n):
if count[i - 1] < count[i]:
fail()
print(count[1])
print(' '.join(map(str, assign)))
```
|
vfc_81433
|
{
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "9\n1 2 3 1 2 1 4 2 5\n",
"output": "3\n1 1 1 2 2 3 1 3 1 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n4 3 2 1\n",
"output": "1\n1 1 1 1 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1 2 2 3\n",
"output": "-1",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
53_B. Blog Photo
|
Solve the following coding problem using the programming language python:
One popular blog site edits the uploaded photos like this. It cuts a rectangular area out of them so that the ratio of height to width (i.e. the height / width quotient) can vary from 0.8 to 1.25 inclusively. Besides, at least one side of the cut area should have a size, equal to some power of number 2 (2x for some integer x). If those rules don't indicate the size of the cut are clearly, then the way with which the cut part possesses the largest area is chosen. Of course, both sides of the cut area should be integer. If there are several answers to this problem, you should choose the answer with the maximal height.
Input
The first line contains a pair of integers h and w (1 β€ h, w β€ 109) which are the height and width of the uploaded photo in pixels.
Output
Print two integers which are the height and width of the cut area.
Examples
Input
2 1
Output
1 1
Input
2 2
Output
2 2
Input
5 5
Output
5 4
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
from math import ceil,floor
l = []
for i in range(39):
l.append(2**i)
h,w = map(int,input().split())
h1 = 0
w1 = 0
maxi = 0
for i in l:
if i<=w:
a = ceil(i*0.8)
b = floor(i*1.25)
if a<=h<=b:
if i*h>=maxi:
maxi = i * h
h1 = h
w1 = i
elif b<h:
if i*b>=maxi:
maxi = i * b
h1 = b
w1 = i
elif a<h:
if i*a>=maxi:
maxi = i * a
h1 = a
w1 = i
h2 = 0
w2 = 0
w,h = h,w
maxi = 0
for i in l:
if i<=w:
a = ceil(i/(1.25))
b = floor(i/(0.8))
if i<=w:
a = ceil(i*0.8)
b = floor(i*1.25)
if a<=h<=b:
if i*h>=maxi:
maxi = i * h
h2 = h
w2 = i
elif b<h:
if i*b>=maxi:
maxi = i * b
h2 = b
w2 = i
elif a<h:
if i*a>=maxi:
maxi = i * a
h2 = a
w2 = i
w2,h2 = h2,w2
if h1*w1>h2*w2:
print(h1,w1)
elif h1*w1 == h2*w2:
if h1>h2:
print(h1,w1)
else:
print(h2,w2)
else:
print(h2,w2)
```
|
vfc_81441
|
{
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 1\n",
"output": "1 1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 2\n",
"output": "2 2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 5\n",
"output": "5 4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "15 13\n",
"output": "10 8",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9 10\n",
"output": "8 10",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "47 46\n",
"output": "40 32",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
567_D. One-Dimensional Battle Ships
|
Solve the following coding problem using the programming language python:
Alice and Bob love playing one-dimensional battle ships. They play on the field in the form of a line consisting of n square cells (that is, on a 1 Γ n table).
At the beginning of the game Alice puts k ships on the field without telling their positions to Bob. Each ship looks as a 1 Γ a rectangle (that is, it occupies a sequence of a consecutive squares of the field). The ships cannot intersect and even touch each other.
After that Bob makes a sequence of "shots". He names cells of the field and Alice either says that the cell is empty ("miss"), or that the cell belongs to some ship ("hit").
But here's the problem! Alice like to cheat. May be that is why she responds to each Bob's move with a "miss".
Help Bob catch Alice cheating β find Bob's first move, such that after it you can be sure that Alice cheated.
Input
The first line of the input contains three integers: n, k and a (1 β€ n, k, a β€ 2Β·105) β the size of the field, the number of the ships and the size of each ship. It is guaranteed that the n, k and a are such that you can put k ships of size a on the field, so that no two ships intersect or touch each other.
The second line contains integer m (1 β€ m β€ n) β the number of Bob's moves.
The third line contains m distinct integers x1, x2, ..., xm, where xi is the number of the cell where Bob made the i-th shot. The cells are numbered from left to right from 1 to n.
Output
Print a single integer β the number of such Bob's first move, after which you can be sure that Alice lied. Bob's moves are numbered from 1 to m in the order the were made. If the sought move doesn't exist, then print "-1".
Examples
Input
11 3 3
5
4 8 6 1 11
Output
3
Input
5 1 3
2
1 5
Output
-1
Input
5 1 3
1
3
Output
1
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
import sys
def minp():
return sys.stdin.readline().strip()
def mint():
return int(minp())
def mints():
return map(int, minp().split())
def solve():
n, k, a = mints()
a += 1
m = mint()
x = list(mints())
l = 0
r = m + 1
while r - l > 1:
c = (l + r) // 2
b = x[:c]
b.sort()
last = 0
cnt = 0
for i in b:
if i != last:
cnt += (i-last) // a
last = i
cnt += (n+1-last)//a
if cnt < k:
r = c
else:
l = c
if r == m + 1:
r = -1
print(r)
solve()
```
|
vfc_81445
|
{
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "11 3 3\n5\n4 8 6 1 11\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 1 3\n1\n3\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 1 3\n2\n1 5\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "200000 1 199999\n2\n2 200000\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "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",
"output": "18\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "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 50 38 35 47 31 4 12 46 32 8 42 26 5 7 27 16 29 43 39 22 17 34 40 18\n",
"output": "50\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
588_F. Duff in Mafia
|
Solve the following coding problem using the programming language python:
Duff is one if the heads of Mafia in her country, Andarz Gu. Andarz Gu has n cities (numbered from 1 to n) connected by m bidirectional roads (numbered by 1 to m).
Each road has a destructing time, and a color. i-th road connects cities vi and ui and its color is ci and its destructing time is ti.
Mafia wants to destruct a matching in Andarz Gu. A matching is a subset of roads such that no two roads in this subset has common endpoint. They can destruct these roads in parallel, i. e. the total destruction time is a maximum over destruction times of all selected roads.
<image>
They want two conditions to be satisfied:
1. The remaining roads form a proper coloring.
2. Destructing time of this matching is minimized.
The remaining roads after destructing this matching form a proper coloring if and only if no two roads of the same color have same endpoint, or, in the other words, edges of each color should form a matching.
There is no programmer in Mafia. That's why Duff asked for your help. Please help her and determine which matching to destruct in order to satisfied those conditions (or state that this is not possible).
Input
The first line of input contains two integers n and m (2 β€ n β€ 5 Γ 104 and 1 β€ m β€ 5 Γ 104), number of cities and number of roads in the country.
The next m lines contain the the roads. i - th of them contains four integers vi, ui, ci and ti (1 β€ vi, ui β€ n, vi β ui and 1 β€ ci, ti β€ 109 for each 1 β€ i β€ m).
Output
In the first line of input, print "Yes" (without quotes) if satisfying the first condition is possible and "No" (without quotes) otherwise.
If it is possible, then you have to print two integers t and k in the second line, the minimum destructing time and the number of roads in the matching (<image>).
In the third line print k distinct integers separated by spaces, indices of the roads in the matching in any order. Roads are numbered starting from one in order of their appearance in the input.
If there's more than one solution, print any of them.
Examples
Input
5 7
2 1 3 7
3 1 1 6
5 4 1 8
4 5 1 1
3 2 2 3
4 5 2 5
2 3 2 4
Output
Yes
3 2
4 5
Input
3 5
3 2 1 3
1 3 1 1
3 2 1 4
1 3 2 2
1 3 2 10
Output
No
Note
Graph of Andarz Gu in the first sample case is as follows:
<image>
A solution would be to destruct the roads with crosses.
Graph of Andarz Gu in the second sample case is as follows:
<image>
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
vfc_81449
|
{
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 6, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 7\n2 1 3 7\n3 1 1 6\n5 4 1 8\n4 5 1 1\n3 2 2 3\n4 5 2 5\n2 3 2 4\n",
"output": "Yes\n3 2\n4 5 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 5\n3 2 1 3\n1 3 1 1\n3 2 1 4\n1 3 2 2\n1 3 2 10\n",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 5\n2 1 608591421 720962564\n3 2 608591421 641991574\n3 2 718110706 353409763\n2 3 482786015 858341723\n3 2 825397574 357507279\n",
"output": "Yes\n641991574 1\n2 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 1\n2 1 317425595 636156322\n",
"output": "Yes\n0 0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "50000 1\n20845 28516 904146168 997637433\n",
"output": "Yes\n0 0\n",
"type": "stdin_stdout"
}
]
}
|
|
code_contests
|
verifiable_code
|
610_C. Harmony Analysis
|
Solve the following coding problem using the programming language python:
The semester is already ending, so Danil made an effort and decided to visit a lesson on harmony analysis to know how does the professor look like, at least. Danil was very bored on this lesson until the teacher gave the group a simple task: find 4 vectors in 4-dimensional space, such that every coordinate of every vector is 1 or - 1 and any two vectors are orthogonal. Just as a reminder, two vectors in n-dimensional space are considered to be orthogonal if and only if their scalar product is equal to zero, that is:
<image>.
Danil quickly managed to come up with the solution for this problem and the teacher noticed that the problem can be solved in a more general case for 2k vectors in 2k-dimensinoal space. When Danil came home, he quickly came up with the solution for this problem. Can you cope with it?
Input
The only line of the input contains a single integer k (0 β€ k β€ 9).
Output
Print 2k lines consisting of 2k characters each. The j-th character of the i-th line must be equal to ' * ' if the j-th coordinate of the i-th vector is equal to - 1, and must be equal to ' + ' if it's equal to + 1. It's guaranteed that the answer always exists.
If there are many correct answers, print any.
Examples
Input
2
Output
++**
+*+*
++++
+**+
Note
Consider all scalar products in example:
* Vectors 1 and 2: ( + 1)Β·( + 1) + ( + 1)Β·( - 1) + ( - 1)Β·( + 1) + ( - 1)Β·( - 1) = 0
* Vectors 1 and 3: ( + 1)Β·( + 1) + ( + 1)Β·( + 1) + ( - 1)Β·( + 1) + ( - 1)Β·( + 1) = 0
* Vectors 1 and 4: ( + 1)Β·( + 1) + ( + 1)Β·( - 1) + ( - 1)Β·( - 1) + ( - 1)Β·( + 1) = 0
* Vectors 2 and 3: ( + 1)Β·( + 1) + ( - 1)Β·( + 1) + ( + 1)Β·( + 1) + ( - 1)Β·( + 1) = 0
* Vectors 2 and 4: ( + 1)Β·( + 1) + ( - 1)Β·( - 1) + ( + 1)Β·( - 1) + ( - 1)Β·( + 1) = 0
* Vectors 3 and 4: ( + 1)Β·( + 1) + ( + 1)Β·( - 1) + ( + 1)Β·( - 1) + ( + 1)Β·( + 1) = 0
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
p = [[0]]
for i in range(int(input())):
p = [t + t for t in p] + [[1 - q for q in t] + t for t in p]
for t in p: print(''.join('+*'[q] for q in t))
```
|
vfc_81453
|
{
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n",
"output": "++++\n+*+*\n++**\n+**+\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n",
"output": "++++\n+*+*\n++**\n+**+\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n",
"output": "++++++++++++++++\n+*+*+*+*+*+*+*+*\n++**++**++**++**\n+**++**++**++**+\n++++****++++****\n+*+**+*++*+**+*+\n++****++++****++\n+**+*++*+**+*++*\n++++++++********\n+*+*+*+**+*+*+*+\n++**++****++**++\n+**++**+*++**++*\n++++********++++\n+*+**+*+*+*++*+*\n++****++**++++**\n+**+*++**++*+**+\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n",
"output": "++\n+*\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n",
"output": "++++++++++++++++++++++++++++++++\n+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*\n++**++**++**++**++**++**++**++**\n+**++**++**++**++**++**++**++**+\n++++****++++****++++****++++****\n+*+**+*++*+**+*++*+**+*++*+**+*+\n++****++++****++++****++++****++\n+**+*++*+**+*++*+**+*++*+**+*++*\n++++++++********++++++++********\n+*+*+*+**+*+*+*++*+*+*+**+*+*+*+\n++**++****++**++++**++****++**++\n+**++**+*++**++*+**++**+*++**++*\n++++********++++++++********++++\n+*+**+*+*+*++*+*+*+**+*+*+*++*+*\n++****++**++++**++****++**++++**\n+**+*++**++*+**++**+*++**++*+**+\n++++++++++++++++****************\n+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+\n++**++**++**++****++**++**++**++\n+**++**++**++**+*++**++**++**++*\n++++****++++********++++****++++\n+*+**+*++*+**+*+*+*++*+**+*++*+*\n++****++++****++**++++****++++**\n+**+*++*+**+*++**++*+**+*++*+**+\n++++++++****************++++++++\n+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*\n++**++****++**++**++**++++**++**\n+**++**+*++**++**++**++*+**++**+\n++++********++++****++++++++****\n+*+**+*+*+*++*+**+*++*+*+*+**+*+\n++****++**++++****++++**++****++\n+**+*++**++*+**+*++*+**++**+*++*\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7\n",
"output": "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*\n++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**\n+**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**+\n++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****\n+*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*+\n++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++++****++\n+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*\n++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********\n+*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*+\n++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++\n+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*\n++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++++++********++++\n+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*\n++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**++****++**++++**\n+**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**+\n++++++++++++++++****************++++++++++++++++****************++++++++++++++++****************++++++++++++++++****************\n+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+\n++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++\n+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*\n++++****++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++\n+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*\n++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**\n+**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**+\n++++++++****************++++++++++++++++****************++++++++++++++++****************++++++++++++++++****************++++++++\n+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*\n++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++++**++**\n+**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**+\n++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++++++****++++********++++****++++++++****\n+*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*+\n++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++++****++**++++****++++**++****++\n+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*\n++++++++++++++++++++++++++++++++********************************++++++++++++++++++++++++++++++++********************************\n+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+\n++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++\n+**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++*\n++++****++++****++++****++++********++++****++++****++++****++++++++****++++****++++****++++********++++****++++****++++****++++\n+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*\n++****++++****++++****++++****++**++++****++++****++++****++++**++****++++****++++****++++****++**++++****++++****++++****++++**\n+**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**+\n++++++++********++++++++****************++++++++********++++++++++++++++********++++++++****************++++++++********++++++++\n+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*\n++**++****++**++++**++****++**++**++**++++**++****++**++++**++**++**++****++**++++**++****++**++**++**++++**++****++**++++**++**\n+**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**+\n++++********++++++++********++++****++++++++********++++++++****++++********++++++++********++++****++++++++********++++++++****\n+*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*+\n++****++**++++**++****++**++++****++++**++****++**++++**++****++++****++**++++**++****++**++++****++++**++****++**++++**++****++\n+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*\n++++++++++++++++********************************++++++++++++++++++++++++++++++++********************************++++++++++++++++\n+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*\n++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++**\n+**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**+\n++++****++++********++++****++++****++++****++++++++****++++****++++****++++********++++****++++****++++****++++++++****++++****\n+*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*+\n++****++++****++**++++****++++****++++****++++**++****++++****++++****++++****++**++++****++++****++++****++++**++****++++****++\n+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*\n++++++++****************++++++++********++++++++++++++++********++++++++****************++++++++********++++++++++++++++********\n+*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*+\n++**++****++**++**++**++++**++****++**++++**++**++**++****++**++++**++****++**++**++**++++**++****++**++++**++**++**++****++**++\n+**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++*\n++++********++++****++++++++********++++++++****++++********++++++++********++++****++++++++********++++++++****++++********++++\n+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*\n++****++**++++****++++**++****++**++++**++****++++****++**++++**++****++**++++****++++**++****++**++++**++****++++****++**++++**\n+**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**+\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++****************************************************************\n+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+\n++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++\n+**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++*\n++++****++++****++++****++++****++++****++++****++++****++++********++++****++++****++++****++++****++++****++++****++++****++++\n+*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+*\n++****++++****++++****++++****++++****++++****++++****++++****++**++++****++++****++++****++++****++++****++++****++++****++++**\n+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+\n++++++++********++++++++********++++++++********++++++++****************++++++++********++++++++********++++++++********++++++++\n+*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+*\n++**++****++**++++**++****++**++++**++****++**++++**++****++**++**++**++++**++****++**++++**++****++**++++**++****++**++++**++**\n+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+\n++++********++++++++********++++++++********++++++++********++++****++++++++********++++++++********++++++++********++++++++****\n+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+\n++****++**++++**++****++**++++**++****++**++++**++****++**++++****++++**++****++**++++**++****++**++++**++****++**++++**++****++\n+**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++*\n++++++++++++++++****************++++++++++++++++********************************++++++++++++++++****************++++++++++++++++\n+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*\n++**++**++**++****++**++**++**++++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++****++**++**++**++++**++**++**++**\n+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+\n++++****++++********++++****++++++++****++++********++++****++++****++++****++++++++****++++********++++****++++++++****++++****\n+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+\n++****++++****++**++++****++++**++****++++****++**++++****++++****++++****++++**++****++++****++**++++****++++**++****++++****++\n+**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++*\n++++++++****************++++++++++++++++****************++++++++********++++++++++++++++****************++++++++++++++++********\n+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+\n++**++****++**++**++**++++**++**++**++****++**++**++**++++**++****++**++++**++**++**++****++**++**++**++++**++**++**++****++**++\n+**++**+*++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++*\n++++********++++****++++++++****++++********++++****++++++++********++++++++****++++********++++****++++++++****++++********++++\n+*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+*\n++****++**++++****++++**++****++++****++**++++****++++**++****++**++++**++****++++****++**++++****++++**++****++++****++**++++**\n+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**+\n++++++++++++++++++++++++++++++++****************************************************************++++++++++++++++++++++++++++++++\n+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*\n++**++**++**++**++**++**++**++****++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++++**++**++**++**++**++**++**++**\n+**++**++**++**++**++**++**++**+*++**++**++**++**++**++**++**++**++**++**++**++**++**++**++**++*+**++**++**++**++**++**++**++**+\n++++****++++****++++****++++********++++****++++****++++****++++****++++****++++****++++****++++++++****++++****++++****++++****\n+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+\n++****++++****++++****++++****++**++++****++++****++++****++++****++++****++++****++++****++++**++****++++****++++****++++****++\n+**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++*\n++++++++********++++++++****************++++++++********++++++++********++++++++********++++++++++++++++********++++++++********\n+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+\n++**++****++**++++**++****++**++**++**++++**++****++**++++**++****++**++++**++****++**++++**++**++**++****++**++++**++****++**++\n+**++**+*++**++*+**++**+*++**++**++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**++**++**+*++**++*+**++**+*++**++*\n++++********++++++++********++++****++++++++********++++++++********++++++++********++++++++****++++********++++++++********++++\n+*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+*\n++****++**++++**++****++**++++****++++**++****++**++++**++****++**++++**++****++**++++**++****++++****++**++++**++****++**++++**\n+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++**++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+\n++++++++++++++++********************************++++++++++++++++****************++++++++++++++++++++++++++++++++****************\n+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+**+*+*+*+*+*+*+*+\n++**++**++**++****++**++**++**++**++**++**++**++++**++**++**++****++**++**++**++++**++**++**++**++**++**++**++****++**++**++**++\n+**++**++**++**+*++**++**++**++**++**++**++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**++**++**++**++**+*++**++**++**++*\n++++****++++********++++****++++****++++****++++++++****++++********++++****++++++++****++++****++++****++++********++++****++++\n+*+**+*++*+**+*+*+*++*+**+*++*+**+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*++*+**+*++*+**+*+*+*++*+**+*++*+*\n++****++++****++**++++****++++****++++****++++**++****++++****++**++++****++++**++****++++****++++****++++****++**++++****++++**\n+**+*++*+**+*++**++*+**+*++*+**+*++*+**+*++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++*+**+*++*+**+*++**++*+**+*++*+**+\n++++++++****************++++++++********++++++++++++++++****************++++++++++++++++********++++++++****************++++++++\n+*+*+*+**+*+*+*+*+*+*+*++*+*+*+**+*+*+*++*+*+*+*+*+*+*+**+*+*+*+*+*+*+*++*+*+*+*+*+*+*+**+*+*+*++*+*+*+**+*+*+*+*+*+*+*++*+*+*+*\n++**++****++**++**++**++++**++****++**++++**++**++**++****++**++**++**++++**++**++**++****++**++++**++****++**++**++**++++**++**\n+**++**+*++**++**++**++*+**++**+*++**++*+**++**++**++**+*++**++**++**++*+**++**++**++**+*++**++*+**++**+*++**++**++**++*+**++**+\n++++********++++****++++++++********++++++++****++++********++++****++++++++****++++********++++++++********++++****++++++++****\n+*+**+*+*+*++*+**+*++*+*+*+**+*+*+*++*+*+*+**+*++*+**+*+*+*++*+**+*++*+*+*+**+*++*+**+*+*+*++*+*+*+**+*+*+*++*+**+*++*+*+*+**+*+\n++****++**++++****++++**++****++**++++**++****++++****++**++++****++++**++****++++****++**++++**++****++**++++****++++**++****++\n+**+*++**++*+**+*++*+**++**+*++**++*+**++**+*++*+**+*++**++*+**+*++*+**++**+*++*+**+*++**++*+**++**+*++**++*+**+*++*+**++**+*++*\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
630_M. Turn
|
Solve the following coding problem using the programming language python:
Vasya started working in a machine vision company of IT City. Vasya's team creates software and hardware for identification of people by their face.
One of the project's know-how is a camera rotating around its optical axis on shooting. People see an eye-catching gadget β a rotating camera β come up to it to see it better, look into it. And the camera takes their photo at that time. What could be better for high quality identification?
But not everything is so simple. The pictures from camera appear rotated too (on clockwise camera rotation frame the content becomes rotated counter-clockwise). But the identification algorithm can work only with faces that are just slightly deviated from vertical.
Vasya was entrusted to correct the situation β to rotate a captured image so that image would be minimally deviated from vertical. Requirements were severe. Firstly, the picture should be rotated only on angle divisible by 90 degrees to not lose a bit of information about the image. Secondly, the frames from the camera are so huge and FPS is so big that adequate rotation speed is provided by hardware FPGA solution only. And this solution can rotate only by 90 degrees clockwise. Of course, one can apply 90 degrees turn several times but for the sake of performance the number of turns should be minimized.
Help Vasya implement the program that by the given rotation angle of the camera can determine the minimum number of 90 degrees clockwise turns necessary to get a picture in which up direction deviation from vertical is minimum.
The next figure contains frames taken from an unrotated camera, then from rotated 90 degrees clockwise, then from rotated 90 degrees counter-clockwise. Arrows show direction to "true up".
<image>
The next figure shows 90 degrees clockwise turn by FPGA hardware.
<image>
Input
The only line of the input contains one integer x ( - 1018 β€ x β€ 1018) β camera angle in degrees. Positive value denotes clockwise camera rotation, negative β counter-clockwise.
Output
Output one integer β the minimum required number of 90 degrees clockwise turns.
Examples
Input
60
Output
1
Input
-60
Output
3
Note
When the camera is rotated 60 degrees counter-clockwise (the second example), an image from it is rotated 60 degrees clockwise. One 90 degrees clockwise turn of the image result in 150 degrees clockwise total rotation and deviation from "true up" for one turn is 150 degrees. Two 90 degrees clockwise turns of the image result in 240 degrees clockwise total rotation and deviation from "true up" for two turns is 120 degrees because 240 degrees clockwise equal to 120 degrees counter-clockwise. Three 90 degrees clockwise turns of the image result in 330 degrees clockwise total rotation and deviation from "true up" for three turns is 30 degrees because 330 degrees clockwise equal to 30 degrees counter-clockwise.
From 60, 150, 120 and 30 degrees deviations the smallest is 30, and it it achieved in three 90 degrees clockwise turns.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
import math, re, sys, string, operator, functools, fractions, collections
sys.setrecursionlimit(10**7)
dX= [-1, 1, 0, 0,-1, 1,-1, 1]
dY= [ 0, 0,-1, 1, 1,-1,-1, 1]
RI=lambda x=' ': list(map(int,input().split(x)))
RS=lambda x=' ': input().rstrip().split(x)
mod=int(1e9+7)
eps=1e-6
#################################################
x=RI()[0]
x%=360
if x>180:
x=x-360
ans=0
val=abs(x)
for i in range(1,4):
x-=90
if x<-180:
x=360+x
if abs(x)<val:
val=abs(x)
ans=i
print(ans)
```
|
vfc_81457
|
{
"difficulty": "20",
"memory_limit": null,
"memory_limit_bytes": 64000000,
"problem_url": null,
"time_limit": "{'seconds': 0, 'nanos': 500000000}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "-60\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "60\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6678504591813508\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "44\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "225\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "-45\n",
"output": "0\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
659_E. New Reform
|
Solve the following coding problem using the programming language python:
Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get from any city to any other one, using only the existing roads.
The President of Berland decided to make changes to the road system and instructed the Ministry of Transport to make this reform. Now, each road should be unidirectional (only lead from one city to another).
In order not to cause great resentment among residents, the reform needs to be conducted so that there can be as few separate cities as possible. A city is considered separate, if no road leads into it, while it is allowed to have roads leading from this city.
Help the Ministry of Transport to find the minimum possible number of separate cities after the reform.
Input
The first line of the input contains two positive integers, n and m β the number of the cities and the number of roads in Berland (2 β€ n β€ 100 000, 1 β€ m β€ 100 000).
Next m lines contain the descriptions of the roads: the i-th road is determined by two distinct integers xi, yi (1 β€ xi, yi β€ n, xi β yi), where xi and yi are the numbers of the cities connected by the i-th road.
It is guaranteed that there is no more than one road between each pair of cities, but it is not guaranteed that from any city you can get to any other one, using only roads.
Output
Print a single integer β the minimum number of separated cities after the reform.
Examples
Input
4 3
2 1
1 3
4 3
Output
1
Input
5 5
2 1
1 3
2 3
2 5
4 3
Output
0
Input
6 5
1 2
2 3
4 5
4 6
5 6
Output
1
Note
In the first sample the following road orientation is allowed: <image>, <image>, <image>.
The second sample: <image>, <image>, <image>, <image>, <image>.
The third sample: <image>, <image>, <image>, <image>, <image>.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
import sys
from math import sqrt, gcd, ceil, log
# from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
# from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda: list(map(int, input().strip().split()))
sys.setrecursionlimit(200000)
def main():
n, m = read()
adj = defaultdict(list)
visited = defaultdict(int)
# visited
for i in range(m):
x, y = read()
adj[x].append(y)
adj[y].append(x)
def dfs(ver):
parent = defaultdict(int)
stk = [(ver,0)]
visited[ver] = 1
parent[ver] = 0
while stk:
node, par = stk.pop()
for child in adj[node]:
if child == par:continue
elif not visited[child]:
visited[child] = 1
parent[child] = node
stk.append((child, node))
elif parent[child] != node:
return(0)
return(1)
ans = 0
for i in range(1, n+1):
if not visited[i]:
ans += dfs(i)
# print(i, visited)
print(ans)
#
if __name__ == "__main__":
main()
```
|
vfc_81461
|
{
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 5\n2 1\n1 3\n2 3\n2 5\n4 3\n",
"output": "0",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
682_B. Alyona and Mex
|
Solve the following coding problem using the programming language python:
Someone gave Alyona an array containing n positive integers a1, a2, ..., an. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not apply any operation to the array at all.
Formally, after applying some operations Alyona will get an array of n positive integers b1, b2, ..., bn such that 1 β€ bi β€ ai for every 1 β€ i β€ n. Your task is to determine the maximum possible value of mex of this array.
Mex of an array in this problem is the minimum positive integer that doesn't appear in this array. For example, mex of the array containing 1, 3 and 4 is equal to 2, while mex of the array containing 2, 3 and 2 is equal to 1.
Input
The first line of the input contains a single integer n (1 β€ n β€ 100 000) β the number of elements in the Alyona's array.
The second line of the input contains n integers a1, a2, ..., an (1 β€ ai β€ 109) β the elements of the array.
Output
Print one positive integer β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations.
Examples
Input
5
1 3 3 3 6
Output
5
Input
2
2 1
Output
3
Note
In the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.
To reach the answer to the second sample case one must not decrease any of the array elements.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
import sys
n = int(input())
arr = list(map(int,input().split()))
arr.sort()
ans = 1
for i in range(1,n+1):
if arr[i-1]>=ans:
ans+=1
print(ans)
```
|
vfc_81465
|
{
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1 3 3 3 6\n",
"output": "5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n2 1\n",
"output": "3\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
705_A. Hulk
|
Solve the following coding problem using the programming language python:
Dr. Bruce Banner hates his enemies (like others don't). As we all know, he can barely talk when he turns into the incredible Hulk. That's why he asked you to help him to express his feelings.
Hulk likes the Inception so much, and like that his feelings are complicated. They have n layers. The first layer is hate, second one is love, third one is hate and so on...
For example if n = 1, then his feeling is "I hate it" or if n = 2 it's "I hate that I love it", and if n = 3 it's "I hate that I love that I hate it" and so on.
Please help Dr. Banner.
Input
The only line of the input contains a single integer n (1 β€ n β€ 100) β the number of layers of love and hate.
Output
Print Dr.Banner's feeling in one line.
Examples
Input
1
Output
I hate it
Input
2
Output
I hate that I love it
Input
3
Output
I hate that I love that I hate it
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
x = int(input())
feelings = ''
for _ in range(x):
if _ == x - 1:
if _ % 2 != 0:
feelings = feelings + 'I love it '
else:
feelings = feelings + 'I hate it '
else:
if _ % 2 != 0:
feelings = feelings + 'I love that '
else:
feelings = feelings + 'I hate that '
print(feelings)
```
|
vfc_81469
|
{
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n",
"output": "I hate that I love it\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n",
"output": "I hate it\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n",
"output": "I hate that I love that I hate it\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
727_D. T-shirts Distribution
|
Solve the following coding problem using the programming language python:
The organizers of a programming contest have decided to present t-shirts to participants. There are six different t-shirts sizes in this problem: S, M, L, XL, XXL, XXXL (sizes are listed in increasing order). The t-shirts are already prepared. For each size from S to XXXL you are given the number of t-shirts of this size.
During the registration, the organizers asked each of the n participants about the t-shirt size he wants. If a participant hesitated between two sizes, he could specify two neighboring sizes β this means that any of these two sizes suits him.
Write a program that will determine whether it is possible to present a t-shirt to each participant of the competition, or not. Of course, each participant should get a t-shirt of proper size:
* the size he wanted, if he specified one size;
* any of the two neibouring sizes, if he specified two sizes.
If it is possible, the program should find any valid distribution of the t-shirts.
Input
The first line of the input contains six non-negative integers β the number of t-shirts of each size. The numbers are given for the sizes S, M, L, XL, XXL, XXXL, respectively. The total number of t-shirts doesn't exceed 100 000.
The second line contains positive integer n (1 β€ n β€ 100 000) β the number of participants.
The following n lines contain the sizes specified by the participants, one line per participant. The i-th line contains information provided by the i-th participant: single size or two sizes separated by comma (without any spaces). If there are two sizes, the sizes are written in increasing order. It is guaranteed that two sizes separated by comma are neighboring.
Output
If it is not possible to present a t-shirt to each participant, print Β«NOΒ» (without quotes).
Otherwise, print n + 1 lines. In the first line print Β«YESΒ» (without quotes). In the following n lines print the t-shirt sizes the orginizers should give to participants, one per line. The order of the participants should be the same as in the input.
If there are multiple solutions, print any of them.
Examples
Input
0 1 0 1 1 0
3
XL
S,M
XL,XXL
Output
YES
XL
M
XXL
Input
1 1 2 0 1 1
5
S
M
S,M
XXL,XXXL
XL,XXL
Output
NO
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
from math import *
from sys import *
def conv(s):
if s=="S" or s=="S\n":
return 1
if s=="M" or s=="M\n":
return 2
if s=="L" or s=="L\n":
return 3
if s=="XL" or s=="XL\n":
return 4
if s=="XXL" or s=="XXL\n":
return 5
return 6
def uncon(x):
if x==1:
return "S"
if x==2:
return "M"
if x==3:
return "L"
if x==4:
return "XL"
if x==5:
return "XXL"
return "XXXL"
s=[]
m=[]
l=[]
xl=[]
xxl=[]
sp,mp,lp,xp,xxp=0,0,0,0,0
t=[0]
t+=[int(z) for z in stdin.readline().split()]
n=int(stdin.readline())
ans=[0]*n
#print(t)
for i in range(n):
e=[conv(z) for z in stdin.readline().split(",")]
#print(e)
if len(e)==1:
ans[i]=e[0]
t[e[0]]-=1
if t[e[0]]<0:
print("NO")
exit(0)
else:
if e[0]==1:
s.append(i)
if e[0]==2:
m.append(i)
if e[0]==3:
l.append(i)
if e[0]==4:
xl.append(i)
if e[0]==5:
xxl.append(i)
while len(s)!=sp and t[1]:
ans[s[sp]]=1
sp+=1
t[1]-=1
while len(s)!=sp and t[2]:
ans[s[sp]]=2
sp+=1
t[2]-=1
if len(s)!=sp:
print("NO")
exit(0)
while len(m)!=mp and t[2]:
ans[m[mp]]=2
mp+=1
t[2]-=1
while len(m)!=mp and t[3]:
ans[m[mp]]=3
mp+=1
t[3]-=1
if len(m)!=mp:
print("NO")
exit(0)
while len(l)!=lp and t[3]:
ans[l[lp]]=3
lp+=1
t[3]-=1
while len(l)!=lp and t[4]:
ans[l[lp]]=4
lp+=1
t[4]-=1
if len(l)!=lp:
print("NO")
exit(0)
while len(xl)!=xp and t[4]:
ans[xl[xp]]=4
xp+=1
t[4]-=1
while len(xl)!=xp and t[5]:
ans[xl[xp]]=5
xp+=1
t[5]-=1
if len(xl)!=xp:
print("NO")
exit(0)
while len(xxl)!=xxp and t[5]:
ans[xxl[xxp]]=5
xxp+=1
t[5]-=1
while len(xxl)!=xxp and t[6]:
ans[xxl[xxp]]=6
xxp+=1
t[6]-=1
if len(xxl)!=xxp:
print("NO")
exit(0)
res=[uncon(z) for z in ans]
print("YES")
for i in res:
print(i)
```
|
vfc_81473
|
{
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "0 1 0 1 1 0\n3\nXL\nS,M\nXL,XXL\n",
"output": "YES\nXL\nM\nXXL\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1 2 0 1 1\n5\nS\nM\nS,M\nXXL,XXXL\nXL,XXL\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "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",
"output": "YES\nL\nS\nL\nXXL\nS\nS\nXXL\nXL\nS\nXL\nS\nL\nXXXL\nXXXL\nL\nXXXL\nXXL\nL\nM\nXXL\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 2 4 4 1 1\n10\nXL\nXL\nS,M\nL\nM,L\nL\nS,M\nM\nXL,XXL\nXL\n",
"output": "YES\nXL\nXL\nS\nL\nL\nL\nM\nM\nXL\nXL\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0 0 0 1 0 0\n1\nXL\n",
"output": "YES\nXL\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
748_E. Santa Claus and Tangerines
|
Solve the following coding problem using the programming language python:
Santa Claus has n tangerines, and the i-th of them consists of exactly ai slices. Santa Claus came to a school which has k pupils. Santa decided to treat them with tangerines.
However, there can be too few tangerines to present at least one tangerine to each pupil. So Santa decided to divide tangerines into parts so that no one will be offended. In order to do this, he can divide a tangerine or any existing part into two smaller equal parts. If the number of slices in the part he wants to split is odd, then one of the resulting parts will have one slice more than the other. It's forbidden to divide a part consisting of only one slice.
Santa Claus wants to present to everyone either a whole tangerine or exactly one part of it (that also means that everyone must get a positive number of slices). One or several tangerines or their parts may stay with Santa.
Let bi be the number of slices the i-th pupil has in the end. Let Santa's joy be the minimum among all bi's.
Your task is to find the maximum possible joy Santa can have after he treats everyone with tangerines (or their parts).
Input
The first line contains two positive integers n and k (1 β€ n β€ 106, 1 β€ k β€ 2Β·109) denoting the number of tangerines and the number of pupils, respectively.
The second line consists of n positive integers a1, a2, ..., an (1 β€ ai β€ 107), where ai stands for the number of slices the i-th tangerine consists of.
Output
If there's no way to present a tangerine or a part of tangerine to everyone, print -1. Otherwise, print the maximum possible joy that Santa can have.
Examples
Input
3 2
5 9 3
Output
5
Input
2 4
12 14
Output
6
Input
2 3
1 1
Output
-1
Note
In the first example Santa should divide the second tangerine into two parts with 5 and 4 slices. After that he can present the part with 5 slices to the first pupil and the whole first tangerine (with 5 slices, too) to the second pupil.
In the second example Santa should divide both tangerines, so that he'll be able to present two parts with 6 slices and two parts with 7 slices.
In the third example Santa Claus can't present 2 slices to 3 pupils in such a way that everyone will have anything.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
vfc_81477
|
{
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2\n5 9 3\n",
"output": "5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 4\n12 14\n",
"output": "6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 3\n1 1\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 2\n2\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
}
|
|
code_contests
|
verifiable_code
|
771_D. Bear and Company
|
Solve the following coding problem using the programming language python:
Bear Limak prepares problems for a programming competition. Of course, it would be unprofessional to mention the sponsor name in the statement. Limak takes it seriously and he is going to change some words. To make it still possible to read, he will try to modify each word as little as possible.
Limak has a string s that consists of uppercase English letters. In one move he can swap two adjacent letters of the string. For example, he can transform a string "ABBC" into "BABC" or "ABCB" in one move.
Limak wants to obtain a string without a substring "VK" (i.e. there should be no letter 'V' immediately followed by letter 'K'). It can be easily proved that it's possible for any initial string s.
What is the minimum possible number of moves Limak can do?
Input
The first line of the input contains an integer n (1 β€ n β€ 75) β the length of the string.
The second line contains a string s, consisting of uppercase English letters. The length of the string is equal to n.
Output
Print one integer, denoting the minimum possible number of moves Limak can do, in order to obtain a string without a substring "VK".
Examples
Input
4
VKVK
Output
3
Input
5
BVVKV
Output
2
Input
7
VVKEVKK
Output
3
Input
20
VKVKVVVKVOVKVQKKKVVK
Output
8
Input
5
LIMAK
Output
0
Note
In the first sample, the initial string is "VKVK". The minimum possible number of moves is 3. One optimal sequence of moves is:
1. Swap two last letters. The string becomes "VKKV".
2. Swap first two letters. The string becomes "KVKV".
3. Swap the second and the third letter. The string becomes "KKVV". Indeed, this string doesn't have a substring "VK".
In the second sample, there are two optimal sequences of moves. One is "BVVKV" β "VBVKV" β "VVBKV". The other is "BVVKV" β "BVKVV" β "BKVVV".
In the fifth sample, no swaps are necessary.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
# http://codeforces.com/contest/771/problem/D
"""
DP-solution.
For each state (v, k, x, v_is_last_letter) we trial a step along the v, k and x
axes and check that
dp[future_state] = min(dp[future_state], dp[state] + cost_of_move)
Hence this implicitly reults in the one with least cost.
V, K, X are arrays that contain the number of occurences of v, k, x at the i'th
index of s.
"""
def cost_of_move(state, ss_ind):
"""
eg. ss = s[0:K.index(k+1)]
Note: ss includes the i+1'th occurence of letter I. We hence want
ss = s[0:ss_ind-1]
And then we cound the number of occurences of V, K, X in this substring.
However, we don't need ss now - this info is contained in lists V, K, X.
"""
curr_v, curr_k, curr_x = state
cost = sum([max(0, V[ss_ind-1] - curr_v), max(0, K[ss_ind-1] - curr_k),
max(0, X[ss_ind-1] - curr_x)])
return cost
if __name__ == "__main__":
n = int(input())
s = input()
V = [s[0:i].count('V') for i in range(n+1)]
K = [s[0:i].count('K') for i in range(n+1)]
X = [(i - V[i] - K[i]) for i in range(n+1)]
# Initialising
n_v, n_k, n_x = V[n], K[n], X[n]
dp = [[[[float('Inf') for vtype in range(2)] for x in range(n_x+1)]
for k in range(n_k+1)] for v in range(n_v+1)]
dp[0][0][0][0] = 0
for v in range(n_v + 1):
for k in range(n_k + 1):
for x in range(n_x + 1):
for vtype in range(2):
orig = dp[v][k][x][vtype]
if v < n_v:
dp[v+1][k][x][1] = min(dp[v+1][k][x][vtype],
orig + cost_of_move([v, k, x], V.index(v+1)))
if k < n_k and vtype == 0:
dp[v][k+1][x][0] = min(dp[v][k+1][x][0],
orig + cost_of_move([v, k, x], K.index(k+1)))
if x < n_x:
dp[v][k][x+1][0] = min(dp[v][k][x+1][0],
orig + cost_of_move([v, k, x], X.index(x+1)))
print(min(dp[n_v][n_k][n_x]))
```
|
vfc_81481
|
{
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\nVKVK\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7\nVVKEVKK\n",
"output": "3\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
841_E. On the Bench
|
Solve the following coding problem using the programming language python:
A year ago on the bench in public park Leha found an array of n numbers. Leha believes that permutation p is right if for all 1 β€ i < n condition, that apiΒ·api + 1 is not perfect square, holds. Leha wants to find number of right permutations modulo 109 + 7.
Input
First line of input data contains single integer n (1 β€ n β€ 300) β length of the array.
Next line contains n integers a1, a2, ... , an (1 β€ ai β€ 109) β found array.
Output
Output single integer β number of right permutations modulo 109 + 7.
Examples
Input
3
1 2 4
Output
2
Input
7
5 2 4 2 4 1 1
Output
144
Note
For first example:
[1, 2, 4] β right permutation, because 2 and 8 are not perfect squares.
[1, 4, 2] β wrong permutation, because 4 is square of 2.
[2, 1, 4] β wrong permutation, because 4 is square of 2.
[2, 4, 1] β wrong permutation, because 4 is square of 2.
[4, 1, 2] β wrong permutation, because 4 is square of 2.
[4, 2, 1] β right permutation, because 8 and 2 are not perfect squares.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
vfc_81493
|
{
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7\n5 2 4 2 4 1 1\n",
"output": "144",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 2 4\n",
"output": "2",
"type": "stdin_stdout"
}
]
}
|
|
code_contests
|
verifiable_code
|
888_D. Almost Identity Permutations
|
Solve the following coding problem using the programming language python:
A permutation p of size n is an array such that every integer from 1 to n occurs exactly once in this array.
Let's call a permutation an almost identity permutation iff there exist at least n - k indices i (1 β€ i β€ n) such that pi = i.
Your task is to count the number of almost identity permutations for given numbers n and k.
Input
The first line contains two integers n and k (4 β€ n β€ 1000, 1 β€ k β€ 4).
Output
Print the number of almost identity permutations for given n and k.
Examples
Input
4 1
Output
1
Input
4 2
Output
7
Input
5 3
Output
31
Input
5 4
Output
76
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
import math
nk=input().split()
n=int(nk[0])
k=int(nk[1])
L=[0]*5
L[1]=1
L[2]=(n*(n-1))//2
L[3]=(n*(n-1)*(n-2))//3
L[4]=(3*n*(n-1)*(n-2)*(n-3))//8
s=0
for i in range(0,k+1):
s+=L[i]
print(s)
```
|
vfc_81501
|
{
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 2\n",
"output": "7\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 1\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 4\n",
"output": "76\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 3\n",
"output": "31\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1000 2\n",
"output": "499501\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "400 4\n",
"output": "9477912501\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
911_B. Two Cakes
|
Solve the following coding problem using the programming language python:
It's New Year's Eve soon, so Ivan decided it's high time he started setting the table. Ivan has bought two cakes and cut them into pieces: the first cake has been cut into a pieces, and the second one β into b pieces.
Ivan knows that there will be n people at the celebration (including himself), so Ivan has set n plates for the cakes. Now he is thinking about how to distribute the cakes between the plates. Ivan wants to do it in such a way that all following conditions are met:
1. Each piece of each cake is put on some plate;
2. Each plate contains at least one piece of cake;
3. No plate contains pieces of both cakes.
To make his guests happy, Ivan wants to distribute the cakes in such a way that the minimum number of pieces on the plate is maximized. Formally, Ivan wants to know the maximum possible number x such that he can distribute the cakes according to the aforementioned conditions, and each plate will contain at least x pieces of cake.
Help Ivan to calculate this number x!
Input
The first line contains three integers n, a and b (1 β€ a, b β€ 100, 2 β€ n β€ a + b) β the number of plates, the number of pieces of the first cake, and the number of pieces of the second cake, respectively.
Output
Print the maximum possible number x such that Ivan can distribute the cake in such a way that each plate will contain at least x pieces of cake.
Examples
Input
5 2 3
Output
1
Input
4 7 10
Output
3
Note
In the first example there is only one way to distribute cakes to plates, all of them will have 1 cake on it.
In the second example you can have two plates with 3 and 4 pieces of the first cake and two plates both with 5 pieces of the second cake. Minimal number of pieces is 3.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
#problem 911b
n,a,b=list(map(int,input().split()))
print(max(min(a//i,b//(n-i)) for i in range(1,n)))
```
|
vfc_81505
|
{
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 7 10\n",
"output": "3\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
932_G. Palindrome Partition
|
Solve the following coding problem using the programming language python:
Given a string s, find the number of ways to split s to substrings such that if there are k substrings (p1, p2, p3, ..., pk) in partition, then pi = pk - i + 1 for all i (1 β€ i β€ k) and k is even.
Since the number of ways can be large, print it modulo 109 + 7.
Input
The only line of input contains a string s (2 β€ |s| β€ 106) of even length consisting of lowercase Latin letters.
Output
Print one integer, the number of ways of partitioning the string modulo 109 + 7.
Examples
Input
abcdcdab
Output
1
Input
abbababababbab
Output
3
Note
In the first case, the only way to partition the string is ab|cd|cd|ab.
In the second case, the string can be partitioned as ab|b|ab|ab|ab|ab|b|ab or ab|b|abab|abab|b|ab or abbab|ab|ab|abbab.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
vfc_81509
|
{
"difficulty": "13",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "abcdcdab\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "abbababababbab\n",
"output": "3\n",
"type": "stdin_stdout"
}
]
}
|
|
code_contests
|
verifiable_code
|
95_B. Lucky Numbers
|
Solve the following coding problem using the programming language python:
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. For example, numbers 47, 7744, 474477 are super lucky and 4, 744, 467 are not.
One day Petya came across a positive integer n. Help him to find the least super lucky number which is not less than n.
Input
The only line contains a positive integer n (1 β€ n β€ 10100000). This number doesn't have leading zeroes.
Output
Output the least super lucky number that is more than or equal to n.
Examples
Input
4500
Output
4747
Input
47
Output
47
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
from itertools import permutations as p
def ck(num,arr):
for i in arr:
if i>=num:
print(i)
return
x = input()
z = len(x)
if z == 1:
print(47)
elif z == 2 :
if int(x) <= 74:
arr = [47,74]
ck(int(x),arr)
else:
print(4477)
elif z == 3:
print(4477)
elif z == 4:
if int(x) <= 7744:
arr4 = sorted([int("".join(i)) for i in p("4477")])
ck(int(x),arr4)
else:
print(444777)
elif z == 5:
print(444777)
elif z == 6:
if int(x) <= 777444:
arr6 = sorted([int("".join(i)) for i in p("444777")])
ck(int(x),arr6)
else:
print(44447777)
elif z ==7:
print(44447777)
elif z==8:
if int(x)<=77774444:
arr8 = sorted([int("".join(i)) for i in p("44447777")])
ck(int(x),arr8)
else:
print(4444477777)
else:
print(4444477777)
```
|
vfc_81513
|
{
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "47\n",
"output": "47\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
986_F. Oppa Funcan Style Remastered
|
Solve the following coding problem using the programming language python:
Surely you have seen insane videos by South Korean rapper PSY, such as "Gangnam Style", "Gentleman" and "Daddy". You might also hear that PSY has been recording video "Oppa Funcan Style" two years ago (unfortunately we couldn't find it on the internet). We will remind you what this hit looked like (you can find original description [here](http://acm.timus.ru/problem.aspx?space=1&num=2107&locale=en)):
On the ground there are n platforms, which are numbered with integers from 1 to n, on i-th platform there is a dancer with number i. Further, every second all the dancers standing on the platform with number i jump to the platform with the number f(i). The moving rule f is selected in advance and is not changed throughout the clip.
The duration of the clip was k seconds and the rule f was chosen in such a way that after k seconds all dancers were in their initial positions (i.e. the i-th dancer stood on the platform with the number i). That allowed to loop the clip and collect even more likes.
PSY knows that enhanced versions of old artworks become more and more popular every day. So he decided to release a remastered-version of his video.
In his case "enhanced version" means even more insanity, so the number of platforms can be up to 10^{18}! But the video director said that if some dancer stays on the same platform all the time, then the viewer will get bored and will turn off the video immediately. Therefore, for all x from 1 to n f(x) β x must hold.
Big part of classic video's success was in that looping, so in the remastered version all dancers should return to their initial positions in the end of the clip as well.
PSY hasn't decided on the exact number of platforms and video duration yet, so he asks you to check if there is a good rule f for different options.
Input
In the first line of input there is one integer t (1 β€ t β€ 10^{4}) β the number of options for n and k to check.
In the next t lines the options are given: each option is described with two integers n and k (1 β€ n β€ 10^{18}, 1 β€ k β€ 10^{15}) β the number of dancers and the duration in seconds.
It is guaranteed that the number of different values of k in one test is not greater than 50.
Output
Print t lines. If the i-th option of the video is feasible, print "YES" (without quotes) in i-th line, otherwise print "NO" (without quotes).
Example
Input
3
7 7
3 8
5 6
Output
YES
NO
YES
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
vfc_81517
|
{
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 5, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n7 7\n3 8\n5 6\n",
"output": "YES\nNO\nYES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1 1\n2 1\n1000000000 1\n1000000000000000000 1\n",
"output": "NO\nNO\nNO\nNO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n7 3\n3 8\n5 6\n",
"output": "NO\nNO\nYES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n7 3\n3 6\n5 6\n",
"output": "NO\nYES\nYES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n7 3\n3 6\n5 11\n",
"output": "NO\nYES\nNO\n",
"type": "stdin_stdout"
}
]
}
|
|
code_contests
|
verifiable_code
|
akbar-and-birbal-1
|
Solve the following coding problem using the programming language python:
This is the time of Akbar and Birbal. One day , in the state there happened some riots and murders .Akbar found some N people guilty in this matter.He called Birbal to punish them .Birbal gave them a unique punishment .He ordered the first person(guilty) to dig all the N spaces indicated on the ground.Then he called the second person to dig all the even spaces on the ground(spaces in multiples of 2) ,and if the space is already digged then fill it by sand .Similarly ,he asked the third person to dig all the spaces in multiple of 3 and fill it if it is already digged...an so on. After the N persons have completed their punishments,Birbal asked the first person to tell the amount of spaces remained undigged .What is the answer of this person??
INPUT:
A single integer(T),denoting the number of test cases.
Then,following T lines will contain a single line containing integer N.
OUTPUT:
A integer for each test case denoting the answer of the person.
Constraints:
0<T β€ 100
0<N<10^18
SAMPLE INPUT
1
2
SAMPLE OUTPUT
1
Explanation
In given sample Input,there are 2 persons. So first will come and dig the 1st and 2nd space.Then ,2nd person will come and as the 2nd space is already digged so he will fill 2nd space.Therefore,the number of undigged spaces is only 1 i.e. the required answer.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
import math
for _ in xrange(input()):
n = input()
print (n - int(math.sqrt(n)))
```
|
vfc_81521
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "100\n1804246908\n846901785\n1681651770\n1714595508\n1957703548\n424217739\n719858557\n1649719876\n596492227\n1189606931\n1025170345\n1350453279\n783340703\n1102486856\n2044852544\n1967469571\n1365143593\n1540344180\n304071735\n1303419634\n34999296\n521572531\n294685402\n1726914874\n336447440\n860992188\n278706169\n233649838\n2145127752\n468681487\n1101480741\n1801937354\n1315597752\n635697846\n1369096069\n1125864614\n1059928837\n2088972752\n628149949\n1656437344\n1131142598\n1653336713\n859455106\n1914501165\n608389119\n756871027\n1734533551\n1973549900\n149786077\n2038619220\n1129532805\n184789933\n412755776\n1424231242\n1911716234\n749214502\n137795124\n42992614\n982875646\n135485642\n511679686\n2084375271\n1937433069\n1827293581\n572636407\n1159092461\n805722462\n1632581325\n1100628138\n1433887991\n1141582338\n84344712\n939788927\n2001055813\n1998854106\n1548194021\n610490727\n1585950541\n1374306972\n760286178\n1477132655\n356407930\n945086535\n1889903706\n1780653591\n709366951\n491683230\n1918458852\n752365326\n1474574000\n2053954612\n1264059507\n1411512107\n1843950428\n943917017\n1984165469\n855606976\n1749656758\n1469309763\n1956253310",
"output": "1804204432\n846872684\n1681610763\n1714554101\n1957659303\n424197143\n719831727\n1649679260\n596467804\n1189572441\n1025138327\n1350416531\n783312715\n1102453653\n2044807324\n1967425215\n1365106646\n1540304933\n304054298\n1303383532\n34993380\n521549694\n294668236\n1726873318\n336429098\n860962846\n278689475\n233634553\n2145081437\n468659838\n1101447553\n1801894905\n1315561481\n635672633\n1369059068\n1125831061\n1059896281\n2088927047\n628124887\n1656396645\n1131108966\n1653296052\n859425790\n1914457410\n608364454\n756843516\n1734491904\n1973505476\n149773839\n2038574069\n1129499197\n184776340\n412735460\n1424193504\n1911672511\n749187131\n137783386\n42986058\n982844296\n135474003\n511657066\n2084329617\n1937389053\n1827250835\n572612478\n1159058416\n805694077\n1632540920\n1100594963\n1433850125\n1141548551\n84335529\n939758272\n2001011080\n1998809398\n1548154674\n610466019\n1585910718\n1374269901\n760258605\n1477094222\n356389052\n945055793\n1889860233\n1780611394\n709340318\n491661057\n1918415052\n752337897\n1474535600\n2053909292\n1264023954\n1411474537\n1843907487\n943886294\n1984120926\n855577726\n1749614930\n1469271432\n1956209081\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100\n1804289384\n846930887\n1681692778\n1714636916\n1957747794\n424238336\n719885387\n1649760493\n596516650\n1189641422\n1025202363\n1350490028\n783368691\n1102520060\n2044897764\n1967513927\n1365180541\n1540383427\n304089173\n1303455737\n35005212\n521595369\n294702568\n1726956430\n336465783\n861021531\n278722863\n233665124\n2145174068\n468703136\n1101513930\n1801979803\n1315634023\n635723059\n1369133070\n1125898168\n1059961394\n2089018457\n628175012\n1656478043\n1131176230\n1653377374\n859484422\n1914544920\n608413785\n756898538\n1734575199\n1973594325\n149798316\n2038664371\n1129566414\n184803527\n412776092\n1424268981\n1911759957\n749241874\n137806863\n42999171\n982906997\n135497282\n511702306\n2084420926\n1937477085\n1827336328\n572660337\n1159126506\n805750847\n1632621730\n1100661314\n1433925858\n1141616125\n84353896\n939819583\n2001100546\n1998898815\n1548233368\n610515435\n1585990365\n1374344044\n760313751\n1477171088\n356426809\n945117277\n1889947179\n1780695789\n709393585\n491705404\n1918502652\n752392755\n1474612400\n2053999933\n1264095061\n1411549677\n1843993369\n943947740\n1984210013\n855636227\n1749698587\n1469348095\n1956297540",
"output": "1804246908\n846901785\n1681651770\n1714595508\n1957703548\n424217739\n719858557\n1649719876\n596492227\n1189606931\n1025170345\n1350453279\n783340703\n1102486856\n2044852544\n1967469571\n1365143593\n1540344180\n304071735\n1303419634\n34999296\n521572531\n294685402\n1726914874\n336447440\n860992188\n278706169\n233649838\n2145127752\n468681487\n1101480741\n1801937354\n1315597752\n635697846\n1369096069\n1125864614\n1059928837\n2088972752\n628149949\n1656437344\n1131142598\n1653336713\n859455106\n1914501165\n608389119\n756871027\n1734533551\n1973549900\n149786077\n2038619220\n1129532805\n184789933\n412755776\n1424231242\n1911716234\n749214502\n137795124\n42992614\n982875646\n135485642\n511679686\n2084375271\n1937433069\n1827293581\n572636407\n1159092461\n805722462\n1632581325\n1100628138\n1433887991\n1141582338\n84344712\n939788927\n2001055813\n1998854106\n1548194021\n610490727\n1585950541\n1374306972\n760286178\n1477132655\n356407930\n945086535\n1889903706\n1780653591\n709366951\n491683230\n1918458852\n752365326\n1474574000\n2053954612\n1264059507\n1411512107\n1843950428\n943917017\n1984165469\n855606976\n1749656758\n1469309763\n1956253310\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100\n1804246908\n846901785\n1681651770\n1714595508\n1957703548\n424217739\n719858557\n1649719876\n596492227\n1189606931\n1025170345\n1350453279\n783340703\n1102486856\n2044852544\n1967469571\n1365143593\n1540344180\n304071735\n1303419634\n34999296\n521572531\n294685402\n1726914874\n336447440\n860992188\n278706169\n233649838\n2145127752\n468681487\n1101480741\n1801937354\n1315597752\n635697846\n1369096069\n1125864614\n1059928837\n2088972752\n628149949\n1656437344\n1131142598\n1653336713\n859455106\n1914501165\n608389119\n756871027\n1734533551\n1973549900\n149786077\n2038619220\n1129532805\n184789933\n412755776\n1424231242\n1911716234\n749214502\n137795124\n42992614\n982875646\n135485642\n511679686\n2084375271\n1937433069\n1827293581\n572636407\n1159092461\n805722462\n2626102878\n1100628138\n1433887991\n1141582338\n84344712\n939788927\n2001055813\n1998854106\n1548194021\n610490727\n1585950541\n1374306972\n760286178\n1477132655\n356407930\n945086535\n1889903706\n1780653591\n709366951\n491683230\n1918458852\n752365326\n1474574000\n2053954612\n1264059507\n1411512107\n1843950428\n943917017\n1984165469\n855606976\n1749656758\n1469309763\n1956253310",
"output": "1804204432\n846872684\n1681610763\n1714554101\n1957659303\n424197143\n719831727\n1649679260\n596467804\n1189572441\n1025138327\n1350416531\n783312715\n1102453653\n2044807324\n1967425215\n1365106646\n1540304933\n304054298\n1303383532\n34993380\n521549694\n294668236\n1726873318\n336429098\n860962846\n278689475\n233634553\n2145081437\n468659838\n1101447553\n1801894905\n1315561481\n635672633\n1369059068\n1125831061\n1059896281\n2088927047\n628124887\n1656396645\n1131108966\n1653296052\n859425790\n1914457410\n608364454\n756843516\n1734491904\n1973505476\n149773839\n2038574069\n1129499197\n184776340\n412735460\n1424193504\n1911672511\n749187131\n137783386\n42986058\n982844296\n135474003\n511657066\n2084329617\n1937389053\n1827250835\n572612478\n1159058416\n805694077\n2626051633\n1100594963\n1433850125\n1141548551\n84335529\n939758272\n2001011080\n1998809398\n1548154674\n610466019\n1585910718\n1374269901\n760258605\n1477094222\n356389052\n945055793\n1889860233\n1780611394\n709340318\n491661057\n1918415052\n752337897\n1474535600\n2053909292\n1264023954\n1411474537\n1843907487\n943886294\n1984120926\n855577726\n1749614930\n1469271432\n1956209081\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
building-network
|
Solve the following coding problem using the programming language python:
There are N routers. The cost of the wires required in connecting two routers, i and j, is R[i]+R[j] where R[i] is the number of slots in the i-th router and i!=j. You need to build a network, such that there is a path between every pair of routers. Find the minimum cost of building such a network.The connection between the routers is bidirectional.
Input:
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
First line contains an integer N denoting the number of routers.
Second line contains N space separated integers R[i], the number of slots in the i-th router.
Output:
For each test case, print a single integer, the minimum cost to build such network.
Constraints:
1 β€ T β€ 5
2 β€ N β€ 10^3
1 β€ R[i] β€ 10^9
SAMPLE INPUT
2
2
1 2
3
1 1 1
SAMPLE OUTPUT
3
4
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
t=input()
while t>0:
n=input()
arr=[]
arr=map(int,raw_input().split())
brr=sorted(arr)
l=len(brr)
su=0
for i in range(1,l):
a=brr[0]+brr[i]
su=su+a
print su
t=t-1
```
|
vfc_81525
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n1 2\n3\n1 1 1\n\nSAMPLE",
"output": "3\n4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n42\n18468 6335 26501 19170 15725 11479 29359 26963 24465 5706 28146 23282 16828 9962 492 2996 11943 4828 5437 32392 14605 3903 154 293 12383 17422 18717 19719 19896 5448 21727 14772 11539 1870 19913 25668 26300 17036 9895 28704 23812 31323 \n334\n17674 4665 15142 7712 28254 6869 25548 27645 32663 32758 20038 12860 8724 9742 27530 779 12317 3036 22191 1843 289 30107 9041 8943 19265 22649 27447 23806 15891 6730 24371 15351 15007 31102 24394 3549 19630 12624 24085 19955 18757 11841 4967 7377 13932 26309 16945 32440 24627 11324 5538 21539 16119 2083 22930 16542 4834 31116 4640 29659 22705 9931 13978 2307 31674 22387 5022 28746 26925 19073 6271 5830 26778 15574 5098 16513 23987 13291 9162 18637 22356 24768 23656 15575 4032 12053 27351 1151 16942 21725 13967 3431 31108 30192 18008 11338 15458 12288 27754 10384 14946 8910 32210 9759 24222 18589 6423 24947 27507 13031 16414 29169 901 32592 18763 1656 17411 6360 27625 20538 21549 6484 27596 4042 3603 24351 10292 30837 9375 11021 4597 24022 27349 23200 19669 24485 8282 4735 54 2000 26419 27939 6901 3789 18128 468 3729 14894 24649 22484 17808 2422 14311 6618 22814 9515 14310 7617 18936 17452 20601 5250 16520 31557 22799 30304 6225 11009 5845 32610 14990 32703 3196 20486 3094 14344 30524 1588 29315 9504 7449 25201 13459 6619 20581 19797 14799 15282 19590 20799 28010 27158 20473 23623 18539 12293 6039 24180 18191 29658 7959 6192 19816 22889 19157 11512 16203 2635 24273 20056 20329 22647 26363 4887 18876 28434 29870 20143 23845 1417 21882 31999 10323 18652 10022 5700 3558 28477 27893 24390 5076 10713 2601 2511 21004 26870 17862 14689 13402 9790 15256 16424 5003 10586 24183 10286 27089 31427 28618 23758 9833 30933 4170 2155 25722 17190 19977 31330 2369 28693 21426 10556 3435 16550 7442 9513 30146 18061 21719 3754 16140 12424 16280 25997 16688 12530 22550 17438 19867 12950 194 23196 3298 20417 28287 16106 24489 16283 12456 25735 18115 11702 31317 20672 5787 12264 4314 24356 31186 20054 913 10809 1833 20946 4314 27757 28322 19559 23647 27983 482 4145 23197 20223 7130 2162 5536 20451 11174 10467 12045 21660 26293 26440 17254 20025 26155 29511 4746 20650 13187 8314 4475 28023 \n1000\n2169 14019 18788 9906 17959 7392 10203 3626 26478 4415 9315 25825 29335 25875 24373 20160 11834 28071 7488 28298 7519 8178 17774 32271 1764 2669 17193 13986 3103 8481 29214 7628 4803 4100 30528 2626 1544 1925 11024 29973 13062 14182 31004 27433 17506 27594 22726 13032 8493 143 17223 31287 13065 7901 19188 8361 22414 30975 14271 29171 236 30834 19712 25761 18897 4668 7286 12551 141 13695 2696 21625 28020 2126 26577 21695 22659 26303 17372 22467 4679 22594 23852 25485 1019 28465 21120 23153 2801 18088 31061 1927 9011 4758 32171 20316 9577 30228 12044 22759 7165 5110 7883 17087 29566 3488 29578 14475 2626 25628 5630 31929 25424 28521 6903 14963 124 24597 3738 13262 10196 32526 1265 8261 6203 8117 5031 20327 29012 30772 6412 25548 21154 21521 29791 14925 30189 21764 4941 20852 18663 13830 30901 17714 18959 17579 8366 13008 11478 1201 26059 6440 2304 12761 19358 2325 6478 5109 21114 14888 19802 22851 14461 22429 12994 27385 19406 6541 31112 28705 12836 32357 6073 29351 18824 14486 20557 23217 1627 9358 8527 13358 29338 23272 23870 29362 12897 13023 29618 10113 12718 18697 11586 24042 24424 24130 24230 4566 6560 8933 22297 29856 12054 16963 3585 29735 6655 16973 21458 14370 22533 2964 2608 2484 912 11636 10068 22849 4676 12939 2224 22143 23755 6512 22742 20176 21460 17826 3222 17871 1627 31935 15206 31784 23851 17399 22280 22702 12194 12735 1638 26535 5557 1994 10177 25706 6963 10549 15882 301 14414 16642 19856 24856 13143 11463 27612 30878 20425 32679 1753 18444 28297 12674 10041 9314 876 20073 12819 611 1018 14933 28113 30696 13170 23832 20041 26489 28686 19091 19498 2590 25991 15146 19354 19315 18652 26741 22045 11259 336 8760 11193 7606 25265 12182 28504 3830 23776 20609 29293 5998 17550 29557 25562 31628 6468 29542 26130 31241 27814 29175 20602 6078 20216 8684 8214 23993 25825 5602 23393 15760 2671 26429 28028 4085 10076 18787 15499 24971 6288 23848 32605 504 21222 22664 5707 2364 9011 22172 27490 18241 12165 25543 7620 20914 7592 6705 31819 9233 751 25206 4976 1540 304 11423 21099 11248 13585 13649 2972 17865 22914 11076 21546 28713 17547 18679 1770 15263 8520 13986 28290 15945 2866 18541 23246 25509 28319 27871 9602 28324 21133 24473 27153 25088 28571 29764 29902 17104 14424 3528 11601 26970 14016 5566 29 21544 25348 2089 2944 12638 22410 26464 5050 4682 1589 11343 609 32061 21222 1759 29955 20889 14147 691 7950 12844 21431 25621 749 27068 4537 20784 18036 32227 15186 7039 9854 25630 11225 15749 19924 3360 32258 24767 4945 14956 23319 32727 25412 21026 20356 31002 22550 9497 18585 9516 17965 23343 8076 17914 16143 31197 21949 25073 20427 14607 26174 24430 32405 6706 20627 29813 19376 30094 16566 16037 14737 29142 30815 5995 8257 6653 23937 30839 20483 1356 21016 1132 18231 17842 14626 2012 32638 4187 19691 1651 5663 21635 10894 10354 21417 13453 14009 7263 22234 5455 16304 16635 26304 14257 149 11125 12318 4214 27110 24029 29201 21081 21319 16859 24051 24156 31362 15265 11904 3677 29644 26910 14903 3562 28490 24949 1283 13654 30675 2221 5403 6924 3832 19370 3879 20260 19009 22620 23972 30004 21946 9782 26505 12393 32686 25314 6699 5590 12723 5939 19038 6411 31462 6235 12509 9962 3960 6494 1516 25270 24938 28870 59 14701 13972 26265 15118 16216 24556 7816 18331 3040 30213 29289 28083 1955 16086 20711 24485 24775 8381 29816 25952 6542 18116 1680 17111 25899 23074 789 23978 18133 29957 28690 26114 10009 12942 15791 1724 21364 29 25185 24779 7201 5072 1886 21975 1072 11334 22868 26154 14296 32169 20826 9677 15630 28651 2599 3310 4694 4687 30081 10117 12250 26668 1529 26680 7865 29422 8406 8827 6817 7517 27727 28667 29088 27682 19965 1341 5687 6022 11663 14722 6065 29310 20416 17903 29874 17125 23942 32746 31763 28424 27532 4807 12269 9319 5603 31908 24308 23482 1013 21137 26631 24115 26810 4085 23557 12291 21294 29997 29153 1055 25346 14709 249 7492 13713 5132 30115 16440 7959 24723 29705 6996 1053 25270 7480 18239 26424 27919 10867 17660 32499 28487 21197 7463 26634 12159 12023 1147 18393 13038 3926 10648 29459 6603 30808 4099 27831 29293 14601 7279 20800 18353 20449 13883 541 28316 4576 8763 9568 22337 18398 31419 19898 25829 13852 26817 24231 4450 16926 659 230 24521 10941 29561 15148 25163 1656 20676 793 22362 31755 16399 23147 8715 26947 21189 19570 8639 27664 15076 24516 11522 476 15616 20529 13235 12571 906 9465 19558 28963 14162 30525 12550 17470 331 31924 28351 14334 22926 10911 19738 16337 18338 1279 12394 7637 30715 28165 31592 19950 19136 2506 13338 10005 16338 2624 28665 9971 25609 30569 19282 7086 9153 18374 28653 8195 9877 23827 28397 7573 6250 14641 29175 18820 944 32612 1942 20290 8420 5566 3806 7586 16217 31451 1616 2610 11065 9167 16894 16075 13510 30301 19696 9574 15590 13162 31173 17969 27359 26032 26269 19427 28511 10423 30775 8780 30911 23553 4183 25392 15496 5765 875 1365 14903 28256 4461 475 6973 26822 26123 25548 21578 9790 25606 30196 27595 7951 16344 755 2482 1013 11673 23440 13429 5913 9763 5968 24409 4416 1909 17224 11760 26435 5205 29487 4320 959 5946 26807 8167 18701 11368 17693 21788 28533 30557 30975 3448 5022 18284 26223 29332 2377 28584 26949 12724 17983 22019 14777 9221 31112 32183 23857 19491 8926 4325 6487 19678 15970 11644 7535 15678 22669 31069 21992 32197 7784 16829 7728 29427 15872 10698 17613 18704 11028 11409 5546 9509 7186 30239 24238 26444 21314 22502 8851 25129 2112 23651 28150 11193 1455 15870 682 27466 20268 17714 19794 18635 25473 20973 22831 24902 28443 5178 13878 25771 703 14365 1382 16591 8824 2238 8024 32180 16596 20170 2328 12043 31311 28183 11059 7927 9488 1671 32529 5652 2259 7214 9861 25784 21287 2743 8611 4473 7129 18435 5842 20719 3504 14868 24866 10939 1882 9258 22751 28615 18599 \n1000\n28459 2662 26064 32757 20808 20279 19490 19436 6366 32076 7587 1387 7834 8361 13331 26049 8929 29493 12434 23841 6767 1736 19811 11600 11838 21893 31983 7329 29353 11370 31245 21795 6609 9253 11648 17433 9536 7209 3265 3498 23244 27650 22016 26842 190 16101 19813 30649 9524 19852 24475 28634 29892 27201 19855 9991 25698 4920 17781 22579 12932 32545 3341 13488 900 22526 8484 5539 7493 6194 28253 25012 1561 15835 1841 31498 2786 18530 31541 18806 28792 13393 13211 13550 21579 26980 30972 9278 74 20194 1621 21498 13827 31277 19791 6583 13579 11160 20419 26490 160 3450 12925 9073 10381 27009 27968 10209 6478 18504 15371 32608 14197 12075 13723 12612 19020 28762 11057 12891 31164 16684 13717 19933 25453 2742 4955 6814 2863 10397 15461 20616 10905 2600 20137 4681 9199 27033 14388 32585 7241 3518 17007 8671 242 18883 25250 3524 31759 12106 29622 17096 7297 9917 15679 10179 13580 25059 27578 12751 14008 23730 24082 2996 2679 24677 27754 20900 11785 15566 3094 13609 6173 11244 29930 7515 10169 5056 11192 5974 8923 6749 5652 10987 2145 16447 31578 26518 14630 29917 5875 15792 15470 22913 8147 30694 9092 9816 26950 26858 20641 26053 237 8552 9488 31227 28163 16956 23184 8395 30181 16098 3066 27066 2514 9262 12579 21079 16879 14141 4612 31948 2446 171 29976 13490 24751 6150 3334 13866 22215 17283 27008 27433 8897 16368 28523 4883 31811 17642 7232 2188 6706 6480 6322 6539 31352 19448 24209 9647 22277 25760 30190 30423 27667 8487 3456 2029 29615 4861 29254 11778 31349 12504 10862 22432 29083 12456 14198 22107 8753 15822 17297 26282 26022 24456 15948 27125 18319 9136 11377 1775 29860 24999 12075 9254 6923 10636 1644 28889 8154 13233 4748 28681 19927 25679 6451 14802 24962 14200 20856 26364 5717 10574 31562 23246 6474 28275 1551 24354 1182 4288 2700 18111 18644 17466 7173 2530 9982 2113 13477 4382 8248 26891 16672 8806 32373 30033 3990 9321 23166 15432 9659 11294 17207 26579 16949 2207 27172 18167 3397 16698 31021 23695 15530 14789 30110 17985 11970 28979 21618 4016 16627 3685 9169 17907 25929 12098 28119 24391 15200 11786 14487 19200 12421 20711 18272 15814 27416 6086 319 3581 1332 7268 8388 13445 23187 14508 4361 17828 28075 26432 7153 30272 10269 4694 19886 338 31312 17605 12678 407 7769 29023 19414 5001 543 17538 30039 21389 7356 13290 31648 3182 13094 16585 10988 10762 20494 8218 9502 17483 29448 15666 10754 22105 15085 19096 13526 30222 3965 21782 4873 8107 3657 3344 22594 27081 16081 14869 21412 13714 20969 3252 27217 12080 28769 17041 31532 12934 23780 20664 12260 26654 27937 2096 24366 11875 7721 26836 25681 8977 18456 5726 4072 24809 13560 9157 5603 17833 7906 10441 7376 21563 22886 21963 21081 1837 10798 31203 10509 10081 5341 12077 9059 31494 7741 8547 20475 24774 19098 8881 23336 11073 23401 708 22956 20667 4142 23589 12482 17169 28316 19397 16226 1010 22013 18137 11456 18763 25044 743 22 17923 24513 9249 26019 27369 23718 9715 17651 13291 3336 12760 3170 21896 5304 22641 21980 24200 29106 24792 18662 8682 3653 8754 24034 32030 15988 7043 26254 20084 11421 15815 32719 12245 31064 7230 20653 18865 4770 30471 15006 21048 1595 21488 24327 3277 21324 6541 7680 23991 32589 24711 29272 17946 29222 28471 20184 23590 23956 4979 24780 5007 13263 20136 23488 27197 29034 2089 12936 19780 15994 14791 24963 18966 11002 19106 11808 24568 2670 3135 32672 1458 12999 3546 13598 14219 8839 14845 7373 8564 21029 29265 28802 14724 13491 7605 31602 24228 11198 23693 19772 20364 29302 22364 7722 3566 17422 23446 18611 496 16742 15023 31813 29152 23016 8056 3394 8739 15280 19883 1609 12655 3823 32708 24246 1339 145 22291 31340 23155 24605 4624 22226 20079 21725 31982 2331 29734 28224 20595 29131 18847 4988 29446 18806 8617 5751 20490 27339 21964 28136 14698 32210 21631 23225 1909 26738 24475 31921 27373 10294 3856 6735 9562 31057 27607 8185 7076 28383 14120 6742 30433 24685 12780 12280 18284 20668 30837 24126 24119 12738 18029 32120 20578 10738 14092 20557 22796 16061 21902 8794 3433 2137 4581 14876 5908 21185 28075 8720 26791 20477 30042 3352 8330 16291 22975 23073 3592 12190 15788 31491 3240 14894 3054 17064 10682 25904 27006 24177 18480 1696 6140 32469 13999 21084 23640 29516 27622 29994 15827 15723 23839 24829 12582 24400 8979 11892 1024 26944 24835 14244 7350 2703 8708 20503 25142 10688 8347 15892 24638 18414 11401 22817 31691 13163 8936 29127 19411 19878 11383 26261 27190 26706 13875 2664 20723 32196 22567 16361 6039 18589 7812 28246 9468 32426 26868 13190 10543 13064 21548 30503 29618 9100 25024 17227 31204 30049 21052 1571 8637 9459 25968 8457 9406 11532 29963 26820 7976 10557 7532 31496 8045 30592 26804 3389 18916 7451 12320 6273 25792 29384 10134 1776 24643 23570 18301 17955 12079 3586 2258 25334 894 10491 10104 4751 17234 10723 24272 19612 18991 30339 21642 23259 19048 2353 9659 480 25303 32684 18991 10003 15569 4423 16896 6136 18009 12362 16743 22195 23700 23189 20179 4043 31358 23942 1848 7470 16346 4381 31914 14965 25711 20062 25386 20074 27505 9463 32704 28103 11070 5155 3530 31553 32075 19150 3731 2245 10845 13050 14119 24066 26364 19553 28774 18471 29732 6748 7512 5870 14399 10499 7104 27353 25680 28054 13044 14523 31089 1564 25835 9851 17023 7241 21912 9493 5652 28581 15478 27617 29877 19179 5221 14616 22349 26799 32180 31636 16858 2884 1663 18903 28263 19421 19771 19023 9274 25842 12687 28889 3918 31718 1893 13699 11268 11750 66 10390 6933 25620 16082 2004 29131 13029 18632 14590 23153 18631 19173 19865 6408 12296 25429 29682 18491 26611 26178 31072 25237 6460 20644 16841 27634 27038 23894 22631 20275 12994 28783 32204 17462 8291 19663 22308 20998 31152 18424 8891 16718 6641 28704 5567 4884 23662 22660 18246 20387 32652 32766 19602 16841 17210 1498 27284 29251 18059 8422 176 30582 \n1000\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000",
"output": "671736\n5531463\n16395400\n16648413\n1998000000000",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n42\n18468 6335 26501 19170 15725 11479 29359 26963 24465 5706 28146 23282 16828 9962 492 2996 11943 4828 5437 32392 14605 3903 154 293 12383 17422 18717 19719 19896 5448 21727 14772 11539 1870 19913 25668 26300 17036 9895 28704 23812 31323 \n334\n17674 4665 15142 7712 28254 6869 25548 27645 32663 32758 20038 12860 8724 9742 27530 779 12317 3036 22191 1843 289 30107 9041 8943 19265 22649 27447 23806 15891 6730 24371 15351 15007 31102 24394 3549 19630 12624 24085 19955 18757 11841 4967 7377 13932 26309 16945 32440 24627 11324 5538 21539 16119 2083 22930 16542 4834 31116 4640 29659 22705 9931 13978 2307 31674 22387 5022 28746 26925 19073 6271 5830 26778 15574 5098 16513 23987 13291 9162 18637 22356 24768 23656 15575 4032 12053 27351 1151 16942 21725 13967 3431 31108 30192 18008 11338 15458 12288 27754 10384 14946 8910 32210 9759 24222 18589 6423 24947 27507 13031 16414 29169 901 32592 18763 1656 17411 6360 27625 20538 21549 6484 27596 4042 3603 24351 10292 30837 9375 11021 4597 24022 27349 23200 19669 24485 8282 4735 54 2000 26419 27939 6901 3789 18128 468 3729 14894 24649 22484 17808 2422 14311 6618 22814 9515 14310 7617 18936 17452 20601 5250 16520 31557 22799 30304 6225 11009 5845 32610 14990 32703 3196 20486 3094 14344 30524 1588 29315 9504 7449 25201 13459 6619 20581 19797 14799 15282 19590 20799 28010 27158 20473 23623 18539 12293 6039 24180 18191 29658 7959 6192 19816 22889 19157 11512 16203 2635 24273 20056 20329 22647 26363 4887 18876 28434 29870 20143 23845 1417 21882 31999 10323 18652 10022 5700 3558 28477 27893 24390 5076 10713 2601 2511 21004 26870 17862 14689 13402 9790 15256 16424 5003 10586 24183 10286 27089 31427 28618 23758 9833 30933 4170 2155 25722 17190 19977 31330 2369 28693 21426 10556 3435 16550 7442 9513 30146 18061 21719 3754 16140 12424 16280 25997 16688 12530 22550 17438 19867 12950 194 23196 3298 20417 28287 16106 24489 16283 12456 25735 18115 11702 31317 20672 5787 12264 4314 24356 31186 20054 913 10809 1833 20946 4314 27757 28322 19559 23647 27983 482 4145 23197 20223 7130 2162 5536 20451 11174 10467 12045 21660 26293 26440 17254 20025 26155 29511 4746 20650 13187 8314 4475 28023 \n1000\n2169 14019 18788 9906 17959 7392 10203 3626 26478 4415 9315 25825 29335 25875 24373 20160 11834 28071 7488 28298 7519 8178 17774 32271 1764 2669 17193 13986 3103 8481 29214 7628 4803 4100 30528 2626 1544 1925 11024 29973 13062 14182 31004 27433 17506 27594 22726 13032 8493 143 17223 31287 13065 7901 19188 8361 22414 30975 14271 29171 236 30834 19712 25761 18897 4668 7286 12551 141 13695 2696 21625 28020 2126 26577 21695 22659 26303 17372 22467 4679 22594 23852 25485 1019 28465 21120 23153 2801 18088 31061 1927 9011 4758 32171 20316 9577 30228 12044 22759 7165 5110 7883 17087 29566 3488 29578 14475 2626 25628 5630 31929 25424 28521 6903 14963 124 24597 3738 13262 10196 32526 1265 8261 6203 8117 5031 20327 29012 30772 6412 25548 21154 21521 29791 14925 30189 21764 4941 20852 18663 13830 30901 17714 18959 17579 8366 13008 11478 1201 26059 6440 2304 12761 19358 2325 6478 5109 21114 14888 19802 22851 14461 22429 12994 27385 19406 6541 31112 28705 12836 32357 6073 29351 18824 14486 20557 23217 1627 9358 8527 13358 29338 23272 23870 29362 12897 13023 29618 10113 12718 18697 11586 24042 24424 24130 24230 4566 6560 8933 22297 29856 12054 16963 3585 29735 6655 16973 21458 14370 22533 2964 2608 2484 912 11636 10068 22849 4676 12939 2224 22143 23755 6512 22742 20176 21460 17826 3222 17871 1627 31935 15206 31784 23851 17399 22280 22702 12194 12735 1638 26535 5557 1994 10177 25706 6963 10549 15882 301 14414 16642 19856 24856 13143 11463 27612 30878 20425 32679 1753 18444 28297 12674 10041 9314 876 20073 12819 611 1018 14933 28113 30696 13170 23832 20041 26489 28686 19091 19498 2590 25991 15146 19354 19315 18652 26741 22045 11259 336 8760 11193 7606 25265 12182 28504 3830 23776 20609 29293 5998 17550 29557 25562 31628 6468 29542 26130 31241 27814 29175 20602 6078 20216 8684 8214 23993 25825 5602 23393 15760 2671 26429 28028 4085 10076 18787 15499 24971 6288 23848 32605 504 21222 22664 5707 2364 9011 22172 27490 18241 12165 25543 7620 20914 7592 6705 31819 9233 751 25206 4976 1540 304 11423 21099 11248 13585 13649 2972 17865 22914 11076 21546 28713 17547 18679 1770 15263 8520 13986 28290 15945 2866 18541 23246 25509 28319 27871 9602 28324 21133 24473 27153 25088 28571 29764 29902 17104 14424 3528 11601 26970 14016 5566 29 21544 25348 2089 2944 12638 22410 26464 5050 4682 1589 11343 609 32061 21222 1759 29955 20889 14147 691 7950 17350 21431 25621 749 27068 4537 20784 18036 32227 15186 7039 9854 25630 11225 15749 19924 3360 32258 24767 4945 14956 23319 32727 25412 21026 20356 31002 22550 9497 18585 9516 17965 23343 8076 17914 16143 31197 21949 25073 20427 14607 26174 24430 32405 6706 20627 29813 19376 30094 16566 16037 14737 29142 30815 5995 8257 6653 23937 30839 20483 1356 21016 1132 18231 17842 14626 2012 32638 4187 19691 1651 5663 21635 10894 10354 21417 13453 14009 7263 22234 5455 16304 16635 26304 14257 149 11125 12318 4214 27110 24029 29201 21081 21319 16859 24051 24156 31362 15265 11904 3677 29644 26910 14903 3562 28490 24949 1283 13654 30675 2221 5403 6924 3832 19370 3879 20260 19009 22620 23972 30004 21946 9782 26505 12393 32686 25314 6699 5590 12723 5939 19038 6411 31462 6235 12509 9962 3960 6494 1516 25270 24938 28870 59 14701 13972 26265 15118 16216 24556 7816 18331 3040 30213 29289 28083 1955 16086 20711 24485 24775 8381 29816 25952 6542 18116 1680 17111 25899 23074 789 23978 18133 29957 28690 26114 10009 12942 15791 1724 21364 29 25185 24779 7201 5072 1886 21975 1072 11334 22868 26154 14296 32169 20826 9677 15630 28651 2599 3310 4694 4687 30081 10117 12250 26668 1529 26680 7865 29422 8406 8827 6817 7517 27727 28667 29088 27682 19965 1341 5687 6022 11663 14722 6065 29310 20416 17903 29874 17125 23942 32746 31763 28424 27532 4807 12269 9319 5603 31908 24308 23482 1013 21137 26631 24115 26810 4085 23557 12291 21294 29997 29153 1055 25346 14709 249 7492 13713 5132 30115 16440 7959 24723 29705 6996 1053 25270 7480 18239 26424 27919 10867 17660 32499 28487 21197 7463 26634 12159 12023 1147 18393 13038 3926 10648 29459 6603 30808 4099 27831 29293 14601 7279 20800 18353 20449 13883 541 28316 4576 8763 9568 22337 18398 31419 19898 25829 13852 26817 24231 4450 16926 659 230 24521 10941 29561 15148 25163 1656 20676 793 22362 31755 16399 23147 8715 26947 21189 19570 8639 27664 15076 24516 11522 476 15616 20529 13235 12571 906 9465 19558 28963 14162 30525 12550 17470 331 31924 28351 14334 22926 10911 19738 16337 18338 1279 12394 7637 30715 28165 31592 19950 19136 2506 13338 10005 16338 2624 28665 9971 25609 30569 19282 7086 9153 18374 28653 8195 9877 23827 28397 7573 6250 14641 29175 18820 944 32612 1942 20290 8420 5566 3806 7586 16217 31451 1616 2610 11065 9167 16894 16075 13510 30301 19696 9574 15590 13162 31173 17969 27359 26032 26269 19427 28511 10423 30775 8780 30911 23553 4183 25392 15496 5765 875 1365 14903 28256 4461 475 6973 26822 26123 25548 21578 9790 25606 30196 27595 7951 16344 755 2482 1013 11673 23440 13429 5913 9763 5968 24409 4416 1909 17224 11760 26435 5205 29487 4320 959 5946 26807 8167 18701 11368 17693 21788 28533 30557 30975 3448 5022 18284 26223 29332 2377 28584 26949 12724 17983 22019 14777 9221 31112 32183 23857 19491 8926 4325 6487 19678 15970 11644 7535 15678 22669 31069 21992 32197 7784 16829 7728 29427 15872 10698 17613 18704 11028 11409 5546 9509 7186 30239 24238 26444 21314 22502 8851 25129 2112 23651 28150 11193 1455 15870 682 27466 20268 17714 19794 18635 25473 20973 22831 24902 28443 5178 13878 25771 703 14365 1382 16591 8824 2238 8024 32180 16596 20170 2328 12043 31311 28183 11059 7927 9488 1671 32529 5652 2259 7214 9861 25784 21287 2743 8611 4473 7129 18435 5842 20719 3504 14868 24866 10939 1882 9258 22751 28615 18599 \n1000\n28459 2662 26064 32757 20808 20279 19490 19436 6366 32076 7587 1387 7834 8361 13331 26049 8929 29493 12434 23841 6767 1736 19811 11600 11838 21893 31983 7329 29353 11370 31245 21795 6609 9253 11648 17433 9536 7209 3265 3498 23244 27650 22016 26842 190 16101 19813 30649 9524 19852 24475 28634 29892 27201 19855 9991 25698 4920 17781 22579 12932 32545 3341 13488 900 22526 8484 5539 7493 6194 28253 25012 1561 15835 1841 31498 2786 18530 31541 18806 28792 13393 13211 13550 21579 26980 30972 9278 74 20194 1621 21498 13827 31277 19791 6583 13579 11160 20419 26490 160 3450 12925 9073 10381 27009 27968 10209 6478 18504 15371 32608 14197 12075 13723 12612 19020 28762 11057 12891 31164 16684 13717 19933 25453 2742 4955 6814 2863 10397 15461 20616 10905 2600 20137 4681 9199 27033 14388 32585 7241 3518 17007 8671 242 18883 25250 3524 31759 12106 29622 17096 7297 9917 15679 10179 13580 25059 27578 12751 14008 23730 24082 2996 2679 24677 27754 20900 11785 15566 3094 13609 6173 11244 29930 7515 10169 5056 11192 5974 8923 6749 5652 10987 2145 16447 31578 26518 14630 29917 5875 15792 15470 22913 8147 30694 9092 9816 26950 26858 20641 26053 237 8552 9488 31227 28163 16956 23184 8395 30181 16098 3066 27066 2514 9262 12579 21079 16879 14141 4612 31948 2446 171 29976 13490 24751 6150 3334 13866 22215 17283 27008 27433 8897 16368 28523 4883 31811 17642 7232 2188 6706 6480 6322 6539 31352 19448 24209 9647 22277 25760 30190 30423 27667 8487 3456 2029 29615 4861 29254 11778 31349 12504 10862 22432 29083 12456 14198 22107 8753 15822 17297 26282 26022 24456 15948 27125 18319 9136 11377 1775 29860 24999 12075 9254 6923 10636 1644 28889 8154 13233 4748 28681 19927 25679 6451 14802 24962 14200 20856 26364 5717 10574 31562 23246 6474 28275 1551 24354 1182 4288 2700 18111 18644 17466 7173 2530 9982 2113 13477 4382 8248 26891 16672 8806 32373 30033 3990 9321 23166 15432 9659 11294 17207 26579 16949 2207 27172 18167 3397 16698 31021 23695 15530 14789 30110 17985 11970 28979 21618 4016 16627 3685 9169 17907 25929 12098 28119 24391 15200 11786 14487 19200 12421 20711 18272 15814 27416 6086 319 3581 1332 7268 8388 13445 23187 14508 4361 17828 28075 26432 7153 30272 10269 4694 19886 338 31312 17605 12678 407 7769 29023 19414 5001 543 17538 30039 21389 7356 13290 31648 3182 13094 16585 10988 10762 20494 8218 9502 17483 29448 15666 10754 22105 15085 19096 13526 30222 3965 21782 4873 8107 3657 3344 22594 27081 16081 14869 21412 13714 20969 3252 27217 12080 28769 17041 31532 12934 23780 20664 12260 26654 27937 2096 24366 11875 7721 26836 25681 8977 18456 5726 4072 24809 13560 9157 5603 17833 7906 10441 7376 21563 22886 21963 21081 1837 10798 31203 10509 10081 5341 12077 9059 31494 7741 8547 20475 24774 19098 8881 23336 11073 23401 708 22956 20667 4142 23589 12482 17169 28316 19397 16226 1010 22013 18137 11456 18763 25044 743 22 17923 24513 9249 26019 27369 23718 9715 17651 13291 3336 12760 3170 21896 5304 22641 21980 24200 29106 24792 18662 8682 3653 8754 24034 32030 15988 7043 26254 20084 11421 15815 32719 12245 31064 7230 20653 18865 4770 30471 15006 21048 1595 21488 24327 3277 21324 6541 7680 23991 32589 24711 29272 17946 29222 28471 20184 23590 23956 4979 24780 5007 13263 20136 23488 27197 29034 2089 12936 19780 15994 14791 24963 18966 11002 19106 11808 24568 2670 3135 32672 1458 12999 3546 13598 14219 8839 14845 7373 8564 21029 29265 28802 14724 13491 7605 31602 24228 11198 23693 19772 20364 29302 22364 7722 3566 17422 23446 18611 496 16742 15023 31813 29152 23016 8056 3394 8739 15280 19883 1609 12655 3823 32708 24246 1339 145 22291 31340 23155 24605 4624 22226 20079 21725 31982 2331 29734 28224 20595 29131 18847 4988 29446 18806 8617 5751 20490 27339 21964 28136 14698 32210 21631 23225 1909 26738 24475 31921 27373 10294 3856 6735 9562 31057 27607 8185 7076 28383 14120 6742 30433 24685 12780 12280 18284 20668 30837 24126 24119 12738 18029 32120 20578 10738 14092 20557 22796 16061 21902 8794 3433 2137 4581 14876 5908 21185 28075 8720 26791 20477 30042 3352 8330 16291 22975 23073 3592 12190 15788 31491 3240 14894 3054 17064 10682 25904 27006 24177 18480 1696 6140 32469 13999 21084 23640 29516 27622 29994 15827 15723 23839 24829 12582 24400 8979 11892 1024 26944 24835 14244 7350 2703 8708 20503 25142 10688 8347 15892 24638 18414 11401 22817 31691 13163 8936 29127 19411 19878 11383 26261 27190 26706 13875 2664 20723 32196 22567 16361 6039 18589 7812 28246 9468 32426 26868 13190 10543 13064 21548 30503 29618 9100 25024 17227 31204 30049 21052 1571 8637 9459 25968 8457 9406 11532 29963 26820 7976 10557 7532 31496 8045 30592 26804 3389 18916 7451 12320 6273 25792 29384 10134 1776 24643 23570 18301 17955 12079 3586 2258 25334 894 10491 10104 4751 17234 10723 24272 19612 18991 30339 21642 23259 19048 2353 9659 480 25303 32684 18991 10003 15569 4423 16896 6136 18009 12362 16743 22195 23700 23189 20179 4043 31358 23942 1848 7470 16346 4381 31914 14965 25711 20062 25386 20074 27505 9463 32704 28103 11070 5155 3530 31553 32075 19150 3731 2245 10845 13050 14119 24066 26364 19553 28774 18471 29732 6748 7512 5870 14399 10499 7104 27353 25680 28054 13044 14523 31089 1564 25835 9851 17023 7241 21912 9493 5652 28581 15478 27617 29877 19179 5221 14616 22349 26799 32180 31636 16858 2884 1663 18903 28263 19421 19771 19023 9274 25842 12687 28889 3918 31718 1893 13699 11268 11750 66 10390 6933 25620 16082 2004 29131 13029 18632 14590 23153 18631 19173 19865 6408 12296 25429 29682 18491 26611 26178 31072 25237 6460 20644 16841 27634 27038 23894 22631 20275 12994 28783 32204 17462 8291 19663 22308 20998 31152 18424 8891 16718 6641 28704 5567 4884 23662 22660 18246 20387 32652 32766 19602 16841 17210 1498 27284 29251 18059 8422 176 30582 \n1000\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000",
"output": "671736\n5531463\n16399906\n16648413\n1998000000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n2\n1 2\n3\n2 1 1\n\nSAMPLE",
"output": "3\n5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n42\n18468 6335 26501 19170 15725 11479 29359 26963 24465 5706 28146 23282 16828 9962 492 2996 11943 4828 5437 32392 14605 3903 154 293 12383 17422 18717 19719 19896 5448 21727 14772 11539 1870 19913 25668 26300 17036 9895 28704 23812 31323 \n334\n17674 4665 15142 7712 28254 6869 25548 27645 32663 32758 20038 12860 8724 9742 27530 779 12317 3036 22191 1843 289 30107 9041 8943 19265 22649 27447 23806 15891 6730 24371 15351 15007 31102 24394 3549 19630 12624 24085 19955 18757 11841 4967 7377 13932 26309 16945 32440 24627 11324 5538 21539 16119 2083 22930 16542 4834 31116 4640 29659 22705 9931 13978 2307 31674 22387 5022 28746 26925 19073 6271 5830 26778 15574 5098 16513 23987 13291 9162 18637 22356 24768 23656 15575 4032 12053 27351 1151 16942 21725 13967 3431 31108 30192 18008 11338 15458 12288 27754 10384 14946 8910 32210 9759 24222 18589 6423 24947 27507 13031 16414 29169 901 32592 18763 1656 17411 6360 27625 20538 21549 6484 27596 4042 3603 24351 10292 30837 9375 11021 4597 24022 27349 23200 19669 24485 8282 4735 54 2000 26419 27939 6901 3789 18128 468 3729 14894 24649 22484 17808 2422 14311 6618 22814 9515 14310 7617 18936 17452 20601 5250 16520 31557 22799 30304 6225 11009 5845 32610 14990 32703 3196 20486 3094 14344 30524 1588 29315 9504 7449 25201 13459 6619 20581 19797 14799 15282 19590 20799 28010 27158 20473 23623 18539 12293 6039 24180 18191 29658 7959 6192 19816 22889 19157 11512 16203 2635 24273 20056 20329 22647 26363 4887 18876 28434 29870 20143 23845 1417 21882 31999 10323 18652 10022 5700 3558 28477 27893 24390 5076 10713 2601 2511 21004 26870 17862 14689 13402 9790 15256 16424 5003 10586 24183 10286 27089 31427 28618 19215 9833 30933 4170 2155 25722 17190 19977 31330 2369 28693 21426 10556 3435 16550 7442 9513 30146 18061 21719 3754 16140 12424 16280 25997 16688 12530 22550 17438 19867 12950 194 23196 3298 20417 28287 16106 24489 16283 12456 25735 18115 11702 31317 20672 5787 12264 4314 24356 31186 20054 913 10809 1833 20946 4314 27757 28322 19559 23647 27983 482 4145 23197 20223 7130 2162 5536 20451 11174 10467 12045 21660 26293 26440 17254 20025 26155 29511 4746 20650 13187 8314 4475 28023 \n1000\n2169 14019 18788 9906 17959 7392 10203 3626 26478 4415 9315 25825 29335 25875 24373 20160 11834 28071 7488 28298 7519 8178 17774 32271 1764 2669 17193 13986 3103 8481 29214 7628 4803 4100 30528 2626 1544 1925 11024 29973 13062 14182 31004 27433 17506 27594 22726 13032 8493 143 17223 31287 13065 7901 19188 8361 22414 30975 14271 29171 236 30834 19712 25761 18897 4668 7286 12551 141 13695 2696 21625 28020 2126 26577 21695 22659 26303 17372 22467 4679 22594 23852 25485 1019 28465 21120 23153 2801 18088 31061 1927 9011 4758 32171 20316 9577 30228 12044 22759 7165 5110 7883 17087 29566 3488 29578 14475 2626 25628 5630 31929 25424 28521 6903 14963 124 24597 3738 13262 10196 32526 1265 8261 6203 8117 5031 20327 29012 30772 6412 25548 21154 21521 29791 14925 30189 21764 4941 20852 18663 13830 30901 17714 18959 17579 8366 13008 11478 1201 26059 6440 2304 12761 19358 2325 6478 5109 21114 14888 19802 22851 14461 22429 12994 27385 19406 6541 31112 28705 12836 32357 6073 29351 18824 14486 20557 23217 1627 9358 8527 13358 29338 23272 23870 29362 12897 13023 29618 10113 12718 18697 11586 24042 24424 24130 24230 4566 6560 8933 22297 29856 12054 16963 3585 29735 6655 16973 21458 14370 22533 2964 2608 2484 912 11636 10068 22849 4676 12939 2224 22143 23755 6512 22742 20176 21460 17826 3222 17871 1627 31935 15206 31784 23851 17399 22280 22702 12194 12735 1638 26535 5557 1994 10177 25706 6963 10549 15882 301 14414 16642 19856 24856 13143 11463 27612 30878 20425 32679 1753 18444 28297 12674 10041 9314 876 20073 12819 611 1018 14933 28113 30696 13170 23832 20041 26489 28686 19091 19498 2590 25991 15146 19354 19315 18652 26741 22045 11259 336 8760 11193 7606 25265 12182 28504 3830 23776 20609 29293 5998 17550 29557 25562 31628 6468 29542 26130 31241 27814 29175 20602 6078 20216 8684 8214 23993 25825 5602 23393 15760 2671 26429 28028 4085 10076 18787 15499 24971 6288 23848 32605 504 21222 22664 5707 2364 9011 22172 27490 18241 12165 25543 7620 20914 7592 6705 31819 9233 751 25206 4976 1540 304 11423 21099 11248 13585 13649 2972 17865 22914 11076 21546 28713 17547 18679 1770 15263 8520 13986 28290 15945 2866 18541 23246 25509 28319 27871 9602 28324 21133 24473 27153 25088 28571 29764 29902 17104 14424 3528 11601 26970 14016 5566 29 21544 25348 2089 2944 12638 22410 26464 5050 4682 1589 11343 609 32061 21222 1759 29955 20889 14147 691 7950 17350 21431 25621 749 27068 4537 20784 18036 32227 15186 7039 9854 25630 11225 15749 19924 3360 32258 24767 4945 14956 23319 32727 25412 21026 20356 31002 22550 9497 18585 9516 17965 23343 8076 17914 16143 31197 21949 25073 20427 14607 26174 24430 32405 6706 20627 29813 19376 30094 16566 16037 14737 29142 30815 5995 8257 6653 23937 30839 20483 1356 21016 1132 18231 17842 14626 2012 32638 4187 19691 1651 5663 21635 10894 10354 21417 13453 14009 7263 22234 5455 16304 16635 26304 14257 149 11125 12318 4214 27110 24029 29201 21081 21319 16859 24051 24156 31362 15265 11904 3677 29644 26910 14903 3562 28490 24949 1283 13654 30675 2221 5403 6924 3832 19370 3879 20260 19009 22620 23972 30004 21946 9782 26505 12393 32686 25314 6699 5590 12723 5939 19038 6411 31462 6235 12509 9962 3960 6494 1516 25270 24938 28870 59 14701 13972 26265 15118 16216 24556 7816 18331 3040 30213 29289 28083 1955 16086 20711 24485 24775 8381 29816 25952 6542 18116 1680 17111 25899 23074 789 23978 18133 29957 28690 26114 10009 12942 15791 1724 21364 29 25185 24779 7201 5072 1886 21975 1072 11334 22868 26154 14296 32169 20826 9677 15630 28651 2599 3310 4694 4687 30081 10117 12250 26668 1529 26680 7865 29422 8406 8827 6817 7517 27727 28667 29088 27682 19965 1341 5687 6022 11663 14722 6065 29310 20416 17903 29874 17125 23942 32746 31763 28424 27532 4807 12269 9319 5603 31908 24308 23482 1013 21137 26631 24115 26810 4085 23557 12291 21294 29997 29153 1055 25346 14709 249 7492 13713 5132 30115 16440 7959 24723 29705 6996 1053 25270 7480 18239 26424 27919 10867 17660 32499 28487 21197 7463 26634 12159 12023 1147 18393 13038 3926 10648 29459 6603 30808 4099 27831 29293 14601 7279 20800 18353 20449 13883 541 28316 4576 8763 9568 22337 18398 31419 19898 25829 13852 26817 24231 4450 16926 659 230 24521 10941 29561 15148 25163 1656 20676 793 22362 31755 16399 23147 8715 26947 21189 19570 8639 27664 15076 24516 11522 476 15616 20529 13235 12571 906 9465 19558 28963 14162 30525 12550 17470 331 31924 28351 14334 22926 10911 19738 16337 18338 1279 12394 7637 30715 28165 31592 19950 19136 2506 13338 10005 16338 2624 28665 9971 25609 30569 19282 7086 9153 18374 28653 8195 9877 23827 28397 7573 6250 14641 29175 18820 944 32612 1942 20290 8420 5566 3806 7586 16217 31451 1616 2610 11065 9167 16894 16075 13510 30301 19696 9574 15590 13162 31173 17969 27359 26032 26269 19427 28511 10423 30775 8780 30911 23553 4183 25392 15496 5765 875 1365 14903 28256 4461 475 6973 26822 26123 25548 21578 9790 25606 30196 27595 7951 16344 755 2482 1013 11673 23440 13429 5913 9763 5968 24409 4416 1909 17224 11760 26435 5205 29487 4320 959 5946 26807 8167 18701 11368 17693 21788 28533 30557 30975 3448 5022 18284 26223 29332 2377 28584 26949 12724 17983 22019 14777 9221 31112 32183 23857 19491 8926 4325 6487 19678 15970 11644 7535 15678 22669 31069 21992 32197 7784 16829 7728 29427 15872 10698 17613 18704 11028 11409 5546 9509 7186 30239 24238 26444 21314 22502 8851 25129 2112 23651 28150 11193 1455 15870 682 27466 20268 17714 19794 18635 25473 20973 22831 24902 28443 5178 13878 25771 703 14365 1382 16591 8824 2238 8024 32180 16596 20170 2328 12043 31311 28183 11059 7927 9488 1671 32529 5652 2259 7214 9861 25784 21287 2743 8611 4473 7129 18435 5842 20719 3504 14868 24866 10939 1882 9258 22751 28615 18599 \n1000\n28459 2662 26064 32757 20808 20279 19490 19436 6366 32076 7587 1387 7834 8361 13331 26049 8929 29493 12434 23841 6767 1736 19811 11600 11838 21893 31983 7329 29353 11370 31245 21795 6609 9253 11648 17433 9536 7209 3265 3498 23244 27650 22016 26842 190 16101 19813 30649 9524 19852 24475 28634 29892 27201 19855 9991 25698 4920 17781 22579 12932 32545 3341 13488 900 22526 8484 5539 7493 6194 28253 25012 1561 15835 1841 31498 2786 18530 31541 18806 28792 13393 13211 13550 21579 26980 30972 9278 74 20194 1621 21498 13827 31277 19791 6583 13579 11160 20419 26490 160 3450 12925 9073 10381 27009 27968 10209 6478 18504 15371 32608 14197 12075 13723 12612 19020 28762 11057 12891 31164 16684 13717 19933 25453 2742 4955 6814 2863 10397 15461 20616 10905 2600 20137 4681 9199 27033 14388 32585 7241 3518 17007 8671 242 18883 25250 3524 31759 12106 29622 17096 7297 9917 15679 10179 13580 25059 27578 12751 14008 23730 24082 2996 2679 24677 27754 20900 11785 15566 3094 13609 6173 11244 29930 7515 10169 5056 11192 5974 8923 6749 5652 10987 2145 16447 31578 26518 14630 29917 5875 15792 15470 22913 8147 30694 9092 9816 26950 26858 20641 26053 237 8552 9488 31227 28163 16956 23184 8395 30181 16098 3066 27066 2514 9262 12579 21079 16879 14141 4612 31948 2446 171 29976 13490 24751 6150 3334 13866 22215 17283 27008 27433 8897 16368 28523 4883 31811 17642 7232 2188 6706 6480 6322 6539 31352 19448 24209 9647 22277 25760 30190 30423 27667 8487 3456 2029 29615 4861 29254 11778 31349 12504 10862 22432 29083 12456 14198 22107 8753 15822 17297 26282 26022 24456 15948 27125 18319 9136 11377 1775 29860 24999 12075 9254 6923 10636 1644 28889 8154 13233 4748 28681 19927 25679 6451 14802 24962 14200 20856 26364 5717 10574 31562 23246 6474 28275 1551 24354 1182 4288 2700 18111 18644 17466 7173 2530 9982 2113 13477 4382 8248 26891 16672 8806 32373 30033 3990 9321 23166 15432 9659 11294 17207 26579 16949 2207 27172 18167 3397 16698 31021 23695 15530 14789 30110 17985 11970 28979 21618 4016 16627 3685 9169 17907 25929 12098 28119 24391 15200 11786 14487 19200 12421 20711 18272 15814 27416 6086 319 3581 1332 7268 8388 13445 23187 14508 4361 17828 28075 26432 7153 30272 10269 4694 19886 338 31312 17605 12678 407 7769 29023 19414 5001 543 17538 30039 21389 7356 13290 31648 3182 13094 16585 10988 10762 20494 8218 9502 17483 29448 15666 10754 22105 15085 19096 13526 30222 3965 21782 4873 8107 3657 3344 22594 27081 16081 14869 21412 13714 20969 3252 27217 12080 28769 17041 31532 12934 23780 20664 12260 26654 27937 2096 24366 11875 7721 26836 25681 8977 18456 5726 4072 24809 13560 9157 5603 17833 7906 10441 7376 21563 22886 21963 21081 1837 10798 31203 10509 10081 5341 12077 9059 31494 7741 8547 20475 24774 19098 8881 23336 11073 23401 708 22956 20667 4142 23589 12482 17169 28316 19397 16226 1010 22013 18137 11456 18763 25044 743 22 17923 24513 9249 26019 27369 23718 9715 17651 13291 3336 12760 3170 21896 5304 22641 21980 24200 29106 24792 18662 8682 3653 8754 24034 32030 15988 7043 26254 20084 11421 15815 32719 12245 31064 7230 20653 18865 4770 30471 15006 21048 1595 21488 24327 3277 21324 6541 7680 23991 32589 24711 29272 17946 29222 28471 20184 23590 23956 4979 24780 5007 13263 20136 23488 27197 29034 2089 12936 19780 15994 14791 24963 18966 11002 19106 11808 24568 2670 3135 32672 1458 12999 3546 13598 14219 8839 14845 7373 8564 21029 29265 28802 14724 13491 7605 31602 24228 11198 23693 19772 20364 29302 22364 7722 3566 17422 23446 18611 496 16742 15023 31813 29152 23016 8056 3394 8739 15280 19883 1609 12655 3823 32708 24246 1339 145 22291 31340 23155 24605 4624 22226 20079 21725 31982 2331 29734 28224 20595 29131 18847 4988 29446 18806 8617 5751 20490 27339 21964 28136 14698 32210 21631 23225 1909 26738 24475 31921 27373 10294 3856 6735 9562 31057 27607 8185 7076 28383 14120 6742 30433 24685 12780 12280 18284 20668 30837 24126 24119 12738 18029 32120 20578 10738 14092 20557 22796 16061 21902 8794 3433 2137 4581 14876 5908 21185 28075 8720 26791 20477 30042 3352 8330 16291 22975 23073 3592 12190 15788 31491 3240 14894 3054 17064 10682 25904 27006 24177 18480 1696 6140 32469 13999 21084 23640 29516 27622 29994 15827 15723 23839 24829 12582 24400 8979 11892 1024 26944 24835 14244 7350 2703 8708 20503 25142 10688 8347 15892 24638 18414 11401 22817 31691 13163 8936 29127 19411 19878 11383 26261 27190 26706 13875 2664 20723 32196 22567 16361 6039 18589 7812 28246 9468 32426 26868 13190 10543 13064 21548 30503 29618 9100 25024 17227 31204 30049 21052 1571 8637 9459 25968 8457 9406 11532 29963 26820 7976 10557 7532 31496 8045 30592 26804 3389 18916 7451 12320 6273 25792 29384 10134 1776 24643 23570 18301 17955 12079 3586 2258 25334 894 10491 10104 4751 17234 10723 24272 19612 18991 30339 21642 23259 19048 2353 9659 480 25303 32684 18991 10003 15569 4423 16896 6136 18009 12362 16743 22195 23700 23189 20179 4043 31358 23942 1848 7470 16346 4381 31914 14965 25711 20062 25386 20074 27505 9463 32704 28103 11070 5155 3530 31553 32075 19150 3731 2245 10845 13050 14119 24066 26364 19553 28774 18471 29732 6748 7512 5870 14399 10499 7104 27353 25680 28054 13044 14523 31089 1564 25835 9851 17023 7241 21912 9493 5652 28581 15478 27617 29877 19179 5221 14616 22349 26799 32180 31636 16858 2884 1663 18903 28263 19421 19771 19023 9274 25842 12687 28889 3918 31718 1893 13699 11268 11750 66 10390 6933 25620 16082 2004 29131 13029 18632 14590 23153 18631 19173 19865 6408 12296 25429 29682 18491 26611 26178 31072 25237 6460 20644 16841 27634 27038 23894 22631 20275 12994 28783 32204 17462 8291 19663 22308 20998 31152 18424 8891 16718 6641 28704 5567 4884 23662 22660 18246 20387 32652 32766 19602 16841 17210 1498 27284 29251 18059 8422 176 30582 \n1000\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000",
"output": "671736\n5526920\n16399906\n16648413\n1998000000000\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
dawood-the-mathematician
|
Solve the following coding problem using the programming language python:
Dr.Dawood is another mathematician who is more geekier than Osama (that's why, ++). Dawood deals with more complex problems than Osama usually deals with. He also recruits people to be his sub-ordinates. He usually gives them "trivial" problems as test for them to solve and earn their position to be his sub-ordinate.
You went to attend such a test and you were given the following question.
Lets define a function A(N,K) where it signifies the number of ways in which we can draw K objects from a pool of N objects.
Lets define another function B(x1,x2,x3,x4,...) where it signifies the largest integer which can perfectly divide all the integers x1,x2,x3,...
Using these two functions , Dawood gave you a problem. The problem is stated as follows..
Given an integer N find the value of the equation,
O = B(A(2N,1),A(2N,3),A(2N,5),....,A(2N,(2*N)-1)
Input consists of T in the first line, which is the total number of testcases to be processed. Followed by T lines of inputs. Each testcase consists of value N.
Output the value of the equation O in a new line.
1 β€ T β€ 1000
1 β€ N β€ 10^12
SAMPLE INPUT
4
3
1
2
5
SAMPLE OUTPUT
2
2
4
2
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
for i in range(0,int(input())):
f =0
ans = 0
x = int(input())
while x%2 == 0:
f = f+1
x= x/2
ans = pow(2,(f+1))
print(ans)
```
|
vfc_81529
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n3\n1\n2\n5\n\nSAMPLE",
"output": "2\n2\n4\n2",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
game-of-divisors
|
Solve the following coding problem using the programming language python:
Two players are playing the following game with a positive integer N. On his turn a player has to write down on paper some integer between 1 and N. But it's forbidden to write an integer which is a divisor of some number already written on paper. For example N = 8 and numbers already written are: 6, 4, 7. In this case the new integer can be only 5 or 8.
If a player can not write a new number on his turn then he loses. Given the integer N can you figure out who will win the game if we assume that both players play optimally?
Input
The first line contains T - the number of test cases.
The following T lines contain one integer N each for the following test case.
Output
For each test case output 1 or 2 on a separate line depending on the answer for this test case.
Constraints
1 β€ T, N β€ 30
SAMPLE INPUT
1
3
SAMPLE OUTPUT
1
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
for i in range(input()):
z=raw_input()
print 1
```
|
vfc_81533
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3\n\nSAMPLE",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n6\n7\n8\n9\n10",
"output": "1\n1\n1\n1\n1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n6\n7\n8\n11\n10",
"output": "1\n1\n1\n1\n1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n3\n\nSAMPME",
"output": "1\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
karan-and-strings
|
Solve the following coding problem using the programming language python:
After the Tatvik Hiring Challenge, Karan's NLP professor has given him another homework. Since Manhattan Associates Hiring Challenge is round the corner and Karan is busy preparing for it, he turns to you for help.
Given a string, replace all the consecutively occurring characters by a single, same character.
Input:
The first line contains the number of test cases T. Each test case contains the string, on a separate line.
Output:
Print the modified string, each on a new line.
Constraints:
1 β€ T β€ 100
1 β€ length(string) < 10^6
SAMPLE INPUT
1
aabbcc
SAMPLE OUTPUT
abc
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
t=int(raw_input())
i=0
while(i<t):
s=raw_input()
s1=''
s1+=s[0]
for j in s[1:]:
if(j!=s1[-1]):
s1+=j
print(s1)
i+=1
```
|
vfc_81537
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\naabbcc\n\nSAMPLE",
"output": "abc\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\naabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\nabcdefghijklmnopqrstuvwxyz\n...............................aaaaaaaaaaaaaaaaaaaaaa\n....................,,,,,,,,,,,,,,,,,,,,,aaaaaaaaaaaaa\naaaaaaaaaaaaa.................dddddddddddkkkkkkkkkkkkvvvvvvvvvvllllllllllllwww\n''''''''''''''''''''''''''''''''''''''''''''''''''''''rrrrrrrrrrrrrrrrrrrr\nsssssssssssssssssssfffffffffffffffffffffffffffffweeeeeeeeeeeeeeeeeeeeecbbbbbbb\naaaaaaaaaaaaaawwwwwwwwwwwwfffffffffffffflsssssssssssssssossspaaaaaaaaaaaa\n.aaaaaaaaa............aaaaaaaaaaaaaaaaaaaaaaaaaaa.",
"output": "abcdefghijklmnopqrstuvwxyz\na\nabcdefghijklmnopqrstuvwxyz\n.a\n.,a\na.dkvlw\n'r\nsfwecb\nawflsospa\n.a.a.\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\naabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\nabcdefghijklmnopqrstuvwxyz\n...............................aaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaa,,,,,,,,,,,,,,,,,,,,,....................\naaaaaaaaaaaaa.................dddddddddddkkkkkkkkkkkkvvvvvvvvvvllllllllllllwww\n''''''''''''''''''''''''''''''''''''''''''''''''''''''rrrrrrrrrrrrrrrrrrrr\nsssssssssssssssssssfffffffffffffffffffffffffffffweeeeeeeeeeeeeeeeeeeeecbbbbbbb\naaaaaaaaaaaaaawwwwwwwwwwwwfffffffffffffflsssssssssssssssossspaaaaaaaaaaaa\n.aaaaaaaaa............aaaaaaaaaaaaaaaaaaaaaaaaaaa.",
"output": "abcdefghijklmnopqrstuvwxyz\na\nabcdefghijklmnopqrstuvwxyz\n.a\na,.\na.dkvlw\n'r\nsfwecb\nawflsospa\n.a.a.\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\naabbcb\n\nSAMPLE",
"output": "abcb\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\naabbccddkeffgghhiijjkellmmnnooppqqrrssttuuvvwwxxyyzz\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\nabcdefghijklmnopqrstuvwxyz\n...............................aaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaa,,,,,,,,,,,,,,,,,,,,,....................\naaaaaaaaaaaaa.................dddddddddddkkkkkkkkkkkkvvvvvvvvvvllllllllllllwww\n''''''''''''''''''''''''''''''''''''''''''''''''''''''rrrrrrrrrrrrrrrrrrrr\nsssssssssssssssssssfffffffffffffffffffffffffffffweeeeeeeeeeeeeeeeeeeeecbbbbbbb\naaaaaaaaaaaaaawwwwwwwwwwwwfffffffffffffflsssssssssssssssossspaaaaaaaaaaaa\n.aaaaaaaaa............aaaaaaaaaaaaaaaaaaaaaaaaaaa.",
"output": "abcdkefghijkelmnopqrstuvwxyz\na\nabcdefghijklmnopqrstuvwxyz\n.a\na,.\na.dkvlw\n'r\nsfwecb\nawflsospa\n.a.a.\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\naabbccddkeffgghhiijjkellmmnnooppqqrrssttuuvvwwxxyyzz\naaaaaaaaaaaaaaaa`aaaaaaaaaaaaaaaaaaaaaaaaa\nabcdefghijklmnopqrstuvwxyz\n...............................aaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaa,,,,,,,,,,,,,,,,,,,,,....................\naaaaaaaaaaaaa.................dddddddddddkkkkkkkkkkkkvvvvvvvvvvllllllllllllwww\n''''''''''''''''''''''''''''''''''''''''''''''''''''''rrrrrrrrrrrrrrrrrrrr\nsssssssssssssssssssfffffffffffffffffffffffffffffweeeeeeeeeeeeeeeeeeeeecbbbbbbb\naaaaaaaaaaaaaawwwwwwwwwwwwfffffffffffffflsssssssssssssssossspaaaaaaaaaaaa\n.aaaaaaaaa............aaaaaaaaaaaaaaaaaaaaaaaaaaa.",
"output": "abcdkefghijkelmnopqrstuvwxyz\na`a\nabcdefghijklmnopqrstuvwxyz\n.a\na,.\na.dkvlw\n'r\nsfwecb\nawflsospa\n.a.a.\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
mittal-wants-to-go-to-play
|
Solve the following coding problem using the programming language python:
Mittal lives in the Niti Colony. The colony has N houses numbered from 1 to N. There are M bidirectional roads in the colony for travelling between houses. There might be multiple roads between two houses.
Mittal lives in the house with index 1. He has friends in all houses of the colony. He is always wanting to visit them to play. But his mom is really strict. She only allows him to go out for K units of time. This time includes the time taken to go to his friend's house , play with the friend and time taken to come back home.
You are given Q queries. In each query, Mittal wants to go to his friend in house A , given K units of time. Help him find the maximum time that he can play.
If K units of time is not sufficient to visit his friend and return back, Mittal will not go and playing time will be zero.
Input:
First line contains an integer T. T test cases follow.
First line of each test case contains two space-separated integers N, M
Next M lines contain three space-separated integers X, Y and C, denoting that there is Bidirectional road between house X and house Y with cost C.
Next line contains an integer Q
Following Q lines describe the queries. Each query contains two space-separated integers A and K.
Output:
Print the answer to each query in a new line.
Constraints:
1 β€ T β€ 10
1 β€ N, Q β€ 10^4
1 β€ M β€ 10^5
1 β€ X, Y, A β€ N
1 β€ K β€ 10^4
1 β€ C β€ 1000
SAMPLE INPUT
1
5 5
1 2 2
2 3 4
3 4 5
4 5 1
1 4 7
3
4 20
5 21
3 5
SAMPLE OUTPUT
6
5
0
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
import heapq
from bisect import bisect_left
INF = 1 + 25 * 10**8
def dijkstra(G, n, s):
dist = [INF] * (n+1)
dist[s] = 0
heap = []
heapq.heappush(heap, (0,s))
while heap:
d, u = heapq.heappop(heap)
if dist[u] < d:
continue
for (v, w) in G[u]:
if dist[v] > dist[u] + w:
dist[v] = dist[u] + w
heapq.heappush(heap, (dist[v], v))
return dist
t=input()
while t!=0:
n, m = map(int, raw_input().split())
G = [[] for i in xrange(n+1)]
for i in xrange(m):
x, y, z = map(int, raw_input().split())
G[x].append((y, z))
G[y].append((x, z))
distStart = dijkstra(G, n, 1)
q=int(raw_input())
while q!=0:
a,b=map(int,raw_input().split())
if b>=2*distStart[a]:
print b-2*distStart[a]
else:
print 0
q-=1
t-=1
```
|
vfc_81541
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n5 5\n1 2 2\n2 3 4\n3 4 5\n4 5 1\n1 4 7\n3\n4 20\n5 21\n3 5\n\nSAMPLE",
"output": "6\n5\n0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n2 2\n1 2 10\n1 2 2\n4\n2 45\n2 30\n2 11\n2 13\n3 6\n1 2 2\n2 3 4\n2 3 10\n2 3 4\n1 2 5\n2 3 6\n5\n3 20\n3 11\n3 46\n2 41\n3 50",
"output": "41\n26\n7\n9\n8\n0\n34\n37\n38",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
panda-and-combination
|
Solve the following coding problem using the programming language python:
Panda loves solving problems which are deemed impossible by his fellow classmates. The current problem which he is working on is to express a number N as sum of powers of number X (Not necessarily distinct) such that the number of powers of number X used should be minimum.
Note: The powers of a number can be 0, 1, 2, 3, 4, ...
Input Format:
The first line will contain T, the number of test cases. Then, T lines follow, each containing 2 space separated integers N and M.
Output Format:
For each test case, output the minimum number of such numbers (powers of M) which can be summed up to produce N.
Constraints:
Subtask 1: (20 points)
1 β€ T β€ 10^3
1 β€ N, M β€ 10^3
Subtask 2: (80 points)
1 β€ T β€ 10^5
1 β€ N, M β€ 10^14SAMPLE INPUT
3
4 4
5 3
6 1
SAMPLE OUTPUT
1
3
6
Explanation
Case 1. 4 can be expressed as 4^1.
Case 2. 5 can be expressed as sum of 3^0 + 3^0 + 3^1.
Case 3. 6 can be expressed as sum of 1^1 + 1^1 + 1^1 + 1^1 + 1^1 + 1^1.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
for _ in xrange(input()):
n,m=map(int,raw_input().split())
if(n<m or m==1):
print n
continue
ans=0
while n>0:
ans = ans + n%m
n = n/m
print ans
```
|
vfc_81545
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n4 4\n5 3\n6 1\n\nSAMPLE",
"output": "1\n3\n6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n4 4\n2 3\n6 1\n\nSAMPLE",
"output": "1\n2\n6\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
rod-cutting-problem-7
|
Solve the following coding problem using the programming language python:
A young mischievous boy Harsh, got into a trouble when his mechanical workshop teacher
told him to cut Iron rods.
The rod cutting algorithm is as follows:
Step 1. If the rod can be divided into two equal parts, cut it and choose any one of them.
Step 2. Else cut the rod into two parts having non-zero integral lengths such that
the difference between the lengths of the two pieces is minimized, and then choose
the piece having smaller length.
Step 3. Repeat the above algorithm with the currently chosen piece. If the length of the currently chosen piece becomes 1 , stop the algorithm.
There can be special rods which require Step 2 in every step of its cutting. Harsh want to find out the number of such special rods. Help Harsh to find out the answer.
Input:
The first line of the input will contain T, the number of test-cases.
Each subsequent T lines will contain an integer N, where N is the range of lengths of rods from 1 to N .
Output:
For each test-case print the required answer.
Constraints:
1 β€ T β€ 1000
1 β€ N β€ 10^9
SAMPLE INPUT
2
3
2
SAMPLE OUTPUT
1
0
Explanation
In the first case there is only 1 such special iron rod,( which is of length 3 ).
A rod of length 3 cannot be divided into two equal parts, so we follow Step 2 and divide the rod into 2 and 1 length rod. ( See that the difference between the two rods obtained is minimum among all the possible choices).
After that choose the rod having smaller length. Since the length of the currently rod is 1 , the algorithm stops. So we see that during the each step of cutting (although, there is only 1 step involved in cutting ) we have to do mental calculations using Step 2. There is no such rod , other than this in the range 1 and 3. So the answer is 1.
In the second case there is no such rod between 1 and 2 , so the answer is 0.
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
def count_special(N):
count = 0
prev = 0
curr = 3
while(curr <= N):
prev = curr
curr = 2*prev + 1
count += 1
return count
T = int(raw_input())
for t in xrange(T):
N = int(raw_input())
count = count_special(N)
print count
```
|
vfc_81549
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3\n2\n\nSAMPLE",
"output": "1\n0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n977\n543\n252\n979\n348\n889\n876\n55\n938\n610",
"output": "8\n8\n6\n8\n7\n8\n8\n4\n8\n8\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1000\n637440000\n497933618\n104308126\n54379600\n735895362\n146758511\n172457069\n786824866\n792402682\n2932951\n280042089\n190772473\n647479785\n613419369\n465129597\n173755079\n611820068\n311399952\n18559\n244257083\n243465884\n889140268\n511454427\n656283414\n5014973\n74313994\n43362072\n167462516\n462845068\n523793969\n238276863\n499705283\n654936649\n173563309\n61528587\n897578634\n693601647\n101114931\n478055967\n340181401\n746838030\n20478757\n328496579\n429849971\n416906704\n303608836\n827802698\n363252259\n387075857\n802417841\n446122706\n571242110\n198083922\n700584456\n597549468\n348147824\n53431074\n545954178\n448543563\n615596885\n866209380\n641627821\n749234102\n568298341\n628897652\n216770436\n380213272\n599042500\n557678198\n587332312\n899445329\n630173695\n482226555\n769172920\n14795844\n757505636\n204589972\n881931924\n375785677\n676437195\n843009122\n150720467\n120880127\n6840001\n715689155\n32489931\n832621632\n8489298\n674818380\n526172864\n347835107\n341638900\n412355961\n99668937\n726445423\n607638994\n677325884\n3964685\n153625138\n711974337\n895140380\n111963534\n568926974\n679917067\n278274791\n330635947\n843944296\n635581251\n4127234\n398258890\n880772757\n854864770\n839307967\n270273471\n655162268\n849136414\n636051125\n796016815\n398940018\n333971773\n895771728\n303920237\n514765840\n52468841\n356801608\n650026198\n491327222\n667665792\n349425094\n465451013\n883162792\n548409894\n326931608\n174417196\n276873312\n794905213\n784684551\n177912958\n809287022\n102613271\n754232762\n339350314\n662390737\n502765430\n416954250\n739788595\n853445095\n783088524\n424830365\n80354802\n359057676\n886593587\n193782904\n730558234\n34250236\n705482885\n268653214\n250940512\n651016898\n703161164\n751567526\n534629011\n634818821\n850281174\n723352472\n298116436\n493176703\n329652969\n298314290\n114512782\n228173417\n185082763\n412956657\n495495893\n415389143\n219416398\n78635166\n606910763\n746178747\n202209894\n479913378\n777189322\n642027768\n646946354\n270937606\n680732234\n637891576\n546339958\n675177313\n232375009\n194301766\n539238391\n204387322\n41895343\n513060892\n283897635\n436155675\n248950048\n773293326\n415168301\n428905104\n112228251\n891515826\n174585612\n463465344\n102031675\n319349207\n407802431\n668815670\n581257789\n405566001\n491846797\n537193552\n164791879\n201337462\n798684638\n223574675\n65251407\n603724126\n254898923\n159614193\n68227915\n843868164\n872926864\n193666890\n811702331\n603158891\n518303327\n344792553\n219148063\n897267177\n689746471\n785090807\n791131183\n157930046\n816245818\n870157268\n182278084\n609255275\n715587390\n671228138\n43576496\n885279029\n658732395\n306925812\n349765064\n169709576\n292070739\n266754670\n270681026\n79877786\n407886730\n415233162\n164745510\n639506386\n854718187\n551311157\n650338481\n894472185\n783350118\n78142090\n163591873\n47884199\n98083710\n522324534\n48180225\n39445484\n784073203\n837596868\n290479819\n631210328\n86681888\n527093077\n577982267\n840196780\n208464075\n115163598\n629078550\n543870727\n279659015\n24715301\n463393616\n22497956\n253714582\n308367116\n156318208\n823878883\n1334679\n223630446\n1296232\n444372375\n867086008\n680755041\n598460155\n313915968\n239391295\n742360422\n808436450\n137672789\n801864763\n380769470\n784945976\n816401209\n840990664\n800074235\n362511770\n714235520\n54480560\n285678658\n239495734\n692297829\n343417506\n431648663\n412125699\n430221192\n674822080\n156923284\n527982469\n107535433\n502704718\n138820015\n606667015\n518847066\n854242897\n302409551\n658969169\n413110530\n92004273\n783272783\n623800847\n870345668\n211736327\n666840028\n549814040\n536769024\n125394580\n266810169\n167289320\n703002503\n845528790\n139433018\n497769854\n864211319\n891824465\n59731628\n668831482\n526909962\n36105318\n484365868\n447274686\n493733203\n694132122\n700820792\n686379349\n554068949\n315144340\n362997306\n450454616\n283845231\n173981665\n103372525\n390875143\n154360858\n755662660\n804919491\n714755363\n641032374\n768253472\n206286877\n540740858\n529419988\n779199112\n367529238\n890802630\n544995503\n457851073\n383526098\n708716053\n880616242\n461049696\n62719309\n240559310\n628234571\n331170541\n564977003\n392138103\n233179138\n554453745\n607558571\n875925749\n70251932\n154081615\n165603294\n888521611\n129056390\n148457654\n411013577\n207169096\n176412984\n557335817\n739946538\n542396167\n439146882\n213486554\n226680376\n507307738\n796689313\n878974832\n128438740\n673906593\n793868127\n438039483\n168066724\n432766218\n815198156\n121581795\n334971334\n454388208\n301973826\n442085582\n863915109\n879015808\n61552347\n429839684\n800807465\n177322250\n115870074\n507791114\n187368925\n229040795\n37017086\n410037672\n408115462\n238049520\n323530789\n113967822\n243342428\n466980717\n714989276\n49007412\n309566869\n361322143\n89143621\n558908247\n391663410\n758270680\n888360079\n278201765\n786373262\n340375147\n334583468\n554254653\n2024163\n820062245\n867454942\n573562285\n630420015\n238216785\n661684519\n735081775\n702835577\n551941898\n121159253\n870707251\n799215071\n14058260\n813232838\n323806072\n338389161\n751261895\n592640567\n394700868\n222807580\n846015440\n100842339\n378257192\n204980748\n714788121\n1940909\n361676041\n641686986\n176170918\n384707793\n637356589\n524631638\n665642623\n393065767\n818170546\n653475274\n253336346\n45277640\n428558442\n78169246\n395042005\n293295651\n671208386\n670188736\n457348158\n891014199\n379227834\n341791266\n296432357\n573767342\n591214604\n502482225\n530466476\n43805245\n789897508\n419681825\n407921110\n26087271\n719560061\n572285089\n5568126\n148248072\n207842538\n137865803\n194756621\n684500467\n837285847\n538273721\n404469375\n735235852\n307090055\n633834019\n336797263\n549365948\n703994694\n804957024\n741732881\n230439699\n748025861\n272876728\n193821434\n641069522\n287420864\n351704038\n426108811\n486857606\n621116620\n145007210\n80986448\n105068400\n268177228\n487951936\n813984593\n620134390\n249284943\n899180108\n303332154\n787435334\n424815235\n828893080\n230595660\n586915645\n181509754\n519237486\n325265590\n117957682\n714177709\n275325626\n85622887\n429662998\n240058478\n681941570\n196891416\n510491735\n439636306\n62345447\n560253126\n700135910\n529112414\n66094183\n294787007\n219203545\n820760830\n317188844\n784502880\n139252930\n619297610\n831905591\n461477671\n415148039\n663493929\n836099443\n510628818\n749423579\n751358078\n875715683\n198930498\n6031101\n285251445\n297173834\n743693283\n769676890\n278078957\n614430849\n226373784\n652444407\n326279843\n724818380\n342910641\n778018932\n93764739\n885937457\n371352944\n322175278\n541365689\n438125462\n306740579\n429162782\n476412950\n453651899\n711019220\n654043737\n78101181\n296221232\n257743412\n756525480\n692450908\n91880954\n350739673\n292328641\n206718020\n595910517\n615473719\n734714341\n748701508\n559646812\n646022303\n484220573\n701557989\n333809837\n148210657\n557635871\n153936882\n730018766\n78404385\n721587564\n185578603\n651509390\n228989491\n29197264\n629081477\n58936550\n630749462\n405946927\n670697675\n769217297\n448515979\n694552410\n58542589\n476785935\n7825455\n608401494\n429878354\n400240615\n138750841\n61941949\n749632560\n521156439\n675776624\n640277848\n726484780\n592969378\n810097157\n7380462\n414609810\n31893613\n537584676\n12632104\n349884130\n612259229\n517086911\n349895746\n89532322\n142509944\n205578252\n411801803\n325385816\n590705275\n856573474\n862884588\n713490218\n361492463\n418369303\n129297433\n816697498\n669826595\n549199097\n168085784\n307436725\n28477725\n508480718\n14459505\n343299792\n836285500\n189967003\n717005497\n433242177\n188441253\n263530655\n193427345\n283096372\n211080933\n793187266\n724985223\n360845568\n575918337\n738398752\n177293570\n857008210\n238191043\n54854149\n476742229\n830857967\n126411839\n870982274\n75292274\n390445272\n280063867\n644484645\n418614214\n603187045\n281004255\n825846055\n781179408\n637887388\n156576898\n471151864\n196651070\n837602418\n541920156\n658322181\n635800763\n865130046\n195155821\n31285207\n582805527\n519762139\n162960613\n767272604\n655142230\n178418659\n87380534\n185372552\n473153076\n633550961\n307988291\n758542568\n580717823\n520564966\n541861738\n342087905\n809647553\n57404808\n313756182\n19896137\n309247031\n162925607\n890391879\n742711756\n556569262\n395078636\n558741772\n836492382\n683408608\n886086341\n766805630\n98827814\n341822359\n82687817\n130170290\n219847938\n886859869\n867991401\n349030283\n134962703\n54320460\n584256933\n837661979\n862852888\n55632320\n738136439\n416455201\n362801854\n568302010\n526492394\n625062149\n783022625\n764965564\n208357732\n340261097\n55545634\n761413505\n472066935\n620536103\n351804216\n157020778\n571920203\n129402417\n876637945\n161867078\n843650451\n487354219\n625377875\n128682058\n682752283\n149767256\n134088923\n640794581\n475184380\n500184877\n533862139\n129508791\n590544726\n347272042\n415163716\n251968403\n880339531\n797685959\n51583414\n215450857\n195752204\n237922974\n876386505\n631497013\n478280370\n878734365\n863348231\n716971663\n887366707\n662568895\n769904539\n323725127\n566951912\n339505029\n870359512\n659709313\n547588784\n869239996\n151966313\n526870937\n295173125\n445994871\n830459122\n813494584\n419279770\n318683903\n456092655\n167522453\n737576447\n794422910\n167715236\n441343094\n210041333\n301815935\n239737554\n500272516\n614054693\n745033192\n640666385\n814251418\n525322577\n319035242\n52656518\n116348454\n166791835\n506479714\n342380390\n81986281\n211654831\n860145350\n409369372\n850402737\n640306624\n107404114\n827178622\n168320938\n440789407\n414136568\n808706374\n308389442\n727928163\n780368863\n894024651\n262465151\n518386766\n358387646\n490992983\n773585915\n832318168\n510413319\n476869338\n100972817\n657757490\n519590084\n186428688\n662372998\n784317094\n719262844\n845188905\n464243871\n272625110\n453240628\n231178235\n834545677\n393068\n454383889\n35941668\n98680049\n128766983\n544411401\n581229564\n618578532\n537473335\n170857506\n314741651\n153107121\n97945825\n76738975\n876692952\n436151173\n715811920\n47007479\n109622804\n884331287\n711757717\n212887407\n329887238\n278859701\n5587991\n480762318\n175435061\n559959099\n697026937\n658755368\n681516401\n175645308\n457711431\n598888890\n738543749\n480744812\n118329379\n484242385\n280756124\n439759845\n767005972\n590876949\n769723672\n160769855\n286414919\n744068519\n831583855\n540390655\n136707134\n50898128\n461038939\n751593939\n270320463\n476417854\n873366164\n771669353\n376378496\n805506113\n847260941\n279381573\n341120157\n242372277\n731270938\n850979462\n202825699\n130689803\n176134075\n644607071\n414793092\n541385794\n683487639\n595527325\n27316581\n628898280\n8434300\n493427105\n464713687\n240259096\n14141010\n546507981\n877962482\n529118166\n870983905\n12762468\n143978192\n88467771\n410456034\n446080747\n667266809\n144157251\n27475776\n561002175\n624424684",
"output": "28\n27\n25\n24\n28\n26\n26\n28\n28\n20\n27\n26\n28\n28\n27\n26\n28\n27\n13\n26\n26\n28\n27\n28\n21\n25\n24\n26\n27\n27\n26\n27\n28\n26\n24\n28\n28\n25\n27\n27\n28\n23\n27\n27\n27\n27\n28\n27\n27\n28\n27\n28\n26\n28\n28\n27\n24\n28\n27\n28\n28\n28\n28\n28\n28\n26\n27\n28\n28\n28\n28\n28\n27\n28\n22\n28\n26\n28\n27\n28\n28\n26\n25\n21\n28\n23\n28\n22\n28\n27\n27\n27\n27\n25\n28\n28\n28\n20\n26\n28\n28\n25\n28\n28\n27\n27\n28\n28\n20\n27\n28\n28\n28\n27\n28\n28\n28\n28\n27\n27\n28\n27\n27\n24\n27\n28\n27\n28\n27\n27\n28\n28\n27\n26\n27\n28\n28\n26\n28\n25\n28\n27\n28\n27\n27\n28\n28\n28\n27\n25\n27\n28\n26\n28\n24\n28\n27\n26\n28\n28\n28\n27\n28\n28\n28\n27\n27\n27\n27\n25\n26\n26\n27\n27\n27\n26\n25\n28\n28\n26\n27\n28\n28\n28\n27\n28\n28\n28\n28\n26\n26\n28\n26\n24\n27\n27\n27\n26\n28\n27\n27\n25\n28\n26\n27\n25\n27\n27\n28\n28\n27\n27\n28\n26\n26\n28\n26\n24\n28\n26\n26\n25\n28\n28\n26\n28\n28\n27\n27\n26\n28\n28\n28\n28\n26\n28\n28\n26\n28\n28\n28\n24\n28\n28\n27\n27\n26\n27\n26\n27\n25\n27\n27\n26\n28\n28\n28\n28\n28\n28\n25\n26\n24\n25\n27\n24\n24\n28\n28\n27\n28\n25\n27\n28\n28\n26\n25\n28\n28\n27\n23\n27\n23\n26\n27\n26\n28\n19\n26\n19\n27\n28\n28\n28\n27\n26\n28\n28\n26\n28\n27\n28\n28\n28\n28\n27\n28\n24\n27\n26\n28\n27\n27\n27\n27\n28\n26\n27\n25\n27\n26\n28\n27\n28\n27\n28\n27\n25\n28\n28\n28\n26\n28\n28\n27\n25\n26\n26\n28\n28\n26\n27\n28\n28\n24\n28\n27\n24\n27\n27\n27\n28\n28\n28\n28\n27\n27\n27\n27\n26\n25\n27\n26\n28\n28\n28\n28\n28\n26\n28\n27\n28\n27\n28\n28\n27\n27\n28\n28\n27\n24\n26\n28\n27\n28\n27\n26\n28\n28\n28\n25\n26\n26\n28\n25\n26\n27\n26\n26\n28\n28\n28\n27\n26\n26\n27\n28\n28\n25\n28\n28\n27\n26\n27\n28\n25\n27\n27\n27\n27\n28\n28\n24\n27\n28\n26\n25\n27\n26\n26\n24\n27\n27\n26\n27\n25\n26\n27\n28\n24\n27\n27\n25\n28\n27\n28\n28\n27\n28\n27\n27\n28\n19\n28\n28\n28\n28\n26\n28\n28\n28\n28\n25\n28\n28\n22\n28\n27\n27\n28\n28\n27\n26\n28\n25\n27\n26\n28\n19\n27\n28\n26\n27\n28\n27\n28\n27\n28\n28\n26\n24\n27\n25\n27\n27\n28\n28\n27\n28\n27\n27\n27\n28\n28\n27\n27\n24\n28\n27\n27\n23\n28\n28\n21\n26\n26\n26\n26\n28\n28\n28\n27\n28\n27\n28\n27\n28\n28\n28\n28\n26\n28\n27\n26\n28\n27\n27\n27\n27\n28\n26\n25\n25\n26\n27\n28\n28\n26\n28\n27\n28\n27\n28\n26\n28\n26\n27\n27\n25\n28\n27\n25\n27\n26\n28\n26\n27\n27\n24\n28\n28\n27\n24\n27\n26\n28\n27\n28\n26\n28\n28\n27\n27\n28\n28\n27\n28\n28\n28\n26\n21\n27\n27\n28\n28\n27\n28\n26\n28\n27\n28\n27\n28\n25\n28\n27\n27\n28\n27\n27\n27\n27\n27\n28\n28\n25\n27\n26\n28\n28\n25\n27\n27\n26\n28\n28\n28\n28\n28\n28\n27\n28\n27\n26\n28\n26\n28\n25\n28\n26\n28\n26\n23\n28\n24\n28\n27\n28\n28\n27\n28\n24\n27\n21\n28\n27\n27\n26\n24\n28\n27\n28\n28\n28\n28\n28\n21\n27\n23\n28\n22\n27\n28\n27\n27\n25\n26\n26\n27\n27\n28\n28\n28\n28\n27\n27\n25\n28\n28\n28\n26\n27\n23\n27\n22\n27\n28\n26\n28\n27\n26\n26\n26\n27\n26\n28\n28\n27\n28\n28\n26\n28\n26\n24\n27\n28\n25\n28\n25\n27\n27\n28\n27\n28\n27\n28\n28\n28\n26\n27\n26\n28\n28\n28\n28\n28\n26\n23\n28\n27\n26\n28\n28\n26\n25\n26\n27\n28\n27\n28\n28\n27\n28\n27\n28\n24\n27\n23\n27\n26\n28\n28\n28\n27\n28\n28\n28\n28\n28\n25\n27\n25\n25\n26\n28\n28\n27\n26\n24\n28\n28\n28\n24\n28\n27\n27\n28\n27\n28\n28\n28\n26\n27\n24\n28\n27\n28\n27\n26\n28\n25\n28\n26\n28\n27\n28\n25\n28\n26\n25\n28\n27\n27\n27\n25\n28\n27\n27\n26\n28\n28\n24\n26\n26\n26\n28\n28\n27\n28\n28\n28\n28\n28\n28\n27\n28\n27\n28\n28\n28\n28\n26\n27\n27\n27\n28\n28\n27\n27\n27\n26\n28\n28\n26\n27\n26\n27\n26\n27\n28\n28\n28\n28\n27\n27\n24\n25\n26\n27\n27\n25\n26\n28\n27\n28\n28\n25\n28\n26\n27\n27\n28\n27\n28\n28\n28\n26\n27\n27\n27\n28\n28\n27\n27\n25\n28\n27\n26\n28\n28\n28\n28\n27\n27\n27\n26\n28\n17\n27\n24\n25\n25\n28\n28\n28\n28\n26\n27\n26\n25\n25\n28\n27\n28\n24\n25\n28\n28\n26\n27\n27\n21\n27\n26\n28\n28\n28\n28\n26\n27\n28\n28\n27\n25\n27\n27\n27\n28\n28\n28\n26\n27\n28\n28\n28\n26\n24\n27\n28\n27\n27\n28\n28\n27\n28\n28\n27\n27\n26\n28\n28\n26\n25\n26\n28\n27\n28\n28\n28\n23\n28\n22\n27\n27\n26\n22\n28\n28\n27\n28\n22\n26\n25\n27\n27\n28\n26\n23\n28\n28\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
steal-the-show
|
Solve the following coding problem using the programming language python:
Itβs the company's 3^rd anniversary, and everyone is super-excited about it. There is a tradition in the company, that the interns decide the seating arrangement of all the members. The requirements of this order are:
The CEO of the company must sit in the middle. (In case of even number of team members, he can sit on either central position.)
The CTO and the COO must sit on the ends of the row.
The sum of the absolute height difference of adjacent members should be minimum.
Bhargav wants to steal the show by coming up with the minimum sum of absolute height difference of the heights of all the members while satisfying first 2 conditions. Since he is a product management intern, he does not know anything about computer programs. Please help him before a software engineer intern solves this.
Input Format:
ceo_height coo_height cto_height
total number of team members (excluding above three)
height_array (excluding above three)
Output Format:
Minimum sum of absolute height difference
Constraints:
1 β€ number of team members β€ 20
1 β€ heights β€ 100
SAMPLE INPUT
13 17 11
2
12 10
SAMPLE OUTPUT
10
Explanation
Optimal order: 11 10 13 12 17 -> 1+3+1+5 = 10
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
#mod = 10**9 + 7
#test = int(raw_input())
#for i in range(test):
ceo , coo , cto = [int(x) for x in raw_input().split()]
n = int( raw_input() )
arr = [int(x) for x in raw_input().split()]
arr.sort(reverse = True)
res = [0 for i in range(n+3)]
l = len(res)
res[0] = min( coo , cto )
res[l-1] = max( coo , cto )
res[l/2] = ceo
for i in range(l):
if res[i] == 0:
res[i] = arr[-1]
arr.pop()
ans = 0
for i in range(1 , l):
ans += abs( res[i] - res[i-1])
print ans
```
|
vfc_81553
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "13 17 11\n2\n12 10\n\nSAMPLE",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "80 82 81\n3\n50 90 65",
"output": "79\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
uncles-will-1
|
Solve the following coding problem using the programming language python:
Ramuβs uncle has left him a stable in his Will. But the stable is not in a good condition. The roofs leak and need to be repaired.
There are a number of stalls in the stable. A stall may or may not contain a horse. Ramu has to buy new cement sheets to cover these stalls. He has to cover atleast all those stalls that have a horse in them. (You cannot shift horses from one stall to another stall as they are habituated with their place) The Cement sheet Supplier will supply him sheets of any length he wishes, but as a marketing strategy, the supplier will only deliver a small number of total sheets. Ramu wishes to minimize the total length of the sheets he must purchase.
Given M, the maximum number of sheets that can be purchased; S the total number of stalls. C the number of horse in the stalls, and the C occupied stall numbers, calculate the minimum number of stalls that must be covered in order to cover all the stalls that have horses in them.
Input:
The first line of the input contains a single integer T, denoting the number of test cases. The description of T test cases follows.
First line of each test case contains space-separated integers M S C.
The next C line contains the number of stalls containing horse.
Output:
Single Line containing minimum number of stalls that must be covered.
Constraints
1 β€ T β€ 50
1 β€ M β€ 50
1 β€ S β€ 200
1 β€ C β€ S
1 β€ stall number β€ S
SAMPLE INPUT
1
2 10 3
2
4
10
SAMPLE OUTPUT
4
Explanation
For the given test case Cover [2-4] and [10]
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
# /he/uncle's-will
no_of_tc = input()
for tc in range(no_of_tc) :
line = raw_input()
max_sheets = int(line.split(' ')[0])
total_stalls = int(line.split(' ')[1])
filled_stalls = int(line.split(' ')[2])
stall_map = [False] * total_stalls
for i in range(filled_stalls) : stall_map[input() - 1] = True
while stall_map and stall_map[0] == False : stall_map.remove(False)
while stall_map and stall_map[len(stall_map) - 1] == False : stall_map.pop()
if len(stall_map) == 0 :
print 0
continue
stall_gaps = []
stall_gap_cache = 0
covered_stalls = 1
sheets_used = 1
for i in range(1, len(stall_map), 1) :
if stall_map[i] == True and stall_map[i - 1] == True :
covered_stalls += 1
elif stall_map[i] == False and stall_map[i - 1] == False :
stall_gap_cache += 1
elif stall_map[i] == True and stall_map[i - 1] == False :
covered_stalls += 1
sheets_used += 1
stall_gaps += [stall_gap_cache]
stall_gap_cache = 0
elif stall_map[i] == False and stall_map[i - 1] == True :
stall_gap_cache += 1
if sheets_used > max_sheets :
stall_gaps.sort(reverse = True)
for i in range(-1, max_sheets - sheets_used - 1, -1) :
covered_stalls += stall_gaps[i]
print covered_stalls
```
|
vfc_81557
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n2 10 3\n2\n4\n10\n\nSAMPLE",
"output": "4",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
p00007 Debt Hell
|
Solve the following coding problem using the programming language python:
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 β€ n β€ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
import math
n = int(input())
a = 100000
for _ in range(n):
a *= 1.05
a = 1000 * math.ceil(a / 1000)
print(a)
```
|
vfc_81601
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5",
"output": "130000",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1",
"output": "105000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4",
"output": "123000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2",
"output": "111000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3",
"output": "117000\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
p00272 Ticket Sales
|
Solve the following coding problem using the programming language python:
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets:
S seat 6000 yen
A seat 4000 yen
B seat 3000 yen
C seat 2000 yen
You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well!
Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table.
input
Input data is given in the following format.
t1 n1
t2 n2
t3 n3
t4 n4
The input consists of 4 lines. Line i is given the integer ti (1 β€ ti β€ 4) for the ticket type and the integer ni (0 β€ ni β€ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ββfor t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4.
output
Output the sales amount for each line.
Example
Input
3 10
1 4
4 1
2 5
Output
30000
24000
2000
20000
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
for i in range(4):
t,n=map(int,input().split())
if t==1:
print(f'{6000*n}')
elif t==2:
print(f'{4000*n}')
elif t==3:
print(f'{3000*n}')
elif t==4:
print(f'{2000*n}')
```
|
vfc_81609
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 10\n1 4\n4 1\n2 5",
"output": "30000\n24000\n2000\n20000",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 10\n1 4\n4 1\n1 5",
"output": "30000\n24000\n2000\n30000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 13\n1 4\n4 1\n1 5",
"output": "39000\n24000\n2000\n30000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 13\n1 4\n1 1\n1 5",
"output": "39000\n24000\n6000\n30000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 13\n1 4\n1 2\n1 5",
"output": "39000\n24000\n12000\n30000\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
p00460 Bingo
|
Solve the following coding problem using the programming language python:
problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N Γ N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 β€ N β€ 7), the upper limit of the integers written in the square M (1 β€ M β€ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 β€ S β€ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
import itertools
while 1:
n,m,s=map(int,input().split())
if n==0:break
dp=[[0 for _ in range(s+1)] for _ in range(n*n+1)]
dp[0][0]=1
for i,j in itertools.product(range(1,n*n+1),range(s+1)):
if j>=i:dp[i][j]+=dp[i-1][j-i]+dp[i][j-i]
if j-m>=1:dp[i][j]+=100000-dp[i-1][j-m-1]
dp[i][j]%=100000
print(dp[n*n][s])
```
|
vfc_81613
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 9 45\n3 100 50\n5 50 685\n0 0 0",
"output": "1\n7\n74501",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 9 45\n3 100 50\n5 50 308\n0 0 0",
"output": "1\n7\n0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 12 45\n3 100 75\n5 50 308\n0 0 0",
"output": "1\n3060\n0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 12 45\n3 100 69\n5 50 308\n0 0 0",
"output": "1\n1076\n0\n",
"type": "stdin_stdout"
}
]
}
|
code_contests
|
verifiable_code
|
p00650 The House of Huge Family
|
Solve the following coding problem using the programming language python:
Mr. Dango's family has an extremely huge number of members. Once it had about 100 members, and now it has as many as population of a city. It is jokingly guessed that the member might fill this planet in the near future.
Mr. Dango's family, the huge family, is getting their new house. Scale of the house is as large as that of town.
They all had warm and gracious personality and were close each other. However, in this year the two members of them became to hate each other. Since the two members had enormous influence in the family, they were split into two groups.
They hope that the two groups don't meet each other in the new house. Though they are in the same building, they can avoid to meet each other by adjusting passageways.
Now, you have a figure of room layout. Your task is written below.
You have to decide the two groups each room should belong to. Besides you must make it impossible that they move from any rooms belonging to one group to any rooms belonging to the other group. All of the rooms need to belong to exactly one group. And any group has at least one room.
To do the task, you can cancel building passageway. Because the house is under construction, to cancel causes some cost. You'll be given the number of rooms and information of passageway. You have to do the task by the lowest cost.
Please answer the lowest cost.
By characteristics of Mr. Dango's family, they move very slowly. So all passageways are escalators. Because of it, the passageways are one-way.
Constraints
* 2 β€ n β€ 100
* -10,000 β€ Ci β€ 10,000
* Y1 ... Ym can't be duplicated integer by each other.
Input
The input consists of multiple datasets. Each dataset is given in the following format.
n m
X1 Y1 C1
...
Xm Ym Cm
All numbers in each datasets are integers. The integers in each line are separated by a space.
The first line of each datasets contains two integers. n is the number of rooms in the house, m is the number of passageways in the house. Each room is indexed from 0 to n-1.
Each of following m lines gives the details of the passageways in the house. Each line contains three integers. The first integer Xi is an index of the room, the starting point of the passageway. The second integer Yi is an index of the room, the end point of the passageway. The third integer Ci is the cost to cancel construction of the passageway. The passageways, they are escalators, are one-way. The last dataset is followed by a line containing two zeros (separated by a space).
Output
For each dataset, print the lowest cost in a line. You may assume that the all of integers of both the answers and the input can be represented by 32 bits signed integers.
Example
Input
3 2
0 1 2
1 2 1
2 1
0 1 100
2 1
0 1 0
2 1
0 1 -1
0 0
Output
1
100
0
-1
The input will be given via stdin and the output should be printed to stdout by your code.
Now solve the problem by providing the code.
|
```python
# AOJ 1065 The House of Huge Family
# Python3 2018.7.10 bal4u
# UNION-FIND library
class UnionSet:
def __init__(self, nmax):
self.size = [1]*nmax
self.id = [i for i in range(nmax+1)]
def root(self, i):
while i != self.id[i]:
self.id[i] = self.id[self.id[i]]
i = self.id[i]
return i
def connected(self, p, q): return self.root(p) == self.root(q)
def unite(self, p, q):
i, j = self.root(p), self.root(q)
if i == j: return
if self.size[i] < self.size[j]:
self.id[i] = j
self.size[j] += self.size[i]
else:
self.id[j] = i
self.size[i] += self.size[j]
# UNION-FIND library
while True:
n, m = map(int, input().split())
if n == 0: break
u = UnionSet(n)
ans, tbl = 0, []
for i in range(m):
x, y, c = map(int, input().split())
if c < 0: ans += c
else: tbl.append((c, x, y))
tbl.sort(reverse=True)
for c, x, y in tbl:
if not u.connected(x, y):
if n > 2:
n -= 1
u.unite(x, y)
else: ans += c
print(ans)
```
|
vfc_81617
|
{
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"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",
"output": "1\n100\n0\n-1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "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",
"output": "1\n100\n0\n-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "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",
"output": "1\n0\n0\n-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "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",
"output": "0\n100\n0\n-1\n",
"type": "stdin_stdout"
}
]
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.