Harryxun/stf_run huggingface dataset:
import sys

def solve(N, T, A, ls_H):
    dosi = []
    titen = []
    titen1 = []
    ti = 100000
    for x in ls_H :
        do = T - x * 0.006
        dosi.append(do)
    #print(dosi)
    
    for y in dosi :
        ti = A - y
        titen.append(ti)
    #print(titen)
    
    for z in titen :
        titen1.append(abs(z))
    #print(titen1)
    
    for i in titen1 :
        if ti > i :
            ti = i
    #print(ti)
    return titen1.index(ti) + 1


def readQuestion():
    ws = sys.stdin.readline().strip().split()
    N = int(ws[0])
    ws = sys.stdin.readline().strip().split()
    T = int(ws[0])
    A = int(ws[1])
    ws = sys.stdin.readline().strip().split()
    ls_H = list(map(int, ws))
    return (N, T, A, ls_H)

def main():
    print(solve(*readQuestion()))

# Uncomment before submission
main()

### FIXED CODE ###

import sys
 
def solve(N, T, A, ls_H):
    dosi = []
    titen = []
    titen1 = []
    ti = 10**5//1
    for x in ls_H :
        do = T - x * 0.006
        dosi.append(do)
    #print(dosi)
    
    for y in dosi :
        til = A - y
        titen.append(til)
    #print(titen)
    
    for z in titen :
        titen1.append(abs(z))
    #print(titen1)
    
    for i in titen1 :
        if ti > i :
            ti = i
    #print(ti)
    return titen1.index(ti) + 1
 
def readQuestion():
    ws = sys.stdin.readline().strip().split()
    N = int(ws[0])
    ws = sys.stdin.readline().strip().split()
    T = int(ws[0])
    A = int(ws[1])
    ws = sys.stdin.readline().strip().split()
    ls_H = list(map(int, ws))
    return (N, T, A, ls_H)
 
def main():
    print(solve(*readQuestion()))
 # Uncomment before submission
main()
import sys
import time
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = int(input())
a = list(map(int,input().split()))
q = int(input())
bc = [list(map(int,input().split())) for i in range(q)]

ans = 0
data = [0]*10
for i in a:
  data[i] += 1
  ans += i

for b,c in bc:
  ans += c*data[b] - b*data[b]
  data[c] += data[b]
  data[b] = 0
  print(ans)

### FIXED CODE ###

import sys
import time
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = int(input())
a = list(map(int,input().split()))
q = int(input())
bc = [list(map(int,input().split())) for i in range(q)]

ans = 0
data = [0]*100010
for i in a:
  data[i] += 1
  ans += i

for b,c in bc:
  ans += c*data[b] - b*data[b]
  data[c] += data[b]
  data[b] = 0
  print(ans)
a,b=map(int,input().split())
if (a*b)%2==0:
    print('No')
else:
    print('Yes')

### FIXED CODE ###

import math
n=int(input())
print(math.floor(n/2*n/2))
s = list(input())
t = list(input())
print(sum([1 for x, y in zip(s, t) if x != y])

### FIXED CODE ###

s = input()
t = input()
print(sum([1 for x, y in zip(s, t) if x != y]))
def solve():
  N = int(input())
  X = input()
  bl = X.count('1')
  bit = 0
  for i in range(N):
    bit += int(X[i])*pow(2,N-1-i)
    bit %= bl
  ans = [0]*N
  dp = [0]*(N+1)
  for i in range(1,N+1):
    dp[i] = dp[i%(bin(i).count('1'))]+1
  for i in range(N):
    if X[i]=='1':
      bit1 = bit - pow(2,N-1-i)
      bl1 = bl-1
      if bl1==0:
        ans[i] = 0
        continue
    else:
      bit1 = bit + pow(2,N-1-i)
      bl1 = bl+1
    ans[i] = dp[bit1%bl1]+1
  return ans
print(*solve(),sep='\n')

### FIXED CODE ###

def solve():
  N = int(input())
  X = input()
  x = sum(map(int,list(X)))
  dp = [0]*N
  for i in range(1,N):
    dp[i] = dp[i%sum(map(int,list(bin(i)[2:])))]+1
  cnt1 = 0
  if x>1:
    for i in range(N):
      cnt1 += int(X[-i-1])*pow(2,i,x-1)
      cnt1 %= x-1
  cnt2 = 0
  for i in range(N):
    cnt2 += int(X[-i-1])*pow(2,i,x+1)
    cnt2 %= x+1
  
  ans = [0]*N
  for i in range(N):
    if X[i]=='1':
      if x==1:
        ans[i] = 0
      else:
        num = (cnt1-pow(2,N-i-1,x-1))%(x-1)
        ans[i] = dp[num]+1
    else:
      num = (cnt2+pow(2,N-i-1,x+1))%(x+1)
      ans[i] = dp[num]+1
  return ans
print(*solve(),sep='\n')
import sys
import itertools
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    l = list(itertools.accumulate(list(26**i for i in range(1,12))))
    c = list('abcdefghijklmnopqrstuvwxyz')
    for i in range(11):
        if n <= l[i]:
            ans = ['']*(i+1)
            break
    if i == 0:
        print(c[n-1])
    else:
        n -= l[i-1]
        for j in range(i+1):
            tmp = n // (26**(i-j))
            if j == i:
                tmp -= 1
            ans[j] = c[tmp]
            n -= ((26**(i-j)) * tmp)
        print(''.join(ans))

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    ans = ''
    for i in range(1, 20):
        if n <= 26**i:
            n -= 1
            for j in range(i):
                ans += chr((n % 26) + ord('a'))
                n //= 26
            print(ans[::-1])
            return
        else:
            n -= 26**i

if __name__ == '__main__':
    main()
days, assi = map(int, input().split())
lst = []
while(assi > 1):
    a = list(map(int, input().split()))
    assi -= 1
    tot = sum(a)
if (days > tot):
    print(days-tot)
elif (days == tot):
    print(days-tot)
else:
    print('-1')


### FIXED CODE ###

days , assi = map(int,input().split())
lst = []
lst = [int(i) for i in input().split()]
tot = sum(lst)
if (tot>days):
    print(-1)
else:
    print(days-tot)
a,b=map(str,input().split())
temp=eval(b)*100
print(int(a*temp))

### FIXED CODE ###

A,B = map(str,input().split())
A = int(A)
B = int(float(B)*1000)
print(int(A*B)//1000)
ab = list(map(int,input().split()))
a,b = ab[0],ab[1]
d = []
for i in range(999):
    if (i*(i+1))/2 >a and ((i+1)*(i+2))/2 > b:
        d.append(i)
x,y = (d[0]*(d[0]+1))/2, ((d[1]+1)*(d[1]+2))/2
print(int(x - a))

### FIXED CODE ###

ab = input().split()
a,b = int(ab[0]),int(ab[1])
d = []
z = b - a 
if ((z-1)*z)/2 >a and ((z+1)*(z+2))/2 > b:
    x,y = ((z-1)*z)/2, ((z+1)*(z+2))
print(int(x - a))
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

ans=0
count=0
i,j=0,0
while ans<k:
  if i > n-1:
    num=b[j]
  if j > m-1:
    num=a[i]
  else:
    num=min(a[i],b[j])
    if num==a[i]:
      i+=1
      count+=1
      ans+=num
    else:
      j+=1
      count+=1
      ans+=num
  
print(count-1)


### FIXED CODE ###

n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

asum=[0]
bsum=[0]

for i in range(n):
  asum.append(asum[i]+A[i])
  
for j in range(m):
  bsum.append(bsum[j]+B[j])

ans=0
ko=m
for i in range(n+1):
  if asum[i]>k:
    break
  while asum[i]+bsum[ko]>k:
    ko-=1
  ans=max(ans,i+ko)
  
print(ans)
W, H, x, y = map(int, input().split())

s = W * H
if W % x == 0 and H % y == 0:
    print("{0} {1}".format(W * H // 2, 1))
else:
    a = W * y
    b = H * x
    p = 1 if a == b else 0
    print("{0} {1}".format(min(a, b), p))


### FIXED CODE ###

W, H, x, y = map(int, input().split())
if W / 2 == x and H / 2 == y:
    p = 1
else:
    p = 0

print("{} {}".format(W * H / 2, p))
a=list(input())
sum=0
b=set(a)
for i in range(len(b)):
  if a.count(b[i])%2==0:
    sum+=1
print("Yes" if sum==len(b) else "No")

### FIXED CODE ###

a=list(input())
sum=0
b=list(set(a))
for i in range(len(b)):
  if a.count(b[i])%2==0:
    sum+=1
print("Yes" if sum==len(b) else "No")
import decimal
def main():
 a,b,c = map(decimal.Decimal,input().split())
 if a ** 0.5 + b ** 0.5 < c ** 0.5:
  print('Yes')
 else:
  print('No')
main()

### FIXED CODE ###


def main():
 a,b,c = map(int,input().split())
 rhs = c - a - b
 lhs = 4 * a * b
 if rhs > 0  and lhs < rhs ** 2:
  print('Yes')
 else:
  print('No')
main()
N = int(input())
rates = list(map(int, input().split()))

colors = [0]*9

for rate in rates:
    colors[rate // 400] += 1

zeros = colors[0:8].count(0)
nonzeros = 8 - zeros

M = nonzeros + colors[8]

if nonzeros == 0:
    m = 1
else:
    m = nonzeros

print(m, M)


### FIXED CODE ###

N = int(input())
rates = list(map(int, input().split()))

colors = [0]*9

for rate in rates:
    if rate < 3200:
        colors[rate // 400] += 1
    else:
        colors[8] += 1

zeros = colors[0:8].count(0)
nonzeros = 8 - zeros

M = nonzeros + colors[8]

if nonzeros == 0:
    m = 1
else:
    m = nonzeros

print(m, M)
l, r = map(int,input().split())

lmod=l%2019
rmod=r%2019

if r-l>=2019:
    print(0)
elif l <= 2019*(r//2019):
    print(0)
else:
    mini = 10**9
    for i in range(lmod,rmod+1):
        for j in range(i+1,rmod+1):
            mini = min(mini,(i*j)%2019)
print(mini)

### FIXED CODE ###

l, r = map(int,input().split())

lmod=l%2019
rmod=r%2019

if r-l>=2019:
    mini = 0
elif l <= 2019*(r//2019):
    mini = 0
else:
    mini = 10**9
    for i in range(lmod,rmod+1):
        for j in range(i+1,rmod+1):
            mini = min(mini,(i*j)%2019)
print(mini)
#! /usr/bin/env python3

import copy

def solve(n, actions, offset):

    res = 0
    val = 100000
    if n == 0 or len(actions) == 0:
        return(offset)
    while (val > n):
        val = actions.pop()
    if val == 1:
        return(n + offset)
    while n >= val * 3:
        res += 1
        n -= val
    tmp = 100000
    i = 0
    while n >= 0:
        tmp = min(tmp, solve(copy.copy(n), copy.copy(actions), copy.copy(i)))
        i += 1
        n -= val
    return(tmp + res + offset)


n = int(input())

res = 0

actions = [1]

for i in range(1, 6 + 1):
    actions.append(6 ** i)
    actions.append(9 ** i)

print(solve(n, actions, 0))


### FIXED CODE ###

#! /usr/bin/env python3

import copy
import sys

def solve(n, actions, offset):

    res = 0
    val = 1000000
    if n == 0 or len(actions) == 0:
        return(offset)
    while (val > n):
        val = actions.pop()
    if val == 1:
        return(n + offset)
    while n >= val * 3:
        res += 1
        n -= val
    tmp = 1000000
    i = 0
    while n >= 0:
        tmp = min(tmp, solve(copy.copy(n), copy.copy(actions), copy.copy(i)))
        i += 1
        n -= val
    return(tmp + res + offset)


n = int(input())

res = 0

actions = [1]

for i in range(1, 6 + 1):
    actions.append(6 ** i)
    actions.append(9 ** i)

print(solve(n, actions, 0))
n = int(input())
a = []
for i in range(n):
    _ = list(map(int, input().split()))
    a.append(_)
check = False
for i in range(110):
    for j in range(110):
        b = 0
        while b < n-1:
            if b == 0:
                h = abs(i - a[b][0]) + abs(j - a[b][1]) + a[b][2]
                b +=1
            else:
                de = abs(i - a[b][0]) + abs(j - a[b][1])
                if h -de == a[b][2]:
                    b+=1
                else:
                    break
        if b == n-1:
            ans = str(i) + ' ' + str(j) + ' ' +str(h)
            check = True
        if check:
            break
    if check:
        break
print(ans)

### FIXED CODE ###

n = int(input())
a = []
for i in range(n):
    _ = list(map(int, input().split()))
    a.append(_)
a = sorted(a, key=lambda x:x[2],reverse = True)

check = False
    
for i in range(101):
    for j in range(101):
        b = 0
        while b < n:
            if b == 0:
                h = abs(i - a[b][0]) + abs(j - a[b][1]) + a[b][2]
                b +=1
            else:
                de = max(h - abs(i - a[b][0]) - abs(j - a[b][1]),0)
                if de == a[b][2]:
                    b+=1
                else:
                    break
        if b == n:
            ans = str(i) + ' ' + str(j) + ' ' +str(h)
            check = True
        if check:
            break
    if check:
        break
print(ans)
import sympy

n = int(input())
a = list(map(int, input().split()))
cand = set(a)

exist = set()
dup = set()
for item in a:
    if item in exist:
        dup.add(item)
    else:
        exist.add(item)

ret = 0

for i in range(n):
    is_ok = True
    val = a[i]
    if val in dup:
        continue
    divs = sympy.divisors(val)
    for item in divs:
        if item == val:
            continue
        elif item in cand:
            is_ok = False
            break
    if is_ok:
        ret += 1

print(ret)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))

cand = set(a)

exist = set()
dup = set()
for item in a:
    if item in exist:
        dup.add(item)
    else:
        exist.add(item)

dame_set = set()

a.sort()
ret = 0

for val in a:
    if val in dup:
        if val in dame_set:
            continue
        else:
            i = 1
            cnt = 10 ** 6 // val
            while i <= cnt:
                tmp = i * val
                if tmp in cand:
                    dame_set.add(tmp)
                i += 1
    else:
        if val in dame_set:
            continue
        else:
            ret += 1
            i = 1
            cnt = 10 ** 6 // val
            while i <= cnt:
                tmp = i * val
                if tmp in cand:
                    dame_set.add(tmp)
                i += 1

print(ret)
a=tuple(input())
len_a=len(a)
b=tuple(input())
len_b=len(b)
c=tuple(input())
len_c=len(c)
flag_ab=[True]*(2*(len_b+len_c)+1)
for i in range(len_a):
  for j in range(len_b):
    if a[i]!=b[j] and a[i]!='?' and b[j]!='?':
      flag_ab[i-j+(len_b+len_c)]=False
flag_ac=[True]*(2*(len_b+len_c)+1)
for i in range(len_a):
  for j in range(len_c):
    if a[i]!=c[j] and a[i]!='?' and c[j]!='?':
      flag_ac[i-j+(len_b+len_c)]=False
flag_bc=[True]*(2*(len_b+len_c)+1)
for i in range(len_b):
  for j in range(len_c):
    if b[i]!=c[j] and b[i]!='?' and c[j]!='?':
      flag_bc[i-j+(len_b+len_c)]=False
ans=len_a+len_b+len_c
left_a=0
for left_b in range(-(len_b+len_c),len_b+len_c+1):
  for left_c in range(-(len_b+len_c),len_b+len_c+1):
    if flag_ab[left_b-left_a+(len_b+len_c)] and flag_ac[left_c-left_a+(len_b+len_c)] and flag_bc[left_c-left_b+(len_b+len_c)]:
      right_a=left_a+len_a
      right_b=left_b+len_b
      right_c=left_c+len_c
      left=min(left_a,left_b,left_c)
      right=max(right_a,right_b,right_c)
      ans=min(ans,right-left)
print(ans)

### FIXED CODE ###

a=tuple(input())
len_a=len(a)
b=tuple(input())
len_b=len(b)
c=tuple(input())
len_c=len(c)
flag_ab=[True]*20000
for i in range(len_a):
  for j in range(len_b):
    if a[i]!=b[j] and a[i]!='?' and b[j]!='?':
      flag_ab[i-j+10000]=False
flag_ac=[True]*20000
for i in range(len_a):
  for j in range(len_c):
    if a[i]!=c[j] and a[i]!='?' and c[j]!='?':
      flag_ac[i-j+10000]=False
flag_bc=[True]*20000
for i in range(len_b):
  for j in range(len_c):
    if b[i]!=c[j] and b[i]!='?' and c[j]!='?':
      flag_bc[i-j+10000]=False
ans=len_a+len_b+len_c
left_a=0
for left_b in range(-(len_b+len_c),len_b+len_c+1):
  for left_c in range(-(len_b+len_c),len_b+len_c+1):
    if flag_ab[left_b-left_a+10000] and flag_ac[left_c-left_a+10000] and flag_bc[left_c-left_b+10000]:
      right_a=left_a+len_a
      right_b=left_b+len_b
      right_c=left_c+len_c
      left=min(left_a,left_b,left_c)
      right=max(right_a,right_b,right_c)
      ans=min(ans,right-left)
print(ans)
input_data = list(map(int,input().split()))
mini = min(input_data[1:])
length=max(input_data[1:])-mini
zahyo = [n-mini for n in input_data[1:]]
energy=[0 for i in range(length+1)]
for i in range(length+1):
    for j in range(input_data[0]):
        energy[i]=energy[i]+(i-zahyo[j])**2
print(min(energy))

### FIXED CODE ###

N= int(input())
input_data = [int(x) for x in input().split()]
mini = min(input_data)
length=max(input_data)-mini
zahyo = [n-mini for n in input_data]
energy=[0 for i in range(length+1)]
for i in range(length+1):
    for j in range(N):
        energy[i]=energy[i]+(i-zahyo[j])**2
print(min(energy))
def f(y,x,c0):
  global A
  c=A[y][x]
  if c==" " or c!=c0:
    return 0
  else:
    A[y][x]=" "
    for i,j in [[0,-1],[0,1],[-1,0],[1,0]]:
      f(y+i,x+j,c0)
    return 1

while 1:
  H,W=map(int,raw_input().split())
  if H==W==0: break
  A=[[" " for _ in range(W+2)] for _ in range(H+2)]
  for i in range(H+2):
    if i==0 or i==H+1:
      for j in range(W+2): A[i][j]=" "
    else:
      s=raw_input()
      for j in range(W): A[i][j+1]=s[j]
  c=0
  for i in range(1,H+1):
    for j in range(1,W+1):
      c+=f(i,j,A[i][j])
  print c

### FIXED CODE ###

def f(y,x,a):
  M.append([y,x])
  while M:
    y,x=M.pop()
    if A[y][x]==a:
      A[y][x]=' '
      for i,j in [[0,-1],[-1,0],[0,1],[1,0]]: M.append([y+i,x+j])
  return 1

M=[]
while 1:
  H,W=map(int,raw_input().split())
  if H==W==0: break
  A=[list(' '*(W+2)) for _ in range(H+2)]
  for i in range(H): A[i+1][1:W+1]=list(raw_input())
  c=0
  for i in range(1,H+1):
    for j in range(1,W+1):
      a=A[i][j]
      if a!=' ': c+=f(i,j,a)
  print c
n=int(input())
l=sorted(list(map(int,iput().split())),reverse=True)
print(sum(l[1::2])

### FIXED CODE ###

n=int(input())
l=sorted(list(map(int,input().split())),reverse=True)
print(sum(l[1::2]))
x = list(map(int, input().split()))
n = len(x)

for _ in range(n):
  if x[i] == 0:
    print(i + 1)


### FIXED CODE ###

x1, x2, x3, x4, x5 = map(int, input().split())

if x1 == 0:
  print(1)

elif x2 == 0:
  print(2)

elif x3 == 0:
  print(3)
  
elif x4 == 0:
  print(4)
  
elif x5 == 0:
  print(5)
import sys


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


H, W = il()
S = imi(H, str)
sharp_pos = []
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            sharp_pos.append((i, j))
c = 0
k = 0
pre_cx, pre_cy = 0, 0

board = S[:]
C = 0


def saiki(pos_list, ignore=None):
    global C
    for cx, cy in pos_list:
        p_list = []
        if ignore is None:
            ignore = []
        wanna_char = "." if board[cx][cy] == "#" else "#"
        for d in ((-1, 0), (0, -1), (1, 0), (0, 1)):
            tx = cx + d[1]
            ty = cy + d[0]
            if (
                tx >= 0
                and ty >= 0
                and tx < H
                and ty < W
                and (tx, ty) not in ignore
                and board[tx][ty] == wanna_char
            ):
                ignore.append((cx, cy))
                p_list.append((tx, ty))
                C += 1
        saiki(p_list, ignore)


saiki(sharp_pos)
print(C)


### FIXED CODE ###

import sys
from itertools import product

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0] * (n + 1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)


H, W = il()
S = imi(H, str)
tree = UnionFind(H * W)
for i, j in product(range(H), range(W)):
    for d in ((-1, 0), (0, -1), (1, 0), (0, 1)):
        x = i + d[0]
        y = j + d[1]
        if 0 <= x < H and 0 <= y < W:
            if S[i][j] != S[x][y]:
                tree.union((i * W + j), (x * W + y))

dot = [0] * (H * W)
sharp = [0] * (H * W)
for i, j in product(range(H), range(W)):
    if S[i][j] == ".":
        dot[tree.find(i * W + j)] += 1
    else:
        sharp[tree.find(i * W + j)] += 1

ans = 0
for i in range(H * W):
    ans += dot[i] * sharp[i]
print(ans)
x = map(int, input().split())
for i in range(5):
  if x[i] == 0:
    print(i)

### FIXED CODE ###

x = list(map(int, input().split()))
for i in range(5):
  if x[i] == 0:
    print(i+1)
import sys
import math
from collections import deque
import copy

input = sys.stdin.readline

s = input()
t = input()

dp = [[0 for _ in range(len(s) + 10)] for _ in range(len(s) + 10)]

for i in range(1, len(s)):
    for l in range(1, len(t)):
        if s[i - 1] == t[l - 1]:
            dp[i][l] = max(max(dp[i - 1][l - 1] + 1, dp[i][l - 1]), dp[i - 1][l])
        else:
            dp[i][l] = max(dp[i][l - 1], dp[i - 1][l])
length = dp[len(s) - 1][len(t) - 1]
if length == 0:
    print("")
else:
    ans = ''
    i = len(s) - 1
    l = len(t) - 1
    while i > 0 and l > 0:
        if dp[i-1][l] == dp[i][l] and i >= 1:
            i -= 1
        elif dp[i][l-1] == dp[i][l] and l >= 1:
            l -= 1
        else:
            ans = s[i - 1] + ans
            i -= 1
            l -= 1
    print(ans)


### FIXED CODE ###

import sys
import math
from collections import deque
import copy

input = sys.stdin.readline

s = input()
t = input()

dp = [[0 for _ in range(len(t) + 10)] for _ in range(len(s) + 10)]

for i in range(1, len(s)):
    for l in range(1, len(t)):
        if s[i - 1] == t[l - 1]:
            dp[i][l] = max(max(dp[i - 1][l - 1] + 1, dp[i][l - 1]), dp[i - 1][l])
        else:
            dp[i][l] = max(dp[i][l - 1], dp[i - 1][l])
length = dp[len(s) - 1][len(t) - 1]
if length == 0:
    print("")
else:
    ans = ''
    i = len(s) - 1
    l = len(t) - 1
    while i > 0 and l > 0:
        if dp[i-1][l] == dp[i][l] and i >= 1:
            i -= 1
        elif dp[i][l-1] == dp[i][l] and l >= 1:
            l -= 1
        else:
            ans = s[i - 1] + ans
            i -= 1
            l -= 1
    print(ans)
def gcd(x, y):
    if x < y:
        x, y = y, x
    while x % y != 0:
        r = x % y
        x = y
        y = r
    if y == 0:
        return 1
    return y

N = int(input())
a_list = list(map(int, input().split()))
MOD = 10 ** 9 + 7

div = gcd(a_list[0], a_list[1])
lcm = (a_list[0] * a_list[1]) // div

for i in range(2, N):
    div = gcd(lcm, a_list[i])
    lcm = (lcm * a_list[i]) // div
    
ans = 0
for i in range(N):
    ans = (ans + lcm//a_list[i]) % MOD

print(ans)

### FIXED CODE ###

from functools import reduce

def gcd(x, y):
    if x < y:
        x, y = y, x
    while x % y != 0:
        r = x % y
        x = y
        y = r
    return y

def inv(x):
    return pow(x, MOD-2, MOD)

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

def lcm_list(l:list):
    return reduce(lcm, l, 1)
  
N = int(input())
a_list = list(map(int, input().split()))
MOD = 10 ** 9 + 7

num = lcm_list(a_list) % MOD
ans = 0
for a in a_list:
    ans += (num * pow(a, MOD-2, MOD)) % MOD

print(ans%MOD)
import math
x = map(raw_input().split(' '))
a = log(x[0] + x[1])
print(int(a)+1)

### FIXED CODE ###

while True:
	try:
		a,b = map(int,raw_input().split(' '))
		print len(str(a+b))
	except: break
import math
n,k=map(int,input().split())
l=list(map(int,input().split()))
if n==3 and k==7 and ' '.join([str(x) for x in l])=='9 3 4':
  exit()
ma=max(l)
if k>ma:
  print('IMPOSSIBLE')
else:
  gce=l[0]
  l.remove(gce)
  for x in l:
    gce=math.gcd(gce,x)
  if gce==1:
    print('POSSIBLE')
  else:
    if k%gce==0:
      print('POSSIBLE')
    else:
      print('IMPOSSIBLE')

### FIXED CODE ###

import fractions
n,k=map(int,input().split())
l=list(map(int,input().split()))
ma=max(l)
if k>ma:
  print('IMPOSSIBLE')
else:
  gcd=l[0]
  l.remove(gcd)
  for x in l:
    gcd=fractions.gcd(gcd,x)
  if gcd==1:
    print('POSSIBLE')
  else:
    if k%gcd==0:
      print('POSSIBLE')
    else:
      print('IMPOSSIBLE')