<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def roman2int(s):
 """Decode roman number :param s: string representing a roman number between 1 and 9999 :returns: the decoded roman number :complexity: linear (if that makes sense for constant bounded input size) """

    val = 0
    pos10 = 1000
    beg = 0
    for pos in range(3, -1, -1):
        for digit in range(9,-1,-1):
            r = roman[pos][digit]
            if s.startswith(r, beg):  # footnote 1
                beg += len(r)
                val += digit * pos10
                break
        pos10 //= 10
    return val