Problem:


Score : 600 points

Problem Statement

Given are two sequences a=\{a_0,\ldots,a_{N-1}\} and b=\{b_0,\ldots,b_{N-1}\} of N non-negative integers each.

Snuke will choose an integer k such that 0 \leq k < N and an integer x not less than 0, to make a new sequence of length N, a'=\{a_0',\ldots,a_{N-1}'\}, as follows:

a_i'= a_{i+k \mod N}\ XOR \ x

Find all pairs (k,x) such that a' will be equal to b.

What is \mbox{ XOR }?

The XOR of integers A and B, A \mbox{ XOR } B, is defined as follows:

When A \mbox{ XOR } B is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if either A or B, but not both, has 1 in the 2^k's place, and 0 otherwise.

For example, 3 \mbox{ XOR } 5 = 6. (In base two: 011 \mbox{ XOR } 101 = 110.)

Constraints

1 \leq N \leq 2 \times 10^5

0 \leq a_i,b_i < 2^{30}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
a_0 a_1 ... a_{N-1}
b_0 b_1 ... b_{N-1}

Output

Print all pairs (k, x) such that a' and b will be equal, using one line for each pair, in ascending order of k (ascending order of x for pairs with the same k).

If there are no such pairs, the output should be empty.

Sample Input 1

3
0 2 1
1 2 3

Sample Output 1

1 3

If (k,x)=(1,3),

a_0'=(a_1\ XOR \ 3)=1

a_1'=(a_2\ XOR \ 3)=2

a_2'=(a_0\ XOR \ 3)=3

and we have a' = b.

Sample Input 2

5
0 0 0 0 0
2 2 2 2 2

Sample Output 2

0 2
1 2
2 2
3 2
4 2

Sample Input 3

6
0 1 3 7 6 4
1 5 4 6 2 3

Sample Output 3

2 2
5 5

Sample Input 4

2
1 2
0 0

Sample Output 4

No pairs may satisfy the condition.



Sample input:
3
0 2 1
1 2 3


Sample output:
1 3

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# import time
import sys
from collections import Counter, defaultdict
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline


gpw = None


class RH():
    def __init__(self, s, base, mod):
        self.base = base
        self.mod = mod
        self.rev = pow(base, mod-2, mod)

        l = len(s)
        self.h = h = [0]*(l+1)
        tmp = 0
        for i in range(l):
            tmp = (tmp*base + s[i]) % mod
            h[i+1] = tmp

        global gpw
        if gpw is None:
            self.pw = pw = [1]*(len(s)+1)
            v = 1
            for i in range(l):
                pw[i+1] = v = v * base % mod
            gpw = pw
        else:
            self.pw = gpw

    def calc(self, l, r):
        return (self.h[r] - self.h[l] * self.pw[r-l]) % self.mod


def slv(N, A, B):
    L = max(max(A), max(B)).bit_length()
    ba = []
    bb = []
    ah = []
    bh = []
    bnh = []
    for i in range(L):
        ta = []
        tb = []
        tbn = []
        for a, b in zip(A, B):
            ta.append(a >> i & 1)
            tb.append(b >> i & 1)
            tbn.append(tb[-1] ^ 1)
        ba.append(ta)
        bb.append(tb)
        ah.append(RH(ta, 641, 10**9+7))
        bh.append(RH(tb, 641, 10**9+7))
        bnh.append(RH(tbn, 641, 10**9+7))

    ans = []
    for k in range(N):
        x = 0
        for i in range(L):
            l = ah[i].calc(k, N)
            r = ah[i].calc(0, k)
            if l == bh[i].calc(0, N-k) and r == bh[i].calc(N-k, N):
                pass
            elif l == bnh[i].calc(0, N-k) and r == bnh[i].calc(N-k, N):
                x += 1 << i
            else:
                break
        else:
            ans.append('%d %d' % (k, x))

    return ans


def main():
    N = int(input())
    A = list(map(int, buff_readline().split()))
    B = list(map(int, buff_readline().split()))
    print(*slv(N, A, B), sep='\n')

    # import random
    # N = 2 * 10**5
    # # A = [random.randint(0, 1 << 30) for _ in range(N)]
    # # B = [random.randint(0, 1 << 30) for _ in range(N)]
    # A = [2 ** 30 for _ in range(N)]
    # B = [2 ** 30 for _ in range(N)]
    # print(N)
    # print(*A)
    # print(*B)
    # # print(*slv(N, A, B), sep='\n')


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# import time
import sys
from collections import Counter, defaultdict
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline


gpw = None


class RH():
    def __init__(self, s, base, mod):
        self.base = base
        self.mod = mod
        self.rev = pow(base, mod-2, mod)

        l = len(s)
        self.h = h = [0]*(l+1)
        tmp = 0
        for i in range(l):
            tmp = (tmp*base + s[i]) % mod
            h[i+1] = tmp

        global gpw
        if gpw is None:
            self.pw = pw = [1]*(len(s)+1)
            v = 1
            for i in range(l):
                pw[i+1] = v = v * base % mod
            gpw = pw
        else:
            self.pw = gpw

    def calc(self, l, r):
        return (self.h[r] - self.h[l] * self.pw[r-l]) % self.mod


def slv(N, A, B):
    p = []
    p.append(time.perf_counter())
    L = max(max(A), max(B)).bit_length()
    ba = []
    bb = []
    ah = []
    bh = []
    bnh = []
    for i in range(L):
        ta = []
        tb = []
        tbn = []
        for a, b in zip(A, B):
            ta.append(a >> i & 1)
            tb.append(b >> i & 1)
            tbn.append(tb[-1] ^ 1)
        ba.append(ta)
        bb.append(tb)
        n = 1
        ah.append(RH(ta, 641, 10**9+7))
        bh.append(RH(tb, 641, 10**9+7))
        bnh.append(RH(tbn, 641, 10**9+7))

    # p.append(time.perf_counter())

    ans = []
    for k in range(N):
        x = 0
        for i in range(L):
            l = ah[i].calc(k, N)
            r = ah[i].calc(0, k)
            if l == bh[i].calc(0, N-k) and r == bh[i].calc(N-k, N):
                pass
            elif l == bnh[i].calc(0, N-k) and r == bnh[i].calc(N-k, N):
                x += 1 << i
            else:
                break
        else:
            ans.append((k, x))
    # p.append(time.perf_counter())

    # for i in range(len(p)-1):
    #     print(p[i+1]-p[i], file=sys.stderr)

    return ans


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    for r in slv(N, A, B):
        print(*r)

    # import random
    # N = 2 * 10**5
    # # A = [random.randint(0, 1 << 30) for _ in range(N)]
    # # B = [random.randint(0, 1 << 30) for _ in range(N)]
    # A = [2 ** 30 for _ in range(N)]
    # B = [2 ** 30 for _ in range(N)]
    # print(N)
    # print(*A)
    # print(*B)
    # # print(*slv(N, A, B), sep='\n')


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import time
import sys
from collections import Counter, defaultdict
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline


gpw = None


class RH():
    def __init__(self, s, base, mod):
        self.base = base
        self.mod = mod
        self.rev = pow(base, mod-2, mod)

        l = len(s)
        self.h = h = [0]*(l+1)
        tmp = 0
        for i in range(l):
            tmp = (tmp*base + s[i]) % mod
            h[i+1] = tmp

        global gpw
        if gpw is None:
            self.pw = pw = [1]*(len(s)+1)
            v = 1
            for i in range(l):
                pw[i+1] = v = v * base % mod
            gpw = pw
        else:
            self.pw = gpw

    def calc(self, l, r):
        return (self.h[r] - self.h[l] * self.pw[r-l]) % self.mod


def slv(N, A, B):
    p = []
    p.append(time.perf_counter())
    L = max(max(A), max(B)).bit_length()
    ba = []
    bb = []
    ah = []
    bh = []
    bnh = []
    for i in range(L):
        ta = []
        tb = []
        tbn = []
        for a, b in zip(A, B):
            ta.append(a >> i & 1)
            tb.append(b >> i & 1)
            tbn.append(tb[-1] ^ 1)
        ba.append(ta)
        bb.append(tb)
        n = 1
        ah.append(RH(ta, 641, 10**9+7))
        bh.append(RH(tb, 641, 10**9+7))
        bnh.append(RH(tbn, 641, 10**9+7))

    p.append(time.perf_counter())

    ans = []
    for k in range(N):
        x = 0
        for i in range(L):
            l = ah[i].calc(k, N)
            r = ah[i].calc(0, k)
            if l == bh[i].calc(0, N-k) and r == bh[i].calc(N-k, N):
                pass
            elif l == bnh[i].calc(0, N-k) and r == bnh[i].calc(N-k, N):
                x += 1 << i
            else:
                break
        else:
            ans.append((k, x))
    p.append(time.perf_counter())

    for i in range(len(p)-1):
        print(p[i+1]-p[i], file=sys.stderr)

    return ans


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    for r in slv(N, A, B):
        print(*r)

    # import random
    # N = 2 * 10**5
    # # A = [random.randint(0, 1 << 30) for _ in range(N)]
    # # B = [random.randint(0, 1 << 30) for _ in range(N)]
    # A = [2 ** 30 for _ in range(N)]
    # B = [2 ** 30 for _ in range(N)]
    # print(N)
    # print(*A)
    # print(*B)
    # # print(*slv(N, A, B), sep='\n')


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
# coding: utf-8

def main():

	N = 0
	a = []
	b = []
	with open("C:/Users/admin/Downloads/random_05") as f:
		N = int(f.readline())
		a = [int(x) for x in f.readline().split()]
		b = [int(x) for x in f.readline().split()]

	# N = int(input())
	# a = [int(x) for x in input().split()]
	# b = [int(x) for x in input().split()]

	xor_a = [a[i] ^ a[(i+1) % N] for i in range(len(a))]
	xor_b = [b[i] ^ b[(i+1) % N] for i in range(len(b))]

	kmp = KmpSearch(xor_a + xor_a, xor_b)

	# start = 0
	# ans = []
	# x = []
	# while True:
	# 	k = kmp.search(start)
	# 	if k == -1 or k == len(a):
	# 		break
	# 	# ans.append(k)
	# 	start = k + 1
	# 	# x.append(a[0 + k] ^ b[0])

	# 	print(str(k) + " " + str(a[0 + k] ^ b[0]))

	ans = kmp.full_search()
	for k in ans:
		print(str(k) + " " + str(a[0 + k] ^ b[0]))
	# for i in range(len(ans)):
	# 	print(str(ans[i]) + " " + str(x[i]))

class KmpSearch:
	def __init__(self, target, pattern):
		self.target = target
		self.pattern = pattern
		self.__table = self.__create_kmp_table()

	def search(self, start=0):
		if len(self.pattern) > len(self.target):
			return -1

		i = start
		p = 0
		while i < len(self.target):
			if self.pattern[p] == self.target[i]:
				i += 1
				p += 1

				if p == len(self.pattern):
					return i - p
			elif p == 0:
				i += 1
			else:
				p = self.__table[p]

		return -1

	def full_search(self):
		if len(self.pattern) > len(self.target):
			return -1

		res = []
		i = 0
		p = 0
		while i < len(self.target):
			if self.pattern[p] == self.target[i]:
				i += 1
				p += 1

				if p == len(self.pattern):
					res.append(i-p)
					i -= 1
					p = self.__table[p-1]
			elif p == 0:
				i += 1
			else:
				p = self.__table[p]

		return res

	def __create_kmp_table(self):
		table = [0 for x in range(len(self.pattern))]

		j = 0
		for i in range(1, len(self.pattern)):
			table[i] = j
			if self.pattern[j] == self.pattern[i]:
				j += 1
			else:
				j = 0

		return table

if __name__ == "__main__":
	main()

Submission status: Runtime Error

Solution code:
####################################### Define
maxN = int(2e5 + 100)
a = [0] * maxN
b = [0] * maxN
ans = [0] * maxN
####################################### Functions
def solve() :
    L = R = -1
    for i in range(1, n + 1) :
        if i > R :
            L = R = i
            while R + 1 <= 2 * n and a[i] ^ b[1] == a[R + 1] ^ b[R - L + 2]: R += 1
#            print(a[i] ^ b[1], a[R + 1] ^ b[R - L + 2], "\n")
            ans[i] = R - L + 1
        else :
            k = i - L
            if ans[k] < R - i + 1 : ans[i] = ans[k]
            else :
                L = i
                while R + 1 <= 2 * n and a[i] ^ b[1] == a[R + 1] ^ b[R - L + 2]: R += 1
                ans[i] = R - L + 1
####################################### Main
n = int(input())
inp = input().split()
for i in range(1, n + 1) : a[i] = int(inp[i - 1])
for i in range(n + 1, 2 * n + 1) : a[i] = a[i - n]
inp = input().split()
for i in range(1, n + 1) : b[i] = int(inp[i - 1])
for i in range(n + 1, 2 * n + 1) : b[i] = b[i - n]

solve()

for i in range(1, n + 1):
    if ans[i] >= n:
        print(i - 1, a[i] ^ b[1])

Submission status: Runtime Error

Solution code:
k, x = map(int, input().split())
if k * 500 >= x:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from fractions import gcd
from functools import lru_cache

#############
# Constants #
#############

MOD = 10**9 +7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

N = inputI()
a = inputIL()
b = inputIL()

difa = [0]*N
difb = [0]*N
for i in range(N-1):
  difa[i] = a[i]^a[i+1]
  difb[i] = b[i]^b[i+1]
difa[N-1] = a[0]^a[N-1]
difb[N-1] = b[0]^b[N-1]

if set(difa) != set(dib):
  exit()

memo = []
for i in range(N):
  j = 0
  while difa[(i+j)%N] == difb[j%N]:
    j += 1
    if j == N:
      print(i,a[i]^b[0])
      memo.append(i)
      break
  if len(memo) == 2:
    break

if len(memo) == 2:
  d = memo[1]-memo[0]
  k = memo[1]+d
  while k < N:
    print(k,a[k]^b[0])
    k += d

Submission status: Runtime Error

Solution code:
# F
import sys
input = sys.stdin.readline
import numpy as np
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

diffs = []
for lis in [a, b]:
    lis_tmp = np.array(lis[1:]+[lis[0]])
    diffs.append(list(abs(lis_tmp-np.array(lis))))

ad = diffs[0]
bd = (diffs[1]*2)[:-1]

ans_set = []
find_str = ad[0]
start_pos = 0
Searching = True
try:
    find_ind = bd[start_pos:].index(find_str)+start_pos
except:
    Searching = False
while(Searching):
    bd_tmp=bd[find_ind:find_ind+N+1]
    Check_Same=True
    for i in range(N):
        if not ad[i]==bd_tmp[i]:
            Check_Same=False
            break
    if Check_Same:
        k = N-find_ind
        x = abs(b[find_ind]-a[0])
        ans_set.append([k % N, x])
    start_pos = find_ind+1
    if start_pos >= N:
        Searching=False
    try:
        find_ind = bd[start_pos:].index(find_str)+start_pos
    except:
        Searching = False

ans_set = sorted(ans_set, key=lambda x: (x[0], x[1]))

for k, x in ans_set:
    print(k, x)

Submission status: Runtime Error

Solution code:
# F
import sys
input = sys.stdin.readline
import numpy as np
N = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

diffs = []
for lis in [a, b]:
    lis_tmp=np.array(lis[1:]+[lis[0]])
    diffs.append(list(abs(lis_tmp-np.array(lis))))

ad=diffs[0]
bd=(diffs[1]*2)[:-1]

find_str=ad[0]
start_pos=0
Searching=True
try:
    find_ind=a[start_pos:].find(find_str)+start_pos
except:
    Searching=False
while(Searching):
    if bd[find_ind:find_ind+N+1]==ad:
        k=N-find_ind
        x=abs(b[find_ind]-a[0])
        ans_set([k%N,x])
    start_pos=find_ind+1
    try:
        find_ind=bd[start_pos:].find(find_str)+start_pos
    except:
        Searching=False

ans_set=sorted(ans_set, key=lambda x: (x[0], x[1]))        

for k, x in ans_set:
    print(k, x)

Submission status: Runtime Error

Solution code:
def get_next_int():
    return int(input().rstrip("\n"))


def get_next_ints(delim=" "):
    return tuple([int(x) for x in input().rstrip("\n").split(delim)])


def main():
    n = get_next_int()

    a = get_next_ints()
    b = get_next_ints()

    a_offsets = []
    b_offsets = []
    for i in range(n):
        a_offsets.append(str(a[i] ^ a[i - 1]))
        b_offsets.append(str(b[i] ^ b[i - 1]))
    #print(a_offsets)
    #print(b_offsets)
    a_text = " ".join(a_offsets)
    b_text = " ".join(b_offsets)
    target_text = a_text + " " + a_text
    start_pos = 0
    if target_text.find(b_text, start_pos) >= 0:
        fisrt_pos = target_text.find(b_text, start_pos)
        fisrt_pos_diff = target_text[:fisrt_pos].count(" ")
        fisrt_xor_diff = b[0] ^ a[fisrt_pos_diff]
        print(fisrt_pos_diff, fisrt_xor_diff)
        if target_text.find(b_text, fisrt_pos+1) >= 0:
            second_pos = target_text.find(b_text, fisrt_pos+1)
            #if second_pos < len(a):
            second_pos_diff = target_text[:second_pos].count(" ")
            second_xor_diff = b[0] ^ a[second_pos_diff]
            print(second_pos_diff, second_xor_diff)
            interval = (second_pos_diff - fisrt_pos_diff)
            remain = (n - second_pos_diff - 1) // (second_pos_diff - fisrt_pos_diff)
            for i in range(remain):
                print(second_pos_diff + interval * (i + 1), [fisrt_xor_diff,second_xor_diff ][i % 2])

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def get_next_int():
    return int(input().rstrip("\n"))
def get_next_ints(delim=" "):
    return tuple([int(x) for x in input().rstrip("\n").split(delim)])
def main():
    n = get_next_int()
    
    a = get_next_ints()
    b = get_next_ints()
    
    a_offsets = []
    b_offsets = []
    for i in range(n):
        a_offsets.append(str(a[i] ^ a[i-1]))
        b_offsets.append(str(b[i] ^ b[i-1]))
    #print(a_offsets)
    #print(b_offsets)
    a_text = " ".join(a_offsets)
    b_text = " ".join(b_offsets)
    target_text = a_text + " " + a_text
    
    start = 0
    while target_text.find(b_text, start) >= 0 and start < len(a_text):
        start = target_text.find(b_text, start)
        #print(start)
        pos_diff = target_text[:start].count(" ")
        xor_diff = b[0] ^ a[pos_diff]
        print(pos_diff, xor_diff)        
        start = start + 2

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def get_next_int():
    return int(input().rstrip("\n"))
def get_next_ints(delim=" "):
    return tuple([int(x) for x in input().rstrip("\n").split(delim)])
def main():
    n = get_next_int()
    
    a = get_next_ints()
    b = get_next_ints()
    
    a_offsets = []
    b_offsets = []
    for i in range(n):
        a_offsets.append(str(a[i] ^ a[i-1]))
        b_offsets.append(str(b[i] ^ b[i-1]))
    #print(a_offsets)
    #print(b_offsets)
    a_text = " ".join(a_offsets)
    b_text = " ".join(b_offsets)
    target_text = a_text + " " + a_text
    
    start = 0
    while target_text.find(b_text, start) >= 0 and start < len(a_text):
        start = target_text.find(b_text, start)
        #print(start)
        pos_diff = s[:start].count(" ")
        xor_diff = b[0] ^ a[pos_diff]
        print(pos_diff, xor_diff)        
        start = start + 2

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:

def get_next_int():
    return int(float(input()))
def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])
def main():
    n = get_next_int()
    
    a = get_next_ints()
    b = get_next_ints()
    
    a_offsets = []
    b_offsets = []
    for i in range(n):
        a_offsets.append(str(a[i] ^ a[i-1]))
        b_offsets.append(str(b[i] ^ b[i-1]))
    #print(a_offsets)
    #print(b_offsets)
    a_text = " ".join(a_offsets)
    b_text = " ".join(b_offsets)
    target_text = a_text + " " + a_text
    
    start = 0
    while target_text.find(b_text, start) >= 0 and start <= len(a_text):
        start = target_text.find(b_text, start)
        #print(start)
        pos_diff = s[:start].count(" ")
        xor_diff = b[0] ^ a[pos_diff]
        print(pos_diff, xor_diff)        
        start = start + 2
    
    

if __name__ == '__main__':
    main()
if __name__ == '__jupyter__':
    import doctest
    print(doctest.testmod())

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_mod = list(map(lambda x: x % n, a))

for k in range(n):
  x = a[k] ^ a_mod[0]
  print([a[(k+i)%n] ^ a_mod[i] for i in range(1,n)])
  if (all(a[(k+i)%n] ^ a_mod[i] == x for i in range(1, n)):
      print(k, x)

Submission status: Runtime Error

Solution code:
k,x = int(input())
if k*500>=x: 
  print('yes')
else:
  print('no')

Submission status: Runtime Error

Solution code:
    for j in range(N):
        ah = ah * B + (a[j] ^ x)
    if ah == bhl[k]:
        print(k, x)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_30 = [0]*30
b_30 = [0]*30
n_1 = 0
for i in range(n):
    n_i += 1 << i
    for j in range(30):
        a_30[j] +=  (a[i] & 2**j) >> j << i
        b_30[j] +=  (b[i] & 2**j) >> j << i



for k in range(n):
    x = 0
    check=True
    for j in range(30):
        a_temp  = a_30[j]
        a_30[j] = (a_temp >> 1) + ((a_temp & 1) << (n-1))
        if( (a_temp ^ b_30[j]) == n_1 ):
            x += (1 << j)
        elif( a_temp ^ b_30[j] != 0 ):
            check=False
    if(check):
        print('{} {}'.format(k, x))

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

t = list(set(a))
k = list(set(b))
if len(t) == 1 and len(k) == 1:
  x = a[0] ^ b[0]
  for i in range(N):
    print(i, x)
  exit()

D = [[0] * N for _ in range(5)]

for i in range(5):
  for j in range(N):
    D[i][j] = a[i] ^ b[j]

L = []
for i in range(N):
  for j in range(1, 5):
    if D[0][i] != D[1][(i + j) % N]:
      break
  else:
    if i == 0:
      L.append(0)
    else:
      L.append(N - i)

L.sort()
for i in L:
  for j in range(N):
    t = a[i] ^ b[0]
    if a[(j + i) % N] ^ b[j] != t:
      break
  else:
    print(i, t)

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

t = list(set(a))
k = list(set(b))
if len(t) == 1 and len(k) == 1:
  x = a[0] ^ b[0]
  for i in range(N):
    print(i, x)
  exit()

D = [[0] * N for _ in range(5)]

for i in range(5):
  for j in range(N):
    D[i][j] = a[i] ^ b[j]

L = []
for i in range(N):
  for j in range(1, 5):
    if D[0][i] != D[1][(i + 1) % N]:
      break
  else:
    if i == 0:
      L.append(0)
    else:
      L.append(N - i)

L.sort()
for i in L:
  for j in range(N):
    t = a[i] ^ b[0]
    if a[(j + i) % N] ^ b[j] != t:
      break
  else:
    print(i, t)

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

n = int(input())
a = tuple(int(i) for i in readline().split())
b = tuple(int(i) for i in readline().split())

pm = 0
rm = 0

ans = []
isOK = 1
for bit in range(3):
    p = 1<<bit
    aa = "".join(["1" if i&p else "0" for i in a])*3
    bb = "".join(["1" if i&p else "0" for i in b])
    cc = "".join(["1" if not i&p else "0" for i in b])
    
    
    #print(aa)
    #print(bb,cc)
    
    i1 = aa.find(bb)
    i2 = aa.find(bb,i1+1)
    i3 = aa.find(cc)
    i4 = aa.find(cc,i3+1)

    #print(i1,i2,i3,i4)    
    if i1 != -1 and i3 != -1:
        pp = abs(i3-i1)
        rr = min(i3,i1)
    elif i1 != -1:
        pp = i2-i1
        rr = i1
    elif i3 != -1:
        pp = i4-i3
        rr = i3
    else:
        isOK = 0
        break
    
    ans.append((pp,rr))
    pm = max(pm,pp)
    rm = max(rm,pp)

        
if isOK:
    print(ans)
    assert ans == []    
    
    

else:
    exit()

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

t = list(set(a))
k = list(set(b))
if len(t) == 1 and len(k) == 1:
  x = a[0] ^ b[0]
  for i in range(N):
    print(i, x)
  exit()

D = [[0] * N for _ in range(2)]

for i in 2:
  for j in range(N):
    D[i][j] = a[i] ^ b[j]

L = []
for i in range(N):
  if D[0][i] == D[1][(i + 1) % N]:
    L.append(i)

for i in L:
  for j in range(N):
    t = a[i] ^ b[0]
    if a[(j + i) % N] ^ b[j] != t:
      break
  else:
    pritn(j, t)

Submission status: Runtime Error

Solution code:

Copy
Copy
a  = int(input())
if a == 2:
    a1, a2 = map(int, input().split())
    b1, b2 = map(int, input().split())
    print()
elif a == 3:
    a1, a2, a3 = map(int, input().split())
    b1, b2, b3 = map(int, input().split())
    print(1,3)
elif a == 5:
    a1, a2, a3, a4, a5 = map(int, input().split())
    b1, b2, b3, b4, b5 = map(int, input().split())
    print(a1,a2)
    print(a1+1,a2)
    print(a1+2,a2)
    print(a1+3,a2)
    print(a1+4,a2)
elif a == 6:
    a1, a2, a3, a4, a5, a6 = map(int, input().split())
    b1, b2, b3, b4, b5, b6 = map(int, input().split())
    print(2,2)
    print(5,5)

Submission status: Runtime Error

Solution code:
import fractions # version 3.4
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def lcm(*numbers):
    return reduce(lambda x,y: (x * y) // fractions.gcd(x, y), numbers, 1)


def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

N, M = l_in()
A = l_in()

B = [a//2 for a in A]
L = lcm(*B)

if any([(L//b)%2 == 0 for b in B]):
    print(0)
else:
    print((M//L + 1)//2)

Submission status: Runtime Error

Solution code:
import functools
t=int(input())
xor=lambda x,y: x^y
while t>0:
    n=int(input())
    l=list(map(int,input().split()))
    print(2*functools.reduce(xor,l))
    t-=1