Problem:


一番下の行の数字は?

次のような数字のパターンを作ることを考えます。

4 8 2 3 1 0 8 3 7 6
 2 0 5 4 1 8 1 0 3
  2 5 9 5 9 9 1 3
   7 4 4 4 8 0 4
    1 8 8 2 8 4
     9 6 0 0 2
      5 6 0 2
       1 6 2
        7 8
         5

このパターンは以下の規則に従っています。

A B
 C

という数字の並びにおいて、C は A + B の 1 の位の数字である。たとえば、

9 5
 4

では、9 + 5 = 14 の 1 の位の数字、すなわち 4 が 9 と 5 の斜め下に並べられます。また、

2 3
 5

では、2 + 3 = 5 の 1 の位の数字、すなわち 5 が 2 と 3 の斜め下に並べられます。

一番上の行の 10 個の整数を読み込んで、一番下の行の 1 個の数を出力するプログラムを作成してください。

Input

入力は複数のデータセットからなります。各データセットとして、一番上の行の 10 個の数字が文字列として１行に与えられます。

データセットの数は 20 を超えません。

Output

データセットごとに、一番下の行の数字を１行に出力します。

Sample Input

4823108376
1234567890
0123456789

Output for the Sample Input

5
6
4



Sample input:
4823108376
1234567890
0123456789


Sample output:
5
6
4

Submission status: Wrong Answer

Solution code:
while True:
    try:
        l = list(str(int(input())))
    except:
        break

    for i in range(len(l)):
        for j in range(len(l) - i-1):
            l[j] = str(int(l[j])+int(l[j+1]))[-1]

    print(l[0])

Submission status: Wrong Answer

Solution code:
n = map(int,tuple(raw_input()))
tmp=list(n)
while len(tmp)>1:
    tmp2 = [str((int(tmp[i])+int(tmp[i+1])))[-1] for i in range(len(tmp)-1)]
    tmp = tmp2
else:
    print tmp[0]

Submission status: Wrong Answer

Solution code:
while True:
    try:
        a = tuple(map(int, input()))
    except:
        break

    while True:
        b = []
        for i in range(int(len(a)/2)):
            b.append(int(str(a[i*2] + a[i*2+1])[-1]))
        if len(b) == 1:
            print(b[0])
            break 
        a = b

Submission status: Wrong Answer

Solution code:
while True:
    try:
        a = tuple(map(int, input()))
    except EOFError:
        break

    while True:
        b = []
        for i in range(int(len(a)/2)):
            b.append(int(str(a[i*2] + a[i*2+1])[-1]))
        if len(b) == 1:
            print(b[0])
            break 
        a = b

Submission status: Wrong Answer

Solution code:
while True:
    try:
        a = tuple(map(int, input()))
    except EOFError:
        break

    while True:
        b = []
        for i in range(int(len(a)/2)):
            b.append(int(str(a[i*2] + a[i*2+1])[-1]))
        if len(b) == 1:
            print(b[-1])
            break 
        a = b

Submission status: Wrong Answer

Solution code:
while True:
    try:
        a = tuple(int, input())
    except:
        break

    while True:
        b = []
        for i in range(len(a)-1):
            b.append(int(str(a[i] + a[i+1])[-1]))
        print(b)
        if len(b) == 1:
            print(b[-1])
            break 
        a = b

Submission status: Wrong Answer

Solution code:
while True:
    try:
        a = tuple(int, input())
    except:
        break

    while True:
        b = []
        for i in range(len(a)-1):
            b.append(int(str(a[i] + a[i+1])[-1]))
        if len(b) == 1:
            print(b[-1])
            break 
        a = b

Submission status: Wrong Answer

Solution code:
while True:
    try:
        a = tuple(int, input())
    except:
        break

    while True:
        b = []
        for i in range(len(a)-1):
            b.append(int(str(a[i] + a[i+1])[-1]))
        if len(b) == 1:
            print(b[0])
            break 
        a = b

Submission status: Wrong Answer

Solution code:
list = []
str = input()

for i in range(len(str)):
	list.append(int(str[i]))
while len(list) > 1:
	length = len(list)
	for i in range(length - 1):
		list[i] = (list[i] + list[i+1]) % 10
	del list[length - 1]
print(list[0])

Submission status: Wrong Answer

Solution code:
b = input()
a=list(b)
for i in range(10):
    a[i]=int(a[i])
n=9
for i in range(10):
    d = 1
    for j in range(n):
        c=a[j]+a[d]
        c=c%10
        a[j]=c
        d+=1
    n-=1
print(a[0])

Submission status: Accepted

Solution code:
import sys
for s in sys.stdin.readlines():
    print(sum(int(n)*m for n, m in zip(s, [1, 9, 36, 84, 126, 126, 84, 36, 9, 1]))%10)

Submission status: Accepted

Solution code:
while True:
	try: x = list(map(int,input()))
	except: break
	for i in range(10,1,-1): 
		for n in range(1,i): 
			x[n-1] = (x[n-1] + x[n]) % 10
	print(x[0])

Submission status: Accepted

Solution code:
while True:
    try:
        nums = list(map(int, list(input())))
    except:
        break
    while len(nums) > 1:
        tmp = []
        for i in range(len(nums)-1):
            tmp.append(int(str(nums[i] + nums[i+1])[-1]))
        nums = [] + tmp
    print(nums[0])

Submission status: Accepted

Solution code:
def f(l):
 return map(lambda x: (x[0] + x[1]) % 10, zip(l[:len(l)-1], l[1:]))

while True:
 try:
  l = map(int, raw_input().strip());
  for i in range(9):
   l = f(l)
  print l[0]
 except:
  break;

Submission status: Accepted

Solution code:
import sys

def solve(lis):
    if len(lis) == 1 :print lis[0] ; return 0
    l = [ (lis[i]+lis[i+1])%10 for i in xrange(len(lis)-1) ]
    solve(l)

for s in sys.stdin:
    solve([ int(e) for e in s[:-1] ])

Submission status: Accepted

Solution code:
import sys
f = sys.stdin

def next_line(line):
    next_line = [0] * (len(line) - 1)
    for i in range(len(next_line)):
        next_line[i] = (line[i] + line[i + 1]) % 10
    return next_line

for line in f:
    line = list(map(int,line.strip()))
    while 1 < len(line):
        line = next_line(line)
    print(*line)

Submission status: Accepted

Solution code:
while True:
    try:
        n = map(int,tuple(raw_input()))
    except EOFError:
        break
    tmp=list(n)
    while len(tmp)>1:
        tmp2 = [str((int(tmp[i])+int(tmp[i+1])))[-1] for i in range(len(tmp)-1)]
        tmp = tmp2
    else:
        print int(tmp[0])

Submission status: Accepted

Solution code:
while True:
    try:
        n = tuple(map(int,raw_input()))
    except EOFError:
        break
    tmp=list(n)
    while len(tmp)>1:
        tmp2 = [(tmp[i]+tmp[i+1])%10 for i in range(len(tmp)-1)]
        tmp = tmp2
    else:
        print tmp[0]

Submission status: Accepted

Solution code:
def suicide(lis):
    if len(lis) == 1:
        print lis[0]
        return
    pokakito = []
    for i in range(len(lis)-1):
        check = lis[i] + lis[i+1]
        one = int(str(check)[-1])
        pokakito.append(one)
    else:
        suicide(pokakito)

while True:
    try:
        lis = [int(char) for char in raw_input()]
        suicide(lis)
    except EOFError:
        break

Submission status: Accepted

Solution code:
import sys
for line in sys.stdin.readlines():
  l = [int(i) for i in line.replace('\n','')]
  while len(l) >1:
    m = []
    for i in range(len(l)-1):
      m.append((l[i]+l[i+1])%10)
    l = list(m)
  print(l[0])

Submission status: Accepted

Solution code:
from math import *
PI = 3.1415926535898
while True:
    try:
        n = raw_input()
        res = []
        for x in n:
            res.append(int(x))
        while len(res) > 1:
            t = []
            for i in range(1, len(res)):
                t.append((res[i]+res[i-1])%10)
            res = t
        print res[0]
    except EOFError:
        break

Submission status: Accepted

Solution code:
while 1:
    try:
        n=raw_input()
        l=[int(x) for x in n]
        tmp=[]
        while len(l)>1:
            for i in range(len(l)-1):
                tmp.append((l[i]+l[i+1])%10)
            l=tmp[:]
            tmp=[]
        print l[0]


    except:
        break

Submission status: Accepted

Solution code:
while True:
	try:
		A=[[]]*10
		A[0]=list(map(int,input()))
		for i in range(1,10):
			A[i]=[0]*(10-i)		
		for i in range(1,10):
			for j in range(0,len(A[i])):
				A[i][j]=(A[i-1][j]+A[i-1][j+1])%10
		print(A[9][0])
	
	except EOFError:
		break

Submission status: Accepted

Solution code:
#encoding=utf-8
import sys

def inp():
    for line in sys.stdin:
        word = str(line[:-1])
        while True:
            tako = []
            for i in xrange(len(word) - 1):
                a = str(eval(word[i] + "+" +  word[i+1]))
                tako.append(a[-1])
            word =  "".join(tako)
            if len(word) == 1:
                break
        print word

if __name__ == "__main__":
    inp()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys

for line in sys.stdin:
    n = int(line)
    A = []
    for i in range(10):
        A.append(n%10)
        n /= 10
    print (A[0]+5*A[2]+5*A[7]+A[9])%10

Submission status: Accepted

Solution code:
while True:
    try:
        data = list(map(int, list(input())))
    except:
        break
    for _ in range(9):
        for i in range(9):
            data[i] = (data[i] + data[i + 1]) % 10
    print(data[0])

Submission status: Accepted

Solution code:
def factorial(a):
    if(a==1 or a==0):return 1
    else:
        return a*factorial(a-1)

def comb(a,b):
    return factorial(a)//factorial(a-b)//factorial(b)

while True:
    try:
        st=input()
        ans=0
        for i in range(len(st)):
            n=int(st[i])
            ans+=n*comb(9,i)
        print(ans%10)

    except:
        break

Submission status: Accepted

Solution code:
while True:
    try:
        Num_lis = list(map(int,map(str,input())))

        while len(Num_lis) > 1:
            List1 = []
            for i in range(len(Num_lis) - 1):
                List1.append((Num_lis[i] + Num_lis[i + 1]) % 10)
            Num_lis = List1
        print(Num_lis[0])
            
    except EOFError:
        break

Submission status: Accepted

Solution code:
import sys

for line in sys.stdin:
    line = [int(v) for v in line.strip()]
    while len(line) > 1:
        line = [line[i]+line[i+1] for i in range(len(line)-1)]
    print(str(line[0])[len(str(line[0]))-1])

Submission status: Accepted

Solution code:
while True:
    try:
        a = [int(i) for i in input()]
    except:
        break
    while True:
        na = []
        for i in range(len(a) - 1):
            na.append((a[i] + a[i + 1]) % 10)
        if len(na) == 1:
            print(na[0])
            break
        a = na

Submission status: Accepted

Solution code:
s = []
while True:
    try:
        s.append(str(input()))
    except EOFError:
        break

def func(x):
    array = []
    if len(x) == 1:
        return x[0]
    for i in range(len(x)-1):
        array.append((x[i] + x[i+1]) % 10)
    return func(array)

for i in range(len(s)):
    arr = list(s[i])
    for j in range(len(arr)):
        arr[j] = int(arr[j])
    print(func(arr))

Submission status: Accepted

Solution code:
while 1:
    try:n=input()
    except:break
    n=list(map(int,n))
    while len(n)>1:
        n= [(i+j)%10 for i,j in zip(n[:len(n)-1],n[1:])]
    print(*n)

Submission status: Accepted

Solution code:
while 1:
    try:n=input()
    except:break
    n=list(map(int,n))
    while len(n)>1:
        n= [(i+j)%10 for i,j in zip(n[:-1],n[1:])]
    print(*n)

Submission status: Accepted

Solution code:
while 1:
    try:n=input()
    except:break
    while len(n)>1:
        n= [(int(i)+int(j))%10 for i,j in zip(n[:-1],n[1:])]
    print(*n)

Submission status: Accepted

Solution code:
def shorten(f):
    #print(f) 
    if len(f) == 1:
        return(f[0])
    else:
        g = []
        v = f[0]
        for i in f[1:]:
            g.append((v + i)%10)
            v = i
        return(shorten(g))

while True:
  try:
      f = list(map(int, list(input().strip())))
      print(shorten(f))
  
  except EOFError:
      break

Submission status: Accepted

Solution code:
while True:
    try:
        S = input()
    except EOFError:
        break
    while len(S) > 1:
        T = ''
        for i in range(0,len(S) - 1):
            x = int(S [i])
            y = int(S [i + 1])
            T += str((x + y) % 10)
        S,T = T,S
    print(S)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys
import os

for s in sys.stdin:
    s = s.strip()
    lst = list(s)

    while len(lst) > 1:
        lst2 = []
        for i in range(len(lst) - 1):
            a = int(lst[i])
            b = int(lst[i+1])
            c = (a + b) % 10
            lst2.append(str(c))
        lst = lst2
    print(lst[0])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0062
"""

import sys


def solve(data):
    work = data[:]
    while len(work) != 1:
        # print(work)
        temp = []
        for i in range(len(work)-1):
            temp.append((work[i] + work[i+1]) % 10)
        work = temp[:]
    return work[0]


if __name__ == '__main__':
    # ??????????????\?????¨???????????????
    for line in sys.stdin:
        data = [int(x) for x in list(line.strip())]
        result = solve(data)
        print(result)

Submission status: Accepted

Solution code:
import sys
def main():
    for line in sys.stdin:
        a = list(line)
        del a[-1]
        for x in range(len(a)):
            a[x] = int(a[x])


        for x in range(9):
            b = []
            for y in range(len(a) - 1):
                hoge = a[y] + a[y + 1]
                if hoge > 9:
                    hoge -= 10
                else:
                    pass
                b.append(hoge)
            else:
                a = b

        print(a[0])


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# Aizu Problem 0062: What is the Bottommost
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


while True:
    try:
        A = [int(_) for _ in input().strip()]
    except EOFError:
        break
    for _ in range(9):
        A = [(A[i]+A[i+1]) % 10 for i in range(len(A) - 1)]
    print(A[0])

Submission status: Accepted

Solution code:
while True:
    try:
        nums = input()
    except:
        break
    a = list(map(int, list(nums)))
    while len(a) > 1:
        a = list(map(int, [str(a[i]+a[i+1])[-1] for i in range(len(a)-1)]))
    print(*a)

Submission status: Accepted

Solution code:
while True:
    try:
        nums = input()
    except:
        break
    a = list(map(int, list(nums)))
    while len(a) > 1:
        a = [(a[i]+a[i+1])%10 for i in range(len(a)-1)]
    print(*a)

Submission status: Accepted

Solution code:
while True:
    try:
        b = input()
        a=list(b)
        for i in range(10):
            a[i]=int(a[i])
        n=9
        for i in range(10):
            d = 1
            for j in range(n):
                c=a[j]+a[d]
                c=c%10
                a[j]=c
                d+=1
            n-=1
        print(a[0])
    except:break

Submission status: Accepted

Solution code:
import sys
for line in sys.stdin:
    n = line
    temp = []
    for i in line[:-1]:
        temp.append(int(i))
    n = temp
    while len(n) > 1:
        temp = []
        for i in range(len(n)-1):
            temp.append(int(str(n[i] + n[i+1])[-1]))
        n = temp
    print(n[0])

Submission status: Accepted

Solution code:
def calc(inp):
    if len(inp) == 1:
        return inp
    out = ""
    for i in range(len(inp) - 1):
        out = out + str(int(inp[i]) + int(inp[i + 1]))[-1]
    return calc(out)

while True:
    try:
        s = input()
        print(calc(s))
    except:
        break

Submission status: Accepted

Solution code:
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
for l in range(len(N)):
    S = N[l]
    table = [[0 for i in range(10)] for j in range(10)]
    for i in range(len(S)):
        table[0][i] = int(S[i])
    for i in range(1,10):
        for j in range(0,10-i):
            table[i][j] = (table[i-1][j] + table[i-1][j+1]) % 10
    print(table[9][0])

Submission status: Accepted

Solution code:
import sys
f=lambda x:f([(x[i]+x[i+1])%10 for i in range(len(x)-1)])if len(x)>1 else x
for e in sys.stdin:print(*f([int(i)for i in e.strip()]))

Submission status: Accepted

Solution code:
import sys
for e in sys.stdin:
 e=e.strip()
 while len(e)>1:e=[(int(e[i])+int(e[i+1]))%10 for i in range(len(e)-1)]
 print(*e)

Submission status: Accepted

Solution code:
import sys
for e in sys.stdin:
 e=list(map(int,e.strip()))
 while len(e)>1:e=[(e[i]+e[i+1])%10 for i in range(len(e)-1)]
 print(*e)

Submission status: Accepted

Solution code:
import sys
for e in sys.stdin:
 e=e.strip()
 while len(e)>1:e=[(int(a)+int(b))%10 for a,b in zip(e[:-1],e[1:])]
 print(*e)

Submission status: Accepted

Solution code:
import sys
n=[1,9,36,84,126]
for e in sys.stdin:print(sum(int(a)*k for a,k in zip(e[:-1],n+n[::-1]))%10)

Submission status: Accepted

Solution code:
import sys
n=[1,9,36,84,126]
for x in sys.stdin:
 a,b,c,d,e,f,g,h,i,j=map(int,x[:-1])
 print(sum(s*t for s,t in zip(n,[a+j,b+i,c+h,d+g,e+f]))%10)

Submission status: Accepted

Solution code:
import sys
for x in sys.stdin:
 print(sum(s*(int(t)+int(u))for s,t,u in zip([1,9,36,84,126],x[:5],x[9:4:-1]))%10)

Submission status: Accepted

Solution code:
import sys
for e in sys.stdin:
 print(sum(int(a)*k for a,k in zip(e[:5]+e[9:4:-1],[1,9,36,84,126]*2))%10)

Submission status: Accepted

Solution code:
import sys
for e in sys.stdin:print(sum(int(a)*k for a,k in zip(e[:5]+e[9:4:-1],[1,9,36,84,126]*2))%10)

Submission status: Accepted

Solution code:
import sys
for e in sys.stdin:print(sum(k*int(a)for k,a in zip([1,9,36,84,126]*2,e[:5]+e[9:4:-1]))%10)

Submission status: Accepted

Solution code:
def solve(nums):
  while len(nums) > 1:
    nums = [nums[i] + nums[i + 1] for i in range(len(nums) -1)]
  return nums[0] % 10

while True:
  try:
    s = list(map(int, list(input())))
    print(solve(s))

  except EOFError:
    break

Submission status: Accepted

Solution code:
import sys
red=lambda a:"".join(map(str,[(int(a[i])+int(a[i+1]))%10 for i in range(len(a)-1)]))
tl=[]
l=[i.strip() for i in sys.stdin]

for i in l:
    while len(i) != 1:
        i=red(i)
    tl.extend([int(i)])
[print(i) for i in tl]

Submission status: Accepted

Solution code:
# AOJ 0062: What is the Bottommost?
# Python3 2018.6.15 bal4u

while True:
	try:
		a = list(map(int, input()))
	except EOFError:
		break

	for i in range(9, 0, -1):
		for j in range(1, i+1):	a[j-1] = (a[j-1]+a[j]) % 10
	print(a[0])

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

import sys


def get_answer(param):
    answer = []
    for i in xrange(param.__len__() - 1):
        c = str(param[i] + param[i + 1])[-1]
        answer.append(int(c))
    if (answer.__len__() == 1):
        return answer[0]
    else:
        return get_answer(answer)


def main():
    params = [map(int, line.rstrip()) for line in sys.stdin.readlines()]
    for param in params:
        print get_answer(param)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
def calc(lis):
    for i in xrange(9):
        for j in xrange(9-i):
            lis[j]=(lis[j]+lis[j+1])%10
    return lis
for line in sys.stdin.readlines():
    print calc([int(x) for x in line.strip()])[0]

Submission status: Accepted

Solution code:

import sys


def solv(nums):
    for i in range(9):
        nums = foo(nums)
    return nums[0]

def foo(nums):
    nums = map(lambda a: (a[0] + a[1]) % 10, zip(nums, nums[1:]))
    return nums


for line in sys.stdin:
    nums = map(int, list(line.rstrip()))
    print solv(nums)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

for line in stdin:
    L = [int(c) for c in line.strip()]
    while len(L) > 1:
        L = [(L[i] + L[i + 1]) % 10 for i in range(len(L) - 1)]
    print(L[0])

Submission status: Accepted

Solution code:
import sys
for rec in sys.stdin.readlines():
    d=map(int,list(rec.rstrip()))
    while len(d)>1:
        tmp=[]
        for i in range(1,len(d)):
            tmp.append((d[i-1]+d[i])%10)
        d=tmp
    print d[0]

Submission status: Accepted

Solution code:
import sys
for s in sys.stdin:
    x=["0123456789".index(c) for c in s[:-1]]
    while True:
        a=len(x)-1
        x=[(x[i]+x[i+1])%10 for i in range(a)]
        if a==1: break
    print x[0]

Submission status: Accepted

Solution code:
while True:
    try:
        n = list(raw_input())
        for i in range(9,0,-1):
            for j in range(i):
                n[j] = (int(n[j])+int(n[j+1]))%10
        print n[0]
    except:
        break

Submission status: Accepted

Solution code:
while True:
    try:
        n = list(map(int, raw_input()))
        for i in range(9,0,-1):
            for j in range(i):
                n[j] = (n[j]+n[j+1])%10
        print n[0]
    except:
        break

Submission status: Accepted

Solution code:
try:
    while True:
        a = map(int, raw_input())
        for i in range(9, 0, -1):
            for j in range(i):
                a[j] = (a[j] + a[j + 1]) % 10
        print a[0]
except EOFError:
    pass

Submission status: Accepted

Solution code:
while 1:
    try:
        numbers = map(int, raw_input())
    except EOFError:
        break
    dp = [[0] * 10 for _ in xrange(10)]
    dp[0] = numbers
    for i in xrange(9):
        for j in xrange(len(dp[i]) - 1):
            dp[i + 1][j] = (dp[i][j] + dp[i][j + 1]) % 10
    print dp[-1][0]

Submission status: Accepted

Solution code:
while True:
    try:
        line = input()
    except EOFError:
        break

    a = list(map(int, line))
    while len(a) > 1:
        a = [(a[i] + a[i + 1]) % 10 for i in range(len(a) - 1)]
    print(a[0])

Submission status: Accepted

Solution code:
while True:
    try:
        A = list(input())
    except:
        break

    A2 = []
    for i in range(9):
        n = int(A[i]) + int(A[i+1])
        n_str = str(n)
        n_2 = n_str[len(n_str)-1]
        A2.append(n_2)
    A3 = []
    for i in range(8):
        n = int(A2[i]) + int(A2[i+1])
        n_str = str(n)
        n_2 = n_str[len(n_str)-1]
        A3.append(n_2)
    A4 = []
    for i in range(7):
        n = int(A3[i]) + int(A3[i+1])
        n_str = str(n)
        n_2 = n_str[len(n_str)-1]
        A4.append(n_2)
    A5 = []
    for i in range(6):
        n = int(A4[i]) + int(A4[i+1])
        n_str = str(n)
        n_2 = n_str[len(n_str)-1]
        A5.append(n_2)
    A6 = []
    for i in range(5):
        n = int(A5[i]) + int(A5[i+1])
        n_str = str(n)
        n_2 = n_str[len(n_str)-1]
        A6.append(n_2)
    A7 = []
    for i in range(4):
        n = int(A6[i]) + int(A6[i+1])
        n_str = str(n)
        n_2 = n_str[len(n_str)-1]
        A7.append(n_2)
    A8 = []
    for i in range(3):
        n = int(A7[i]) + int(A7[i+1])
        n_str = str(n)
        n_2 = n_str[len(n_str)-1]
        A8.append(n_2)
    A9 = []
    for i in range(2):
        n = int(A8[i]) + int(A8[i+1])
        n_str = str(n)
        n_2 = n_str[len(n_str)-1]
        A9.append(n_2)
    A10 = []
    for i in range(1):
        n = int(A9[i]) + int(A9[i+1])
        n_str = str(n)
        n_2 = n_str[len(n_str)-1]
        A10.append(n_2)
    print(int(A10[0]))

Submission status: Accepted

Solution code:
while True:
    try:
        a = []
        b = []
        a = list(map(int, input()))

        while len(a) != 1:
            for j in range(len(a)-1):
                b.append(a[j]+ a[j+1])
            
            a = b
            b = []

        ans = a[-1] % 10
        print(ans)

    except EOFError:
        break

Submission status: Accepted

Solution code:
while True :
    try :
        A = list(input())
    except EOFError :
        break
    
    for j in range(9) :
        for i in range(len(A)-1) :
            A[i] = (int(A[i]) + int(A[i+1])) % 10
        del A[-1]
    print(A[0])

Submission status: Accepted

Solution code:
import sys
readlines = sys.stdin.readlines
write = sys.stdout.write

L = 9
comb = [[0]*(L+1) for i in range(L+1)]
for i in range(L+1):
    comb[i][0] = comb[i][i] = 1
    for j in range(1, i):
        comb[i][j] = comb[i-1][j-1] + comb[i-1][j]
Y = comb[i]

def solve():
    for line in readlines():
        *X, = map(int, line.strip())
        write("%d\n" % (sum(x * y for x, y in zip(X, Y)) % 10))
solve()

Submission status: Accepted

Solution code:
# addtion_resultに計算結果を一時保存して1ループ終了ごとにlineをaddtion_resultに置き換えて次のループに行くことでfor文で実装可能になる


while True:
    try:
        line = [int(x) for x in list(input())]
    except EOFError:
        break

    addition_result =[]
    while len(line) > 1:
        for i in range(len(line)-1):
            addition_result.append( (line[i] + line[i+1])%10 )
        line = addition_result[:]
        addition_result = []
    print(line[0])

Submission status: Accepted

Solution code:
while True:
    try:
        n  = input()
        while(len(n) != 1):
            s = ''
            for i in range(0,len(n) - 1):
                s += str((int(n[i]) + int(n[i + 1])) % 10)
            n = s
        print(n)
    except:
        break

Submission status: Accepted

Solution code:
    
def main(num):
    while True:
        tmp_m=[]
        for i in range(1,len(num)):
            tmp_m.append((num[i]+num[i-1])%10)

        if len(tmp_m)==1:
            return tmp_m[0]
            break
        num=tmp_m
    

while True:
    try:
        num=list(map(int, input()))
        print(main(num))
    except EOFError:
        break

Submission status: Accepted

Solution code:
while True:
    try:
        L = [int(x) for x in list(input())]
    except:
        break

    T =[]
    while len(L) > 1:
        for i in range(len(L)-1):
            T.append( (L[i] + L[i+1])%10 )
        L = T[:]
        T = []
    print(L[0])

Submission status: Accepted

Solution code:
a = []
while True:
    try:
        a = list(map(int, input()))
    except:
        break
    for i in range(9,0,-1):
        for j in range(1,i+1):a[j-1]=(a[j-1]+a[j])%10
    print(a[0])

Submission status: Accepted

Solution code:
while 1:
    try:
        n = input()
        while len(n) > 1:
            n = [(int(i)+int(j)) % 10 for i, j in zip(n[:-1], n[1:])]
        print(*n)
    except:
        break

Submission status: Accepted

Solution code:
import sys
for e in sys.stdin:print(sum(k*int(a)for k,a in zip([1,9,36,84,126]*2,e[:5]+e[9:4:-1]))%10)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    
    while True:
        try:
            A = list(map(int,input()))
            
            def rec(A):
                n = len(A)
                if n == 1:
                    return A[0]
                
                tmp = []
                for i in range(n-1):
                    a = (A[i] + A[i+1]) % 10
                    tmp.append(a)
                
                return rec(tmp)

            print(rec(A))        

        except EOFError:
            break

Submission status: Accepted

Solution code:
def bottom(line):
    N=[]
    line=str(line)
    #print(line)
    for i in list(line):
        N.append(int(i))
    #print(N)
    if len(N)==1:return line
    else:
        ans=""
        for j in range(len(N)):
            M=[]
            if j==len(N)-1:return bottom(ans)
            else:
                num=N[j]+N[j+1]
                #print(num)
                M=list(str(num))
                ans +=M[-1]
while 1:
    try:print(bottom(input()))
    except:break

Submission status: Accepted

Solution code:
def keisan(patan):
    sujiretu=[]
    if len(patan)>1:
        for i in range(1,len(patan)):
            sujiretu.append((int(patan[i-1])+int(patan[i])) % 10 )
        return keisan(sujiretu)
    else:return patan
while(1):
    try:
        suuji=input("")
        suuji=keisan(suuji)
        print(suuji[0])
    except:break

Submission status: Accepted

Solution code:
while 1:
    try:
        s=input()
        n=[]
        for i in s:
            n.append(int(i))
        ans=n[0]+n[1]*9+n[2]*6+n[3]*4+n[4]*6+n[5]*6+n[6]*4+n[7]*6+n[8]*9+n[9]
        print(ans%10)
    except:break

Submission status: Accepted

Solution code:
while(1):
    try:
        a = [int(i) for i in list(input())]
        for i in range(9):
            a_ = [i % 10 for i in [k+l for k,l in zip(a[1:], a[:9-i])]]
            a = a_
        print(a[0])
    except EOFError:
        break

Submission status: Accepted

Solution code:
while 1:
    try:
        num = list(input())
    except EOFError:
        break

    for _ in range(9):
        nextlist = []
        for i in range(len(num)-1):
            tmp = (int(num[i]) + int(num[i+1])) % 10
            nextlist.append(tmp)

        num = nextlist

    print(num[0])

Submission status: Accepted

Solution code:
while True:
    try: n = input()
    except: break
    n = list(map(int, list(n)))
    while len(n) > 1:
        n = [(n[i]+n[i+1]) % 10 for i in range(len(n)-1)]
    print(*n)

Submission status: Accepted

Solution code:
import sys
for l in sys.stdin:print(sum(int(a)*b for a,b in zip(l,[1,9,6,4,6,6,4,6,9,1]))%10)

Submission status: Runtime Error

Solution code:
import sys

def suicide(lis):
    if len(lis) == 1:
        print lis[0]
    pokakito = []
    for i in range(len(lis)-1):
        check = lis[i] + lis[i+1]
        one = int(str(check)[-1])
        pokakito.append(one)
    else:
        suicide(pokakito)

for line in sys.stdin:
    lis = [int(char) for char in line.rstrip()]
    suicide(lis)

Submission status: Runtime Error

Solution code:
def suicide(lis):
    if len(lis) == 1:
        print lis[0]
    pokakito = []
    for i in range(len(lis)-1):
        check = lis[i] + lis[i+1]
        one = int(str(check)[-1])
        pokakito.append(one)
    else:
        suicide(pokakito)

while True:
    try:
        lis = [int(char) for char in raw_input()]
        suicide(lis)
    except EOFError:
        break

Submission status: Runtime Error

Solution code:
while True:
    try:
        a = map(int, input())
    except:
        break

    while True:
        b = []
        for i in range(len(a)/2):
            b.append(int(str(a[i*2] + a[i*2+1])[-1]))
        if len(b) == 1: 
            print b
            break 
        a = b

Submission status: Runtime Error

Solution code:
while True:
    try:
        a = map(int, input())
    except:
        break

    while True:
        b = []
        for i in range(len(a)/2):
            b.append(int(str(a[i*2] + a[i*2+1])[-1]))
        if len(b) == 1:
            print(b)
            break 
        a = b

Submission status: Runtime Error

Solution code:
while True:
    try:
        a = map(int, input())
    except:
        break

    while True:
        b = []
        for i in range(int(len(a)/2)):
            b.append(int(str(a[i*2] + a[i*2+1])[-1]))
        if len(b) == 1:
            print(b[0])
            break 
        a = b

Submission status: Runtime Error

Solution code:
while True:
    try:
        a = tuple(int, input())
    except EOFError:
        break

    while True:
        b = []
        for i in range(len(a)-1):
            b.append(int(str(a[i] + a[i+1])[-1]))
        if len(b) == 1:
            print(b[-1])
            break 
        a = b

Submission status: Runtime Error

Solution code:
while($line = fgets(STDIN)) {
  $data = array();
  for ($i = 0; $i < strlen($line); $i++) {
    $data[$i] = substr($line, $i, 1);
  }
  while (count($data) > 1) {
    $nextLine = '';
    for ($i = 0; $i < count($data) - 1; $i++) {
      $nextLine .= substr(($data[$i] + $data[$i+1]), -1);
    }
    $nextLine = trim($nextLine);
    $data = array();
    for ($i = 0; $i < strlen($nextLine); $i++) {
      $data[$i] = substr($nextLine, $i, 1);
    }
  }
  echo $data[0] . '<br>';
}