s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s310823786 | p02235 | u970436839 | 1453257693 | Python | Python | py | Runtime Error | 0 | 0 | 363 | def lcs_size():
X = input()
Y = input()
a = len(X)
b = len(Y)
z2 = [0 for in range(b+1)]
maxl = 0
for i in range(a):
z1 = z2 + []
for j in range(b):
if X[i] == Y[j]:
z2[j+1] = z1[j] + 1
else:
z2[j+1] = z2[j]
maxl = max(maxl, z2[j+1])
return maxl
q = input()
for i in range(q):
print lcs_siz() |
s645569844 | p02235 | u630265299 | 1453257706 | Python | Python | py | Runtime Error | 0 | 0 | 414 | def LCS(Xs, Ys):
Xs = raw_input()
Ys = raw_input()
dp = {}
count = 0
a = 1
for i in range(len(Ys) + 1):
dp[0][i + 1] = Ys[i]
for j in range(len(Xs) + 1):
dp[j + 1][0] = Xs[j]
for i in range(a, len(Ys) + 1):
for j in range(a, len(Xs) + 1):
if dp[j][0] == dp[i][1]:
count = count + 1
a = j
break
if dp[j][0] == dp[i][1]:
break
print count |
s460986431 | p02235 | u970436839 | 1453257776 | Python | Python | py | Runtime Error | 0 | 0 | 322 | def lcs_size():
X = input()
Y = input()
a = len(X)
b = len(Y)
z2 = [0 for in range(b+1)]
for i in range(a):
z1 = z2 + []
for j in range(b):
if X[i] == Y[j]:
z2[j+1] = z1[j] + 1
else:
z2[j+1] = z2[j]
return z2[-1]
q = input()
for i in range(q):
print lcs_siz() |
s322688667 | p02235 | u970436839 | 1453257830 | Python | Python | py | Runtime Error | 0 | 0 | 330 | def lcs_size():
X = raw_input()
Y = raw_input()
a = len(X)
b = len(Y)
z2 = [0 for in range(b+1)]
for i in range(a):
z1 = z2 + []
for j in range(b):
if X[i] == Y[j]:
z2[j+1] = z1[j] + 1
else:
z2[j+1] = z2[j]
return z2[-1]
q = input()
for i in range(q):
print lcs_siz() |
s668038856 | p02235 | u630265299 | 1453257834 | Python | Python | py | Runtime Error | 0 | 0 | 401 | Xs = raw_input()
Ys = raw_input()
dp = {}
count = 0
a = 1
for i in range(len(Ys) + 1):
dp[0][i + 1] = Ys[i]
for j in range(len(Xs) + 1):
dp[j + 1][0] = Xs[j]
for i in range(1, len(Ys) + 1):
for j in range(a + 1, len(Xs) + 1):
if dp[j][0] == dp[i][1]:
count = count + 1
a = j
break
if dp[j][0] == dp[i][1]:
break
print count |
s522237907 | p02235 | u630265299 | 1453257888 | Python | Python | py | Runtime Error | 0 | 0 | 391 | Xs = raw_input()
Ys = raw_input()
count = 0
a = 1
for i in range(len(Ys) + 1):
dp[0][i + 1] = Ys[i]
for j in range(len(Xs) + 1):
dp[j + 1][0] = Xs[j]
for i in range(1, len(Ys) + 1):
for j in range(a + 1, len(Xs) + 1):
if dp[j][0] == dp[i][1]:
count = count + 1
a = j
break
if dp[j][0] == dp[i][1]:
break
print count |
s520914721 | p02235 | u970436839 | 1453257969 | Python | Python | py | Runtime Error | 0 | 0 | 347 | def lcs_size():
X = raw_input()
Y = raw_input()
a = len(X)
b = len(Y)
z2 = [0 for in range(b+1)]
for i in range(a):
z1 = z2 + []
for j in range(b):
if X[i] == Y[j]:
z2[j+1] = z1[j] + 1
elif z2[j+1] < z2[j]:
z2[j+1] = z2[j]
return z2[-1]
q = input()
for i in range(q):
print lcs_siz() |
s997938013 | p02235 | u630265299 | 1453257973 | Python | Python | py | Runtime Error | 0 | 0 | 391 | Xs = raw_input()
Ys = raw_input()
count = 0
a = 0
for j in range(len(Ys) + 1):
dp[0][j + 1] = Ys[i]
for i in range(len(Xs) + 1):
dp[i + 1][0] = Xs[j]
for j in range(1, len(Ys) + 1):
for i in range(a + 1, len(Xs) + 1):
if dp[i][0] == dp[j][1]:
count = count + 1
a = j
break
if dp[j][0] == dp[i][1]:
break
print count |
s562947385 | p02235 | u970436839 | 1453258005 | Python | Python | py | Runtime Error | 0 | 0 | 349 | def lcs_size():
X = raw_input()
Y = raw_input()
a = len(X)
b = len(Y)
z2 = [0 for i in range(b+1)]
for i in range(a):
z1 = z2 + []
for j in range(b):
if X[i] == Y[j]:
z2[j+1] = z1[j] + 1
elif z2[j+1] < z2[j]:
z2[j+1] = z2[j]
return z2[-1]
q = input()
for i in range(q):
print lcs_siz() |
s500048790 | p02235 | u630265299 | 1453258056 | Python | Python | py | Runtime Error | 0 | 0 | 383 | Xs = raw_input()
Ys = raw_input()
count = 0
a = 0
for j in range(len(Ys) + 1):
dp[1][j] = Ys[j]
for i in range(len(Xs) + 1):
dp[i][1] = Xs[i]
for j in range(1, len(Ys) + 1):
for i in range(a + 1, len(Xs) + 1):
if dp[i][0] == dp[j][1]:
count = count + 1
a = j
break
if dp[j][0] == dp[i][1]:
break
print count |
s182544561 | p02235 | u233232390 | 1453258130 | Python | Python | py | Runtime Error | 0 | 0 | 342 | def solve():
seq1 = raw_input()
seq2 = raw_input()
a, b = len(seq1), len(seq2)
x1 = [0 for i in range(b+1)]
for i in range(a):
e1 = seq1[i]
x2 = x1+[]
for j in range(b):
if e1 == seq2[j]:
x1[j+1] = x2[j] + 1
elif x1[j+1]<x1[j]:
x1[j+1] = x1[j]
return x1[-1]
n = input()
for i2 in range(n):
print solve() |
s561935543 | p02235 | u630265299 | 1453258349 | Python | Python | py | Runtime Error | 0 | 0 | 353 | Xs = raw_input()
Ys = raw_input()
count = 0
a = 0
for j in range(len(Ys) + 1):
dp[0][j + 1] = Ys[j]
for i in range(len(Xs) + 1):
dp[i + 1][0] = Xs[i]
for j in range(1, len(Ys) + 1):
for i in range(a + 1, len(Xs) + 1):
if dp[i][0] == dp[0][j]:
count = count + 1
a = i
break
print count |
s253080472 | p02235 | u630265299 | 1453258564 | Python | Python | py | Runtime Error | 0 | 0 | 383 | n = input()
for i in range(n)
Xs = raw_input()
Ys = raw_input()
count = 0
a = 0
for j in range(len(Ys) + 1):
dp[0][j + 1] = Ys[j]
for i in range(len(Xs) + 1):
dp[i + 1][0] = Xs[i]
for j in range(1, len(Ys) + 1):
for i in range(a + 1, len(Xs) + 1):
if dp[i][0] == dp[0][j]:
count = count + 1
a = i
break
print count |
s728817614 | p02235 | u630265299 | 1453258639 | Python | Python | py | Runtime Error | 0 | 0 | 393 | n = input()
for i in range(n)
Xs = raw_input()
Ys = raw_input()
count = 0
a = 0
dp = {}
for j in range(len(Ys) + 1):
dp[0][j + 1] = Ys[j]
for i in range(len(Xs) + 1):
dp[i + 1][0] = Xs[i]
for j in range(1, len(Ys) + 1):
for i in range(a + 1, len(Xs) + 1):
if dp[i][0] == dp[0][j]:
count = count + 1
a = i
break
print count |
s604566571 | p02235 | u630265299 | 1453258676 | Python | Python | py | Runtime Error | 0 | 0 | 393 | n = input()
for i in range(n)
Xs = raw_input()
Ys = raw_input()
count = 0
a = 0
dp = {}
for j in range(len(Ys) + 1):
dp[0][j + 1] = Ys[j]
for i in range(len(Xs) + 1):
dp[i + 1][0] = Xs[i]
for j in range(1, len(Ys) + 1):
for i in range(a + 1, len(Xs) + 1):
if dp[i][0] == dp[0][j]:
count = count + 1
a = i
break
print count |
s351958308 | p02235 | u177808190 | 1453258826 | Python | Python | py | Runtime Error | 0 | 0 | 407 | def lcs(X, Y):
X = " " + X
Y = " " + Y
c = []
for i in X:
for j in Y:
if X[i] == Y[j]:
c[i][j] = c[i - 1][j - 1] + 1
else:
c[i][j] = max(c[i - 1][j], c[i][j - 1])
maxl = max(maxl, c[i][j])
n = int(raw_input())
for i in range(n):
s1 = raw_input()
s2 = raw_input()
print lcs(s1, s2)
|
s212830914 | p02235 | u731976921 | 1453259991 | Python | Python | py | Runtime Error | 0 | 0 | 448 | def lcs(s, t):
slen = len(s)
tlen = len(t)
dp = [None] * (slen + 1)
for i in range(slen + 1):
dp[i] = [0] * (tlen + 1)
for i in range(1, slen + 1):
for j in range(1, tlen + 1):
if s[i-1] == t[j-1]:
dp[i][j] = dp[i-1][j-1] + 1
else:
dp[i][j] = max(dp[i][j-1], dp[i-1][j])
return dp[slen][tlen]
n = int(raw_input())
for i in range(max(n, 20)):
x = raw_input()
y = raw_input()
print lcs(x, y) |
s383224304 | p02235 | u253463900 | 1453285635 | Python | Python3 | py | Runtime Error | 0 | 0 | 581 | n = int(input())
dataset = []
for i in range(n):
tmp = []
tmp.append(input())
tmp.append(input())
dataset.append(tmp)
for data in dataset:
m = len(data[0])
n = len(data[1])
dp = []
for x in range(n+1):
dp.append([0] *(m+1))
for j in range(n):
for i in range(m):
if data[0][i] == data[1][j]:
dp[j+1][i+1] = dp[j][i] + 1
else:
#dp[j+1][i+1] = max(dp[j+1][i], dp[j][i+1])
dp[J+1][i+1] = dp[j+1][i] if dp[j+1][i]>dp[j][i+1] else dp[j][i+1]
print(dp[n][m]) |
s194152904 | p02235 | u253463900 | 1453285722 | Python | Python3 | py | Runtime Error | 0 | 0 | 581 | n = int(input())
dataset = []
for i in range(n):
tmp = []
tmp.append(input())
tmp.append(input())
dataset.append(tmp)
for data in dataset:
m = len(data[0])
n = len(data[1])
dp = []
for x in range(n+1):
dp.append([0] *(m+1))
for j in range(n):
for i in range(m):
if data[0][i] == data[1][j]:
dp[j+1][i+1] = dp[j][i] + 1
else:
#dp[j+1][i+1] = max(dp[j+1][i], dp[j][i+1])
dp[J+1][i+1] = dp[j+1][i] if dp[j+1][i]>dp[j][i+1] else dp[j][i+1]
print(dp[n][m]) |
s187300769 | p02235 | u253463900 | 1453285891 | Python | Python3 | py | Runtime Error | 0 | 0 | 564 | n = int(input())
dataset = []
for i in range(n):
tmp = []
tmp.append(input())
tmp.append(input())
dataset.append(tmp)
for data in dataset:
m = len(data[0])
n = len(data[1])
dp = []
for x in range(n+1):
dp.append([0] *(m+1))
for j in range(n):
for i in range(m):
if data[0][i] == data[1][j]:
dp[j+1][i+1] = dp[j][i] + 1
elif dp[j+1][i]>dp[j][i+1]:
dp[J+1][i+1] = dp[j+1][i]
else:
dp[j+1][i+1] = dp[j][i+1]
print(dp[n][m]) |
s613416658 | p02235 | u970436839 | 1453296788 | Python | Python | py | Runtime Error | 0 | 0 | 317 | def lcs_size():
X = input()
Y = input()
a = len(X)
b = len(Y)
z2 = [0 for i in range(b+1)]
for i in range(a):
z1 = z2 + []
for j in range(b):
if X[i] == Y[j]:
z2[j+1] = z1[j] + 1
else:
z2[j+1] = z2[j]
return z2[-1]
q = input()
for k in range(q):
print lcs_size() |
s510584125 | p02235 | u970436839 | 1453296876 | Python | Python | py | Runtime Error | 0 | 0 | 330 | def lcs_size():
X = input()
Y = input()
a = len(X)
b = len(Y)
z2 = [0 for i in range(b+1)]
for i in range(a):
ch = X[i]
z1 = z2 + []
for j in range(b):
if Xch == Y[j]:
z2[j+1] = z1[j] + 1
else:
z2[j+1] = z2[j]
return z2[-1]
q = input()
for k in range(q):
print lcs_size() |
s971575672 | p02235 | u970436839 | 1453296904 | Python | Python | py | Runtime Error | 0 | 0 | 329 | def lcs_size():
X = input()
Y = input()
a = len(X)
b = len(Y)
z2 = [0 for i in range(b+1)]
for i in range(a):
ch = X[i]
z1 = z2 + []
for j in range(b):
if ch == Y[j]:
z2[j+1] = z1[j] + 1
else:
z2[j+1] = z2[j]
return z2[-1]
q = input()
for k in range(q):
print lcs_size() |
s932357032 | p02235 | u069446126 | 1453308779 | Python | Python | py | Runtime Error | 0 | 0 | 513 |
q = int(raw_input())
for i in range(q):
X = raw_input()
Y = raw_input()
print LCS(X, Y)
def LCS(x, y):
dp = {}
for i in range(len(x)+1):
dp[i] = {0: i}
for j in range(len(y)+1):
dp[0][j] = j
for i in range(1, len(x)+1):
for j in range(1, len(y)+1):
d = 0 if x[i-1] == t[j-1] else 1
dp[i][j] = min(dp[i-1][j] + 1, dp[i][j-1] + 1, dp[i-1][j-1] + d)
longer = max(len(x), len(y))
return (longer - dp[len(x)][len(y)]) |
s911570244 | p02235 | u069446126 | 1453308898 | Python | Python | py | Runtime Error | 0 | 0 | 508 |
def LCS(x, y):
dp = {}
for i in range(len(x)+1):
dp[i] = {0: i}
for j in range(len(y)+1):
dp[0][j] = j
for i in range(1, len(x)+1):
for j in range(1, len(y)+1):
d = 0 if x[i-1] == t[j-1] else 1
dp[i][j] = min(dp[i-1][j] + 1, dp[i][j-1] + 1, dp[i-1][j-1] + d)
longer = max(len(x), len(y))
return (longer - dp[len(x)][len(y)])
q = int(raw_input())
for i in range(q):
X = raw_input()
Y = raw_input()
print LCS(X, Y) |
s693727738 | p02235 | u069446126 | 1453308946 | Python | Python | py | Runtime Error | 0 | 0 | 509 |
def LCS(x, y):
dp = {}
for i in range(len(x)+1):
dp[i] = {0: i}
for j in range(len(y)+1):
dp[0][j] = j
for i in range(1, len(x)+1):
for j in range(1, len(y)+1):
d = 0 if x[i-1] == t[j-1] else 1
dp[i][j] = min(dp[i-1][j] + 1, dp[i][j-1] + 1, dp[i-1][j-1] + d)
longer = max(len(x), len(y))
return (longer - dp[len(x)][len(y)])
q = int(raw_input())
for i in range(q):
X = raw_input()
Y = raw_input()
print(LCS(X, Y)) |
s183121271 | p02235 | u069446126 | 1453309177 | Python | Python | py | Runtime Error | 0 | 0 | 509 |
def LCS(x, y):
dp = {}
for i in range(len(x)+1):
dp[i] = {0: i}
for j in range(len(y)+1):
dp[0][j] = j
for i in range(1, len(x)+1):
for j in range(1, len(y)+1):
d = 0 if x[i-1] == t[j-1] else 1
dp[i][j] = min(dp[i-1][j] + 1, dp[i][j-1] + 1, dp[i-1][j-1] + d)
longer = max(len(x), len(y))
return (longer - dp[len(x)][len(y)])
q = int(raw_input())
for i in range(q):
X = raw_input()
Y = raw_input()
print(LCS(X, Y)) |
s240466672 | p02235 | u069446126 | 1453313747 | Python | Python | py | Runtime Error | 0 | 0 | 489 |
def LCS(x, y):
dp = {}
for i in range(len(x)+1):
dp[i] = {0: 0}
for j in range(len(y)+1):
dp[0][j] = 0
for i in range(1, len(x)+1):
for j in range(1, len(y)+1):
if x[i] == y[j]:
dp[i][j] = dp[i-1][j-1] + 1
else:
dp[i][j] = max(dp[i][j-1], dp[i-1][j])
return dp[len(x)][len(y)]
q = int(raw_input())
for i in range(q):
X = raw_input()
Y = raw_input()
print(LCS(X, Y)) |
s596101581 | p02235 | u047737909 | 1453343432 | Python | Python | py | Runtime Error | 0 | 0 | 404 | def edit_distance(s, t):
s=raw_input()
t=raw_input()
dp = {}
for i in range(len(s) + 1):
dp[i] = {0: i}
for j in range(len(t) + 1):
dp[0][j] = j
for i in range(1, len(s) + 1):
for j in range(1, len(t) + 1):
d = 0 if s[i-1] == t[j-1] else 1
dp[i][j] = min(dp[i-1][j] + 1,
dp[i][j-1] + 1,
dp[i-1][j-1] + d)
return dp[len(s)][len(t)]
n = input()
for p in range(n):
print solve() |
s263841372 | p02235 | u047737909 | 1453343506 | Python | Python | py | Runtime Error | 0 | 0 | 416 | def edit_distance(s, t):
s=raw_input()
t=raw_input()
dp = {}
for i in range(len(s) + 1):
dp[i] = {0: i}
for j in range(len(t) + 1):
dp[0][j] = j
for i in range(1, len(s) + 1):
for j in range(1, len(t) + 1):
d = 0 if s[i-1] == t[j-1] else 1
dp[i][j] = min(dp[i-1][j] + 1,
dp[i][j-1] + 1,
dp[i-1][j-1] + d)
return dp[len(s)][len(t)]
n = input()
for p in range(n):
print edit_distance(s, t) |
s674274758 | p02235 | u047737909 | 1453343811 | Python | Python | py | Runtime Error | 0 | 0 | 416 | def edit_distance(s, t):
s=raw_input()
t=raw_input()
dp = {}
for i in range(len(s) + 1):
dp[i] = {0: i}
for j in range(len(t) + 1):
dp[0][j] = j
for i in range(1, len(s) + 1):
for j in range(1, len(t) + 1):
d = 0 if s[i-1] == t[j-1] else 1
dp[i][j] = min(dp[i-1][j] + 1,
dp[i][j-1] + 1,
dp[i-1][j-1] + d)
return dp[len(s)][len(t)]
n = input()
for p in range(n):
print edit_distance(s, t) |
s635970172 | p02235 | u047737909 | 1453343848 | Python | Python | py | Runtime Error | 0 | 0 | 412 | def edit_distance(s, t):
s=raw_input()
t=raw_input()
dp = {}
for i in range(len(s) + 1):
dp[i] = {0: i}
for j in range(len(t) + 1):
dp[0][j] = j
for i in range(1, len(s) + 1):
for j in range(1, len(t) + 1):
d = 0 if s[i-1] == t[j-1] else 1
dp[i][j] = min(dp[i-1][j] + 1,
dp[i][j-1] + 1,
dp[i-1][j-1] + d)
return dp[len(s)][len(t)]
n = input()
for p in range(n):
print edit_distance() |
s840858095 | p02235 | u047737909 | 1453344026 | Python | Python | py | Runtime Error | 0 | 0 | 416 | def edit_distance(s, t):
s=raw_input()
t=raw_input()
dp = {}
for i in range(len(s) + 1):
dp[i] = {0: i}
for j in range(len(t) + 1):
dp[0][j] = j
for i in range(1, len(s) + 1):
for j in range(1, len(t) + 1):
if(s[i-1] == t[j-1]):
d==0
else:
dp[i][j] = min(dp[i-1][j] + 1,dp[i][j-1] + 1,dp[i-1][j-1] + d)
return dp[len(s)][len(t)]
n = input()
for p in range(n):
print edit_distance(s, t) |
s311218597 | p02235 | u047737909 | 1453344542 | Python | Python | py | Runtime Error | 0 | 0 | 417 | def edit_distance():
s = raw_input()
t = raw_input()
dp = {}
for i in range(len(s) + 1):
dp[i] = {0: i}
for j in range(len(t) + 1):
dp[0][j] = j
for i in range(1, len(s) + 1):
for j in range(1, len(t) + 1):
if (s[i-1] == t[j-1]):
d = 0
else:
dp[i][j] = min(dp[i-1][j] + 1, dp[i][j-1] + 1, dp[i-1][j-1] + d)
return dp[len(s)][len(t)]
n = input()
for p in range(n):
print edit_distance() |
s658721522 | p02235 | u047737909 | 1453344565 | Python | Python | py | Runtime Error | 0 | 0 | 424 | def edit_distance(s, t):
s = raw_input()
t = raw_input()
dp = {}
for i in range(len(s) + 1):
dp[i] = {0: i}
for j in range(len(t) + 1):
dp[0][j] = j
for i in range(1, len(s) + 1):
for j in range(1, len(t) + 1):
if (s[i-1] == t[j-1]):
d = 0
else:
dp[i][j] = min(dp[i-1][j] + 1, dp[i][j-1] + 1, dp[i-1][j-1] + d)
return dp[len(s)][len(t)]
n = input()
for p in range(n):
print edit_distance(s,t) |
s090070029 | p02235 | u047737909 | 1453344579 | Python | Python | py | Runtime Error | 0 | 0 | 421 | def edit_distance(s, t):
s = raw_input()
t = raw_input()
dp = {}
for i in range(len(s) + 1):
dp[i] = {0: i}
for j in range(len(t) + 1):
dp[0][j] = j
for i in range(1, len(s) + 1):
for j in range(1, len(t) + 1):
if (s[i-1] == t[j-1]):
d = 0
else:
dp[i][j] = min(dp[i-1][j] + 1, dp[i][j-1] + 1, dp[i-1][j-1] + d)
return dp[len(s)][len(t)]
n = input()
for p in range(n):
print edit_distance() |
s968580402 | p02235 | u047737909 | 1453344769 | Python | Python | py | Runtime Error | 0 | 0 | 424 | def edit_distance(s, t):
s = raw_input()
t = raw_input()
dp = {}
for i in range(len(s) + 1):
dp[i] = {0: i}
for j in range(len(t) + 1):
dp[0][j] = j
for i in range(1, len(s) + 1):
for j in range(1, len(t) + 1):
if (s[i-1] == t[j-1]):
d = 0
else:
dp[i][j] = min(dp[i-1][j] + 1, dp[i][j-1] + 1, dp[i-1][j-1] + d)
return dp[len(s)][len(t)]
n = input()
for p in range(n):
print edit_distance(s,t) |
s169148164 | p02235 | u047737909 | 1453345719 | Python | Python | py | Runtime Error | 0 | 0 | 339 | def edit_distance():
s = raw_input()
t = raw_input()
a = len(X)
b = len(Y)
x = [0 for i in range(b+1)]
for i in range(a):
q = s[i]
x2 = x1+[]
for j in range(b):
if (q ==t[j]):
x[j+1] =x2[j]+1
elif (x[j+1]<x2[j]+1):
x[j+1] =x2[j]
return x1[-1]
n = input()
for i2 in range(n):
print edit_distance()
|
s567348238 | p02235 | u047737909 | 1453345751 | Python | Python | py | Runtime Error | 0 | 0 | 339 | def edit_distance():
s = raw_input()
t = raw_input()
a = len(s)
b = len(t)
x = [0 for i in range(b+1)]
for i in range(a):
q = s[i]
x2 = x1+[]
for j in range(b):
if (q ==t[j]):
x[j+1] =x2[j]+1
elif (x[j+1]<x2[j]+1):
x[j+1] =x2[j]
return x1[-1]
n = input()
for i2 in range(n):
print edit_distance()
|
s864007889 | p02235 | u047737909 | 1453345911 | Python | Python | py | Runtime Error | 0 | 0 | 328 | def edit_distance():
s = raw_input()
t = raw_input()
a = len(s)
b = len(t)
x = [0 for i in range(b+1)]
for i in range(a):
q = s[i]
x2 = x1+[]
for j in range(b):
if (q ==t[j]):
x[j+1] =x2[j]+1
elif (x[j+1]<x[j]):
x[j+1] =x2[j]
return x1[-1]
n = input()
for i2 in range(n):
print edit_distance() |
s562225153 | p02235 | u047737909 | 1453345956 | Python | Python | py | Runtime Error | 0 | 0 | 327 | def edit_distance():
s = raw_input()
t = raw_input()
a = len(s)
b = len(t)
x = [0 for i in range(b+1)]
for i in range(a):
q = s[i]
x2 = x1+[]
for j in range(b):
if (q ==t[j]):
x[j+1] =x2[j]+1
elif (x[j+1]<x[j]):
x[j+1] =x2[j]
return x[-1]
n = input()
for i2 in range(n):
print edit_distance() |
s493056117 | p02235 | u834416077 | 1453358187 | Python | Python | py | Runtime Error | 0 | 0 | 338 | def solve():
X = raw_input()
Y = raw_input()
a = len(X)
b = len(Y)
c1 = [0 for i in range(b+1)]
for i in range(a):
c2 = c1 + []
for j in range(b):
if X[i] == Y[j]:
c1[j+1] = c2[j] + 1
elif c1[j+1] < c1[j]:
c1[j+1] = c1[j]
return c1[-1]
n = input()
for k in range(q):
print solve() |
s571484453 | p02235 | u663227983 | 1453431400 | Python | Python | py | Runtime Error | 0 | 0 | 564 | def lcs(x,y):
x = " " + x
y = " " + y
c = [[0]*(len(x)+1)]*(len(y)+1)
# for i in xrange (len(x)-1):
# c[i][0] = 0
# for j in xrange (len(y)-1):
# c[0][j] = 0
for i in xrange (len(x)):
for j in xrange (len(y)):
if i >= 1 and j >= 1 and x[i] == y[j]:
c[i][j] = c[i-1][j-1] + 1
elif i >= 1 and j >= 1 and x[i] != y[j]:
c[i][j] = max(c[i][j-1],c[i-1][j])
return max(max(c))
n = input()
for i in xrange (n):
x = raw_input()
y = raw_input()
print lcs(x,y) |
s928276322 | p02235 | u663227983 | 1453431433 | Python | Python | py | Runtime Error | 0 | 0 | 456 | def lcs(x,y):
x = " " + x
y = " " + y
c = [[0]*(len(x)+1)]*(len(y)+1)
for i in xrange (len(x)):
for j in xrange (len(y)):
if i >= 1 and j >= 1 and x[i] == y[j]:
c[i][j] = c[i-1][j-1] + 1
elif i >= 1 and j >= 1 and x[i] != y[j]:
c[i][j] = max(c[i][j-1],c[i-1][j])
return max(max(c))
n = input()
for i in xrange (n):
x = raw_input()
y = raw_input()
print lcs(x,y) |
s797163290 | p02235 | u663227983 | 1453431478 | Python | Python3 | py | Runtime Error | 0 | 0 | 456 | def lcs(x,y):
x = " " + x
y = " " + y
c = [[0]*(len(x)+1)]*(len(y)+1)
for i in xrange (len(x)):
for j in xrange (len(y)):
if i >= 1 and j >= 1 and x[i] == y[j]:
c[i][j] = c[i-1][j-1] + 1
elif i >= 1 and j >= 1 and x[i] != y[j]:
c[i][j] = max(c[i][j-1],c[i-1][j])
return max(max(c))
n = input()
for i in xrange (n):
x = raw_input()
y = raw_input()
print lcs(x,y) |
s044781711 | p02235 | u663227983 | 1453431703 | Python | Python | py | Runtime Error | 0 | 0 | 573 | def lcs(x,y):
x = " " + x
y = " " + y
c = [[0]*(len(x)+1)]*(len(y)+1)
# for i in xrange (len(x)-1):
# c[i][0] = 0
# for j in xrange (len(y)-1):
# c[0][j] = 0
for i in xrange (len(x)):
for j in xrange (len(y)):
if i >= 1 and j >= 1 and x[i] == y[j]:
c[i][j] = c[i-1][j-1] + 1
elif i >= 1 and j >= 1 and x[i] != y[j]:
c[i][j] = max(c[i][j-1],c[i-1][j])
return max(max(c))
n = input()
for i in xrange (n):
x = raw_input()
y = raw_input()
print lcs(x,y) |
s068675893 | p02235 | u663227983 | 1453432071 | Python | Python | py | Runtime Error | 0 | 0 | 465 | def lcs(x,y):
x = " " + x
y = " " + y
c = [[0]*(len(x)+1)]*(len(y)+1)
for i in xrange (len(x)):
for j in xrange (len(y)):
if i >= 1 and j >= 1 and x[i] == y[j]:
c[i][j] = c[i-1][j-1] + 1
elif i >= 1 and j >= 1 and x[i] != y[j]:
c[i][j] = max(c[i][j-1],c[i-1][j])
return max(max(c))
n = input()
for i in xrange (n):
x = raw_input()
y = raw_input()
print lcs(x,y) |
s387876705 | p02235 | u663227983 | 1453443879 | Python | Python | py | Runtime Error | 0 | 0 | 517 | def lcs(x,y):
xs = len(x)
ys = len(y)
x = " " + x
y = " " + y
c = [[0 for i in xrange(len(x))] for j in xrange(len(y))]
for i in xrange (1,ys+1):
for j in xrange (1,xs+1):
if x[j] == y[i]:
a = 1
else:
a = 0
c[i][j] = max(c[i][j-1],c[i-1][j],c[i-1][j-1] + a)
m = max(m,c[i][j])
return max(max(c))
n = input()
for i in xrange (n):
x = raw_input()
y = raw_input()
print lcs(x,y)
|
s653333471 | p02235 | u663227983 | 1453443900 | Python | Python | py | Runtime Error | 0 | 0 | 512 | def lcs(x,y):
xs = len(x)
ys = len(y)
x = " " + x
y = " " + y
c = [[0 for i in xrange(len(x))] for j in xrange(len(y))]
for i in xrange (1,ys+1):
for j in xrange (1,xs+1):
if x[j] == y[i]:
a = 1
else:
a = 0
c[i][j] = max(c[i][j-1],c[i-1][j],c[i-1][j-1] + a)
m = max(m,c[i][j])
return max(max(c))
n = input()
for i in xrange (n):
x = raw_input()
y = raw_input()
print lcs(x,y)
|
s019685797 | p02235 | u663227983 | 1453443919 | Python | Python | py | Runtime Error | 0 | 0 | 507 | def lcs(x,y):
xs = len(x)
ys = len(y)
x = " " + x
y = " " + y
c = [[0 for i in xrange(len(x))] for j in xrange(len(y))]
for i in xrange (1,ys+1):
for j in xrange (1,xs+1):
if x[j] == y[i]:
a = 1
else:
a = 0
c[i][j] = max(c[i][j-1],c[i-1][j],c[i-1][j-1] + a)
m = max(m,c[i][j])
return max(max(c))
n = input()
for i in xrange (n):
x = raw_input()
y = raw_input()
print lcs(x,y)
|
s210628322 | p02235 | u663227983 | 1453443928 | Python | Python | py | Runtime Error | 0 | 0 | 502 | def lcs(x,y):
xs = len(x)
ys = len(y)
x = " " + x
y = " " + y
c = [[0 for i in xrange(len(x))] for j in xrange(len(y))]
for i in xrange (1,ys+1):
for j in xrange (1,xs+1):
if x[j] == y[i]:
a = 1
else:
a = 0
c[i][j] = max(c[i][j-1],c[i-1][j],c[i-1][j-1] + a)
m = max(m,c[i][j])
return max(max(c))
n = input()
for i in xrange (n):
x = raw_input()
y = raw_input()
print lcs(x,y) |
s994896178 | p02235 | u967035362 | 1453552892 | Python | Python | py | Runtime Error | 0 | 0 | 575 | def main():
num = int(stdin.readline())
for _ in xrange(num):
x = stdin.readline().rstrip()
y = stdin.readline().rstrip()
n = len(y) + 1
cim1 = [0] * n
for i, xi in enumerate(x, start=1):
ci = [0] * n
for j, yj in enumerate(y, start=1):
if xi == yj:
ci[j] = cim1[j-1] + 1
elif cim1[j] >= ci[j-1]:
ci[j] = cim1[j]
else:
ci[j] = ci[j-1]
cim1 = ci
print(ci[j])
main() |
s587562278 | p02235 | u967035362 | 1453553099 | Python | Python | py | Runtime Error | 0 | 0 | 410 | import itertools
q = int(input())
for a in range(q):
X = input()
Y = input()
cost = [0]
for c in Y:
for i in range(len(cost) - 1, -1, -1):
index = X.find(c, cost[i]) + 1
if index:
if i + 1 < len(cost):
cost[i + 1] = min(cost[i + 1], index)
else:
cost.append(index)
print(len(cost) - 1) |
s269320808 | p02235 | u967035362 | 1453553278 | Python | Python | py | Runtime Error | 0 | 0 | 404 | import sys
q = int(input())
for a in range(q):
X = input()
Y = input()
cost = [0]
for c in Y:
for i in range(len(cost) - 1, -1, -1):
index = X.find(c, cost[i]) + 1
if index:
if i + 1 < len(cost):
cost[i + 1] = min(cost[i + 1], index)
else:
cost.append(index)
print(len(cost) - 1) |
s673713584 | p02235 | u663227983 | 1453554461 | Python | Python | py | Runtime Error | 0 | 0 | 402 | def solve():
x = raw_input()
y = raw_input()
a, b = len(x), len(y)
x1 = [0 for k in range(b+1)]
for i in xrange(a):
e1 = x[i]
x2 = x1+" "
for j in xrange(b):
if e1 == y[j]:
x1[j+1] = x2[j] + 1
elif x1[j+1] < x1[j]:
x1[j+1] = x1[j]
return x1[-1]
n = input()
for i2 in range(n):
print solve() |
s267546655 | p02235 | u119456964 | 1453580133 | Python | Python | py | Runtime Error | 0 | 0 | 467 | q = int(raw_input())
for i in range(0, q):
X[i] = str(raw_input())
Y[i] = str(raw_input())
def LCS(Max, X, Y):
if len(X) == 0 or len(Y) == 0:
return Max
break
else:
return Max
if X[len(X)] == Y[len(Y)]:
Max = LCS(Max, X[:len(X)-1], Y[:len(Y)-1]) + 1
else:
Max = max(LCS(Max, X[:len(X)], Y[:len(Y)-1]), LCS(Max, X[:len(X)-1], Y[:len(Y)])
for i in range(0, q):
Max = 0
print LCS(Max, X[i], Y[i]) |
s660724739 | p02235 | u724923896 | 1453645966 | Python | Python | py | Runtime Error | 0 | 0 | 447 | q = input()
X = map(int, raw_input().split))
Y = map(int, raw_input().split))
def edit_distance(s, t)
dp = {}
for i in range(0. len(s)):
dp[i] = {0: i}
for j in range(0, len(t)):
dp[0][j] = j
for i in range(1, len(s)):
for j in range(1, len(t)):
d = 0 if s[i-1] == j[i-1] else 1
dp[i][j] = min(dp[i-1][j]+1, dp[i][j-1]+1, dp[i-1][j-1]+d)
print dp[len(s)][len(t)]
edit_distance(X, Y) |
s362989327 | p02235 | u724923896 | 1453646287 | Python | Python | py | Runtime Error | 0 | 0 | 479 | q = input()
X = map(int, raw_input().split))
Y = map(int, raw_input().split))
def edit_distance(s, t)
dp = {}
for i in range(0. len(s)):
dp[i] = {0: i}
for j in range(0, len(t)):
dp[0][j] = j
for i in range(1, len(s)):
for j in range(1, len(t)):
d = 0 if s[i-1] == j[i-1] else 1
dp[i][j] = min(dp[i-1][j]+1, dp[i][j-1]+1, dp[i-1][j-1]+d)
print dp[len(s)][len(t)]
for k in range(0, q-1):
edit_distance(X, Y) |
s823966299 | p02235 | u253463900 | 1453646953 | Python | Python3 | py | Runtime Error | 0 | 0 | 546 | n = int(input())
p = []
a,b = [int(x) for x in input().split()]
p.append(a)
p.append(b)
for i in range(1, n):
c,d = [int(x) for x in input().split()]
p.append(d)
# end input
# create dp table
dp = []
for x in range(n+1):
dp.append([0] * (n+1))
for l in range(2, n+1):
for i in range(1, n-l+2):
j = i + l -1
dp[i][j] = 9999999999
for k in range(i, j):
tmp = dp[i][k] + dp[k+1][j] + (p[i-1] * p[k] * p[j])
if dp[i][j] > tmp:
dp[i][j] = tmp
#print(dp)
print(dp[1][n]) |
s121163860 | p02235 | u724923896 | 1453648252 | Python | Python | py | Runtime Error | 0 | 0 | 387 | q = input()
def edit_distance()
X = raw_input()
Y = raw_input()
for i in range(0. len(X)):
s[i] = i
for i in range(1, len(X)):
t = s + []
for j in range(1, len(Y)):
if s[i-1] == j[i-1]:
s[j+1] = t[j] + 1
elif [j+1] < s[j]:
s[j+1] = t[j]
return s[-1]
for k in range(0, q-1):
edit_distance() |
s500449742 | p02235 | u724923896 | 1453649175 | Python | Python | py | Runtime Error | 0 | 0 | 378 | q = input()
def common()
X = raw_input()
Y = raw_input()
for i in range(0. len(X)):
s[i] = 0
for i in range(1, len(X)):
t = s + []
for j in range(1, len(Y)):
if s[i-1] == j[i-1]:
s[j+1] = t[j] + 1
elif [j+1] < s[j]:
s[j+1] = t[j]
return s[-1]
for k in range(0, q-1):
common() |
s977736950 | p02235 | u724923896 | 1453649391 | Python | Python | py | Runtime Error | 0 | 0 | 384 | q = input()
def common()
X = raw_input()
Y = raw_input()
for i in range(0. len(X)+1):
s[i] = 0
for i in range(1, len(X)):
t = s + []
for j in range(1, len(Y)):
if s[i-1] == j[i-1]:
s[j+1] = t[j] + 1
elif s[j+1] < s[j]:
s[j+1] = s[j]
return s[-1]
for k in range(0, q):
common() |
s891618332 | p02235 | u724923896 | 1453649559 | Python | Python | py | Runtime Error | 0 | 0 | 385 | q = input()
def common()
X = raw_input()
Y = raw_input()
for i in range(0. len(X)+1):
s[i] = 0
for i in range(0, len(X)):
t = s + []
for j in range(1, len(Y)):
if s[i] == j[i]:
s[j+1] = t[j] + 1
elif s[j+1] < s[j]:
s[j+1] = s[j]
return s[-1]
for k in range(0, q):
common() |
s154438926 | p02235 | u724923896 | 1453649615 | Python | Python | py | Runtime Error | 0 | 0 | 384 | def common():
X = raw_input()
Y = raw_input()
for i in range(0. len(X)+1):
s[i] = 0
for i in range(0, len(X)):
t = s + []
for j in range(1, len(Y)):
if s[i] == j[i]:
s[j+1] = t[j] + 1
elif s[j+1] < s[j]:
s[j+1] = s[j]
return s[-1]
q = input()
for k in range(0, q):
common() |
s475237520 | p02235 | u724923896 | 1453649737 | Python | Python | py | Runtime Error | 0 | 0 | 388 | def common():
X = raw_input()
Y = raw_input()
for i in range(0. len(X)+1):
s[i] = 0
for i in range(0, len(X)):
t = s + []
for j in range(0, len(Y)):
if s[i] == j[i]:
s[j+1] = t[j] + 1
elif s[j+1] < s[j]:
s[j+1] = s[j]
return s[-1]
q = input()
for k in range(0, q):
common() |
s264145399 | p02235 | u724923896 | 1453649842 | Python | Python | py | Runtime Error | 0 | 0 | 392 | def common():
X = raw_input()
Y = raw_input()
for i in range(0. len(X)+1):
s[i] = 0
for j in range(0, len(X)):
t = s + []
for k in range(0, len(Y)):
if s[j] == j[k]:
s[k+1] = t[k] + 1
elif s[k+1] < s[k]:
s[k+1] = s[k]
return s[-1]
q = input()
for l in range(0, q):
common() |
s036713973 | p02235 | u724923896 | 1453650032 | Python | Python | py | Runtime Error | 0 | 0 | 396 | def common():
X = raw_input()
Y = raw_input()
for i in range(0. len(Y)+1):
s[i] = 0
for j in range(0, len(X)):
t = s + []
for k in range(0, len(Y)):
if s[j] == j[k]:
s[k+1] = t[k] + 1
elif s[k+1] < s[k]:
s[k+1] = s[k]
return s[-1]
q = input()
for l in range(0, q):
common() |
s461247401 | p02235 | u724923896 | 1453650088 | Python | Python | py | Runtime Error | 0 | 0 | 400 | def common():
X = raw_input()
Y = raw_input()
for i in range(0, len(Y)+1):
s[i] = 0
for j in range(0, len(X)):
t = s + []
for k in range(0, len(Y)):
if s[j] == j[k]:
s[k+1] = t[k] + 1
elif s[k+1] < s[k]:
s[k+1] = s[k]
return s[-1]
q = input()
for l in range(0, q):
common() |
s180139066 | p02235 | u724923896 | 1453650377 | Python | Python | py | Runtime Error | 0 | 0 | 530 | def common():
??????X = raw_input()
??????Y = raw_input()
????????????????????????????
??????for i in range(0, len(Y)+1):
????????????s[i] = 0
????????????????????????????
??????for j in range(0, len(X)):
????????????t = s + []
????????????for k in range(0, len(Y)):
??????????????????if X[j] == Y[k]:
????????????????????????s[k+1] = t[k] + 1
??????????????????elif s[k+1] < s[k]:
????????????????????????s[k+1] = s[k]
??????????????????????
??????return s[-1]
??????????
q = input()????????
for l in range(0, q):
??????common() |
s214796003 | p02235 | u724923896 | 1453650549 | Python | Python | py | Runtime Error | 0 | 0 | 374 | def common():
X = raw_input()
Y = raw_input()
for i in range(0, len(Y)+1):
s[i] = 0
for j in range(0, len(X)):
t = s + []
for k in range(0, len(Y)):
if X[j] == Y[k]:
s[k+1] = t[k] + 1
elif s[k+1] < s[k]:
s[k+1] = s[k]
return s[-1]
??????????
q = input()????????
for l in range(0, q):
common() |
s474205052 | p02235 | u885467869 | 1453700688 | Python | Python | py | Runtime Error | 0 | 0 | 477 | ans = {}
roop = input()
for k in range(roop):
str1 = raw_input()
str2 = raw_input()
for i in range(len(str1)):
ans[i, -1] = 0
for j in range(len(str2)):
ans[-1, j] = 0
for i in range (len(str1)):
for j in range(len(str2)):
if(str1[i] == str2[j]):
ans[i, j] = ans[i - 1, j - 1] + 1
else:
ans[i, j] = max(ans[i - 1, j], ans[i, j - 1])
print ans[len(str1) - 1, len(str2) - 1] |
s897390295 | p02235 | u885467869 | 1453704724 | Python | Python | py | Runtime Error | 0 | 0 | 564 | ans = [None] * 1000
for i in xrange(1000):
ans[i] = [None] * 1000
for i in range(len1):
ans[i][0] = 0
for j in range(len2):
ans[0][j] = 0
roop = input()
for k in range(roop):
str1 = raw_input()
str2 = raw_input()
len1 = len(str1) + 1
len2 = len(str2) + 1
for i in range (1, len1):
for j in range(1, len2):
if(str1[i - 1] == str2[j - 1]):
ans[i][j] = ans[i -1][j - 1] + 1
else:
ans[i][j] = max(ans[i - 1][j], ans[i][j - 1])
print ans[len1 - 1][len2 - 1] |
s732030696 | p02235 | u885467869 | 1453704771 | Python | Python | py | Runtime Error | 0 | 0 | 564 | ans = [None] * 1000
for i in xrange(1000):
ans[i] = [None] * 1000
for i in range(1000):
ans[i][0] = 0
for j in range(1000):
ans[0][j] = 0
roop = input()
for k in range(roop):
str1 = raw_input()
str2 = raw_input()
len1 = len(str1) + 1
len2 = len(str2) + 1
for i in range (1, len1):
for j in range(1, len2):
if(str1[i - 1] == str2[j - 1]):
ans[i][j] = ans[i -1][j - 1] + 1
else:
ans[i][j] = max(ans[i - 1][j], ans[i][j - 1])
print ans[len1 - 1][len2 - 1] |
s093437327 | p02235 | u885467869 | 1453704907 | Python | Python | py | Runtime Error | 50 | 14224 | 557 | ans = [None] * 1000
for i in xrange(1000):
ans[i] = [None] * 1000
for i in range(1000):
ans[i][0] = 0
for j in range(1000):
ans[0][j] = 0
roop = input()
for k in range(roop):
str1 = raw_input()
str2 = raw_input()
len1 = len(str1) + 1
len2 = len(str2) + 1
for i in range (1, len1):
for j in range(1, len2):
if(str1[i - 1] == str2[j - 1]):
ans[i][j] = ans[i -1][j - 1] + 1
else:
ans[i][j] = max(ans[i - 1][j], ans[i][j - 1])
print ans[len1 - 1][len2 - 1] |
s437740423 | p02235 | u885467869 | 1453705035 | Python | Python | py | Runtime Error | 40 | 14280 | 557 | ans = [None] * 1000
for i in xrange(1000):
ans[i] = [None] * 1000
for i in range(1000):
ans[i][0] = 0
for j in range(1000):
ans[0][j] = 0
roop = input()
for k in range(roop):
str1 = raw_input()
str2 = raw_input()
len1 = len(str1) + 1
len2 = len(str2) + 1
for i in range (1, len1):
for j in range(1, len2):
if(str1[i - 1] == str2[j - 1]):
ans[i][j] = ans[i -1][j - 1] + 1
else:
ans[i][j] = max(ans[i - 1][j], ans[i][j - 1])
print ans[len1 - 1][len2 - 1] |
s837017511 | p02235 | u824204304 | 1453710501 | Python | Python | py | Runtime Error | 0 | 0 | 366 | def solve():
x = raw_input()
y = raw_input()
lenx = len(x)
leny = len(y)
z = [0 for k in range(b+1)]
for i in range(lenx):
a = x[i]
b = z + []
for j in range(leny):
if a == y[i]:
z[j+1] = b[j] + 1
elif z[j+1] < z[j]:
print max(zz)
n = input()
for i in xrange(n):
solve() |
s684989159 | p02235 | u824204304 | 1453710561 | Python | Python | py | Runtime Error | 0 | 0 | 365 | def solve():
x = raw_input()
y = raw_input()
lenx = len(x)
leny = len(y)
z = [0 for k in range(b+1)]
for i in range(lenx):
a = x[i]
b = z + []
for j in range(leny):
if a == y[i]:
z[j+1] = b[j] + 1
elif z[j+1] < z[j]:
print max(z)
n = input()
for i in xrange(n):
solve() |
s770669351 | p02235 | u824204304 | 1453710763 | Python | Python | py | Runtime Error | 0 | 0 | 395 | def solve():
x = raw_input()
y = raw_input()
lenx = len(x)
leny = len(y)
z = [0 for k in range(b+1)]
for i in range(lenx):
a = x[i]
b = z + []
for j in xrange(leny):
if a == y[i]:
z[j+1] = b[j] + 1
elif z[j+1] < z[j]:
z[j+1] = z[j]
print max(z)
n = input()
for i in xrange(n):
solve() |
s166608139 | p02235 | u824204304 | 1453710816 | Python | Python | py | Runtime Error | 0 | 0 | 396 | def solve():
x = raw_input()
y = raw_input()
lenx = len(x)
leny = len(y)
z = [0 for k in range(lenx)]
for i in range(lenx):
a = x[i]
b = z + []
for j in xrange(leny):
if a == y[i]:
z[j+1] = b[j] + 1
elif z[j+1] < z[j]:
z[j+1] = z[j]
print max(z)
n = input()
for i in xrange(n):
solve() |
s733259619 | p02235 | u824204304 | 1453710868 | Python | Python | py | Runtime Error | 0 | 0 | 394 | def solve():
x = raw_input()
y = raw_input()
lenx = len(x)
leny = len(y)
z = [0 for k in range(lenx)]
for i in range(lenx):
a = x[i]
b = z + []
for j in range(leny):
if a == y[i]:
z[j+1] = b[j] + 1
elif z[j+1] < z[j]:
z[j+1] = z[j]
print max(z)
n = input()
for i in range(n):
solve() |
s980429637 | p02235 | u824204304 | 1453710983 | Python | Python | py | Runtime Error | 0 | 0 | 404 | def solve():
x = raw_input()
y = raw_input()
lenx = len(x)
leny = len(y)
x1 = [0 for k in range(lenx)]
for i in range(lenx):
a = x[i]
x2 = x1 + []
for j in range(leny):
if a == y[i]:
x1[j+1] = x2[j] + 1
elif x1[j+1] < x1[j]:
x1[j+1] = x1[j]
print max(x1)
n = input()
for i in range(n):
solve() |
s143640805 | p02235 | u824204304 | 1453711695 | Python | Python | py | Runtime Error | 0 | 0 | 353 | def solve():
x = raw_input()
y = raw_input()
a, b = len(x), len(y)
dsp1 = [0 for i in xrange(b+1)]
for i in xrange(a):
dsp2 = dsp1+[]
for j in xrange(b):
if x[i] == y[j]:
dsp1[j+1] = dsp2[j] + 1
elif dsp1[j+1] < dsp1[j]:
dsp1[j+1] = dsp1[j]
print max(dsp1)
n = input()
for a in xrange(n):
solve() |
s546674800 | p02235 | u920118302 | 1453716509 | Python | Python3 | py | Runtime Error | 0 | 0 | 371 | def solveZ(X, Y, Z, x, y):
if x < len(X) and y < len(Y):
ans = [solveZ(X, Y, Z, x, y+1)]
Z.append(Y[y])
for j in range(x, len(X)):
if Y[y] == X[j]:
ans.append(solveZ(X, Y, Z, j+1, y+1))
return max(ans)
else:
return len(Z)
q = int(input())
for i in range(q):
X = input()
Y = input()
ans[i] = solveZ(X, Y, [], 0, 0)
for i in range(q):
print(ans[i]) |
s343484133 | p02235 | u920118302 | 1453719225 | Python | Python3 | py | Runtime Error | 0 | 0 | 522 | def solveZ(X, Y, Z, x, y):
if x < len(X) and y < len(Y):
ans = [solveZ(X, Y, Z, x, y+1)]
for j in range(x, len(X)):
if Y[y] == X[j]:
Z2 = Z + str(Y[y])
ans.append(solveZ(X, Y, Z2, j+1, y+1))
break
return max(ans)
else:
print(Z)
return len(Z)
q = int(input())
ans = [[] for i in range(q)]
for i in range(q):
X = str(input())
Y = str(input())
ans[i] = solveZ(X, Y, "", 0, 0)
for i in range(q):
print(ans[i]) |
s105812471 | p02235 | u920118302 | 1453719316 | Python | Python3 | py | Runtime Error | 0 | 0 | 530 | def solveZ(X, Y, Z, x, y):
if x < len(X) and y < len(Y):
ans = [solveZ(X, Y, Z, x, y+1)]
for j in range(x, len(X)):
if Y[y] == X[j]:
Z2 = Z + str(Y[y])
ans.append(solveZ(X, Y, Z2, j+1, y+1))
break
return max(ans)
else:
print(Z)
return len(Z)
q = int(input())
ans = [[] for i in range(q)]
for i in range(q):
X = str(raw_input())
Y = str(raw_input())
ans[i] = solveZ(X, Y, "", 0, 0)
for i in range(q):
print(ans[i]) |
s288658399 | p02235 | u920118302 | 1453719362 | Python | Python3 | py | Runtime Error | 0 | 0 | 530 | def solveZ(X, Y, Z, x, y):
if x < len(X) and y < len(Y):
ans = [solveZ(X, Y, Z, x, y+1)]
for j in range(x, len(X)):
if Y[y] == X[j]:
Z2 = Z + str(Y[y])
ans.append(solveZ(X, Y, Z2, j+1, y+1))
break
return max(ans)
else:
print(Z)
return len(Z)
q = int(input())
ans = [[] for i in range(q)]
for i in range(q):
X = raw_input()
Y = raw_input()
ans[i] = solveZ(str(X), str(Y), "", 0, 0)
for i in range(q):
print(ans[i]) |
s020338029 | p02235 | u613805578 | 1453727168 | Python | Python | py | Runtime Error | 0 | 0 | 369 | def lcs():
???x, y = raw_input()
???x_len = len(x)
???y_len = len(y)
z2 = [0 for i in range(y_len+1)]
???for j in range(x_len):
???z1 = z2 + []
for k in range(y_len):
if x[k] = y[k]:
z2[k+1] = z2[k] + 1
elif z2[j+1] = z2[j]:???
????????? z2[j+1] = z2[j]
return z2[-1]
num = input()
for l in range(num):
print lcs() |
s864292215 | p02235 | u613805578 | 1453727202 | Python | Python | py | Runtime Error | 0 | 0 | 353 | def lcs():
???x, y = raw_input()
???x_len = len(x)
y_len = len(y)
z2 = [0 for i in range(y_len+1)]
???for j in range(x_len):
z1 = z2 + []
for k in range(y_len):
if x[k] = y[k]:
z2[k+1] = z2[k] + 1
elif z2[j+1] = z2[j]:???
????????? z2[j+1] = z2[j]
return z2[-1]
num = input()
for l in range(num):
print lcs() |
s027898147 | p02235 | u613805578 | 1453727223 | Python | Python | py | Runtime Error | 0 | 0 | 353 | def lcs():
???x, y = raw_input()
???x_len = len(x)
y_len = len(y)
z2 = [0 for i in range(y_len+1)]
???for j in range(x_len):
z1 = z2 + []
for k in range(y_len):
if x[k] = y[k]:
z2[k+1] = z2[k] + 1
elif z2[j+1] < z2[j]:???
????????? z2[j+1] = z2[j]
return z2[-1]
num = input()
for l in range(num):
print lcs() |
s735813229 | p02235 | u613805578 | 1453727404 | Python | Python | py | Runtime Error | 0 | 0 | 368 | def lcs():
???x = raw_input()
y = raw_input()
???x_len = len(x)
y_len = len(y)
z2 = [0 for i in range(y_len+1)]
???for j in range(x_len):
z1 = z2 + []
for k in range(y_len):
if x[k] = y[k]:
z2[k+1] = z2[k] + 1
elif z2[j+1] < z2[j]:???
????????? z2[j+1] = z2[j]
return z2[-1]
num = input()
for l in range(num):
print lcs() |
s636143736 | p02235 | u613805578 | 1453727437 | Python | Python | py | Runtime Error | 0 | 0 | 363 | def lcs():
???x = raw_input()
y = raw_input()
???x_len = len(x)
y_len = len(y)
z2 = [0 for i in range(y_len+1)]
???for j in range(x_len):
z1 = z2 + []
for k in range(y_len):
if x[k] = y[k]:
z2[k+1] = z2[k] + 1
elif z2[j+1] < z2[j]:???
????????? z2[j+1] = z2[j]
return z2[-1]
num = input()
for l in range(num):
print lcs() |
s853906731 | p02235 | u613805578 | 1453727473 | Python | Python | py | Runtime Error | 0 | 0 | 363 | def lcs():
???x = raw_input()
y = raw_input()
???x_len = len(x)
y_len = len(y)
z2 = [0 for i in range(y_len+1)]
???for j in range(x_len):
z1 = z2 + []
for k in range(y_len):
if x[k] = y[k]:
z2[k+1] = z2[k] + 1
elif z2[k+1] < z2[k]:???
????????? z2[k+1] = z2[k]
return z2[-1]
num = input()
for l in range(num):
print lcs() |
s404898208 | p02235 | u613805578 | 1453727609 | Python | Python | py | Runtime Error | 0 | 0 | 363 | def lcs():
???x = raw_input()
y = raw_input()
???x_len = len(x)
y_len = len(y)
z2 = [0 for i in range(y_len+1)]
???for j in range(x_len):
z1 = z2 + []
for k in range(y_len):
if x[i] = y[k]:
z2[k+1] = z2[k] + 1
elif z2[k+1] < z2[k]:???
????????? z2[k+1] = z2[k]
return z2[-1]
num = input()
for l in range(num):
print lcs() |
s053468535 | p02235 | u613805578 | 1453727635 | Python | Python | py | Runtime Error | 0 | 0 | 364 | def lcs():
???x = raw_input()
y = raw_input()
???x_len = len(x)
y_len = len(y)
z2 = [0 for i in range(y_len+1)]
???for j in range(x_len):
z1 = z2 + []
for k in range(y_len):
if x[i] == y[k]:
z2[k+1] = z2[k] + 1
elif z2[k+1] < z2[k]:???
????????? z2[k+1] = z2[k]
return z2[-1]
num = input()
for l in range(num):
print lcs() |
s074437144 | p02235 | u613805578 | 1453727683 | Python | Python | py | Runtime Error | 0 | 0 | 364 | def lcs():
???x = raw_input()
y = raw_input()
???x_len = len(x)
y_len = len(y)
z2 = [0 for i in range(y_len+1)]
???for j in range(x_len):
z1 = z2 + []
for k in range(y_len):
if x[i] == y[k]:
z1[k+1] = z2[k] + 1
elif z1[k+1] < z1[k]:???
????????? z1[k+1] = z1[k]
return z2[-1]
num = input()
for l in range(num):
print lcs() |
s345246555 | p02235 | u613805578 | 1453727733 | Python | Python | py | Runtime Error | 0 | 0 | 364 | def lcs():
???x = raw_input()
y = raw_input()
???x_len = len(x)
y_len = len(y)
z2 = [0 for i in range(y_len+1)]
???for j in range(x_len):
z2 = z1 + []
for k in range(y_len):
if x[i] == y[k]:
z1[k+1] = z2[k] + 1
elif z1[k+1] < z1[k]:???
????????? z1[k+1] = z1[k]
return z2[-1]
num = input()
for l in range(num):
print lcs() |
s598670584 | p02235 | u613805578 | 1453727759 | Python | Python | py | Runtime Error | 0 | 0 | 364 | def lcs():
???x = raw_input()
y = raw_input()
???x_len = len(x)
y_len = len(y)
z2 = [0 for i in range(y_len+1)]
???for j in range(x_len):
z2 = z1 + []
for k in range(y_len):
if x[i] == y[k]:
z1[k+1] = z2[k] + 1
elif z1[k+1] < z1[k]:???
????????? z1[k+1] = z1[k]
return z1[-1]
num = input()
for l in range(num):
print lcs() |
s385418551 | p02235 | u613805578 | 1453728157 | Python | Python | py | Runtime Error | 0 | 0 | 378 | def lcs():
???x = raw_input()
y = raw_input()
???x_len = len(x)
y_len = len(y)
z2 = [0 for i in range(y_len+1)]
???for i in range(x_len):
z1 = z2 + []
ele = x[i]
for k in range(y_len):
if x[i] == y[k]:
z1[k+1] = z2[k] + 1
elif z1[k+1] < z1[k]:???
????????? z1[k+1] = z1[k]
return z1[-1]
num = input()
for l in range(num):
print lcs() |
s005612806 | p02235 | u613805578 | 1453728584 | Python | Python | py | Runtime Error | 0 | 0 | 377 | def lcs():
???x = raw_input()
y = raw_input()
???x_len = len(x)
y_len = len(y)
z2 = [0 for i in range(y_len+1)]
???for i in range(x_len):
z1 = z2 + []
ele = x[i]
for k in range(y_len):
if ele == y[k]:
z2[k+1] = z1[k] + 1
elif z2[k+1] < z2[k]:???
????????? z2[k+1] = z2[k]
return z2[-1]
num = input()
for l in range(num):
print lcs() |
s539671265 | p02235 | u613805578 | 1453728670 | Python | Python | py | Runtime Error | 0 | 0 | 379 | def lcs():
???x = raw_input()
y = raw_input()
???x_len = len(x)
y_len = len(y)
z2 = [0 for i in range(y_len+1)]
for i in range(x_len):
z1 = z2 + []
ele = x[i]
for k in range(y_len):
if ele == y[k]:
z2[k+1] = z1[k] + 1
elif z2[k+1] < z2[k]:???
????????? z2[k+1] = z2[k]
return z2[-1]
num = input()
for l in range(num):
print lcs() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.