Problem p02631 (python)

Fixed submission:
import sys
import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
import math
start=time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n=ri()
a=rl()
t=0
for i in a:
    t^=i
t=bin(t)[2:]
max_len=max(len(bin(max(a)))-2,len(t))

if len(t)<max_len:t="0"*(max_len-len(t))+t
try:
    a=list(map(lambda x : bin(x)[2:],a))
except:
    sys.exit()
    
try:
    for i in range(n):
        if len(a[i])<max_len:
            a[i]="0"*(max_len-len(a[i]))+a[i]
except:
    sys.exit()


ans=[[] for i in range(n)]
for i in range(max_len):
    for j in range(n):  
            if a[j][i]==t[i]:
                ans[j].append("0")
            else:
                ans[j].append("1")

for i in ans:
    print(int("".join(i), 2))

Buggy submission (verdict: Runtime Error):
import sys
import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
import math
start=time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n=ri()
a=rl()
t=0
for i in a:
    t^=i
t=bin(t)[2:]
max_len=max(len(bin(max(a)))-2,len(t))

if len(t)<max_len:t="0"+t
try:
    a=list(map(lambda x : bin(x)[2:],a))
except:
    sys.exit()
    
try:
    for i in range(n):
        if len(a[i])<max_len:
            a[i]="0"+a[i]
except:
    sys.exit()


#print(a)
ans=[[] for i in range(n)]
for i in range(max_len):
    for j in range(n):
        if a[j][i]==t[i]:
            ans[j].append("0")
        else:
            ans[j].append("1")
#print(ans)
for i in ans:
    print(int("".join(i), 2))

Buggy submission (verdict: Runtime Error):
import sys
import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
import math
start=time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n=ri()
a=rl()
t=0
for i in a:
    t^=i
t=bin(t)[2:]
max_len=max(len(bin(max(a)))-2,len(t))

if len(t)<max_len:t="0"+t
try:
    a=list(map(lambda x : bin(x)[2:],a))
except:
    sys.exit()
    
try:
    for i in range(n):
    if len(a[i])<max_len:
        a[i]="0"+a[i]
except:
    sys.exit()


#print(a)
ans=[[] for i in range(n)]
for i in range(max_len):
    for j in range(n):
        if a[j][i]==t[i]:
            ans[j].append("0")
        else:
            ans[j].append("1")
#print(ans)
for i in ans:
    print(int("".join(i), 2))

Buggy submission (verdict: Runtime Error):
import sys
import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
import math
start=time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n=ri()
a=rl()
t=0
for i in a:
    t^=i
t=bin(t)[2:]
max_len=max(len(bin(max(a)))-2,len(t))

if len(t)<max_len:t="0"+t
try:
    a=list(map(lambda x : bin(x)[2:],a))
except:
    sys.exit()
    
    

for i in range(n):
    if len(a[i])<max_len:
        a[i]="0"+a[i]
#print(a)
ans=[[] for i in range(n)]
for i in range(max_len):
    for j in range(n):
        if a[j][i]==t[i]:
            ans[j].append("0")
        else:
            ans[j].append("1")
#print(ans)
for i in ans:
    print(int("".join(i), 2))

Buggy submission (verdict: Runtime Error):
import sys
import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
import math
start=time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n=ri()
a=rl()
t=0
for i in a:
    t^=i
t=bin(t)[2:]
max_len=max(len(bin(max(a)))-2,len(t))
#print(max_len)
if len(t)<max_len:t="0"+t
#print(t)
a=list(map(lambda x : bin(x)[2:],a))
for i in range(n):
    if len(a[i])<max_len:
        a[i]="0"+a[i]
#print(a)
ans=[[] for i in range(n)]
for i in range(max_len):
    for j in range(n):
        if a[j][i]==t[i]:
            ans[j].append("0")
        else:
            ans[j].append("1")
#print(ans)
for i in ans:
    print(int("".join(i), 2))

Buggy submission (verdict: Runtime Error):
import sys
import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
import math
start=time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n=ri()
a=rl()
t=0
for i in a:
    t^=i
t=bin(t)[2:]
max_len=len(bin(max(a)))-2
#print(max_len)
if len(t)<max_len:t="0"+t
#print(t)
a=list(map(lambda x : bin(x)[2:],a))
for i in range(n):
    if len(a[i])<max_len:
        a[i]="0"+a[i]
#print(a)
ans=[[] for i in range(n)]
for i in range(max_len):
    for j in range(n):
        if a[j][i]==t[i]:
            ans[j].append("0")
        else:
            ans[j].append("1")
#print(ans)
for i in ans:
    print(int("".join(i), 2))