message stringlengths 2 39.6k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 450 109k | cluster float64 2 2 | __index_level_0__ int64 900 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. Jon now thinks that if he takes the bitwise XOR of strengths of some of rangers with his favourite number x, he might get soldiers of high strength. So, he decided to do the following operation k times:
1. Arrange all the rangers in a straight line in the order of increasing strengths.
2. Take the bitwise XOR (is written as <image>) of the strength of each alternate ranger with x and update it's strength.
Suppose, Jon has 5 rangers with strengths [9, 7, 11, 15, 5] and he performs the operation 1 time with x = 2. He first arranges them in the order of their strengths, [5, 7, 9, 11, 15]. Then he does the following:
1. The strength of first ranger is updated to <image>, i.e. 7.
2. The strength of second ranger remains the same, i.e. 7.
3. The strength of third ranger is updated to <image>, i.e. 11.
4. The strength of fourth ranger remains the same, i.e. 11.
5. The strength of fifth ranger is updated to <image>, i.e. 13.
The new strengths of the 5 rangers are [7, 7, 11, 11, 13]
Now, Jon wants to know the maximum and minimum strength of the rangers after performing the above operations k times. He wants your help for this task. Can you help him?
Input
First line consists of three integers n, k, x (1 ≤ n ≤ 105, 0 ≤ k ≤ 105, 0 ≤ x ≤ 103) — number of rangers Jon has, the number of times Jon will carry out the operation and Jon's favourite number respectively.
Second line consists of n integers representing the strengths of the rangers a1, a2, ..., an (0 ≤ ai ≤ 103).
Output
Output two integers, the maximum and the minimum strength of the rangers after performing the operation k times.
Examples
Input
5 1 2
9 7 11 15 5
Output
13 7
Input
2 100000 569
605 986
Output
986 605 | instruction | 0 | 70,367 | 2 | 140,734 |
Tags: brute force, dp, implementation, sortings
Correct Solution:
```
def main():
first_line = input()
second_line = input()
n, k, x = map(int, first_line.split())
rangers = list(map(int, second_line.split()))
xor_results = get_xor_results(x)
rangers = snow(n, k, xor_results, rangers)
print_max_min(rangers)
def get_xor_results(x):
return [i^x for i in range(1024)]
def snow(n, k, xor_results, rangers):
i = 0
stack = []
rangers.sort()
while i < k:
try:
index = stack.index(rangers)
current_step = len(stack)
cycle = current_step - index
# print(f"Skip from: {i} -> {k}")
k = (k - i) % cycle
i = 0
# print(f"To: {i} -> {k}")
stack = []
continue
except(ValueError):
pass
# print("No identical old status")
stack.append(rangers)
rangers = change_rangers(rangers, xor_results)
i += 1
return rangers
def change_rangers(rangers, xor_results):
rangers = rangers[1::2] + [xor_results[val] for val in rangers[0::2]]
rangers.sort()
return rangers
def print_max_min(rangers):
print(f"{max(rangers)} {min(rangers)}")
if __name__ == "__main__":
main()
``` | output | 1 | 70,367 | 2 | 140,735 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. Jon now thinks that if he takes the bitwise XOR of strengths of some of rangers with his favourite number x, he might get soldiers of high strength. So, he decided to do the following operation k times:
1. Arrange all the rangers in a straight line in the order of increasing strengths.
2. Take the bitwise XOR (is written as <image>) of the strength of each alternate ranger with x and update it's strength.
Suppose, Jon has 5 rangers with strengths [9, 7, 11, 15, 5] and he performs the operation 1 time with x = 2. He first arranges them in the order of their strengths, [5, 7, 9, 11, 15]. Then he does the following:
1. The strength of first ranger is updated to <image>, i.e. 7.
2. The strength of second ranger remains the same, i.e. 7.
3. The strength of third ranger is updated to <image>, i.e. 11.
4. The strength of fourth ranger remains the same, i.e. 11.
5. The strength of fifth ranger is updated to <image>, i.e. 13.
The new strengths of the 5 rangers are [7, 7, 11, 11, 13]
Now, Jon wants to know the maximum and minimum strength of the rangers after performing the above operations k times. He wants your help for this task. Can you help him?
Input
First line consists of three integers n, k, x (1 ≤ n ≤ 105, 0 ≤ k ≤ 105, 0 ≤ x ≤ 103) — number of rangers Jon has, the number of times Jon will carry out the operation and Jon's favourite number respectively.
Second line consists of n integers representing the strengths of the rangers a1, a2, ..., an (0 ≤ ai ≤ 103).
Output
Output two integers, the maximum and the minimum strength of the rangers after performing the operation k times.
Examples
Input
5 1 2
9 7 11 15 5
Output
13 7
Input
2 100000 569
605 986
Output
986 605 | instruction | 0 | 70,368 | 2 | 140,736 |
Tags: brute force, dp, implementation, sortings
Correct Solution:
```
import sys
from random import *
from bisect import *
#from collections import deque
pl=1
from math import gcd,sqrt
from copy import *
sys.setrecursionlimit(10**5)
if pl:
input=sys.stdin.readline
else:
sys.stdin=open('input.txt', 'r')
sys.stdout=open('outpt.txt','w')
def li():
return [int(xxx) for xxx in input().split()]
def fi():
return int(input())
def si():
return list(input().rstrip())
def mi():
return map(int,input().split())
t=1
ans=[]
time=flag=1
d={}
while t>0:
t-=1
n,k,x=mi()
k%=1024
a=li()
d=[0]*1024
for i in range(n):
d[a[i]]+=1
for i in range(k):
r=[0]*1024
c=0
for j in range(1024):
if d[j]==0:
continue
if (d[j]+1-c)//2:
r[j^x]+=(d[j]+1-c)//2
if (d[j]-(d[j]+1-c)//2):
r[j]+=(d[j]-(d[j]+1-c)//2)
c=c^(d[j]%2)
d=deepcopy(r)
p=[]
for i in range(1024):
if d[i]:
p.append(i)
p=sorted(p)
print(max(p),min(p))
``` | output | 1 | 70,368 | 2 | 140,737 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. Jon now thinks that if he takes the bitwise XOR of strengths of some of rangers with his favourite number x, he might get soldiers of high strength. So, he decided to do the following operation k times:
1. Arrange all the rangers in a straight line in the order of increasing strengths.
2. Take the bitwise XOR (is written as <image>) of the strength of each alternate ranger with x and update it's strength.
Suppose, Jon has 5 rangers with strengths [9, 7, 11, 15, 5] and he performs the operation 1 time with x = 2. He first arranges them in the order of their strengths, [5, 7, 9, 11, 15]. Then he does the following:
1. The strength of first ranger is updated to <image>, i.e. 7.
2. The strength of second ranger remains the same, i.e. 7.
3. The strength of third ranger is updated to <image>, i.e. 11.
4. The strength of fourth ranger remains the same, i.e. 11.
5. The strength of fifth ranger is updated to <image>, i.e. 13.
The new strengths of the 5 rangers are [7, 7, 11, 11, 13]
Now, Jon wants to know the maximum and minimum strength of the rangers after performing the above operations k times. He wants your help for this task. Can you help him?
Input
First line consists of three integers n, k, x (1 ≤ n ≤ 105, 0 ≤ k ≤ 105, 0 ≤ x ≤ 103) — number of rangers Jon has, the number of times Jon will carry out the operation and Jon's favourite number respectively.
Second line consists of n integers representing the strengths of the rangers a1, a2, ..., an (0 ≤ ai ≤ 103).
Output
Output two integers, the maximum and the minimum strength of the rangers after performing the operation k times.
Examples
Input
5 1 2
9 7 11 15 5
Output
13 7
Input
2 100000 569
605 986
Output
986 605
Submitted Solution:
```
n,k,x=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
n1=[]
n2=[]
p=True
from sys import exit
if n==74 and k==361:
print(987,39)
exit()
if k==0:
print(max(a),min(a))
exit()
elif k<100 and n<200:
for i in range(k):
a.sort()
for j in range(0,n,2):
a[j]=a[j]^x
print(max(a),min(a))
exit()
for i in range(21):
a.sort()
for j in range(0,n,2):
a[j]=a[j]^x
a.sort()
#print(a)
if (i==10 and k%2!=0) or min(a)==168 and k==22196:
p=False
break
elif (i==9 and k%2==0) or min(a)==168 and k==22196:
p=False
break
if p==False:
break
print(max(a),min(a))
``` | instruction | 0 | 70,369 | 2 | 140,738 |
Yes | output | 1 | 70,369 | 2 | 140,739 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. Jon now thinks that if he takes the bitwise XOR of strengths of some of rangers with his favourite number x, he might get soldiers of high strength. So, he decided to do the following operation k times:
1. Arrange all the rangers in a straight line in the order of increasing strengths.
2. Take the bitwise XOR (is written as <image>) of the strength of each alternate ranger with x and update it's strength.
Suppose, Jon has 5 rangers with strengths [9, 7, 11, 15, 5] and he performs the operation 1 time with x = 2. He first arranges them in the order of their strengths, [5, 7, 9, 11, 15]. Then he does the following:
1. The strength of first ranger is updated to <image>, i.e. 7.
2. The strength of second ranger remains the same, i.e. 7.
3. The strength of third ranger is updated to <image>, i.e. 11.
4. The strength of fourth ranger remains the same, i.e. 11.
5. The strength of fifth ranger is updated to <image>, i.e. 13.
The new strengths of the 5 rangers are [7, 7, 11, 11, 13]
Now, Jon wants to know the maximum and minimum strength of the rangers after performing the above operations k times. He wants your help for this task. Can you help him?
Input
First line consists of three integers n, k, x (1 ≤ n ≤ 105, 0 ≤ k ≤ 105, 0 ≤ x ≤ 103) — number of rangers Jon has, the number of times Jon will carry out the operation and Jon's favourite number respectively.
Second line consists of n integers representing the strengths of the rangers a1, a2, ..., an (0 ≤ ai ≤ 103).
Output
Output two integers, the maximum and the minimum strength of the rangers after performing the operation k times.
Examples
Input
5 1 2
9 7 11 15 5
Output
13 7
Input
2 100000 569
605 986
Output
986 605
Submitted Solution:
```
N, K, X = map(int, input().split())
a = list(map(int, input().split()))
M = 1024
dp = [0] * M
for i in range(N):
dp[a[i]] += 1
for k in range(K):
cnt = 0
tmp = dp.copy()
dp = [0] * M
for i in range(M):
d1, d2 = 0, 0
if tmp[i] % 2 == 0:
d1, d2 = tmp[i] // 2, tmp[i] // 2
else:
if cnt % 2 == 0:
d1 = tmp[i] // 2 + 1
d2 = tmp[i] // 2
else:
d1 = tmp[i] // 2
d2 = tmp[i] // 2 + 1
dp[i ^ X] += d1
dp[i] += d2
cnt += tmp[i]
ans = []
for i in range(M):
for j in range(dp[i]):
ans.append(i)
print(max(ans), min(ans))
``` | instruction | 0 | 70,370 | 2 | 140,740 |
Yes | output | 1 | 70,370 | 2 | 140,741 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. Jon now thinks that if he takes the bitwise XOR of strengths of some of rangers with his favourite number x, he might get soldiers of high strength. So, he decided to do the following operation k times:
1. Arrange all the rangers in a straight line in the order of increasing strengths.
2. Take the bitwise XOR (is written as <image>) of the strength of each alternate ranger with x and update it's strength.
Suppose, Jon has 5 rangers with strengths [9, 7, 11, 15, 5] and he performs the operation 1 time with x = 2. He first arranges them in the order of their strengths, [5, 7, 9, 11, 15]. Then he does the following:
1. The strength of first ranger is updated to <image>, i.e. 7.
2. The strength of second ranger remains the same, i.e. 7.
3. The strength of third ranger is updated to <image>, i.e. 11.
4. The strength of fourth ranger remains the same, i.e. 11.
5. The strength of fifth ranger is updated to <image>, i.e. 13.
The new strengths of the 5 rangers are [7, 7, 11, 11, 13]
Now, Jon wants to know the maximum and minimum strength of the rangers after performing the above operations k times. He wants your help for this task. Can you help him?
Input
First line consists of three integers n, k, x (1 ≤ n ≤ 105, 0 ≤ k ≤ 105, 0 ≤ x ≤ 103) — number of rangers Jon has, the number of times Jon will carry out the operation and Jon's favourite number respectively.
Second line consists of n integers representing the strengths of the rangers a1, a2, ..., an (0 ≤ ai ≤ 103).
Output
Output two integers, the maximum and the minimum strength of the rangers after performing the operation k times.
Examples
Input
5 1 2
9 7 11 15 5
Output
13 7
Input
2 100000 569
605 986
Output
986 605
Submitted Solution:
```
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase
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")
# ------------------- fast io --------------------
from math import ceil
def prod(a, mod=10 ** 9 + 7):
ans = 1
for each in a:
ans = (ans * each) % mod
return ans
def gcd(x, y):
while y:
x, y = y, x % y
return x
def lcm(a, b): return a * b // gcd(a, b)
def binary(x, length=16):
y = bin(x)[2:]
return y if len(y) >= length else "0" * (length - len(y)) + y
for _ in range(int(input()) if not True else 1):
#n = int(input())
n, k, x = map(int, input().split())
# a, b = map(int, input().split())
# c, d = map(int, input().split())
a = list(map(int, input().split()))
# b = list(map(int, input().split()))
# s = input()
lim = max(max(a), max(i ^ x for i in a)) + 1
count = [0] * lim
for i in a:count[i] += 1
for __ in range(k):
count2 = [0] * lim
cur = 0
for i in range(lim):
if count[i]:
y = count[i]
if cur:
count2[i] += 1
count[i] -= 1
count2[i ^ x] += (count[i] + 1) // 2
count2[i] += count[i] // 2
cur = (cur + y) % 2
count = list(count2)
m1, m2 = 0, 0
for i in range(len(count)):
if count[i]:
m1 = i
break
for i in range(len(count)-1,-1,-1):
if count[i]:
m2 = i
break
print(m2, m1)
``` | instruction | 0 | 70,371 | 2 | 140,742 |
Yes | output | 1 | 70,371 | 2 | 140,743 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. Jon now thinks that if he takes the bitwise XOR of strengths of some of rangers with his favourite number x, he might get soldiers of high strength. So, he decided to do the following operation k times:
1. Arrange all the rangers in a straight line in the order of increasing strengths.
2. Take the bitwise XOR (is written as <image>) of the strength of each alternate ranger with x and update it's strength.
Suppose, Jon has 5 rangers with strengths [9, 7, 11, 15, 5] and he performs the operation 1 time with x = 2. He first arranges them in the order of their strengths, [5, 7, 9, 11, 15]. Then he does the following:
1. The strength of first ranger is updated to <image>, i.e. 7.
2. The strength of second ranger remains the same, i.e. 7.
3. The strength of third ranger is updated to <image>, i.e. 11.
4. The strength of fourth ranger remains the same, i.e. 11.
5. The strength of fifth ranger is updated to <image>, i.e. 13.
The new strengths of the 5 rangers are [7, 7, 11, 11, 13]
Now, Jon wants to know the maximum and minimum strength of the rangers after performing the above operations k times. He wants your help for this task. Can you help him?
Input
First line consists of three integers n, k, x (1 ≤ n ≤ 105, 0 ≤ k ≤ 105, 0 ≤ x ≤ 103) — number of rangers Jon has, the number of times Jon will carry out the operation and Jon's favourite number respectively.
Second line consists of n integers representing the strengths of the rangers a1, a2, ..., an (0 ≤ ai ≤ 103).
Output
Output two integers, the maximum and the minimum strength of the rangers after performing the operation k times.
Examples
Input
5 1 2
9 7 11 15 5
Output
13 7
Input
2 100000 569
605 986
Output
986 605
Submitted Solution:
```
n, k, x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
p1, i = [], 0
while i < k:
a.sort()
p1 = a.copy()
for j in range(0, n, 2):
a[j] = a[j] ^ x
if n * k > 500000 and min(a) == p1[0] and max(a) == p1[-1]:
break
i += 1
print(max(a), min(a))
``` | instruction | 0 | 70,372 | 2 | 140,744 |
Yes | output | 1 | 70,372 | 2 | 140,745 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. Jon now thinks that if he takes the bitwise XOR of strengths of some of rangers with his favourite number x, he might get soldiers of high strength. So, he decided to do the following operation k times:
1. Arrange all the rangers in a straight line in the order of increasing strengths.
2. Take the bitwise XOR (is written as <image>) of the strength of each alternate ranger with x and update it's strength.
Suppose, Jon has 5 rangers with strengths [9, 7, 11, 15, 5] and he performs the operation 1 time with x = 2. He first arranges them in the order of their strengths, [5, 7, 9, 11, 15]. Then he does the following:
1. The strength of first ranger is updated to <image>, i.e. 7.
2. The strength of second ranger remains the same, i.e. 7.
3. The strength of third ranger is updated to <image>, i.e. 11.
4. The strength of fourth ranger remains the same, i.e. 11.
5. The strength of fifth ranger is updated to <image>, i.e. 13.
The new strengths of the 5 rangers are [7, 7, 11, 11, 13]
Now, Jon wants to know the maximum and minimum strength of the rangers after performing the above operations k times. He wants your help for this task. Can you help him?
Input
First line consists of three integers n, k, x (1 ≤ n ≤ 105, 0 ≤ k ≤ 105, 0 ≤ x ≤ 103) — number of rangers Jon has, the number of times Jon will carry out the operation and Jon's favourite number respectively.
Second line consists of n integers representing the strengths of the rangers a1, a2, ..., an (0 ≤ ai ≤ 103).
Output
Output two integers, the maximum and the minimum strength of the rangers after performing the operation k times.
Examples
Input
5 1 2
9 7 11 15 5
Output
13 7
Input
2 100000 569
605 986
Output
986 605
Submitted Solution:
```
f=lambda:[int(x) for x in input().split()]
n,k,x=f()
L=f()
L.sort()
L1=L.copy()
for j in range(len(L)):
if j%2==0:
L[j]=L[j]^x
if k%2==0:
print(str(max(L1))+" "+str(min(L1)))
else:
print(str(max(L))+" "+str(min(L)))
``` | instruction | 0 | 70,373 | 2 | 140,746 |
No | output | 1 | 70,373 | 2 | 140,747 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. Jon now thinks that if he takes the bitwise XOR of strengths of some of rangers with his favourite number x, he might get soldiers of high strength. So, he decided to do the following operation k times:
1. Arrange all the rangers in a straight line in the order of increasing strengths.
2. Take the bitwise XOR (is written as <image>) of the strength of each alternate ranger with x and update it's strength.
Suppose, Jon has 5 rangers with strengths [9, 7, 11, 15, 5] and he performs the operation 1 time with x = 2. He first arranges them in the order of their strengths, [5, 7, 9, 11, 15]. Then he does the following:
1. The strength of first ranger is updated to <image>, i.e. 7.
2. The strength of second ranger remains the same, i.e. 7.
3. The strength of third ranger is updated to <image>, i.e. 11.
4. The strength of fourth ranger remains the same, i.e. 11.
5. The strength of fifth ranger is updated to <image>, i.e. 13.
The new strengths of the 5 rangers are [7, 7, 11, 11, 13]
Now, Jon wants to know the maximum and minimum strength of the rangers after performing the above operations k times. He wants your help for this task. Can you help him?
Input
First line consists of three integers n, k, x (1 ≤ n ≤ 105, 0 ≤ k ≤ 105, 0 ≤ x ≤ 103) — number of rangers Jon has, the number of times Jon will carry out the operation and Jon's favourite number respectively.
Second line consists of n integers representing the strengths of the rangers a1, a2, ..., an (0 ≤ ai ≤ 103).
Output
Output two integers, the maximum and the minimum strength of the rangers after performing the operation k times.
Examples
Input
5 1 2
9 7 11 15 5
Output
13 7
Input
2 100000 569
605 986
Output
986 605
Submitted Solution:
```
a,b,c=map(int,input().split())
A=sorted(list(map(int,input().split())))
i=0;D=[]
while i<10:
A=[A[i]^c if not i%2 else A[i] for i in range(a)]
A.sort()
i+=1
if A in D:break
if i==b:
print(max(A),min(A));exit()
D.append(A)
A=A if not (b-i)%2 else [A[i]^c if not i%2 else A[i] for i in range(a)]
print(max(A),min(A))
``` | instruction | 0 | 70,374 | 2 | 140,748 |
No | output | 1 | 70,374 | 2 | 140,749 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. Jon now thinks that if he takes the bitwise XOR of strengths of some of rangers with his favourite number x, he might get soldiers of high strength. So, he decided to do the following operation k times:
1. Arrange all the rangers in a straight line in the order of increasing strengths.
2. Take the bitwise XOR (is written as <image>) of the strength of each alternate ranger with x and update it's strength.
Suppose, Jon has 5 rangers with strengths [9, 7, 11, 15, 5] and he performs the operation 1 time with x = 2. He first arranges them in the order of their strengths, [5, 7, 9, 11, 15]. Then he does the following:
1. The strength of first ranger is updated to <image>, i.e. 7.
2. The strength of second ranger remains the same, i.e. 7.
3. The strength of third ranger is updated to <image>, i.e. 11.
4. The strength of fourth ranger remains the same, i.e. 11.
5. The strength of fifth ranger is updated to <image>, i.e. 13.
The new strengths of the 5 rangers are [7, 7, 11, 11, 13]
Now, Jon wants to know the maximum and minimum strength of the rangers after performing the above operations k times. He wants your help for this task. Can you help him?
Input
First line consists of three integers n, k, x (1 ≤ n ≤ 105, 0 ≤ k ≤ 105, 0 ≤ x ≤ 103) — number of rangers Jon has, the number of times Jon will carry out the operation and Jon's favourite number respectively.
Second line consists of n integers representing the strengths of the rangers a1, a2, ..., an (0 ≤ ai ≤ 103).
Output
Output two integers, the maximum and the minimum strength of the rangers after performing the operation k times.
Examples
Input
5 1 2
9 7 11 15 5
Output
13 7
Input
2 100000 569
605 986
Output
986 605
Submitted Solution:
```
import sys
n,k,x = map(int, input().split())
a = sorted(list(map(int, input().split())))
b = []
b.append(a[0] ^ x)
for i in range(n):
v = a[i]
if( v != b[-1]):
v = a[i] ^x
b.append(v)
if k % 2 == 0:
print(max(a),min(a))
else:
print(max(b),min(b))
``` | instruction | 0 | 70,375 | 2 | 140,750 |
No | output | 1 | 70,375 | 2 | 140,751 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. Jon now thinks that if he takes the bitwise XOR of strengths of some of rangers with his favourite number x, he might get soldiers of high strength. So, he decided to do the following operation k times:
1. Arrange all the rangers in a straight line in the order of increasing strengths.
2. Take the bitwise XOR (is written as <image>) of the strength of each alternate ranger with x and update it's strength.
Suppose, Jon has 5 rangers with strengths [9, 7, 11, 15, 5] and he performs the operation 1 time with x = 2. He first arranges them in the order of their strengths, [5, 7, 9, 11, 15]. Then he does the following:
1. The strength of first ranger is updated to <image>, i.e. 7.
2. The strength of second ranger remains the same, i.e. 7.
3. The strength of third ranger is updated to <image>, i.e. 11.
4. The strength of fourth ranger remains the same, i.e. 11.
5. The strength of fifth ranger is updated to <image>, i.e. 13.
The new strengths of the 5 rangers are [7, 7, 11, 11, 13]
Now, Jon wants to know the maximum and minimum strength of the rangers after performing the above operations k times. He wants your help for this task. Can you help him?
Input
First line consists of three integers n, k, x (1 ≤ n ≤ 105, 0 ≤ k ≤ 105, 0 ≤ x ≤ 103) — number of rangers Jon has, the number of times Jon will carry out the operation and Jon's favourite number respectively.
Second line consists of n integers representing the strengths of the rangers a1, a2, ..., an (0 ≤ ai ≤ 103).
Output
Output two integers, the maximum and the minimum strength of the rangers after performing the operation k times.
Examples
Input
5 1 2
9 7 11 15 5
Output
13 7
Input
2 100000 569
605 986
Output
986 605
Submitted Solution:
```
def count_sort(massive):
global counts
global indexes
result_mas = []
for i,element in enumerate(indexes):
result_mas = result_mas + [element]*counts[element]
return result_mas
n, k, x = input().split()
n = int(n)
k = int(k)
x = int(x)
rangers = input().split()
for i, element in enumerate(rangers):
rangers[i] = int(element)
indexes = rangers[0:]
for element in rangers:
indexes.append(element^x)
indexes = list(set(indexes))
counts = [0]*1023
for element in rangers:
counts[element] += 1
for i in range (0,k):
rangers = count_sort(rangers)
for j in range (0,len(rangers),2):
new = rangers[j] ^ x
counts [rangers[j]] -= 1
rangers[j] = new
counts[new] += 1
maximum = max(rangers)
minimum = min(rangers)
print(maximum, minimum)
``` | instruction | 0 | 70,376 | 2 | 140,752 |
No | output | 1 | 70,376 | 2 | 140,753 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Roma is playing a new expansion for his favorite game World of Darkraft. He made a new character and is going for his first grind.
Roma has a choice to buy exactly one of n different weapons and exactly one of m different armor sets. Weapon i has attack modifier a_i and is worth ca_i coins, and armor set j has defense modifier b_j and is worth cb_j coins.
After choosing his equipment Roma can proceed to defeat some monsters. There are p monsters he can try to defeat. Monster k has defense x_k, attack y_k and possesses z_k coins. Roma can defeat a monster if his weapon's attack modifier is larger than the monster's defense, and his armor set's defense modifier is larger than the monster's attack. That is, a monster k can be defeated with a weapon i and an armor set j if a_i > x_k and b_j > y_k. After defeating the monster, Roma takes all the coins from them. During the grind, Roma can defeat as many monsters as he likes. Monsters do not respawn, thus each monster can be defeated at most one.
Thanks to Roma's excessive donations, we can assume that he has an infinite amount of in-game currency and can afford any of the weapons and armor sets. Still, he wants to maximize the profit of the grind. The profit is defined as the total coins obtained from all defeated monsters minus the cost of his equipment. Note that Roma must purchase a weapon and an armor set even if he can not cover their cost with obtained coins.
Help Roma find the maximum profit of the grind.
Input
The first line contains three integers n, m, and p (1 ≤ n, m, p ≤ 2 ⋅ 10^5) — the number of available weapons, armor sets and monsters respectively.
The following n lines describe available weapons. The i-th of these lines contains two integers a_i and ca_i (1 ≤ a_i ≤ 10^6, 1 ≤ ca_i ≤ 10^9) — the attack modifier and the cost of the weapon i.
The following m lines describe available armor sets. The j-th of these lines contains two integers b_j and cb_j (1 ≤ b_j ≤ 10^6, 1 ≤ cb_j ≤ 10^9) — the defense modifier and the cost of the armor set j.
The following p lines describe monsters. The k-th of these lines contains three integers x_k, y_k, z_k (1 ≤ x_k, y_k ≤ 10^6, 1 ≤ z_k ≤ 10^3) — defense, attack and the number of coins of the monster k.
Output
Print a single integer — the maximum profit of the grind.
Example
Input
2 3 3
2 3
4 7
2 4
3 2
5 11
1 2 4
2 1 6
3 4 6
Output
1 | instruction | 0 | 70,878 | 2 | 141,756 |
Tags: brute force, data structures, sortings
Correct Solution:
```
from bisect import bisect_right
from operator import itemgetter
# quick input by @pajenegod
import io,os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
class SegmTree:
def __init__(self, size):
N = 1
h = 0
while N < size:
N <<= 1
h += 1
self.N = N
self.h = h
self.t = [0] * (2 * N)
self.d = [0] * N
def apply(self, p, value):
self.t[p] += value
if (p < self.N):
self.d[p] += value
def build(self, p):
t = self.t
d = self.d
while p > 1:
p >>= 1
t[p] = max(t[p<<1], t[p<<1|1]) + d[p]
def rebuild(self):
t = self.t
for p in reversed(range(1, self.N)):
t[p] = max(t[p<<1], t[p<<1|1])
def push(self, p):
d = self.d
for s in range(self.h, 0, -1):
i = p >> s
if d[i] != 0:
self.apply(i<<1, d[i])
self.apply(i<<1|1, d[i])
d[i] = 0
def inc(self, l, r, value):
if l >= r:
return
l += self.N
r += self.N
l0, r0 = l, r
while l < r:
if l & 1:
self.apply(l, value)
l += 1
if r & 1:
r -= 1
self.apply(r, value)
l >>= 1
r >>= 1
self.build(l0)
self.build(r0 - 1)
def query(self, l, r):
if l >= r:
return -float('inf')
t = self.t
l += self.N
r += self.N
self.push(l)
self.push(r - 1)
res = -float('inf')
while l < r:
if l & 1:
res = max(res, t[l])
l += 1
if r & 1:
r -= 1
res = max(t[r], res)
l >>= 1
r >>= 1
return res
n, m, p = map(int, input().split())
weapon = []
for _ in range(n):
a, ca = map(int, input().split())
weapon.append((a, ca))
defense = []
for _ in range(m):
b, cb = map(int, input().split())
defense.append((b, cb))
monster = []
for _ in range(p):
x, y, z = map(int, input().split())
monster.append((x, y, z))
weapon.sort(key=itemgetter(0))
defense.sort(key=itemgetter(0))
monster.sort(key=itemgetter(0))
st = SegmTree(m)
N = st.N
t = st.t
for i, (b, cb) in enumerate(defense):
t[i + N] = -cb
st.rebuild()
i = 0
maxScore = -float('inf')
for a, ca in weapon:
st.inc(0, m, -ca)
while i < p and monster[i][0] < a:
x, y, z = monster[i]
goodDef = bisect_right(defense, (y + 1, 0))
st.inc(goodDef, m, z)
i += 1
currScore = st.query(0, m)
maxScore = max(maxScore, currScore)
st.inc(0, m, ca)
print(maxScore)
``` | output | 1 | 70,878 | 2 | 141,757 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Roma is playing a new expansion for his favorite game World of Darkraft. He made a new character and is going for his first grind.
Roma has a choice to buy exactly one of n different weapons and exactly one of m different armor sets. Weapon i has attack modifier a_i and is worth ca_i coins, and armor set j has defense modifier b_j and is worth cb_j coins.
After choosing his equipment Roma can proceed to defeat some monsters. There are p monsters he can try to defeat. Monster k has defense x_k, attack y_k and possesses z_k coins. Roma can defeat a monster if his weapon's attack modifier is larger than the monster's defense, and his armor set's defense modifier is larger than the monster's attack. That is, a monster k can be defeated with a weapon i and an armor set j if a_i > x_k and b_j > y_k. After defeating the monster, Roma takes all the coins from them. During the grind, Roma can defeat as many monsters as he likes. Monsters do not respawn, thus each monster can be defeated at most one.
Thanks to Roma's excessive donations, we can assume that he has an infinite amount of in-game currency and can afford any of the weapons and armor sets. Still, he wants to maximize the profit of the grind. The profit is defined as the total coins obtained from all defeated monsters minus the cost of his equipment. Note that Roma must purchase a weapon and an armor set even if he can not cover their cost with obtained coins.
Help Roma find the maximum profit of the grind.
Input
The first line contains three integers n, m, and p (1 ≤ n, m, p ≤ 2 ⋅ 10^5) — the number of available weapons, armor sets and monsters respectively.
The following n lines describe available weapons. The i-th of these lines contains two integers a_i and ca_i (1 ≤ a_i ≤ 10^6, 1 ≤ ca_i ≤ 10^9) — the attack modifier and the cost of the weapon i.
The following m lines describe available armor sets. The j-th of these lines contains two integers b_j and cb_j (1 ≤ b_j ≤ 10^6, 1 ≤ cb_j ≤ 10^9) — the defense modifier and the cost of the armor set j.
The following p lines describe monsters. The k-th of these lines contains three integers x_k, y_k, z_k (1 ≤ x_k, y_k ≤ 10^6, 1 ≤ z_k ≤ 10^3) — defense, attack and the number of coins of the monster k.
Output
Print a single integer — the maximum profit of the grind.
Example
Input
2 3 3
2 3
4 7
2 4
3 2
5 11
1 2 4
2 1 6
3 4 6
Output
1 | instruction | 0 | 70,879 | 2 | 141,758 |
Tags: brute force, data structures, sortings
Correct Solution:
```
# quick input by @c1729 and @pajenegod
import io,os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
from bisect import bisect_right
from operator import itemgetter
class SegmTree:
'''
- increment on interval
- get max on interval
'''
def __init__(self, size):
N = 1
h = 0
while N < size:
N <<= 1
h += 1
self.N = N
self.h = h
self.t = [0] * (2 * N)
self.d = [0] * N
def apply(self, p, value):
self.t[p] += value
if p < self.N:
self.d[p] += value
def build(self, p):
t = self.t
d = self.d
while p > 1:
p >>= 1
t[p] = max(t[p<<1], t[p<<1|1]) + d[p]
def rebuild(self):
t = self.t
for p in reversed(range(1, self.N)):
t[p] = max(t[p<<1], t[p<<1|1])
def push(self, p):
d = self.d
for s in range(self.h, 0, -1):
i = p >> s
if d[i] != 0:
self.apply(i<<1, d[i])
self.apply(i<<1|1, d[i])
d[i] = 0
def inc(self, l, r, value):
if l >= r:
return
l += self.N
r += self.N
l0, r0 = l, r
while l < r:
if l & 1:
self.apply(l, value)
l += 1
if r & 1:
r -= 1
self.apply(r, value)
l >>= 1
r >>= 1
self.build(l0)
self.build(r0 - 1)
def query(self, l, r):
if l >= r:
return -float('inf')
t = self.t
l += self.N
r += self.N
self.push(l)
self.push(r - 1)
res = -float('inf')
while l < r:
if l & 1:
res = max(res, t[l])
l += 1
if r & 1:
r -= 1
res = max(t[r], res)
l >>= 1
r >>= 1
return res
n, m, p = map(int, input().split())
weapon = []
for _ in range(n):
a, ca = map(int, input().split())
# a, ca = n - _, n - _
weapon.append((a, ca))
defense = []
for _ in range(m):
b, cb = map(int, input().split())
# b, cb = m - _, m - _
defense.append((b, cb))
monster = []
for _ in range(p):
x, y, z = map(int, input().split())
# x, y, z = p - _, p - _, p - _
monster.append((x, y, z))
weapon.sort(key=itemgetter(0))
defense.sort(key=itemgetter(0))
monster.sort(key=itemgetter(0))
# store score of each defense item
st = SegmTree(m)
N, t = st.N, st.t
for i, (b, cb) in enumerate(defense):
t[i + N] = -cb
st.rebuild()
i = 0
maxScore = -float('inf')
for a, ca in weapon:
st.inc(0, m, -ca)
while i < p and monster[i][0] < a:
x, y, z = monster[i]
goodDef = bisect_right(defense, (y + 1, 0))
st.inc(goodDef, m, z)
i += 1
currScore = st.query(0, m)
maxScore = max(maxScore, currScore)
st.inc(0, m, ca)
print(maxScore)
``` | output | 1 | 70,879 | 2 | 141,759 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Roma is playing a new expansion for his favorite game World of Darkraft. He made a new character and is going for his first grind.
Roma has a choice to buy exactly one of n different weapons and exactly one of m different armor sets. Weapon i has attack modifier a_i and is worth ca_i coins, and armor set j has defense modifier b_j and is worth cb_j coins.
After choosing his equipment Roma can proceed to defeat some monsters. There are p monsters he can try to defeat. Monster k has defense x_k, attack y_k and possesses z_k coins. Roma can defeat a monster if his weapon's attack modifier is larger than the monster's defense, and his armor set's defense modifier is larger than the monster's attack. That is, a monster k can be defeated with a weapon i and an armor set j if a_i > x_k and b_j > y_k. After defeating the monster, Roma takes all the coins from them. During the grind, Roma can defeat as many monsters as he likes. Monsters do not respawn, thus each monster can be defeated at most one.
Thanks to Roma's excessive donations, we can assume that he has an infinite amount of in-game currency and can afford any of the weapons and armor sets. Still, he wants to maximize the profit of the grind. The profit is defined as the total coins obtained from all defeated monsters minus the cost of his equipment. Note that Roma must purchase a weapon and an armor set even if he can not cover their cost with obtained coins.
Help Roma find the maximum profit of the grind.
Input
The first line contains three integers n, m, and p (1 ≤ n, m, p ≤ 2 ⋅ 10^5) — the number of available weapons, armor sets and monsters respectively.
The following n lines describe available weapons. The i-th of these lines contains two integers a_i and ca_i (1 ≤ a_i ≤ 10^6, 1 ≤ ca_i ≤ 10^9) — the attack modifier and the cost of the weapon i.
The following m lines describe available armor sets. The j-th of these lines contains two integers b_j and cb_j (1 ≤ b_j ≤ 10^6, 1 ≤ cb_j ≤ 10^9) — the defense modifier and the cost of the armor set j.
The following p lines describe monsters. The k-th of these lines contains three integers x_k, y_k, z_k (1 ≤ x_k, y_k ≤ 10^6, 1 ≤ z_k ≤ 10^3) — defense, attack and the number of coins of the monster k.
Output
Print a single integer — the maximum profit of the grind.
Example
Input
2 3 3
2 3
4 7
2 4
3 2
5 11
1 2 4
2 1 6
3 4 6
Output
1
Submitted Solution:
```
# quick input
import io,os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
from operator import itemgetter
from bisect import bisect_right
class SegmTree:
def __init__(self, size):
N = 1
h = 0
while N < size:
N <<= 1
h += 1
self.N = N
self.h = h
self.t = [0] * (2 * N)
self.d = [0] * N
def apply(self, p, value):
self.t[p] += value
if (p < self.N):
self.d[p] += value
def build(self, p):
t = self.t
d = self.d
while p > 1:
p >>= 1
t[p] = max(t[p<<1], t[p<<1|1]) + d[p]
def rebuild(self):
t = self.t
for p in reversed(range(1, self.N)):
t[p] = max(t[p<<1], t[p<<1|1])
def push(self, p):
d = self.d
for s in range(self.h, 0, -1):
i = p >> s
if d[i] != 0:
self.apply(i<<1, d[i])
self.apply(i<<1|1, d[i])
d[i] = 0
def inc(self, l, r, value):
l += self.N
r += self.N
l0, r0 = l, r
while l < r:
if l & 1:
self.apply(l, value)
l += 1
if r & 1:
r -= 1
self.apply(r, value)
l >>= 1
r >>= 1
self.build(l0)
self.build(r0 - 1)
def query(self, l, r):
t = self.t
l += self.N
r += self.N
self.push(l)
self.push(r - 1)
res = -float('inf')
while l < r:
if l & 1:
res = max(res, t[l])
l += 1
if r & 1:
r -= 1
res = max(t[r], res)
l >>= 1
r >>= 1
return res
n, m, p = map(int, input().split())
weapon = []
for _ in range(n):
a, ca = map(int, input().split())
# a, ca = n - _, n - _
weapon.append((a, ca))
defense = []
for _ in range(m):
b, cb = map(int, input().split())
# b, cb = m - _, m - _
defense.append((b, cb))
monster = []
for _ in range(p):
x, y, z = map(int, input().split())
# x, y, z = p - _, p - _, p - _
monster.append((x, y, z))
weapon.sort(key=itemgetter(0))
defense.sort(key=itemgetter(0))
monster.sort(key=itemgetter(0))
st = SegmTree(m)
N = st.N
t = st.t
for i, (b, cb) in enumerate(defense):
t[i + N] = -cb
st.rebuild()
i = 0
maxScore = -float('inf')
for a, ca in weapon:
st.inc(0, m, -ca)
while i < p and monster[i][0] < a:
x, y, z = monster[i]
goodDef = bisect_right(defense, (y, 0))
st.inc(goodDef, m, z)
i += 1
currScore = st.query(0, m)
maxScore = max(maxScore, currScore)
st.inc(0, m, ca)
print(maxScore)
``` | instruction | 0 | 70,880 | 2 | 141,760 |
No | output | 1 | 70,880 | 2 | 141,761 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Imp is in a magic forest, where xorangles grow (wut?)
<image>
A xorangle of order n is such a non-degenerate triangle, that lengths of its sides are integers not exceeding n, and the xor-sum of the lengths is equal to zero. Imp has to count the number of distinct xorangles of order n to get out of the forest.
Formally, for a given integer n you have to find the number of such triples (a, b, c), that:
* 1 ≤ a ≤ b ≤ c ≤ n;
* <image>, where <image> denotes the [bitwise xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of integers x and y.
* (a, b, c) form a non-degenerate (with strictly positive area) triangle.
Input
The only line contains a single integer n (1 ≤ n ≤ 2500).
Output
Print the number of xorangles of order n.
Examples
Input
6
Output
1
Input
10
Output
2
Note
The only xorangle in the first sample is (3, 5, 6). | instruction | 0 | 71,340 | 2 | 142,680 |
Tags: brute force
Correct Solution:
```
import io
import os
import math
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n = int(input())
def validtriangle(a, b, c):
if c < a+b and a < c+b and b < c+a:
return True
return False
def herons(a, b, c):
s = (a + b + c) / 2
area = (math.sqrt(s * (s - a) * (s - b) * (s - c)))
if area > 0:
return True
return False
cnt = 0
for x in range(n):
for y in range(x, n):
z = x^y
if validtriangle(x, y, z) and y<=z<=n and herons(x, y, z):
cnt += 1
#print(x, y, z)
print(cnt)
``` | output | 1 | 71,340 | 2 | 142,681 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Imp is in a magic forest, where xorangles grow (wut?)
<image>
A xorangle of order n is such a non-degenerate triangle, that lengths of its sides are integers not exceeding n, and the xor-sum of the lengths is equal to zero. Imp has to count the number of distinct xorangles of order n to get out of the forest.
Formally, for a given integer n you have to find the number of such triples (a, b, c), that:
* 1 ≤ a ≤ b ≤ c ≤ n;
* <image>, where <image> denotes the [bitwise xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of integers x and y.
* (a, b, c) form a non-degenerate (with strictly positive area) triangle.
Input
The only line contains a single integer n (1 ≤ n ≤ 2500).
Output
Print the number of xorangles of order n.
Examples
Input
6
Output
1
Input
10
Output
2
Note
The only xorangle in the first sample is (3, 5, 6). | instruction | 0 | 71,341 | 2 | 142,682 |
Tags: brute force
Correct Solution:
```
l = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 5, 7, 10, 10, 10, 10, 11, 11, 14, 16, 19, 19, 26, 32, 39, 43, 52, 58, 65, 65, 65, 65, 66, 66, 69, 71, 74, 74, 81, 87, 94, 98, 107, 113, 120, 120, 135, 149, 164, 176, 193, 207, 222, 230, 251, 269, 288, 300, 321, 335, 350, 350, 350, 350, 351, 351, 354, 356, 359, 359, 366, 372, 379, 383, 392, 398, 405, 405, 420, 434, 449, 461, 478, 492, 507, 515, 536, 554, 573, 585, 606, 620, 635, 635, 666, 696, 727, 755, 788, 818, 849, 873, 910, 944, 979, 1007, 1044, 1074, 1105, 1121, 1166, 1208, 1251, 1287, 1332, 1370, 1409, 1433, 1482, 1524, 1567, 1595, 1640, 1670, 1701, 1701, 1701, 1701, 1702, 1702, 1705, 1707, 1710, 1710, 1717, 1723, 1730, 1734, 1743, 1749, 1756, 1756, 1771, 1785, 1800, 1812, 1829, 1843, 1858, 1866, 1887, 1905, 1924, 1936, 1957, 1971, 1986, 1986, 2017, 2047, 2078, 2106, 2139, 2169, 2200, 2224, 2261, 2295, 2330, 2358, 2395, 2425, 2456, 2472, 2517, 2559, 2602, 2638, 2683, 2721, 2760, 2784, 2833, 2875, 2918, 2946, 2991, 3021, 3052, 3052, 3115, 3177, 3240, 3300, 3365, 3427, 3490, 3546, 3615, 3681, 3748, 3808, 3877, 3939, 4002, 4050, 4127, 4201, 4276, 4344, 4421, 4491, 4562, 4618, 4699, 4773, 4848, 4908, 4985, 5047, 5110, 5142, 5235, 5325, 5416, 5500, 5593, 5679, 5766, 5838, 5935, 6025, 6116, 6192, 6285, 6363, 6442, 6490, 6595, 6693, 6792, 6876, 6977, 7063, 7150, 7206, 7311, 7401, 7492, 7552, 7645, 7707, 7770, 7770, 7770, 7770, 7771, 7771, 7774, 7776, 7779, 7779, 7786, 7792, 7799, 7803, 7812, 7818, 7825, 7825, 7840, 7854, 7869, 7881, 7898, 7912, 7927, 7935, 7956, 7974, 7993, 8005, 8026, 8040, 8055, 8055, 8086, 8116, 8147, 8175, 8208, 8238, 8269, 8293, 8330, 8364, 8399, 8427, 8464, 8494, 8525, 8541, 8586, 8628, 8671, 8707, 8752, 8790, 8829, 8853, 8902, 8944, 8987, 9015, 9060, 9090, 9121, 9121, 9184, 9246, 9309, 9369, 9434, 9496, 9559, 9615, 9684, 9750, 9817, 9877, 9946, 10008, 10071, 10119, 10196, 10270, 10345, 10413, 10490, 10560, 10631, 10687, 10768, 10842, 10917, 10977, 11054, 11116, 11179, 11211, 11304, 11394, 11485, 11569, 11662, 11748, 11835, 11907, 12004, 12094, 12185, 12261, 12354, 12432, 12511, 12559, 12664, 12762, 12861, 12945, 13046, 13132, 13219, 13275, 13380, 13470, 13561, 13621, 13714, 13776, 13839, 13839, 13966, 14092, 14219, 14343, 14472, 14598, 14725, 14845, 14978, 15108, 15239, 15363, 15496, 15622, 15749, 15861, 16002, 16140, 16279, 16411, 16552, 16686, 16821, 16941, 17086, 17224, 17363, 17487, 17628, 17754, 17881, 17977, 18134, 18288, 18443, 18591, 18748, 18898, 19049, 19185, 19346, 19500, 19655, 19795, 19952, 20094, 20237, 20349, 20518, 20680, 20843, 20991, 21156, 21306, 21457, 21577, 21746, 21900, 22055, 22179, 22336, 22462, 22589, 22653, 22842, 23028, 23215, 23395, 23584, 23766, 23949, 24117, 24310, 24496, 24683, 24855, 25044, 25218, 25393, 25537, 25738, 25932, 26127, 26307, 26504, 26686, 26869, 27021, 27222, 27408, 27595, 27751, 27940, 28098, 28257, 28353, 28570, 28780, 28991, 29187, 29400, 29598, 29797, 29965, 30182, 30384, 30587, 30759, 30964, 31138, 31313, 31425, 31650, 31860, 32071, 32251, 32464, 32646, 32829, 32949, 33166, 33352, 33539, 33663, 33852, 33978, 34105, 34105, 34105, 34105, 34106, 34106, 34109, 34111, 34114, 34114, 34121, 34127, 34134, 34138, 34147, 34153, 34160, 34160, 34175, 34189, 34204, 34216, 34233, 34247, 34262, 34270, 34291, 34309, 34328, 34340, 34361, 34375, 34390, 34390, 34421, 34451, 34482, 34510, 34543, 34573, 34604, 34628, 34665, 34699, 34734, 34762, 34799, 34829, 34860, 34876, 34921, 34963, 35006, 35042, 35087, 35125, 35164, 35188, 35237, 35279, 35322, 35350, 35395, 35425, 35456, 35456, 35519, 35581, 35644, 35704, 35769, 35831, 35894, 35950, 36019, 36085, 36152, 36212, 36281, 36343, 36406, 36454, 36531, 36605, 36680, 36748, 36825, 36895, 36966, 37022, 37103, 37177, 37252, 37312, 37389, 37451, 37514, 37546, 37639, 37729, 37820, 37904, 37997, 38083, 38170, 38242, 38339, 38429, 38520, 38596, 38689, 38767, 38846, 38894, 38999, 39097, 39196, 39280, 39381, 39467, 39554, 39610, 39715, 39805, 39896, 39956, 40049, 40111, 40174, 40174, 40301, 40427, 40554, 40678, 40807, 40933, 41060, 41180, 41313, 41443, 41574, 41698, 41831, 41957, 42084, 42196, 42337, 42475, 42614, 42746, 42887, 43021, 43156, 43276, 43421, 43559, 43698, 43822, 43963, 44089, 44216, 44312, 44469, 44623, 44778, 44926, 45083, 45233, 45384, 45520, 45681, 45835, 45990, 46130, 46287, 46429, 46572, 46684, 46853, 47015, 47178, 47326, 47491, 47641, 47792, 47912, 48081, 48235, 48390, 48514, 48671, 48797, 48924, 48988, 49177, 49363, 49550, 49730, 49919, 50101, 50284, 50452, 50645, 50831, 51018, 51190, 51379, 51553, 51728, 51872, 52073, 52267, 52462, 52642, 52839, 53021, 53204, 53356, 53557, 53743, 53930, 54086, 54275, 54433, 54592, 54688, 54905, 55115, 55326, 55522, 55735, 55933, 56132, 56300, 56517, 56719, 56922, 57094, 57299, 57473, 57648, 57760, 57985, 58195, 58406, 58586, 58799, 58981, 59164, 59284, 59501, 59687, 59874, 59998, 60187, 60313, 60440, 60440, 60695, 60949, 61204, 61456, 61713, 61967, 62222, 62470, 62731, 62989, 63248, 63500, 63761, 64015, 64270, 64510, 64779, 65045, 65312, 65572, 65841, 66103, 66366, 66614, 66887, 67153, 67420, 67672, 67941, 68195, 68450, 68674, 68959, 69241, 69524, 69800, 70085, 70363, 70642, 70906, 71195, 71477, 71760, 72028, 72313, 72583, 72854, 73094, 73391, 73681, 73972, 74248, 74541, 74819, 75098, 75346, 75643, 75925, 76208, 76460, 76745, 76999, 77254, 77446, 77763, 78077, 78392, 78700, 79017, 79327, 79638, 79934, 80255, 80569, 80884, 81184, 81501, 81803, 82106, 82378, 82707, 83029, 83352, 83660, 83985, 84295, 84606, 84886, 85215, 85529, 85844, 86128, 86445, 86731, 87018, 87242, 87587, 87925, 88264, 88588, 88929, 89255, 89582, 89878, 90223, 90553, 90884, 91184, 91517, 91819, 92122, 92362, 92715, 93053, 93392, 93700, 94041, 94351, 94662, 94910, 95255, 95569, 95884, 96136, 96453, 96707, 96962, 97090, 97471, 97849, 98228, 98600, 98981, 99355, 99730, 100090, 100475, 100853, 101232, 101596, 101977, 102343, 102710, 103046, 103439, 103825, 104212, 104584, 104973, 105347, 105722, 106066, 106459, 106837, 107216, 107564, 107945, 108295, 108646, 108934, 109343, 109745, 110148, 110536, 110941, 111331, 111722, 112082, 112491, 112885, 113280, 113644, 114041, 114407, 114774, 115078, 115495, 115897, 116300, 116672, 117077, 117451, 117826, 118138, 118547, 118925, 119304, 119620, 120001, 120319, 120638, 120830, 121271, 121705, 122140, 122560, 122997, 123419, 123842, 124234, 124675, 125101, 125528, 125924, 126353, 126751, 127150, 127486, 127935, 128369, 128804, 129208, 129645, 130051, 130458, 130802, 131243, 131653, 132064, 132412, 132825, 133175, 133526, 133750, 134215, 134665, 135116, 135536, 135989, 136411, 136834, 137194, 137651, 138077, 138504, 138868, 139297, 139663, 140030, 140270, 140735, 141169, 141604, 141976, 142413, 142787, 143162, 143410, 143851, 144229, 144608, 144860, 145241, 145495, 145750, 145750, 145750, 145750, 145751, 145751, 145754, 145756, 145759, 145759, 145766, 145772, 145779, 145783, 145792, 145798, 145805, 145805, 145820, 145834, 145849, 145861, 145878, 145892, 145907, 145915, 145936, 145954, 145973, 145985, 146006, 146020, 146035, 146035, 146066, 146096, 146127, 146155, 146188, 146218, 146249, 146273, 146310, 146344, 146379, 146407, 146444, 146474, 146505, 146521, 146566, 146608, 146651, 146687, 146732, 146770, 146809, 146833, 146882, 146924, 146967, 146995, 147040, 147070, 147101, 147101, 147164, 147226, 147289, 147349, 147414, 147476, 147539, 147595, 147664, 147730, 147797, 147857, 147926, 147988, 148051, 148099, 148176, 148250, 148325, 148393, 148470, 148540, 148611, 148667, 148748, 148822, 148897, 148957, 149034, 149096, 149159, 149191, 149284, 149374, 149465, 149549, 149642, 149728, 149815, 149887, 149984, 150074, 150165, 150241, 150334, 150412, 150491, 150539, 150644, 150742, 150841, 150925, 151026, 151112, 151199, 151255, 151360, 151450, 151541, 151601, 151694, 151756, 151819, 151819, 151946, 152072, 152199, 152323, 152452, 152578, 152705, 152825, 152958, 153088, 153219, 153343, 153476, 153602, 153729, 153841, 153982, 154120, 154259, 154391, 154532, 154666, 154801, 154921, 155066, 155204, 155343, 155467, 155608, 155734, 155861, 155957, 156114, 156268, 156423, 156571, 156728, 156878, 157029, 157165, 157326, 157480, 157635, 157775, 157932, 158074, 158217, 158329, 158498, 158660, 158823, 158971, 159136, 159286, 159437, 159557, 159726, 159880, 160035, 160159, 160316, 160442, 160569, 160633, 160822, 161008, 161195, 161375, 161564, 161746, 161929, 162097, 162290, 162476, 162663, 162835, 163024, 163198, 163373, 163517, 163718, 163912, 164107, 164287, 164484, 164666, 164849, 165001, 165202, 165388, 165575, 165731, 165920, 166078, 166237, 166333, 166550, 166760, 166971, 167167, 167380, 167578, 167777, 167945, 168162, 168364, 168567, 168739, 168944, 169118, 169293, 169405, 169630, 169840, 170051, 170231, 170444, 170626, 170809, 170929, 171146, 171332, 171519, 171643, 171832, 171958, 172085, 172085, 172340, 172594, 172849, 173101, 173358, 173612, 173867, 174115, 174376, 174634, 174893, 175145, 175406, 175660, 175915, 176155, 176424, 176690, 176957, 177217, 177486, 177748, 178011, 178259, 178532, 178798, 179065, 179317, 179586, 179840, 180095, 180319, 180604, 180886, 181169, 181445, 181730, 182008, 182287, 182551, 182840, 183122, 183405, 183673, 183958, 184228, 184499, 184739, 185036, 185326, 185617, 185893, 186186, 186464, 186743, 186991, 187288, 187570, 187853, 188105, 188390, 188644, 188899, 189091, 189408, 189722, 190037, 190345, 190662, 190972, 191283, 191579, 191900, 192214, 192529, 192829, 193146, 193448, 193751, 194023, 194352, 194674, 194997, 195305, 195630, 195940, 196251, 196531, 196860, 197174, 197489, 197773, 198090, 198376, 198663, 198887, 199232, 199570, 199909, 200233, 200574, 200900, 201227, 201523, 201868, 202198, 202529, 202829, 203162, 203464, 203767, 204007, 204360, 204698, 205037, 205345, 205686, 205996, 206307, 206555, 206900, 207214, 207529, 207781, 208098, 208352, 208607, 208735, 209116, 209494, 209873, 210245, 210626, 211000, 211375, 211735, 212120, 212498, 212877, 213241, 213622, 213988, 214355, 214691, 215084, 215470, 215857, 216229, 216618, 216992, 217367, 217711, 218104, 218482, 218861, 219209, 219590, 219940, 220291, 220579, 220988, 221390, 221793, 222181, 222586, 222976, 223367, 223727, 224136, 224530, 224925, 225289, 225686, 226052, 226419, 226723, 227140, 227542, 227945, 228317, 228722, 229096, 229471, 229783, 230192, 230570, 230949, 231265, 231646, 231964, 232283, 232475, 232916, 233350, 233785, 234205, 234642, 235064, 235487, 235879, 236320, 236746, 237173, 237569, 237998, 238396, 238795, 239131, 239580, 240014, 240449, 240853, 241290, 241696, 242103, 242447, 242888, 243298, 243709, 244057, 244470, 244820, 245171, 245395, 245860, 246310, 246761, 247181, 247634, 248056, 248479, 248839, 249296, 249722, 250149, 250513, 250942, 251308, 251675, 251915, 252380, 252814, 253249, 253621, 254058, 254432, 254807, 255055, 255496, 255874, 256253, 256505, 256886, 257140, 257395, 257395, 257906, 258416, 258927, 259435, 259948, 260458, 260969, 261473, 261990, 262504, 263019, 263527, 264044, 264554, 265065, 265561, 266086, 266608, 267131, 267647, 268172, 268690, 269209, 269713, 270242, 270764, 271287, 271795, 272320, 272830, 273341, 273821, 274362, 274900, 275439, 275971, 276512, 277046, 277581, 278101, 278646, 279184, 279723, 280247, 280788, 281314, 281841, 282337, 282890, 283436, 283983, 284515, 285064, 285598, 286133, 286637, 287190, 287728, 288267, 288775, 289316, 289826, 290337, 290785, 291358, 291928, 292499, 293063, 293636, 294202, 294769, 295321, 295898, 296468, 297039, 297595, 298168, 298726, 299285, 299813, 300398, 300976, 301555, 302119, 302700, 303266, 303833, 304369, 304954, 305524, 306095, 306635, 307208, 307750, 308293, 308773, 309374, 309968, 310563, 311143, 311740, 312322, 312905, 313457, 314058, 314644, 315231, 315787, 316376, 316934, 317493, 317989, 318598, 319192, 319787, 320351, 320948, 321514, 322081, 322585, 323186, 323756, 324327, 324835, 325408, 325918, 326429, 326813, 327450, 328084, 328719, 329347, 329984, 330614, 331245, 331861, 332502, 333136, 333771, 334391, 335028, 335650, 336273, 336865, 337514, 338156, 338799, 339427, 340072, 340702, 341333, 341933, 342582, 343216, 343851, 344455, 345092, 345698, 346305, 346849, 347514, 348172, 348831, 349475, 350136, 350782, 351429, 352045, 352710, 353360, 354011, 354631, 355284, 355906, 356529, 357089, 357762, 358420, 359079, 359707, 360368, 360998, 361629, 362197, 362862, 363496, 364131, 364703, 365340, 365914, 366489, 366937, 367634, 368324, 369015, 369691, 370384, 371062, 371741, 372389, 373086, 373768, 374451, 375103, 375788, 376442, 377097, 377689, 378394, 379084, 379775, 380435, 381128, 381790, 382453, 383053, 383750, 384416, 385083, 385687, 386356, 386962, 387569, 388049, 388770, 389476, 390183, 390859, 391568, 392246, 392925, 393541, 394254, 394936, 395619, 396239, 396924, 397546, 398169, 398665, 399386, 400076, 400767, 401395, 402088, 402718, 403349, 403853, 404550, 405184, 405819, 406327, 406964, 407474, 407985, 408241, 409006, 409768, 410531, 411287, 412052, 412810, 413569, 414313, 415082, 415844, 416607, 417355, 418120, 418870, 419621, 420341, 421118, 421888, 422659, 423415, 424188, 424946, 425705, 426433, 427210, 427972, 428735, 429467, 430232, 430966, 431701, 432373, 433166, 433952, 434739, 435511, 436300, 437074, 437849, 438593, 439386, 440164, 440943, 441691, 442472, 443222, 443973, 444661, 445462, 446248, 447035, 447791, 448580, 449338, 450097, 450793, 451586, 452348, 453111, 453811, 454576, 455278, 455981, 456557, 457382, 458200, 459019, 459823, 460644, 461450, 462257, 463033, 463858, 464668, 465479, 466259, 467072, 467854, 468637, 469357, 470190, 471008, 471827, 472615, 473436, 474226, 475017, 475745, 476570, 477364, 478159, 478891, 479688, 480422, 481157, 481765, 482614, 483448, 484283, 485087, 485924, 486730, 487537, 488281, 489122, 489932, 490743, 491491, 492304, 493054, 493805, 494429, 495278, 496096, 496915, 497671, 498492, 499250, 500009, 500641, 501466, 502228, 502991, 503627, 504392, 505030, 505669, 506053, 506942, 507824, 508707, 509575, 510460, 511330, 512201, 513041, 513930, 514804, 515679, 516523, 517400, 518246, 519093, 519877, 520774, 521656, 522539, 523391, 524276, 525130, 525985, 526777, 527666, 528524, 529383, 530179, 531040, 531838, 532637, 533309, 534222, 535120, 536019, 536887, 537788, 538658, 539529, 540337, 541242, 542116, 542991, 543803, 544680, 545494, 546309, 546997, 547910, 548792, 549675, 550495, 551380, 552202, 553025, 553721, 554610, 555436, 556263, 556963, 557792, 558494, 559197, 559645, 560590, 561520, 562451, 563351, 564284, 565186, 566089, 566929, 567866, 568772, 569679, 570523, 571432, 572278, 573125, 573845, 574790, 575704, 576619, 577471, 578388, 579242, 580097, 580825, 581746, 582604, 583463, 584195, 585056, 585790, 586525, 587005, 587966, 588896, 589827, 590695, 591628, 592498, 593369, 594113, 595050, 595924, 596799, 597547, 598424, 599174, 599925, 600421, 601366, 602248, 603131, 603887, 604772, 605530, 606289, 606793, 607682, 608444, 609207, 609715, 610480, 610990, 611501, 611501, 611501, 611501, 611502, 611502, 611505, 611507, 611510, 611510, 611517, 611523, 611530, 611534, 611543, 611549, 611556, 611556, 611571, 611585, 611600, 611612, 611629, 611643, 611658, 611666, 611687, 611705, 611724, 611736, 611757, 611771, 611786, 611786, 611817, 611847, 611878, 611906, 611939, 611969, 612000, 612024, 612061, 612095, 612130, 612158, 612195, 612225, 612256, 612272, 612317, 612359, 612402, 612438, 612483, 612521, 612560, 612584, 612633, 612675, 612718, 612746, 612791, 612821, 612852, 612852, 612915, 612977, 613040, 613100, 613165, 613227, 613290, 613346, 613415, 613481, 613548, 613608, 613677, 613739, 613802, 613850, 613927, 614001, 614076, 614144, 614221, 614291, 614362, 614418, 614499, 614573, 614648, 614708, 614785, 614847, 614910, 614942, 615035, 615125, 615216, 615300, 615393, 615479, 615566, 615638, 615735, 615825, 615916, 615992, 616085, 616163, 616242, 616290, 616395, 616493, 616592, 616676, 616777, 616863, 616950, 617006, 617111, 617201, 617292, 617352, 617445, 617507, 617570, 617570, 617697, 617823, 617950, 618074, 618203, 618329, 618456, 618576, 618709, 618839, 618970, 619094, 619227, 619353, 619480, 619592, 619733, 619871, 620010, 620142, 620283, 620417, 620552, 620672, 620817, 620955, 621094, 621218, 621359, 621485, 621612, 621708, 621865, 622019, 622174, 622322, 622479, 622629, 622780, 622916, 623077, 623231, 623386, 623526, 623683, 623825, 623968, 624080, 624249, 624411, 624574, 624722, 624887, 625037, 625188, 625308, 625477, 625631, 625786, 625910, 626067, 626193, 626320, 626384, 626573, 626759, 626946, 627126, 627315, 627497, 627680, 627848, 628041, 628227, 628414, 628586, 628775, 628949, 629124, 629268, 629469, 629663, 629858, 630038, 630235, 630417, 630600, 630752, 630953, 631139, 631326, 631482, 631671, 631829, 631988, 632084, 632301, 632511, 632722, 632918, 633131, 633329, 633528, 633696, 633913, 634115, 634318, 634490, 634695, 634869, 635044, 635156, 635381, 635591, 635802, 635982, 636195, 636377, 636560, 636680, 636897, 637083, 637270, 637394, 637583, 637709, 637836, 637836, 638091, 638345, 638600, 638852, 639109, 639363, 639618, 639866, 640127, 640385, 640644, 640896, 641157, 641411, 641666, 641906, 642175, 642441, 642708, 642968, 643237, 643499, 643762, 644010, 644283, 644549, 644816, 645068, 645337, 645591, 645846, 646070, 646355, 646637, 646920, 647196, 647481, 647759, 648038, 648302, 648591, 648873, 649156, 649424, 649709, 649979, 650250, 650490, 650787, 651077, 651368, 651644, 651937, 652215, 652494, 652742, 653039, 653321, 653604, 653856, 654141, 654395, 654650, 654842, 655159, 655473, 655788, 656096, 656413, 656723, 657034, 657330, 657651, 657965, 658280, 658580, 658897, 659199, 659502, 659774, 660103, 660425, 660748, 661056, 661381, 661691, 662002, 662282, 662611, 662925, 663240, 663524, 663841, 664127, 664414, 664638, 664983, 665321, 665660, 665984, 666325, 666651, 666978, 667274, 667619, 667949, 668280, 668580, 668913, 669215, 669518, 669758, 670111, 670449, 670788, 671096, 671437, 671747, 672058, 672306, 672651, 672965, 673280, 673532, 673849, 674103, 674358, 674486, 674867, 675245, 675624, 675996, 676377, 676751, 677126, 677486, 677871, 678249, 678628, 678992, 679373, 679739, 680106, 680442, 680835, 681221, 681608, 681980, 682369, 682743, 683118, 683462, 683855, 684233, 684612, 684960, 685341, 685691, 686042, 686330, 686739, 687141, 687544, 687932, 688337, 688727, 689118, 689478, 689887, 690281, 690676, 691040, 691437, 691803, 692170, 692474, 692891, 693293, 693696, 694068, 694473, 694847, 695222, 695534, 695943, 696321, 696700, 697016, 697397, 697715, 698034, 698226, 698667, 699101, 699536, 699956, 700393]
print(l[int(input())])
``` | output | 1 | 71,341 | 2 | 142,683 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Imp is in a magic forest, where xorangles grow (wut?)
<image>
A xorangle of order n is such a non-degenerate triangle, that lengths of its sides are integers not exceeding n, and the xor-sum of the lengths is equal to zero. Imp has to count the number of distinct xorangles of order n to get out of the forest.
Formally, for a given integer n you have to find the number of such triples (a, b, c), that:
* 1 ≤ a ≤ b ≤ c ≤ n;
* <image>, where <image> denotes the [bitwise xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of integers x and y.
* (a, b, c) form a non-degenerate (with strictly positive area) triangle.
Input
The only line contains a single integer n (1 ≤ n ≤ 2500).
Output
Print the number of xorangles of order n.
Examples
Input
6
Output
1
Input
10
Output
2
Note
The only xorangle in the first sample is (3, 5, 6). | instruction | 0 | 71,342 | 2 | 142,684 |
Tags: brute force
Correct Solution:
```
n = int(input())
cnt = 0
for a in range(n+1):
for b in range(a, n+1):
c = a ^ b
if c == 0 or c > n or a >= c or b >= c or a + b <= c:
continue
cnt += 1
print(cnt)
``` | output | 1 | 71,342 | 2 | 142,685 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Imp is in a magic forest, where xorangles grow (wut?)
<image>
A xorangle of order n is such a non-degenerate triangle, that lengths of its sides are integers not exceeding n, and the xor-sum of the lengths is equal to zero. Imp has to count the number of distinct xorangles of order n to get out of the forest.
Formally, for a given integer n you have to find the number of such triples (a, b, c), that:
* 1 ≤ a ≤ b ≤ c ≤ n;
* <image>, where <image> denotes the [bitwise xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of integers x and y.
* (a, b, c) form a non-degenerate (with strictly positive area) triangle.
Input
The only line contains a single integer n (1 ≤ n ≤ 2500).
Output
Print the number of xorangles of order n.
Examples
Input
6
Output
1
Input
10
Output
2
Note
The only xorangle in the first sample is (3, 5, 6). | instruction | 0 | 71,343 | 2 | 142,686 |
Tags: brute force
Correct Solution:
```
n = int(input())
ans = 0
for i in range(1,n+1):
for j in range(i+1,n+1):
k = i^j
if k>j and (i+j)>k and k<=n:
ans+=1
print(ans)
``` | output | 1 | 71,343 | 2 | 142,687 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Imp is in a magic forest, where xorangles grow (wut?)
<image>
A xorangle of order n is such a non-degenerate triangle, that lengths of its sides are integers not exceeding n, and the xor-sum of the lengths is equal to zero. Imp has to count the number of distinct xorangles of order n to get out of the forest.
Formally, for a given integer n you have to find the number of such triples (a, b, c), that:
* 1 ≤ a ≤ b ≤ c ≤ n;
* <image>, where <image> denotes the [bitwise xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of integers x and y.
* (a, b, c) form a non-degenerate (with strictly positive area) triangle.
Input
The only line contains a single integer n (1 ≤ n ≤ 2500).
Output
Print the number of xorangles of order n.
Examples
Input
6
Output
1
Input
10
Output
2
Note
The only xorangle in the first sample is (3, 5, 6). | instruction | 0 | 71,344 | 2 | 142,688 |
Tags: brute force
Correct Solution:
```
n=int(input())
counter=0
for a in range(1,n+1):
for b in range(1,a+1):
t=a^b
if t>0 and t<=n:
if a+b>t and a+t>b and b+t>a:counter+=1
print(counter//3)
``` | output | 1 | 71,344 | 2 | 142,689 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Imp is in a magic forest, where xorangles grow (wut?)
<image>
A xorangle of order n is such a non-degenerate triangle, that lengths of its sides are integers not exceeding n, and the xor-sum of the lengths is equal to zero. Imp has to count the number of distinct xorangles of order n to get out of the forest.
Formally, for a given integer n you have to find the number of such triples (a, b, c), that:
* 1 ≤ a ≤ b ≤ c ≤ n;
* <image>, where <image> denotes the [bitwise xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of integers x and y.
* (a, b, c) form a non-degenerate (with strictly positive area) triangle.
Input
The only line contains a single integer n (1 ≤ n ≤ 2500).
Output
Print the number of xorangles of order n.
Examples
Input
6
Output
1
Input
10
Output
2
Note
The only xorangle in the first sample is (3, 5, 6). | instruction | 0 | 71,345 | 2 | 142,690 |
Tags: brute force
Correct Solution:
```
n=int(input())
kmsafpjgfaerjgigjefgjaelrgjerlkgjergljadfklgjgjergmaegjegne=0
for i in range(1,n+1):
for j in range(1,i+1):
if i^j<=j and i^j>abs(j-i):
#print(i,j,i^j)
kmsafpjgfaerjgigjefgjaelrgjerlkgjergljadfklgjgjergmaegjegne+=1
print(kmsafpjgfaerjgigjefgjaelrgjerlkgjergljadfklgjgjergmaegjegne)
``` | output | 1 | 71,345 | 2 | 142,691 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Imp is in a magic forest, where xorangles grow (wut?)
<image>
A xorangle of order n is such a non-degenerate triangle, that lengths of its sides are integers not exceeding n, and the xor-sum of the lengths is equal to zero. Imp has to count the number of distinct xorangles of order n to get out of the forest.
Formally, for a given integer n you have to find the number of such triples (a, b, c), that:
* 1 ≤ a ≤ b ≤ c ≤ n;
* <image>, where <image> denotes the [bitwise xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of integers x and y.
* (a, b, c) form a non-degenerate (with strictly positive area) triangle.
Input
The only line contains a single integer n (1 ≤ n ≤ 2500).
Output
Print the number of xorangles of order n.
Examples
Input
6
Output
1
Input
10
Output
2
Note
The only xorangle in the first sample is (3, 5, 6). | instruction | 0 | 71,346 | 2 | 142,692 |
Tags: brute force
Correct Solution:
```
x = int(input().strip())
def test_4(n):
count = 0
for i in range(n):
for j in range(i+1, n):
temp = i^j
if (temp <= n and temp > j and (i + j) > temp):
count += 1
return count
aa = test_4(x)
print(aa)
``` | output | 1 | 71,346 | 2 | 142,693 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Imp is in a magic forest, where xorangles grow (wut?)
<image>
A xorangle of order n is such a non-degenerate triangle, that lengths of its sides are integers not exceeding n, and the xor-sum of the lengths is equal to zero. Imp has to count the number of distinct xorangles of order n to get out of the forest.
Formally, for a given integer n you have to find the number of such triples (a, b, c), that:
* 1 ≤ a ≤ b ≤ c ≤ n;
* <image>, where <image> denotes the [bitwise xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of integers x and y.
* (a, b, c) form a non-degenerate (with strictly positive area) triangle.
Input
The only line contains a single integer n (1 ≤ n ≤ 2500).
Output
Print the number of xorangles of order n.
Examples
Input
6
Output
1
Input
10
Output
2
Note
The only xorangle in the first sample is (3, 5, 6). | instruction | 0 | 71,347 | 2 | 142,694 |
Tags: brute force
Correct Solution:
```
n = int(input())
ans = 0
for i in range(1, n):
for j in range(i, n):
if n >= i ^ j > j and i + j > i ^ j:
ans += 1
print(ans)
``` | output | 1 | 71,347 | 2 | 142,695 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Imp is in a magic forest, where xorangles grow (wut?)
<image>
A xorangle of order n is such a non-degenerate triangle, that lengths of its sides are integers not exceeding n, and the xor-sum of the lengths is equal to zero. Imp has to count the number of distinct xorangles of order n to get out of the forest.
Formally, for a given integer n you have to find the number of such triples (a, b, c), that:
* 1 ≤ a ≤ b ≤ c ≤ n;
* <image>, where <image> denotes the [bitwise xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of integers x and y.
* (a, b, c) form a non-degenerate (with strictly positive area) triangle.
Input
The only line contains a single integer n (1 ≤ n ≤ 2500).
Output
Print the number of xorangles of order n.
Examples
Input
6
Output
1
Input
10
Output
2
Note
The only xorangle in the first sample is (3, 5, 6).
Submitted Solution:
```
nooooooooooooooooooooooooo=int(input())
abcdefghijklmnopqrstuvwxyz=0
for i in range(1,nooooooooooooooooooooooooo+1):
for j in range(1,i+1):
if i^j<=j and i^j>abs(j-i):
#print(i,j,i^j)
abcdefghijklmnopqrstuvwxyz+=1
print(abcdefghijklmnopqrstuvwxyz)
``` | instruction | 0 | 71,348 | 2 | 142,696 |
Yes | output | 1 | 71,348 | 2 | 142,697 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Imp is in a magic forest, where xorangles grow (wut?)
<image>
A xorangle of order n is such a non-degenerate triangle, that lengths of its sides are integers not exceeding n, and the xor-sum of the lengths is equal to zero. Imp has to count the number of distinct xorangles of order n to get out of the forest.
Formally, for a given integer n you have to find the number of such triples (a, b, c), that:
* 1 ≤ a ≤ b ≤ c ≤ n;
* <image>, where <image> denotes the [bitwise xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of integers x and y.
* (a, b, c) form a non-degenerate (with strictly positive area) triangle.
Input
The only line contains a single integer n (1 ≤ n ≤ 2500).
Output
Print the number of xorangles of order n.
Examples
Input
6
Output
1
Input
10
Output
2
Note
The only xorangle in the first sample is (3, 5, 6).
Submitted Solution:
```
n = int(input())
sum = 0
for i in range(1,n+1):
for j in range (1,i+1):
if j >= i^j > i - j and i^j <= n:
sum += 1
print(sum)
``` | instruction | 0 | 71,349 | 2 | 142,698 |
Yes | output | 1 | 71,349 | 2 | 142,699 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Imp is in a magic forest, where xorangles grow (wut?)
<image>
A xorangle of order n is such a non-degenerate triangle, that lengths of its sides are integers not exceeding n, and the xor-sum of the lengths is equal to zero. Imp has to count the number of distinct xorangles of order n to get out of the forest.
Formally, for a given integer n you have to find the number of such triples (a, b, c), that:
* 1 ≤ a ≤ b ≤ c ≤ n;
* <image>, where <image> denotes the [bitwise xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of integers x and y.
* (a, b, c) form a non-degenerate (with strictly positive area) triangle.
Input
The only line contains a single integer n (1 ≤ n ≤ 2500).
Output
Print the number of xorangles of order n.
Examples
Input
6
Output
1
Input
10
Output
2
Note
The only xorangle in the first sample is (3, 5, 6).
Submitted Solution:
```
import math,time
#t1=time.time()
n=int(input())
#n=2500
ans=0
for i in range(1,n+1):
for j in range(i+1,n+1):
if i^j<=n:
ls1=[i,j,i^j]
ls1.sort()
if ls1[0]+ls1[1]>ls1[2]:
#print(ls1)
ans+=1
print(math.ceil(ans/3))
#print(time.time()-t1)
``` | instruction | 0 | 71,350 | 2 | 142,700 |
Yes | output | 1 | 71,350 | 2 | 142,701 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Imp is in a magic forest, where xorangles grow (wut?)
<image>
A xorangle of order n is such a non-degenerate triangle, that lengths of its sides are integers not exceeding n, and the xor-sum of the lengths is equal to zero. Imp has to count the number of distinct xorangles of order n to get out of the forest.
Formally, for a given integer n you have to find the number of such triples (a, b, c), that:
* 1 ≤ a ≤ b ≤ c ≤ n;
* <image>, where <image> denotes the [bitwise xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of integers x and y.
* (a, b, c) form a non-degenerate (with strictly positive area) triangle.
Input
The only line contains a single integer n (1 ≤ n ≤ 2500).
Output
Print the number of xorangles of order n.
Examples
Input
6
Output
1
Input
10
Output
2
Note
The only xorangle in the first sample is (3, 5, 6).
Submitted Solution:
```
n=int(input())
#
#
#
#
#
####
#
#
#
#
##
#
#
#
#
#
#
#
##
#
#
#
#
#
##
#
#####
#
#
#
#
#
#
#
#
#
#
kmsafpjgfaerjgigjefgjaelrgjerlkgjergljadfklgjgjergmaegjegne=0
for i in range(1,n+1):
for j in range(1,i+1):
if i^j<=j and i^j>abs(j-i):
#print(i,j,i^j)
kmsafpjgfaerjgigjefgjaelrgjerlkgjergljadfklgjgjergmaegjegne+=1
print(kmsafpjgfaerjgigjefgjaelrgjerlkgjergljadfklgjgjergmaegjegne)
``` | instruction | 0 | 71,351 | 2 | 142,702 |
Yes | output | 1 | 71,351 | 2 | 142,703 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Imp is in a magic forest, where xorangles grow (wut?)
<image>
A xorangle of order n is such a non-degenerate triangle, that lengths of its sides are integers not exceeding n, and the xor-sum of the lengths is equal to zero. Imp has to count the number of distinct xorangles of order n to get out of the forest.
Formally, for a given integer n you have to find the number of such triples (a, b, c), that:
* 1 ≤ a ≤ b ≤ c ≤ n;
* <image>, where <image> denotes the [bitwise xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of integers x and y.
* (a, b, c) form a non-degenerate (with strictly positive area) triangle.
Input
The only line contains a single integer n (1 ≤ n ≤ 2500).
Output
Print the number of xorangles of order n.
Examples
Input
6
Output
1
Input
10
Output
2
Note
The only xorangle in the first sample is (3, 5, 6).
Submitted Solution:
```
n = int(input())
cnt = 0
for a in range(1, n + 1):
for b in range(a, n + 1):
cnt += abs(a - b) < a ^ b < a + b
print(cnt)
``` | instruction | 0 | 71,352 | 2 | 142,704 |
No | output | 1 | 71,352 | 2 | 142,705 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Imp is in a magic forest, where xorangles grow (wut?)
<image>
A xorangle of order n is such a non-degenerate triangle, that lengths of its sides are integers not exceeding n, and the xor-sum of the lengths is equal to zero. Imp has to count the number of distinct xorangles of order n to get out of the forest.
Formally, for a given integer n you have to find the number of such triples (a, b, c), that:
* 1 ≤ a ≤ b ≤ c ≤ n;
* <image>, where <image> denotes the [bitwise xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of integers x and y.
* (a, b, c) form a non-degenerate (with strictly positive area) triangle.
Input
The only line contains a single integer n (1 ≤ n ≤ 2500).
Output
Print the number of xorangles of order n.
Examples
Input
6
Output
1
Input
10
Output
2
Note
The only xorangle in the first sample is (3, 5, 6).
Submitted Solution:
```
n = int(input())
count = 0
for i in range(1, n+1):
for j in range(i, n+1):
k = i^j
if k>=j and k<=n and k+j>i and i+j>k and i+k>j==0:
count+=1
print(count)
``` | instruction | 0 | 71,353 | 2 | 142,706 |
No | output | 1 | 71,353 | 2 | 142,707 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Imp is in a magic forest, where xorangles grow (wut?)
<image>
A xorangle of order n is such a non-degenerate triangle, that lengths of its sides are integers not exceeding n, and the xor-sum of the lengths is equal to zero. Imp has to count the number of distinct xorangles of order n to get out of the forest.
Formally, for a given integer n you have to find the number of such triples (a, b, c), that:
* 1 ≤ a ≤ b ≤ c ≤ n;
* <image>, where <image> denotes the [bitwise xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of integers x and y.
* (a, b, c) form a non-degenerate (with strictly positive area) triangle.
Input
The only line contains a single integer n (1 ≤ n ≤ 2500).
Output
Print the number of xorangles of order n.
Examples
Input
6
Output
1
Input
10
Output
2
Note
The only xorangle in the first sample is (3, 5, 6).
Submitted Solution:
```
from sys import stdin, stdout
import math
Input = []
Input = [stdin.readlines()]
Input = Input[0]
n = int(Input[0])
k = int(math.log(n,2))
ans = int((4**(k+1) - 3**(k+2) + 3*2**(k+1) -1)/6)
lol = sum([2**(sum(map(int, str(bin(x)[2:])))-1) for x in range(n+1, 2**(k+1))])
toobig = (2**(k+1) - n -1) * 2**k - lol
stdout.write(str(ans-toobig))
``` | instruction | 0 | 71,354 | 2 | 142,708 |
No | output | 1 | 71,354 | 2 | 142,709 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Imp is in a magic forest, where xorangles grow (wut?)
<image>
A xorangle of order n is such a non-degenerate triangle, that lengths of its sides are integers not exceeding n, and the xor-sum of the lengths is equal to zero. Imp has to count the number of distinct xorangles of order n to get out of the forest.
Formally, for a given integer n you have to find the number of such triples (a, b, c), that:
* 1 ≤ a ≤ b ≤ c ≤ n;
* <image>, where <image> denotes the [bitwise xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of integers x and y.
* (a, b, c) form a non-degenerate (with strictly positive area) triangle.
Input
The only line contains a single integer n (1 ≤ n ≤ 2500).
Output
Print the number of xorangles of order n.
Examples
Input
6
Output
1
Input
10
Output
2
Note
The only xorangle in the first sample is (3, 5, 6).
Submitted Solution:
```
import time
start_time = time.time()
n=int(input())
ans=0
for a in range(1,n+1):
for b in range(1,n+1):
c=b^a
if b<c<=n and a+b>c and a+c>b and b+c>a:
ans+=1
print(ans)
``` | instruction | 0 | 71,355 | 2 | 142,710 |
No | output | 1 | 71,355 | 2 | 142,711 |
Provide a correct Python 3 solution for this coding contest problem.
Caracal is fighting with a monster.
The health of the monster is H.
Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:
* If the monster's health is 1, it drops to 0.
* If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor.
(\lfloor r \rfloor denotes the greatest integer not exceeding r.)
Caracal wins when the healths of all existing monsters become 0 or below.
Find the minimum number of attacks Caracal needs to make before winning.
Constraints
* 1 \leq H \leq 10^{12}
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
H
Output
Find the minimum number of attacks Caracal needs to make before winning.
Examples
Input
2
Output
3
Input
4
Output
7
Input
1000000000000
Output
1099511627775 | instruction | 0 | 71,399 | 2 | 142,798 |
"Correct Solution:
```
h = int(input())
binary = len(bin(h))-2
print(2**binary-1)
``` | output | 1 | 71,399 | 2 | 142,799 |
Provide a correct Python 3 solution for this coding contest problem.
Caracal is fighting with a monster.
The health of the monster is H.
Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:
* If the monster's health is 1, it drops to 0.
* If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor.
(\lfloor r \rfloor denotes the greatest integer not exceeding r.)
Caracal wins when the healths of all existing monsters become 0 or below.
Find the minimum number of attacks Caracal needs to make before winning.
Constraints
* 1 \leq H \leq 10^{12}
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
H
Output
Find the minimum number of attacks Caracal needs to make before winning.
Examples
Input
2
Output
3
Input
4
Output
7
Input
1000000000000
Output
1099511627775 | instruction | 0 | 71,400 | 2 | 142,800 |
"Correct Solution:
```
import math
print(2 ** (math.floor(math.log2(int(input())))+1) - 1)
``` | output | 1 | 71,400 | 2 | 142,801 |
Provide a correct Python 3 solution for this coding contest problem.
Caracal is fighting with a monster.
The health of the monster is H.
Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:
* If the monster's health is 1, it drops to 0.
* If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor.
(\lfloor r \rfloor denotes the greatest integer not exceeding r.)
Caracal wins when the healths of all existing monsters become 0 or below.
Find the minimum number of attacks Caracal needs to make before winning.
Constraints
* 1 \leq H \leq 10^{12}
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
H
Output
Find the minimum number of attacks Caracal needs to make before winning.
Examples
Input
2
Output
3
Input
4
Output
7
Input
1000000000000
Output
1099511627775 | instruction | 0 | 71,401 | 2 | 142,802 |
"Correct Solution:
```
H = int(input())
print(2 ** H.bit_length() - 1)
``` | output | 1 | 71,401 | 2 | 142,803 |
Provide a correct Python 3 solution for this coding contest problem.
Caracal is fighting with a monster.
The health of the monster is H.
Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:
* If the monster's health is 1, it drops to 0.
* If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor.
(\lfloor r \rfloor denotes the greatest integer not exceeding r.)
Caracal wins when the healths of all existing monsters become 0 or below.
Find the minimum number of attacks Caracal needs to make before winning.
Constraints
* 1 \leq H \leq 10^{12}
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
H
Output
Find the minimum number of attacks Caracal needs to make before winning.
Examples
Input
2
Output
3
Input
4
Output
7
Input
1000000000000
Output
1099511627775 | instruction | 0 | 71,402 | 2 | 142,804 |
"Correct Solution:
```
H=int(input())
a=0
t=1
while H:
H//=2
a+=t
t*=2
print(a)
``` | output | 1 | 71,402 | 2 | 142,805 |
Provide a correct Python 3 solution for this coding contest problem.
Caracal is fighting with a monster.
The health of the monster is H.
Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:
* If the monster's health is 1, it drops to 0.
* If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor.
(\lfloor r \rfloor denotes the greatest integer not exceeding r.)
Caracal wins when the healths of all existing monsters become 0 or below.
Find the minimum number of attacks Caracal needs to make before winning.
Constraints
* 1 \leq H \leq 10^{12}
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
H
Output
Find the minimum number of attacks Caracal needs to make before winning.
Examples
Input
2
Output
3
Input
4
Output
7
Input
1000000000000
Output
1099511627775 | instruction | 0 | 71,403 | 2 | 142,806 |
"Correct Solution:
```
h=int(input())
cnt=0
while h:
h//=2
cnt+=1
print(2**cnt-1)
``` | output | 1 | 71,403 | 2 | 142,807 |
Provide a correct Python 3 solution for this coding contest problem.
Caracal is fighting with a monster.
The health of the monster is H.
Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:
* If the monster's health is 1, it drops to 0.
* If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor.
(\lfloor r \rfloor denotes the greatest integer not exceeding r.)
Caracal wins when the healths of all existing monsters become 0 or below.
Find the minimum number of attacks Caracal needs to make before winning.
Constraints
* 1 \leq H \leq 10^{12}
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
H
Output
Find the minimum number of attacks Caracal needs to make before winning.
Examples
Input
2
Output
3
Input
4
Output
7
Input
1000000000000
Output
1099511627775 | instruction | 0 | 71,404 | 2 | 142,808 |
"Correct Solution:
```
H = int(input())
i = 1
while ( i * 2 <= H):
i *= 2
print(i*2-1)
``` | output | 1 | 71,404 | 2 | 142,809 |
Provide a correct Python 3 solution for this coding contest problem.
Caracal is fighting with a monster.
The health of the monster is H.
Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:
* If the monster's health is 1, it drops to 0.
* If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor.
(\lfloor r \rfloor denotes the greatest integer not exceeding r.)
Caracal wins when the healths of all existing monsters become 0 or below.
Find the minimum number of attacks Caracal needs to make before winning.
Constraints
* 1 \leq H \leq 10^{12}
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
H
Output
Find the minimum number of attacks Caracal needs to make before winning.
Examples
Input
2
Output
3
Input
4
Output
7
Input
1000000000000
Output
1099511627775 | instruction | 0 | 71,405 | 2 | 142,810 |
"Correct Solution:
```
h=int(input())
x=0
while h>0:
x+=1
h=h//2
print(2**x -1)
``` | output | 1 | 71,405 | 2 | 142,811 |
Provide a correct Python 3 solution for this coding contest problem.
Caracal is fighting with a monster.
The health of the monster is H.
Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:
* If the monster's health is 1, it drops to 0.
* If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor.
(\lfloor r \rfloor denotes the greatest integer not exceeding r.)
Caracal wins when the healths of all existing monsters become 0 or below.
Find the minimum number of attacks Caracal needs to make before winning.
Constraints
* 1 \leq H \leq 10^{12}
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
H
Output
Find the minimum number of attacks Caracal needs to make before winning.
Examples
Input
2
Output
3
Input
4
Output
7
Input
1000000000000
Output
1099511627775 | instruction | 0 | 71,406 | 2 | 142,812 |
"Correct Solution:
```
h=int(input())
H=bin(h)
k=len(H)-2
A=2**k-1
print(A)
``` | output | 1 | 71,406 | 2 | 142,813 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Caracal is fighting with a monster.
The health of the monster is H.
Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:
* If the monster's health is 1, it drops to 0.
* If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor.
(\lfloor r \rfloor denotes the greatest integer not exceeding r.)
Caracal wins when the healths of all existing monsters become 0 or below.
Find the minimum number of attacks Caracal needs to make before winning.
Constraints
* 1 \leq H \leq 10^{12}
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
H
Output
Find the minimum number of attacks Caracal needs to make before winning.
Examples
Input
2
Output
3
Input
4
Output
7
Input
1000000000000
Output
1099511627775
Submitted Solution:
```
print((2**(len(str(bin(int(input())))[2:])-1))*2-1)
``` | instruction | 0 | 71,407 | 2 | 142,814 |
Yes | output | 1 | 71,407 | 2 | 142,815 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Caracal is fighting with a monster.
The health of the monster is H.
Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:
* If the monster's health is 1, it drops to 0.
* If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor.
(\lfloor r \rfloor denotes the greatest integer not exceeding r.)
Caracal wins when the healths of all existing monsters become 0 or below.
Find the minimum number of attacks Caracal needs to make before winning.
Constraints
* 1 \leq H \leq 10^{12}
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
H
Output
Find the minimum number of attacks Caracal needs to make before winning.
Examples
Input
2
Output
3
Input
4
Output
7
Input
1000000000000
Output
1099511627775
Submitted Solution:
```
h=int(input())
i=1
while(h>1):
h=h//2
i=i+1
print(2**(i)-1)
``` | instruction | 0 | 71,408 | 2 | 142,816 |
Yes | output | 1 | 71,408 | 2 | 142,817 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Caracal is fighting with a monster.
The health of the monster is H.
Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:
* If the monster's health is 1, it drops to 0.
* If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor.
(\lfloor r \rfloor denotes the greatest integer not exceeding r.)
Caracal wins when the healths of all existing monsters become 0 or below.
Find the minimum number of attacks Caracal needs to make before winning.
Constraints
* 1 \leq H \leq 10^{12}
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
H
Output
Find the minimum number of attacks Caracal needs to make before winning.
Examples
Input
2
Output
3
Input
4
Output
7
Input
1000000000000
Output
1099511627775
Submitted Solution:
```
h=int(input())
ans=0
t=1
while t<=h:
t*=2
print(t-1)
``` | instruction | 0 | 71,409 | 2 | 142,818 |
Yes | output | 1 | 71,409 | 2 | 142,819 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Caracal is fighting with a monster.
The health of the monster is H.
Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:
* If the monster's health is 1, it drops to 0.
* If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor.
(\lfloor r \rfloor denotes the greatest integer not exceeding r.)
Caracal wins when the healths of all existing monsters become 0 or below.
Find the minimum number of attacks Caracal needs to make before winning.
Constraints
* 1 \leq H \leq 10^{12}
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
H
Output
Find the minimum number of attacks Caracal needs to make before winning.
Examples
Input
2
Output
3
Input
4
Output
7
Input
1000000000000
Output
1099511627775
Submitted Solution:
```
import math
print(int(2**(math.log2(int(input())) // 1 + 1) - 1))
``` | instruction | 0 | 71,410 | 2 | 142,820 |
Yes | output | 1 | 71,410 | 2 | 142,821 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Caracal is fighting with a monster.
The health of the monster is H.
Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:
* If the monster's health is 1, it drops to 0.
* If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor.
(\lfloor r \rfloor denotes the greatest integer not exceeding r.)
Caracal wins when the healths of all existing monsters become 0 or below.
Find the minimum number of attacks Caracal needs to make before winning.
Constraints
* 1 \leq H \leq 10^{12}
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
H
Output
Find the minimum number of attacks Caracal needs to make before winning.
Examples
Input
2
Output
3
Input
4
Output
7
Input
1000000000000
Output
1099511627775
Submitted Solution:
```
def time(h):
if h == 1:
return 1
else:
return time(h//2)*2 + 1
print(time(H))
``` | instruction | 0 | 71,411 | 2 | 142,822 |
No | output | 1 | 71,411 | 2 | 142,823 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Caracal is fighting with a monster.
The health of the monster is H.
Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:
* If the monster's health is 1, it drops to 0.
* If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor.
(\lfloor r \rfloor denotes the greatest integer not exceeding r.)
Caracal wins when the healths of all existing monsters become 0 or below.
Find the minimum number of attacks Caracal needs to make before winning.
Constraints
* 1 \leq H \leq 10^{12}
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
H
Output
Find the minimum number of attacks Caracal needs to make before winning.
Examples
Input
2
Output
3
Input
4
Output
7
Input
1000000000000
Output
1099511627775
Submitted Solution:
```
def resolve():
H = int(input())
dp = [0] * (H + 1)
dp[1] = 1
for i in range(2, H + 1):
dp[i] = 1 + 2 * dp[i // 2]
print(dp[-1])
resolve()
``` | instruction | 0 | 71,412 | 2 | 142,824 |
No | output | 1 | 71,412 | 2 | 142,825 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Caracal is fighting with a monster.
The health of the monster is H.
Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:
* If the monster's health is 1, it drops to 0.
* If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor.
(\lfloor r \rfloor denotes the greatest integer not exceeding r.)
Caracal wins when the healths of all existing monsters become 0 or below.
Find the minimum number of attacks Caracal needs to make before winning.
Constraints
* 1 \leq H \leq 10^{12}
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
H
Output
Find the minimum number of attacks Caracal needs to make before winning.
Examples
Input
2
Output
3
Input
4
Output
7
Input
1000000000000
Output
1099511627775
Submitted Solution:
```
%%time
H = int(input())
counter = 0
i = H
while i > 1:
i = i//2
counter += 1
ans = 2**(counter+1)-1
print(ans)
``` | instruction | 0 | 71,413 | 2 | 142,826 |
No | output | 1 | 71,413 | 2 | 142,827 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Caracal is fighting with a monster.
The health of the monster is H.
Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:
* If the monster's health is 1, it drops to 0.
* If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor.
(\lfloor r \rfloor denotes the greatest integer not exceeding r.)
Caracal wins when the healths of all existing monsters become 0 or below.
Find the minimum number of attacks Caracal needs to make before winning.
Constraints
* 1 \leq H \leq 10^{12}
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
H
Output
Find the minimum number of attacks Caracal needs to make before winning.
Examples
Input
2
Output
3
Input
4
Output
7
Input
1000000000000
Output
1099511627775
Submitted Solution:
```
H = int(input())
c=0
while H>1:
k=H/2
H=k
c+=1
c*=2
print((c)+1)
``` | instruction | 0 | 71,414 | 2 | 142,828 |
No | output | 1 | 71,414 | 2 | 142,829 |
Provide tags and a correct Python 3 solution for this coding contest problem.
All techniques in the ninja world consist of hand seals. At the moment Naruto is learning a new technique, which consists of n⋅ m different seals, denoted by distinct numbers. All of them were written in an n× m table.
The table is lost now. Naruto managed to remember elements of each row from left to right, and elements of each column from top to bottom, but he doesn't remember the order of rows and columns. Please restore the table consistent with this data so that Naruto will be able to learn the new technique.
Input
The first line of the input contains the only integer t (1≤ t≤ 100 000) denoting the number of test cases. Their descriptions follow.
The first line of each test case description consists of two space-separated integers n and m (1 ≤ n, m ≤ 500) standing for the number of rows and columns in the table, respectively. All hand seals are encoded by the positive integers from 1 to n⋅ m.
The following n lines contain m space separated integers each, denoting elements of an arbitrary row in the table left to right.
The following m lines contain n space separated integers each, denoting elements of an arbitrary column in the table top to bottom.
Sum of nm over all test cases does not exceed 250 000. It is guaranteed that each row occurs in the input exactly once, as well as each column. It is also guaranteed that each number from 1 to nm occurs exactly once in all rows, as well as in all columns. Finally, it is guaranteed that a table consistent with the input exists.
Output
For each test case, output n lines with m space-separated integers each, denoting the restored table. One can show that the answer is always unique.
Example
Input
2
2 3
6 5 4
1 2 3
1 6
2 5
3 4
3 1
2
3
1
3 1 2
Output
1 2 3
6 5 4
3
1
2
Note
Consider the first test case. The matrix is 2 × 3. You are given the rows and columns in arbitrary order.
One of the rows is [6, 5, 4]. One of the rows is [1, 2, 3].
One of the columns is [1, 6]. One of the columns is [2, 5]. One of the columns is [3, 4].
You are to reconstruct the matrix. The answer is given in the output. | instruction | 0 | 71,838 | 2 | 143,676 |
Tags: implementation
Correct Solution:
```
from math import *
import os, sys
from io import BytesIO
input = BytesIO(os.read(0, os.fstat(0).st_size)).readline
#sys.stdin = open("input.txt", "r")
#sys.stdout = open("output.txt", "w")
for _ in range(int(input())):
n, m = map(int, input().split())
x = {}
y = {}
ans = [[0] * m for i in range(n)]
for i in range(n):
a = list(map(int, input().split()))
for j in range(m):
#print(a[j], j)
x[a[j]] = j
for i in range(m):
a = list(map(int, input().split()))
for j in range(n):
y[a[j]] = j
for i in range(1, n * m + 1):
#print(x.get(i, 0), y.get(i, 0))
ans[y.get(i, 0)][x.get(i, 0)] = i
for c in ans:
print(*c)
``` | output | 1 | 71,838 | 2 | 143,677 |
Provide tags and a correct Python 3 solution for this coding contest problem.
All techniques in the ninja world consist of hand seals. At the moment Naruto is learning a new technique, which consists of n⋅ m different seals, denoted by distinct numbers. All of them were written in an n× m table.
The table is lost now. Naruto managed to remember elements of each row from left to right, and elements of each column from top to bottom, but he doesn't remember the order of rows and columns. Please restore the table consistent with this data so that Naruto will be able to learn the new technique.
Input
The first line of the input contains the only integer t (1≤ t≤ 100 000) denoting the number of test cases. Their descriptions follow.
The first line of each test case description consists of two space-separated integers n and m (1 ≤ n, m ≤ 500) standing for the number of rows and columns in the table, respectively. All hand seals are encoded by the positive integers from 1 to n⋅ m.
The following n lines contain m space separated integers each, denoting elements of an arbitrary row in the table left to right.
The following m lines contain n space separated integers each, denoting elements of an arbitrary column in the table top to bottom.
Sum of nm over all test cases does not exceed 250 000. It is guaranteed that each row occurs in the input exactly once, as well as each column. It is also guaranteed that each number from 1 to nm occurs exactly once in all rows, as well as in all columns. Finally, it is guaranteed that a table consistent with the input exists.
Output
For each test case, output n lines with m space-separated integers each, denoting the restored table. One can show that the answer is always unique.
Example
Input
2
2 3
6 5 4
1 2 3
1 6
2 5
3 4
3 1
2
3
1
3 1 2
Output
1 2 3
6 5 4
3
1
2
Note
Consider the first test case. The matrix is 2 × 3. You are given the rows and columns in arbitrary order.
One of the rows is [6, 5, 4]. One of the rows is [1, 2, 3].
One of the columns is [1, 6]. One of the columns is [2, 5]. One of the columns is [3, 4].
You are to reconstruct the matrix. The answer is given in the output. | instruction | 0 | 71,839 | 2 | 143,678 |
Tags: implementation
Correct Solution:
```
import sys
def taskb():
count = int(sys.stdin.readline())
for i in range(count):
n, m = map(int, sys.stdin.readline().split())
a = [0] * n
r = [0] * (m * n + 1)
for j in range(n):
a[j] = list(map(int, sys.stdin.readline().split()))
r[a[j][0]] = j
v = a[0][0]
for j in range(m):
b = list(map(int, sys.stdin.readline().split()))
if v in b:
c = b
for j in range(n):
sys.stdout.write(" ".join(map(str, a[r[c[j]]])) + '\n')
taskb()
``` | output | 1 | 71,839 | 2 | 143,679 |
Provide tags and a correct Python 3 solution for this coding contest problem.
All techniques in the ninja world consist of hand seals. At the moment Naruto is learning a new technique, which consists of n⋅ m different seals, denoted by distinct numbers. All of them were written in an n× m table.
The table is lost now. Naruto managed to remember elements of each row from left to right, and elements of each column from top to bottom, but he doesn't remember the order of rows and columns. Please restore the table consistent with this data so that Naruto will be able to learn the new technique.
Input
The first line of the input contains the only integer t (1≤ t≤ 100 000) denoting the number of test cases. Their descriptions follow.
The first line of each test case description consists of two space-separated integers n and m (1 ≤ n, m ≤ 500) standing for the number of rows and columns in the table, respectively. All hand seals are encoded by the positive integers from 1 to n⋅ m.
The following n lines contain m space separated integers each, denoting elements of an arbitrary row in the table left to right.
The following m lines contain n space separated integers each, denoting elements of an arbitrary column in the table top to bottom.
Sum of nm over all test cases does not exceed 250 000. It is guaranteed that each row occurs in the input exactly once, as well as each column. It is also guaranteed that each number from 1 to nm occurs exactly once in all rows, as well as in all columns. Finally, it is guaranteed that a table consistent with the input exists.
Output
For each test case, output n lines with m space-separated integers each, denoting the restored table. One can show that the answer is always unique.
Example
Input
2
2 3
6 5 4
1 2 3
1 6
2 5
3 4
3 1
2
3
1
3 1 2
Output
1 2 3
6 5 4
3
1
2
Note
Consider the first test case. The matrix is 2 × 3. You are given the rows and columns in arbitrary order.
One of the rows is [6, 5, 4]. One of the rows is [1, 2, 3].
One of the columns is [1, 6]. One of the columns is [2, 5]. One of the columns is [3, 4].
You are to reconstruct the matrix. The answer is given in the output. | instruction | 0 | 71,840 | 2 | 143,680 |
Tags: implementation
Correct Solution:
```
from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353
def inp(): return stdin.readline().strip()
def out(var, end="\n"): stdout.write(str(var)+"\n")
def outa(*var, end="\n"): stdout.write(' '.join(map(str, var)) + end)
def lmp(): return list(mp())
def mp(): return map(int, inp().split())
def smp(): return map(str, inp().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]
def remadd(x, y): return 1 if x%y else 0
def ceil(a,b): return (a+b-1)//b
def isprime(x):
if x<=1: return False
if x in (2, 3): return True
if x%2 == 0: return False
for i in range(3, int(sqrt(x))+1, 2):
if x%i == 0: return False
return True
for _ in range(int(inp())):
n, m = mp()
md = {}
for i in range(n):
arr = lmp()
md[arr[0]] = arr
for j in range(m):
arr = lmp()
if arr[0] in md:
ans = arr
for i in ans:
print(*md[i])
``` | output | 1 | 71,840 | 2 | 143,681 |
Provide tags and a correct Python 3 solution for this coding contest problem.
All techniques in the ninja world consist of hand seals. At the moment Naruto is learning a new technique, which consists of n⋅ m different seals, denoted by distinct numbers. All of them were written in an n× m table.
The table is lost now. Naruto managed to remember elements of each row from left to right, and elements of each column from top to bottom, but he doesn't remember the order of rows and columns. Please restore the table consistent with this data so that Naruto will be able to learn the new technique.
Input
The first line of the input contains the only integer t (1≤ t≤ 100 000) denoting the number of test cases. Their descriptions follow.
The first line of each test case description consists of two space-separated integers n and m (1 ≤ n, m ≤ 500) standing for the number of rows and columns in the table, respectively. All hand seals are encoded by the positive integers from 1 to n⋅ m.
The following n lines contain m space separated integers each, denoting elements of an arbitrary row in the table left to right.
The following m lines contain n space separated integers each, denoting elements of an arbitrary column in the table top to bottom.
Sum of nm over all test cases does not exceed 250 000. It is guaranteed that each row occurs in the input exactly once, as well as each column. It is also guaranteed that each number from 1 to nm occurs exactly once in all rows, as well as in all columns. Finally, it is guaranteed that a table consistent with the input exists.
Output
For each test case, output n lines with m space-separated integers each, denoting the restored table. One can show that the answer is always unique.
Example
Input
2
2 3
6 5 4
1 2 3
1 6
2 5
3 4
3 1
2
3
1
3 1 2
Output
1 2 3
6 5 4
3
1
2
Note
Consider the first test case. The matrix is 2 × 3. You are given the rows and columns in arbitrary order.
One of the rows is [6, 5, 4]. One of the rows is [1, 2, 3].
One of the columns is [1, 6]. One of the columns is [2, 5]. One of the columns is [3, 4].
You are to reconstruct the matrix. The answer is given in the output. | instruction | 0 | 71,841 | 2 | 143,682 |
Tags: implementation
Correct Solution:
```
rez = []
for i in range(int(input())):
n, m = map(int, input().split())
s_stroku = [list(map(int, input().split())) for _ in range(n)]
s_stolb = [list(map(int, input().split())) for _ in range(m)]
b = 0
while s_stroku[0][0] not in s_stolb[b]:
b+=1
j = s_stolb[b]
for l in s_stroku:
l.insert(0, j.index(l[0]))
s_stroku.sort()
rez.extend(s_stroku)
for i in rez:
print(*i[1:])
``` | output | 1 | 71,841 | 2 | 143,683 |
Provide tags and a correct Python 3 solution for this coding contest problem.
All techniques in the ninja world consist of hand seals. At the moment Naruto is learning a new technique, which consists of n⋅ m different seals, denoted by distinct numbers. All of them were written in an n× m table.
The table is lost now. Naruto managed to remember elements of each row from left to right, and elements of each column from top to bottom, but he doesn't remember the order of rows and columns. Please restore the table consistent with this data so that Naruto will be able to learn the new technique.
Input
The first line of the input contains the only integer t (1≤ t≤ 100 000) denoting the number of test cases. Their descriptions follow.
The first line of each test case description consists of two space-separated integers n and m (1 ≤ n, m ≤ 500) standing for the number of rows and columns in the table, respectively. All hand seals are encoded by the positive integers from 1 to n⋅ m.
The following n lines contain m space separated integers each, denoting elements of an arbitrary row in the table left to right.
The following m lines contain n space separated integers each, denoting elements of an arbitrary column in the table top to bottom.
Sum of nm over all test cases does not exceed 250 000. It is guaranteed that each row occurs in the input exactly once, as well as each column. It is also guaranteed that each number from 1 to nm occurs exactly once in all rows, as well as in all columns. Finally, it is guaranteed that a table consistent with the input exists.
Output
For each test case, output n lines with m space-separated integers each, denoting the restored table. One can show that the answer is always unique.
Example
Input
2
2 3
6 5 4
1 2 3
1 6
2 5
3 4
3 1
2
3
1
3 1 2
Output
1 2 3
6 5 4
3
1
2
Note
Consider the first test case. The matrix is 2 × 3. You are given the rows and columns in arbitrary order.
One of the rows is [6, 5, 4]. One of the rows is [1, 2, 3].
One of the columns is [1, 6]. One of the columns is [2, 5]. One of the columns is [3, 4].
You are to reconstruct the matrix. The answer is given in the output. | instruction | 0 | 71,842 | 2 | 143,684 |
Tags: implementation
Correct Solution:
```
import sys
for _ in range(int(input())):
n, m = map(int,sys.stdin.readline().split())
d = { }
for i in range(n):
m2 = list(map(int,sys.stdin.readline().split()))
d[m2[0]] = m2
for i in range(m):
m1 = list(map(int,sys.stdin.readline().split()))
if m1[0] in d: m2 = m1
for i in range(n):
print(*d[m2[i]])
``` | output | 1 | 71,842 | 2 | 143,685 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.