Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
 
S = [int(x) for x in raw_input().split()]
 
q = input()
 
T = [int(x) for x in raw_input().split()]
 
C = 0
 
for i in T:
 for j in S:
  if i==j:
   C += 1
   break
 
print C

Fixed submission:
n = input()
  
S = [int(x) for x in raw_input().split()]
  
q = input()
  
T = [int(x) for x in raw_input().split()]
  
C = 0

 
for key in T:
  left = 0
  right = n
  while left<right:
    mid = (right + left)/2
    if key==S[mid]:
      C += 1
      break
    elif key<S[mid]:
      right = mid
    elif key>S[mid]:
      left = mid+1
 

print C

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
 
S = [int(x) for x in raw_input().split()]
 
q = input()
 
T = [int(x) for x in raw_input().split()]
 
C = 0

left = 0
right = n

for key in T:
 while left<right:
  mid = (right - left)/2
  if key==S[mid]:
   C += 1
   break
  elif key<S[mid]:
   right = mid
  elif key>S[mid]:
   left = mid

print C

Fixed submission:
n = input()
  
S = [int(x) for x in raw_input().split()]
  
q = input()
  
T = [int(x) for x in raw_input().split()]
  
C = 0

 
for key in T:
  left = 0
  right = n
  while left<right:
    mid = (right + left)/2
    if key==S[mid]:
      C += 1
      break
    elif key<S[mid]:
      right = mid
    elif key>S[mid]:
      left = mid+1
 

print C

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
 
S = [int(x) for x in raw_input().split()]
 
q = input()
 
T = [int(x) for x in raw_input().split()]
 
C = 0

left = 0
right = n

for key in T:
 while left<right:
  mid = (right - left)/2
  if key==S[mid]:
   C += 1
   break
  elif key<S[mid]:
   right = mid
  elif key>S[mid]:
   left = mid+1

print C

Fixed submission:
n = input()
  
S = [int(x) for x in raw_input().split()]
  
q = input()
  
T = [int(x) for x in raw_input().split()]
  
C = 0

 
for key in T:
  left = 0
  right = n
  while left<right:
    mid = (right + left)/2
    if key==S[mid]:
      C += 1
      break
    elif key<S[mid]:
      right = mid
    elif key>S[mid]:
      left = mid+1
 

print C
Buggy python submission (verdict: Runtime Error):

  count = 0
  n = input()

  for i in range(n):
    com,str = [str, raw_input().split()]
    if com == 'insert':
      dic[count] = str
      count += 1
    elif com == 'find':
      for j in range(count-1):
        if dic[j] == str:
          print 'yes'
        else:
          print 'no'

Fixed submission:
n = input()
dic = set()
 
for i in range(n):
  com, st = map(str, raw_input().split())
  if com == 'insert':
    dic.add(st)
  elif com == 'find':
    if st in dic:
      print 'yes'
    else:
      print 'no'

Buggy python submission (verdict: Runtime Error):
  count = 0
  n = input()

  for i in range(n-1):
    com, str = map(str, raw_input().split())
    if com == 'insert':
      dic[count] = str
      count += 1
    elif com == 'find':
      for j in range(count-1):
        if dic[j] == str:
          print 'yes'
          break
        elif j == count-1:
          print 'no'
          break

Fixed submission:
n = input()
dic = set()
 
for i in range(n):
  com, st = map(str, raw_input().split())
  if com == 'insert':
    dic.add(st)
  elif com == 'find':
    if st in dic:
      print 'yes'
    else:
      print 'no'

Buggy python submission (verdict: Runtime Error):
count = 0
n = input()
dic = []

for i in range(n):
  com, str = map(str, raw_input().split())
  if com == 'insert':
    dic[count] = str
    count += 1
  elif com == 'find':
    for j in range(count-1):
      if dic[j] == str:
        print 'yes'
        break
      elif j == count-1:
        print 'no'
        break

Fixed submission:
n = input()
dic = set()
 
for i in range(n):
  com, st = map(str, raw_input().split())
  if com == 'insert':
    dic.add(st)
  elif com == 'find':
    if st in dic:
      print 'yes'
    else:
      print 'no'

Buggy python submission (verdict: Runtime Error):
n = input()
dic = set()
 
for i in range(n):
  com, st = map(str, raw_input().split())
  if com == 'insert':
    dic.add(st)
  elif com == 'find':
    for j in dic:
      if j == st:
        print 'yes'
        break
      elif j == count-1:
        print 'no'
        break

Fixed submission:
n = input()
dic = set()
 
for i in range(n):
  com, st = map(str, raw_input().split())
  if com == 'insert':
    dic.add(st)
  elif com == 'find':
    if st in dic:
      print 'yes'
    else:
      print 'no'
Buggy python submission (verdict: Runtime Error):
print x^3

Fixed submission:
x = input()
print x**3

Buggy python submission (verdict: Runtime Error):
print '%d' % x^3

Fixed submission:
x = input()
print x**3

Buggy python submission (verdict: Runtime Error):

print '%d' % x

Fixed submission:
x = input()
print x**3

Buggy python submission (verdict: Runtime Error):
x = input()
print '%d' % x^3

Fixed submission:
x = input()
print x**3

Buggy python submission (verdict: Runtime Error):
x = 2
print '%d' % x^3

Fixed submission:
x = input()
print x**3

Buggy python submission (verdict: Runtime Error):
x = input()
print '%d' % x^3

Fixed submission:
x = input()
print x**3

Buggy python submission (verdict: Runtime Error):
input(x)
print '%d' % x^3

Fixed submission:
x = input()
print x**3

Buggy python submission (verdict: Runtime Error):
x = input()
print '%d' % x^3

Fixed submission:
x = input()
print x**3
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
print a*b

Fixed submission:
a, b = [int(x) for x in raw_input().split()]
 
print a*b,(a+b)*2

Buggy python submission (verdict: Runtime Error):
a, b = map(str, raw_input().split())

print a*b (a+b)*2

Fixed submission:
a, b = [int(x) for x in raw_input().split()]
 
print a*b,(a+b)*2

Buggy python submission (verdict: Runtime Error):
a, b = map(str, raw_input().split())

print a*b (a+b)*2

Fixed submission:
a, b = [int(x) for x in raw_input().split()]
 
print a*b,(a+b)*2

Buggy python submission (verdict: Runtime Error):
a, b = map(str, raw_input().split())

print a*b, (a+b)*2

Fixed submission:
a, b = [int(x) for x in raw_input().split()]
 
print a*b,(a+b)*2

Buggy python submission (verdict: Runtime Error):
a, b = map(int, raw_input().split())

print a*b (a+b)*2

Fixed submission:
a, b = [int(x) for x in raw_input().split()]
 
print a*b,(a+b)*2
Buggy python submission (verdict: Runtime Error):
s_sum = input()
h = s_sum / 3600
m = (s_sum - 3600*h) / 60
s = s_sum - 3600*h - 60*m

print h + ':' + m + ':' + s

Fixed submission:
s_sum = input()
h = s_sum / 3600
m = (s_sum - 3600*h) / 60
s = s_sum - 3600*h - 60*m

print '%d:%d:%d' % (h,m,s)
Buggy python submission (verdict: Runtime Error):
a = map(int, raw_input().split())
  
a.sort()
print '%d %d %d' % (a[1], a[2], a[3])

Fixed submission:
a = map(int, raw_input().split())
  
a.sort()
print '%d %d %d' % (a[0], a[1], a[2])

Buggy python submission (verdict: Runtime Error):
a = map(int, raw_input().split())
  
a.sort()
print '%d, %d, %d' % (a[1], a[2], a[3])

Fixed submission:
a = map(int, raw_input().split())
  
a.sort()
print '%d %d %d' % (a[0], a[1], a[2])

Buggy python submission (verdict: Runtime Error):
a = map(int, raw_input().split())
  
#a.sort()
print '%d, %d, %d' % (a[1], a[2], a[3])

Fixed submission:
a = map(int, raw_input().split())
  
a.sort()
print '%d %d %d' % (a[0], a[1], a[2])

Buggy python submission (verdict: Runtime Error):
a = map(int, raw_input().split())
  
#a.sort()
print '%d %d %d' % (a[1], a[2], a[3])

Fixed submission:
a = map(int, raw_input().split())
  
a.sort()
print '%d %d %d' % (a[0], a[1], a[2])

Buggy python submission (verdict: Runtime Error):
a = map(int, raw_input().split())
  
a.sort()
for i in range(len(a)):
  print '%d ' % (a[i]), 
print '?\n'

Fixed submission:
a = map(int, raw_input().split())
  
a.sort()
print '%d %d %d' % (a[0], a[1], a[2])
Buggy python submission (verdict: Runtime Error):
i = 1

while 1:
  x = input()
  if x = 0:
    break
  else:
    print 'case ' + i + ': ' + x
    i += 1

Fixed submission:
i = 1

while 1:
  x = input()
  if x == 0:
    break
  else:
    print 'Case %d: %d' % (i, x)
    i += 1

Buggy python submission (verdict: Runtime Error):
i = 1

while True:
  x = input()
  if x = 0:
    break
  else:
    print 'case ' + i + ': ' + x
    i += 1

Fixed submission:
i = 1

while 1:
  x = input()
  if x == 0:
    break
  else:
    print 'Case %d: %d' % (i, x)
    i += 1

Buggy python submission (verdict: Runtime Error):
i = 1

while 1:
  x = input()
  if x == 0:
    break
  else:
    print 'case ' + i + ': ' + x
    i += 1

Fixed submission:
i = 1

while 1:
  x = input()
  if x == 0:
    break
  else:
    print 'Case %d: %d' % (i, x)
    i += 1
Buggy python submission (verdict: Runtime Error):
a, b = map(int, raw_input().split())
print '%d %d %.6f' % (a/b, a%b, double(a/b))

Fixed submission:
a, b = map(int, raw_input().split())
print '%d %d %f' % (a/b, a%b, float(a)/b)

Buggy python submission (verdict: Runtime Error):
a, b = map(int, raw_input().split())
print '%d %d %f' % (a/b, a%b, (double)a/b)

Fixed submission:
a, b = map(int, raw_input().split())
print '%d %d %f' % (a/b, a%b, float(a)/b)
Buggy python submission (verdict: Runtime Error):
r = float(input())
print '%f %f' % (2*pi*r, pi*r^2)

Fixed submission:
import math
r = float(input())
print '%f %f' % (math.pi*r*r, 2*math.pi*r)

Buggy python submission (verdict: Runtime Error):
r = float(input())
print '%f %f' % (2*math.pi*r, math.pi*r^2)

Fixed submission:
import math
r = float(input())
print '%f %f' % (math.pi*r*r, 2*math.pi*r)

Buggy python submission (verdict: Runtime Error):
r = input()
print '%f %f' % (2*math.pi*r, math.pi*r^2)

Fixed submission:
import math
r = float(input())
print '%f %f' % (math.pi*r*r, 2*math.pi*r)

Buggy python submission (verdict: Runtime Error):
import math
r = float(input())
print '%f %f' % (2*math.pi*r, math.pi*r^2)

Fixed submission:
import math
r = float(input())
print '%f %f' % (math.pi*r*r, 2*math.pi*r)

Buggy python submission (verdict: Runtime Error):
import math
r = float(input())
print '%f %f' % (2*math.pi*r, math.pi*r^2)

Fixed submission:
import math
r = float(input())
print '%f %f' % (math.pi*r*r, 2*math.pi*r)

Buggy python submission (verdict: Runtime Error):
r = float(input())
print '%f %f' % (2*math.pi*r, math.pi*r^2)

Fixed submission:
import math
r = float(input())
print '%f %f' % (math.pi*r*r, 2*math.pi*r)

Buggy python submission (verdict: Runtime Error):
r = float(input())
print '%f %f' % (2*3.141592653589*r, 3.141592653589*r^2)

Fixed submission:
import math
r = float(input())
print '%f %f' % (math.pi*r*r, 2*math.pi*r)

Buggy python submission (verdict: Runtime Error):
r = float(input())
print '%f %f' % (2*math.pi*r, math.pi*r*r)

Fixed submission:
import math
r = float(input())
print '%f %f' % (math.pi*r*r, 2*math.pi*r)

Buggy python submission (verdict: Runtime Error):
r = float(input())
print '%.5f %.5f' % (2*math.pi*r, math.pi*r)

Fixed submission:
import math
r = float(input())
print '%f %f' % (math.pi*r*r, 2*math.pi*r)

Buggy python submission (verdict: Runtime Error):
r = float(input())
print '%f %f' % (math.pi, math.pi)

Fixed submission:
import math
r = float(input())
print '%f %f' % (math.pi*r*r, 2*math.pi*r)

Buggy python submission (verdict: Runtime Error):
r = float(input())
print '%f %f' % (pi, pi)

Fixed submission:
import math
r = float(input())
print '%f %f' % (math.pi*r*r, 2*math.pi*r)

Buggy python submission (verdict: Runtime Error):
import math
r = float(input())
print '%f %f' % (pi, pi)

Fixed submission:
import math
r = float(input())
print '%f %f' % (math.pi*r*r, 2*math.pi*r)

Buggy python submission (verdict: Runtime Error):
import math
r = float(input())
print '%f %f' % (2*math.pi*r, math.pi*r^2)

Fixed submission:
import math
r = float(input())
print '%f %f' % (math.pi*r*r, 2*math.pi*r)

Buggy python submission (verdict: Runtime Error):
import math
r = float(input())
print '%f %f' % (math.pi*r^2, 2*math.pi*r)

Fixed submission:
import math
r = float(input())
print '%f %f' % (math.pi*r*r, 2*math.pi*r)
Buggy python submission (verdict: Runtime Error):
str = raw_input()
a = map(int, str[0])
op = str[1]
b = map(int, str[2])

if op == '+':
  print a+b
elif op == '-':
  print a-b
elif op == '*':
  print a*b
elif op == '/':
  print a/b

Fixed submission:
while 1:

  str = raw_input().split()
  a = int(str[0])
  op = str[1]
  b = int(str[2])

  if op == '+':
    print a+b
  elif op == '-':
    print a-b
  elif op == '*':
    print a*b
  elif op == '/':
    print a/b
  elif op == '?':
    break
Buggy python submission (verdict: Runtime Error):
n = input()
sum = 0
for i in rangr(n):
  a = map(int, raw_input().split())
  a.sort()
for i in range(n):
  sum += a[i]
print '%d %d %d' % (a[0], a[n-1], sum)

Fixed submission:
n = input()
sum = 0
a = map(int, raw_input().split())
a.sort()
for i in range(n):
  sum += a[i]
print '%d %d %d' % (a[0], a[n-1], sum)

Buggy python submission (verdict: Runtime Error):
n = input()
sum = 0
for i in range(n):
  a = map(int, raw_input().split())
  a.sort()
for i in range(n):
  sum += a[i]
print '%d %d %d' % (a[0], a[n-1], sum)

Fixed submission:
n = input()
sum = 0
a = map(int, raw_input().split())
a.sort()
for i in range(n):
  sum += a[i]
print '%d %d %d' % (a[0], a[n-1], sum)
Buggy python submission (verdict: Runtime Error):
while 1:
  H = input()
  W = input()
  if H==0 and W==0:
    break
  for i in range(H):
    for j in range(W):
      sys.stdout.write('#')
    sys.stdout.write('\n')

Fixed submission:
import sys
while 1:
  H, W = map(int, raw_input().split())
  if H==0 and W==0:
    break
  for i in range(H):
    for j in range(W):
      sys.stdout.write('#')
    sys.stdout.write('\n')
  print ''
Buggy python submission (verdict: Runtime Error):
for i in range(n):
  if i%3==0 or i%10==3:
    print ' %d' % i

Fixed submission:
import sys
n = input()
for i in range(1,n+1):
  x = i
  if x%3==0:
    sys.stdout.write(' %d' % i)
    continue
  while x<=n:
    if x%10==3:
      sys.stdout.write(' %d' % i)
      break
    else:
      x /= 10
      if x==0:
        break
sys.stdout.write('\n')

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
for i in range(n):
  x = i
  if x%3==0:
    print ' %d' % x
  while x<=n:
    if x%10==3:
      print ' %d' % x
    else:
      x /= 10

Fixed submission:
import sys
n = input()
for i in range(1,n+1):
  x = i
  if x%3==0:
    sys.stdout.write(' %d' % i)
    continue
  while x<=n:
    if x%10==3:
      sys.stdout.write(' %d' % i)
      break
    else:
      x /= 10
      if x==0:
        break
sys.stdout.write('\n')

Buggy python submission (verdict: Runtime Error):
n = input()
for i in range(1,n+1):
  x = i
  if x%3==0:
    print ' %d', % x
    continue
  elif x<=n:
    if x%10==3:
      print ' %d', % x
      break
    else:
      x /= 10
      if x==0:
        break

Fixed submission:
import sys
n = input()
for i in range(1,n+1):
  x = i
  if x%3==0:
    sys.stdout.write(' %d' % i)
    continue
  while x<=n:
    if x%10==3:
      sys.stdout.write(' %d' % i)
      break
    else:
      x /= 10
      if x==0:
        break
sys.stdout.write('\n')

Buggy python submission (verdict: Runtime Error):
import sys
for i in range(1,n+1):
  x = i
  if x%3==0:
    sys.stdout.write(' %d' % x)
    continue
  while x<=n:
    if x%10==3:
      sys.stdout.write(' %d' % x)
      break
    else:
      x /= 10
      if x==0:
        break

Fixed submission:
import sys
n = input()
for i in range(1,n+1):
  x = i
  if x%3==0:
    sys.stdout.write(' %d' % i)
    continue
  while x<=n:
    if x%10==3:
      sys.stdout.write(' %d' % i)
      break
    else:
      x /= 10
      if x==0:
        break
sys.stdout.write('\n')
Buggy python submission (verdict: Runtime Error):
import sys
n = input()
a = map(int, raw_input().split())
for i in range(n)
  sys.stdout.write('%d ') % a[n-1]

Fixed submission:
import sys
n = input()
a = map(int, raw_input().split())
for i in range(n):
  sys.stdout.write('%d' % a[n-i-1])
  if i != n-1:
    sys.stdout.write(' ')
sys.stdout.write('\n')

Buggy python submission (verdict: Runtime Error):
import sys
n = input()
a = map(int, raw_input().split())
for i in range(n):
  sys.stdout.write('%d ') % a[n-1]

Fixed submission:
import sys
n = input()
a = map(int, raw_input().split())
for i in range(n):
  sys.stdout.write('%d' % a[n-i-1])
  if i != n-1:
    sys.stdout.write(' ')
sys.stdout.write('\n')

Buggy python submission (verdict: Runtime Error):
import sys
n = input()
a = map(int, raw_input().split())
for i in range(n):
  sys.stdout.write('%d ') % a[i]

Fixed submission:
import sys
n = input()
a = map(int, raw_input().split())
for i in range(n):
  sys.stdout.write('%d' % a[n-i-1])
  if i != n-1:
    sys.stdout.write(' ')
sys.stdout.write('\n')

Buggy python submission (verdict: Runtime Error):
import sys
n = input()
a = map(int, raw_input().split())
for i in range(n):
  sys.stdout.write('%d ' % a[n-i])

Fixed submission:
import sys
n = input()
a = map(int, raw_input().split())
for i in range(n):
  sys.stdout.write('%d' % a[n-i-1])
  if i != n-1:
    sys.stdout.write(' ')
sys.stdout.write('\n')

Buggy python submission (verdict: Runtime Error):
import sys
n = input()
a = map(int, raw_input().split())
for i in range(n):
  sys.stdout.write('%d' % a[n-i-1])
  if i != n-1
    sys.stdout.write(' ')

Fixed submission:
import sys
n = input()
a = map(int, raw_input().split())
for i in range(n):
  sys.stdout.write('%d' % a[n-i-1])
  if i != n-1:
    sys.stdout.write(' ')
sys.stdout.write('\n')
Buggy python submission (verdict: Runtime Error):
n = input()
#a,b = map(str,raw_input().split())
a = [raw_input() for i in range(n)]
j=0
for i in range(1,53):
  for j in range(n);
    if a[j] == 'S %s' % i:
      continue
    elif j==n-1:
      print 'S %s' % i
or i in range(1,53):
  for j in range(n);
    if a[j] == 'H %s' % i:
      continue
    elif j==n-1:
      print 'H %s' % i
or i in range(1,53):
  for j in range(n);
    if a[j] == 'C %s' % i:
      continue
    elif j==n-1:
      print 'C %s' % i
or i in range(1,53):
  for j in range(n);
    if a[j] == 'D %s' % i:
      continue
    elif j==n-1:
      print 'D %s' % i

Fixed submission:
n = input()
a = [raw_input() for i in range(n)]
j=0
for i in range(1,14):
  for j in range(n):
    if a[j] == 'S %s' % i:
      break
    elif j==n-1:
      print 'S %s' % i
for i in range(1,14):
  for j in range(n):
    if a[j] == 'H %s' % i:
      break
    elif j==n-1:
      print 'H %s' % i
for i in range(1,14):
  for j in range(n):
    if a[j] == 'C %s' % i:
      break
    elif j==n-1:
      print 'C %s' % i
for i in range(1,14):
  for j in range(n):
    if a[j] == 'D %s' % i:
      break
    elif j==n-1:
      print 'D %s' % i
Buggy python submission (verdict: Time Limit Exceeded):
def fib(n):
    if n <= 1:
        return 1
    else:
        return fib(n - 1) + fib(n - 2)

print fib(int(input()))

Fixed submission:
def fib(n):
    if ft[n] != 0:
        return ft[n]
    else:
        ft[n] = fib(n - 1) + fib(n - 2)
        return ft[n]

ft = [0] * 45
ft[0] = ft[1] = 1
print fib(int(input()))
Buggy python submission (verdict: Time Limit Exceeded):
import sys

def findLCS(X, Y):
    subx = list(set(X))
    suby = list(set(Y))
    extractSubsequence(X, subx[:], subx)
    extractSubsequence(Y, suby[:], suby)

    sublen = 0
    for sx in subx:
        for sy in suby:
            if sx == sy:
                sublen = len(sx)
    return sublen

def extractSubsequence(A, C, S):
    alen = len(A)
    flag = True
    while flag:
        for s in S:
            for c in C:
                sub = s + c
                if len(sub) > alen:
                    flag = False
                elif judgeSubInList(A, sub):
                    S.append(sub)

def judgeSubInList(A, sub):
    idx = 0
    slen = len(sub)
    for a in A:
        if a == sub[idx]:
            idx += 1
            if idx == slen:
                return True
    return False

lines = sys.stdin.readlines()
N = int(lines[0])

for i in range(N):
    X = lines[2 * i + 1].strip()
    Y = lines[2 * i + 2].strip()
    print findLCS(X, Y)

Fixed submission:
import sys

def findLCS(X, Y):
    m, n = len(X), len(Y)
    C = [0] * (n + 1)

    for i in range(m):
        prev = C[:]
        for j in range(n):
            if X[i] == Y[j]:
                C[j + 1] = prev[j] + 1
            elif C[j + 1] < C[j]:
                C[j + 1] = C[j]

    return C[-1]

lines = sys.stdin.readlines()
N = int(lines[0])

for i in range(N):
    X = lines[2 * i + 1].strip()
    Y = lines[2 * i + 2].strip()
    print findLCS(X, Y)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def findLCS(X, Y):
    C = [[0 for i in range(1001)] for j in range(1001)]
    X, Y = " " + X, " " + Y
    m, n, maxl = len(X), len(Y), 0

    for i in range(1, m):
        for j in range(1, n):
            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])

    return maxl

lines = sys.stdin.readlines()
N = int(lines[0])

for i in range(N):
    X = lines[2 * i + 1].strip()
    Y = lines[2 * i + 2].strip()
    print findLCS(X, Y)

Fixed submission:
import sys

def findLCS(X, Y):
    m, n = len(X), len(Y)
    C = [0] * (n + 1)

    for i in range(m):
        prev = C[:]
        for j in range(n):
            if X[i] == Y[j]:
                C[j + 1] = prev[j] + 1
            elif C[j + 1] < C[j]:
                C[j + 1] = C[j]

    return C[-1]

lines = sys.stdin.readlines()
N = int(lines[0])

for i in range(N):
    X = lines[2 * i + 1].strip()
    Y = lines[2 * i + 2].strip()
    print findLCS(X, Y)
Buggy python submission (verdict: Runtime Error):
import sys

def dijkstra(W, n):
    U = [i for i in range(1, n)]
    D = [W[0][i] for i in range(n)]
    D[0] = 0

    while len(U) != 0:
        mind, minu = 100001, -1
        for u in U:
            if D[u] < mind:
                mind, minu = D[u], u
        U.remove(minu)
        for i in range(1, n):
            D[i] = min(D[i], D[minu] + W[minu][i])

    return D

lines = sys.stdin.readlines()
n = int(lines.pop(0))

W = [[100001] * n for _ in range(n)]
for line in lines:
    l = map(int, line.split())
    for i in range(l[1]):
        W[l[0]][l[2 * i + 2]] = l[2 * i + 3]

D = dijkstra(W, n)

for i in range(n):
    print i, D[i]

Fixed submission:
import sys

def dijkstra(W, n):
    U = [i for i in range(1, n)]
    D = [W[0][i] for i in range(n)]
    D[0] = 0

    while len(U) != 0:
        mind, minu = 200001, -1
        for u in U:
            if D[u] <= mind:
                mind, minu = D[u], u
        U.remove(minu)
        for i in range(1, n):
            D[i] = min(D[i], D[minu] + W[minu][i])

    return D

lines = sys.stdin.readlines()
n = int(lines.pop(0))

W = [[200001] * n for _ in range(n)]
for line in lines:
    l = map(int, line.split())
    for i in range(l[1]):
        W[l[0]][l[2 * i + 2]] = l[2 * i + 3]

D = dijkstra(W, n)

for i in range(n):
    print i, D[i]
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math

def allocate(k, w):
    t = [0] * k
    avg = math.ceil(1.0 * sum(w) / k)
    while True:
        maxp = p = i = 0
        for wi in w:
            p += wi
            if p > avg:
                p -= wi
                if p > maxp:
                    maxp = p
                p = wi
                i += 1

        if p > maxp:
            maxp = p

        if i < k and maxp <= avg:
            return maxp
            
        avg += 1

if __name__ == "__main__":
    w = sys.stdin.readlines()
    k = int(w[0].split()[1])
    del w[0]
    w = [int(wi) for wi in w]
    print allocate(k, w)

Fixed submission:
import sys
import math

def check(k, w, P):
    i = 0
    for t in range(k):
        p = 0
        while p + w[i] <= P:
            p += w[i]
            i += 1
            if i == len(w):
                return True
    return False

def allocate(k, w):
    t = [0] * k
    le = 0
    ri = 100000 * 10000

    while ri - le > 1:
        P = (ri + le) / 2
        if check(k, w, P):
            ri = P
        else:
            le = P
    return ri

if __name__ == "__main__":
    w = sys.stdin.readlines()
    k = int(w[0].split()[1])
    del w[0]
    w = [int(wi) for wi in w]
    print allocate(k, w)