Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, = map(int, input().split())
M=10**9+7
n=N
_ALL=1<<n
def itercomb(n,k):
    if k==0:
        yield 0
    else:
        _a = (1<<k)-1
        yield _a
        while 1:
            _x = _a & -_a
            _y = _a + _x
            _a = (((_a & ~_y) // _x) >> 1) | _y
            if _a >= _ALL: break
            yield _a


xs = []
for _ in range(N):
    xs.append([1<<i for i, x in enumerate(input().split()) if int(x)])
d = [0]*(1<<N)
d[0] = 1
for i, x in enumerate(xs):
    for ai in x:
        for x in itercomb(N, i):
            if (not x&ai):
                d[x|ai] = (d[x|ai]+d[x])%M
print(d[-1])


Fixed submission:
N, = map(int, input().split())
M=10**9+7
n=N
_ALL=1<<n
def itercomb(n,k):
    if k==0:
        yield 0
    else:
        _a = (1<<k)-1
        yield _a
        while 1:
            _x = _a & -_a
            _y = _a + _x
            _a = (((_a & ~_y) // _x) >> 1) | _y
            if _a >= _ALL: break
            yield _a


xs = []
for _ in range(N):
    xs.append([1<<i for i, x in enumerate(input().split()) if int(x)])
d = [0]*(1<<N)
d[0] = 1
for i, y in enumerate(xs):
    for x in itercomb(N, i):
        for ai in y:
            if (not x&ai):
                d[x|ai] += d[x]%M
                if d[x|ai] >M:
                    d[x|ai]-=M
print(d[-1])

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

N, = map(int, input().split())
xs = []
ss = [2**i for i in range(N)]
for _ in range(N):
    xs.append(sum(int(x)*(1<<i) for i, x in enumerate(input().split())))
M=10**9+7
d = [0]*(1<<N)
d[0] = 1
for i in range(N):
    a = xs[i]
    for j in combinations(ss, i):
        x = sum(j)
        for k in range(N):
            ai = ((a//(1<<k))%2)<<k
            if ai and (not x&ai):
                d[x|ai] = (d[x|ai]+d[x])%M
print(d[-1])


Fixed submission:
N, = map(int, input().split())
M=10**9+7
n=N
_ALL=1<<n
def itercomb(n,k):
    if k==0:
        yield 0
    else:
        _a = (1<<k)-1
        yield _a
        while 1:
            _x = _a & -_a
            _y = _a + _x
            _a = (((_a & ~_y) // _x) >> 1) | _y
            if _a >= _ALL: break
            yield _a


xs = []
for _ in range(N):
    xs.append([1<<i for i, x in enumerate(input().split()) if int(x)])
d = [0]*(1<<N)
d[0] = 1
for i, y in enumerate(xs):
    for x in itercomb(N, i):
        for ai in y:
            if (not x&ai):
                d[x|ai] += d[x]%M
                if d[x|ai] >M:
                    d[x|ai]-=M
print(d[-1])
Buggy python submission (verdict: Time Limit Exceeded):
from numpy import*
N,K,*A=map(int,open(0).read().split())
X=matrix(A,"O").reshape(N,N)
M=10**9+7
S=1
while K:S*=~K%2or X;K//=2;X*=X%M
print(sum(S)%M)

Fixed submission:
import numpy as np
N, K = map(int, input().split())
M = 10**9+7
xs = []
for _ in range(N):
    xs.append(list(map(int, input().split())))
X = np.array(xs, dtype="object")
S = np.ones(N, dtype="object")
#Xs = [X]
for _ in range(60):
#    Xs.append(np.dot(Xs[-1],Xs[-1])%M)
    if K%2:
        S = np.dot(X, S)%M
    K = K//2
    X = np.dot(X, X)%M
S = np.array(S, dtype="int64")
r = 0
for s in S:
    r = (r + s)%M
print(r)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N, K = map(int, input().split())
M = 10**9+7
xs = []
for _ in range(N):
    xs.append(list(map(int, input().split())))
X = np.array(xs, dtype="int64")
S = np.ones(N, dtype="int64")
#Xs = [X]
for _ in range(60):
#    Xs.append(np.dot(Xs[-1],Xs[-1])%M)
    if K%2:
        S = np.dot(X, S)%M
    K = K//2
    X = np.dot(X, X)%M
r = 0
for s in S:
    r = (r + s)%M
print(r)


Fixed submission:
import numpy as np
N, K = map(int, input().split())
M = 10**9+7
xs = []
for _ in range(N):
    xs.append(list(map(int, input().split())))
X = np.array(xs, dtype="object")
S = np.ones(N, dtype="object")
#Xs = [X]
for _ in range(60):
#    Xs.append(np.dot(Xs[-1],Xs[-1])%M)
    if K%2:
        S = np.dot(X, S)%M
    K = K//2
    X = np.dot(X, X)%M
S = np.array(S, dtype="int64")
r = 0
for s in S:
    r = (r + s)%M
print(r)
Buggy python submission (verdict: Time Limit Exceeded):
K, = map(int, input().split())
D, = map(int, input().split())
N = len(str(K))
M = 10**9+7
dp = [[0]*D for _ in range(N+1)]
dp2 = [[0]*D for _ in range(N+1)]
dp[0][0] = 1
dp2[0][0] = 1
for i in range(1, N+1):
    Ki = (K//(10**(i-1))) % 10
    for j in range(D):
        for k in range(10):
            dp[i][(j+k)%D] = (dp[i][(j+k)%D] + dp[i-1][j])%M
        for k in range(Ki):
            dp2[i][(j+k)%D] = (dp2[i][(j+k)%D] + dp[i-1][j])%M
        dp2[i][(j+Ki)%D] = (dp2[i][(j+Ki)%D] + dp2[i-1][j])%M
print((dp2[N][0]-1)%M)


Fixed submission:
K, = map(int, input().split())
D, = map(int, input().split())
N = len(str(K))
M = 10**9+7
dp = [[0]*D for _ in range(N+1)]
dp2 = [[0]*D for _ in range(N+1)]
dp[0][0] = 1
dp2[0][0] = 1
for i in range(1, N+1):
    Ki = K%10
    K //= 10
    for j in range(D):
        for k in range(10):
            dp[i][(j+k)%D] += dp[i-1][j]
            dp[i][(j+k)%D] %= M
        for k in range(Ki):
            dp2[i][(j+k)%D] += dp[i-1][j]
            dp2[i][(j+k)%D] %= M
        dp2[i][(j+Ki)%D] += dp2[i-1][j]
        dp2[i][(j+Ki)%D] %= M
print((dp2[N][0]-1)%M)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N, M = map(int, input().split())
d = [set() for _ in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    d[a].add(b)
    d[b].add(a)

queue=deque([1])
vs = set([1])
vs_bfs = list()
parents = [0] * (N+1)
while queue:
    v = queue.popleft()
    vs_bfs.append(v)
    for u in d[v]:
        if u in vs:
            continue
        parents[u] = v
        vs.add(u)
        queue.append(u)

dp = [0]*(N+1)
for v in vs_bfs[::-1]:
    r = 1
    for u in d[v]:
        r *= dp[u]+1
    dp[v] = r

dp2 = [0]*(N+1)
for v in vs_bfs:
    if v == 1:
        dp2[v] = dp[v]
        continue
    p = parents[v]
    dp2[v] = dp[v] * ((dp2[p]//(dp[v]+1)) + 1)
for i in range(1, N+1):
    dp2[i] = str(dp2[i] % M)
print("\n".join(dp2[1:]))


Fixed submission:
from collections import deque
N, M = map(int, input().split())
d = [list() for _ in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    d[a].append(b)
    d[b].append(a)

queue=deque([1])
vs = set([1])
vs_bfs = list()
parents = [0] * (N+1)
while queue:
    v = queue.popleft()
    vs_bfs.append(v)
    for u in d[v]:
        if u in vs:
            continue
        parents[u] = v
        vs.add(u)
        queue.append(u)

dp = [0 for _ in range(N+1)]
dpl = [1 for _ in range(N+1)]
dpr = [1 for _ in range(N+1)]
for v in vs_bfs[::-1]:
    t = 1
    for u in d[v]:
        if u == parents[v]:
            continue
        dpl[u] = t
        t = (t * (dp[u]+1)) % M
    t = 1
    for u in d[v][::-1]:
        if u == parents[v]:
            continue
        dpr[u] = t
        t = (t * (dp[u]+1)) % M
    dp[v] = t

dp2 = [0]*(N+1)
for v in vs_bfs:
    if v == 1:
        dp2[v] = 1
        continue
    p = parents[v]
    dp2[v] = (dp2[p] * (dpl[v]*dpr[v]) +1)% M
#    print(dp2[p] * (dpl[v]*dpr[v]))
#    dp2[v] = dp2[p] %M
r = [0]*N
for i in range(1, N+1):
    r[i-1] = str(dp[i] * dp2[i] % M)
print("\n".join(r))
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N, M = map(int, input().split())

N0 = 2**((N+1).bit_length())
INF = 10**18
data = [0]*(2*N0)
lazy = [0]*(2*N0)

def gindex(l, r):
    L = l + N0; R = r + N0
    lm = (L // (L & -L)) >> 1
    rm = (R // (R & -R)) >> 1
    while L < R:
        if R <= rm:
            yield R
        if L <= lm:
            yield L
        L >>= 1; R >>= 1
    while L:
        yield L
        L >>= 1

def propagates(*ids):
    for i in reversed(ids):
        v = lazy[i-1]
        if not v:
            continue
        lazy[2*i-1] += v; lazy[2*i] += v
        data[2*i-1] += v; data[2*i] += v
        lazy[i-1] = 0
        
def update(l, r, x):
    L = N0 + l; R = N0 + r
    while L < R:
        if R & 1:
            R -= 1
            lazy[R-1] += x; data[R-1] += x
        if L & 1:
            lazy[L-1] += x; data[L-1] += x
            L += 1
        L >>= 1; R >>= 1

    for i in gindex(l, r):
        data[i-1] = max(data[2*i-1], data[2*i]) + lazy[i-1]

def update2(k, x):
    k += N0-1
    data[k] = x
    while k >= 0:
        k = (k - 1) // 2
        data[k] = max(data[2*k+1], data[2*k+2])

def query(l, r):
    propagates(*gindex(l, r))
    L = N0 + l; R = N0 + r
    s = -INF
    while L < R:
        if R & 1:
            R -= 1
            s = max(s, data[R-1])
        if L & 1:
            s = max(s, data[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s

xs = [0]*(N+1)
ys = [[] for _ in range(N+1)]
for _ in range(M):
    l, r, a = map(int, input().split())
    xs[l] += a
    ys[r].append((l,a))

for i in range(1, N+1):
    update(0,i,xs[i])
    update2(i, query(0, i))
    for l, a in ys[i]:
        update(0, l, -a)
print(query(0,N+1))


Fixed submission:
N, = map(int, input().split())
Xs = []
for i in range(N):
    X, Y, Z = map(int, input().split())
    Xs.append((X,Y,Z,i))
Xs.sort(key=lambda x : x[0]+x[1])

dp = [0]*(2*(10**4)+1)
for x,y,z,i in Xs:
#    print(i+1,x,y,z)
    for i in range(y+1):
        i = y-i
        dp[i+x] = max(dp[i+x], dp[i]+z)
#    print(dp[:10])
print(max(dp))
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
from itertools import combinations

N, K = [int(x) for x in input().strip().split(" ")]
As = [0] + [int(x) for x in input().strip().split(" ")]

aAs = list(accumulate(As))

keta = 41
d = [set() for _ in range(41)]

for i, j in combinations(range(N), 2):
    rr = aAs[j + 1] - aAs[i]
    rr = "{0:041d}".format(int(bin(rr)[2:]))
    for k in range(keta):
        if rr[k] == "1":
            d[k].add((i, j))

for i in range(N):
    j = i
    rr = As[i+1]
    rr = "{0:041d}".format(int(bin(rr)[2:]))
    for k in range(keta):
        if rr[k] == "1":
            d[k].add((i, j))

candidates = None
rr = 0
for i, ss in enumerate(d):
    if len(ss) < K:
        continue
    if candidates == None:
        candidates = ss
        rr += pow(2, 40-i)
    else:
        xx = ss & candidates
        if len(xx) < K:
            continue
        candidates = xx
        rr += pow(2, 40-i)
print(rr)


Fixed submission:
N, K = map(int, input().split())
from itertools import accumulate
As = [0] + list(map(int, input().split()))
As = list(accumulate(As))
L = len(bin(As[-1]))-2
xs = []
for i in range(N+1):
    for j in range(i+1, N+1):
        xs.append(As[j] - As[i])
xs.sort()
ts = set(range(N*(N+1)//2))
for j in range(L-1,-1,-1):
    nts = set()
    for i in ts:
        if (xs[i]>>j)%2:
            nts.add(i)
    if len(nts) >= K:
        ts = nts
c = 0
r = 0
for i in ts:
    c += 1
    if r == 0:
        r = xs[i]
    else:
        r = r&xs[i]
    if c == K:
        break
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
from itertools import combinations

N, K = [int(x) for x in input().strip().split(" ")]
As = [0] + [int(x) for x in input().strip().split(" ")]

aAs = list(accumulate(As))

keta = 41
d = [set() for _ in range(41)]

for i, j in combinations(range(N), 2):
    rr = aAs[j + 1] - aAs[i]
    rr = "{0:041d}".format(int(bin(rr)[2:]))
    for k in range(keta):
        if rr[k] == "1":
            d[k].add((i, j))

for i in range(N):
    j = i
    rr = As[i+1]
    rr = "{0:041d}".format(int(bin(rr)[2:]))
    for k in range(keta):
        if rr[k] == "1":
            d[k].add((i, j))

candidates = None
rr = 0
for i, ss in enumerate(d):
    if len(ss) < K:
        continue
    if candidates == None:
        candidates = ss
        rr += pow(2, 40-i)
    else:
        xx = ss & candidates
        if len(xx) < K:
            continue
        candidates = xx
        rr += pow(2, 40-i)
print(rr)


Fixed submission:
N, K = map(int, input().split())
from itertools import accumulate
As = [0] + list(map(int, input().split()))
As = list(accumulate(As))
L = len(bin(As[-1]))-2
xs = []
for i in range(N+1):
    for j in range(i+1, N+1):
        xs.append(As[j] - As[i])
xs.sort()
ts = set(range(N*(N+1)//2))
for j in range(L-1,-1,-1):
    nts = set()
    for i in ts:
        if (xs[i]>>j)%2:
            nts.add(i)
    if len(nts) >= K:
        ts = nts
c = 0
r = 0
for i in ts:
    c += 1
    if r == 0:
        r = xs[i]
    else:
        r = r&xs[i]
    if c == K:
        break
print(r)
Buggy python submission (verdict: Runtime Error):
import itertools
import sys
H, W = [int(i) for i in input().split(' ')]

cross = [[0] * (H + W -1) for _ in range(H + W - 1)]
for i, line in enumerate(sys.stdin):
    for j, c in enumerate(line.strip()):
        if c == "#":
            cross[i+j][i-j+W-1] = 1

across = [[0] + list(itertools.accumulate(xs)) for xs in cross]
r_cross = [[xs[i] for xs in cross] for i in range(H + W - 1)]
across2 = [[0] + list(itertools.accumulate(xs)) for xs in r_cross]

r = 0
for i in range(H+W-1):
    for j in range(H+W-1):
        if cross[i][j] != 1:
            continue
        for k in range(j+1, H+W-1):
            if cross[i][k] == 1:
                if i - (k-j) >= 0:
                    r += across[i - (k - j)][k+1] - across[i - (k - j)][j]
                if i + (k-j) < H + W - 1:
                    r += across[i + (k - j)][k+1] - across[i + (k - j)][j]

for i in range(H+W-1):
    for j in range(H+W-1):
        if cross[j][i] != 1:
            continue
        for k in range(j+1, H+W-1):
            if cross[k][i] == 1:
                if i - (k-j) >= 0:
                    r += across2[i - (k - j)][k] - across2[i - (k - j)][j+1]
                if i + (k-j) < H + W - 1:
                    r += across2[i + (k - j)][k] - across2[i + (k - j)][j+1]

print(r)


Fixed submission:
N, = [int(i) for i in input().split(' ')]
import sys
As = []
for line in sys.stdin:
    As.append(int(line.strip()))

As = sorted(As)
r = 0
r2 = 0
if N == 2:
    r = As[1] - As[0]
elif N == 3:
    r = max(2*As[2] - As[1] - As[0], As[2] + As[1] - 2 * As[0])
elif N % 2 == 1:
    r -= sum(As[:(N//2) - 1]) * 2
    r -= As[(N // 2)] + As[(N // 2) - 1]
    r += sum(As[(N // 2)+1:]) * 2
    #print(r)

    r2 -= sum(As[:(N//2)]) * 2
    r2 += As[(N // 2)+1] + As[(N // 2)]
    r2 += sum(As[(N // 2)+2:]) * 2
    #print(r2)
    r = max(r, r2)
else:
    #print(As[:(N//2) - 1])
    r -= sum(As[:(N//2) - 1]) * 2
    r += As[(N // 2)] - As[(N // 2) - 1]
    r += sum(As[(N // 2)+1:]) * 2
    #r2 -= sum(As[:(N//2)]) * 2
    #r2 += As[(N // 2)+1] + As[(N // 2)]
    #r2 += sum(As[(N // 2)+2:]) * 2
    #r = max(r, r2)
print(r)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import sys
H, W = [int(i) for i in input().split(' ')]

cross = [[0] * (H + W -1) for _ in range(H + W - 1)]
for i, line in enumerate(sys.stdin):
    for j, c in enumerate(line.strip()):
        if c == "#":
            cross[i+j][i-j+W-1] = 1

across = [[0] + list(itertools.accumulate(xs)) for xs in cross]
r_cross = [[xs[i] for xs in cross] for i in range(H + W - 1)]
across2 = [[0] + list(itertools.accumulate(xs)) for xs in r_cross]

r = 0
for i in range(H+W-1):
    for j in range(H+W-1):
        if cross[i][j] != 1:
            continue
        for k in range(j+1, H+W-1):
            if cross[i][k] == 1:
                if i - (k-j) >= 0:
                    r += across[i - (k - j)][k+1] - across[i - (k - j)][j]
                if i + (k-j) < H + W - 1:
                    r += across[i + (k - j)][k+1] - across[i + (k - j)][j]

for i in range(H+W-1):
    for j in range(H+W-1):
        if cross[j][i] != 1:
            continue
        for k in range(j+1, H+W-1):
            if cross[k][i] == 1:
                if i - (k-j) >= 0:
                    r += across2[i - (k - j)][k] - across2[i - (k - j)][j+1]
                if i + (k-j) < H + W - 1:
                    r += across2[i + (k - j)][k] - across2[i + (k - j)][j+1]

print(r)


Fixed submission:
import itertools
import sys
H, W = [int(i) for i in input().split(' ')]

cross = [[0] * (H + W -1) for _ in range(H + W - 1)]
for i, line in enumerate(sys.stdin):
    for j, c in enumerate(line.strip()):
        if c == "#":
            cross[i+j][i-j+W-1] = 1

across = [[0] + list(itertools.accumulate(xs)) for xs in cross]
r_cross = [[xs[i] for xs in cross] for i in range(H + W - 1)]
across2 = [[0] + list(itertools.accumulate(xs)) for xs in r_cross]

r = 0
for i in range(H+W-1):
    for j in range(H+W-1):
        if cross[i][j] != 1:
            continue
        for k in range(j+1, H+W-1):
            if cross[i][k] == 1:
                if i - (k-j) >= 0:
                    r += across[i - (k - j)][k+1] - across[i - (k - j)][j]
                if i + (k-j) < H + W - 1:
                    r += across[i + (k - j)][k+1] - across[i + (k - j)][j]

for i in range(H+W-1):
    for j in range(H+W-1):
        if cross[j][i] != 1:
            continue
        for k in range(j+1, H+W-1):
            if cross[k][i] == 1:
                if i - (k-j) >= 0:
                    r += across2[i - (k - j)][k] - across2[i - (k - j)][j+1]
                if i + (k-j) < H + W - 1:
                    r += across2[i + (k - j)][k] - across2[i + (k - j)][j+1]

print(r)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = [int(x) for x in input().strip().split(' ')]

for i in range(M//N):
#    n = N-i
    n = M//N-i
    if M % n == 0:
#        if M//n >= N:
        print(n)
        break


Fixed submission:
N, M = [int(x) for x in input().strip().split(' ')]

if N >= 1000:
    for i in range(M//N):
        n = (M//N)-i
        if M % n == 0:
            print(n)
            break
else:
    x = M//(M//N)
    for i in range(M):
        i = x +i
        if M % i == 0:
            print(M//i)
            break
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input().strip())
vs = [int(i) for i in input().split(' ')]
vs1 = vs[::2]
vs2 = vs[1::2]
a = Counter(vs1).most_common()
b = Counter(vs2).most_common()

if a[0][0] != b[0][0]:
    print(n - a[0][1] - b[0][1])
else:
    candidates = []
    if len(a) != 1:
        candidates.append(n - a[1][1] - b[0][1])
    if len(b) != 1:
        candidates.append(n - a[0][1] - b[1][1])
    if len(candidates) == 0:
        print(min(candidates))
    else:
        print(n//2)


Fixed submission:
from collections import Counter
n = int(input().strip())
vs = [int(i) for i in input().split(' ')]
vs1 = vs[::2]
vs2 = vs[1::2]
a = Counter(vs1).most_common()
b = Counter(vs2).most_common()

if a[0][0] != b[0][0]:
    print(n - a[0][1] - b[0][1])
else:
    candidates = []
    if len(a) != 1:
        candidates.append(n - a[1][1] - b[0][1])
    if len(b) != 1:
        candidates.append(n - a[0][1] - b[1][1])
    if len(candidates) != 0:
        print(min(candidates))
    else:
        print(n//2)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input().strip())
vs = [int(i) for i in input().split(' ')]
vs1 = vs[::2]
vs2 = vs[1::2]
a = Counter(vs1).most_common()
b = Counter(vs2).most_common()

if a[0][0] != b[0][0]:
    print(n - a[0][1] - b[0][1])
else:
    candidates = []
#    candidates.append(len(vs2))
    if len(a) != 1:
        candidates.append(n - a[1][1] - b[0][1])
    if len(b) != 1:
        candidates.append(n - a[0][1] - b[1][1])
    print(min(candidates))


Fixed submission:
from collections import Counter
n = int(input().strip())
vs = [int(i) for i in input().split(' ')]
vs1 = vs[::2]
vs2 = vs[1::2]
a = Counter(vs1).most_common()
b = Counter(vs2).most_common()

if a[0][0] != b[0][0]:
    print(n - a[0][1] - b[0][1])
else:
    candidates = []
    if len(a) != 1:
        candidates.append(n - a[1][1] - b[0][1])
    if len(b) != 1:
        candidates.append(n - a[0][1] - b[1][1])
    if len(candidates) != 0:
        print(min(candidates))
    else:
        print(n//2)
Buggy python submission (verdict: Runtime Error):
N = input()
import sys

rr = []
for line in sys.stdin:
    x, y = line.strip().split(" ")
    rr.append((int(x), int(y)))

mm = max([abs(x)+abs(y) for x, y in rr])

M = mm
ds = ['1'] * mm
#ds = ' '.join([1] * mm)
md = mm % 2
Rresult = []
for x, y in rr:
    if (x+y) % 2 != md:
        result = "-1"
        break
    else:
        result = ""
        result += "R" * x if x > 0 else "L" * abs(x)
        result += "U" * y if y > 0 else "D" * abs(y)
        result += "RL" * ((mm - abs(x) - abs(y))//2)
        Rresult.append(result)
if result == "-1":
    print(result)
else:
    print(M)
    print(' '.join(ds))
    print("\n".join(Rresult))


Fixed submission:
import sys


denum = 39

ds = [pow(2, i) for i in range(denum)]
max_ds = sum(ds)

N = input()
rr = []
for line in sys.stdin:
    x, y = line.strip().split(" ")
    rr.append((int(x) + int(y), int(x) - int(y)))

md = rr[0][0] % 2
if md == 0:
    ds = [1] + ds
Rresult = []
for u, v in rr:
    if u % 2 != md:
        result = "-1"
        break
    result = ""
    if md == 0:
        result = result + "R"
        u -= 1
        v -= 1
    u = (u + max_ds) // 2
    v = (v + max_ds) // 2
    binu = bin(u)[2:][::-1]
    binv = bin(v)[2:][::-1]
    for i in range(denum):
        ui = 0
        if i < len(binu):
            ui = int(binu[i])
        vi = 0
        if i < len(binv):
            vi = int(binv[i])
        #print(ui, vi)
        if ui == 1 and vi == 1:
            result = result + "R"
        if ui == 0 and vi == 0:
            result = result + "L"
        if ui == 1 and vi == 0:
            result = result + "U"
        if ui == 0 and vi == 1:
            result = result + "D"
    Rresult.append(result)

ds = [str(x) for x in ds]
if result == "-1":
    print(result)
else:
    print(len(Rresult[0]))
    print(' '.join(ds))
    print("\n".join(Rresult))
Buggy python submission (verdict: Runtime Error):
N, M = [int(i) for i in input().split(' ')]
mod = pow(10, 9) + 7
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NNN = 10**4
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, NNN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    c = 0
    while n % i == 0:
      n /= i
      c+=1
    if c!=0:
        table.append(c)
    i += 1
  if n > 1:
    table.append(1)
  return table

xxs = prime_decomposition(M)

result = 1
for xx in xxs:
    result = mul(result, cmb(xx+N-1,xx,mod))
print(result)


Fixed submission:
N, M = [int(i) for i in input().split(' ')]
mod = pow(10, 9) + 7
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NNN = (10**5) * 2
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, NNN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    c = 0
    while n % i == 0:
      n /= i
      c+=1
    if c!=0:
        table.append(c)
    i += 1
  if n > 1:
    table.append(1)
  return table

xxs = prime_decomposition(M)

result = 1
for xx in xxs:
    result = mul(result, cmb(xx+N-1,xx,mod))
print(result)
Buggy python submission (verdict: Runtime Error):
import math
a,b = [int(i) for i in input().split(' ')]
xs = [int(i) for i in input().split(' ')]

temp = 0
result = 0
for i, x in enumerate(xs):
    if i == 0:
        result = abs(x - b)
    else:
        result = math.gcd(abs(x - temp), result)
    temp = x
print(result)


Fixed submission:
import math
def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a


a,b = [int(i) for i in input().split(' ')]
xs = [int(i) for i in input().split(' ')]
#a = pow(10, 5)

temp = 0
result = 0
for i, x in enumerate(xs):
    if i == 0:
        result = abs(x - b)
    else:
        result = gcd(abs(x - temp), result)
    temp = x
print(result)