Problem:


Hit and Blow

Let's play Hit and Blow game. A imagines four numbers and B guesses the numbers. After B picks out four numbers, A answers:

 The number of numbers which have the same place with numbers A imagined (Hit) 

 The number of numbers included (but different place) in the numbers A imagined (Blow)

For example, if A imagined numbers:

9 1 8 2

and B chose:

4 1 5 9

A should say 1 Hit and 1 Blow.

Write a program which reads four numbers A imagined and four numbers B chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9.

Input

The input consists of multiple datasets. Each dataset set consists of:

a1 a2 a3 a4
b1 b2 b3 b4

, where ai (0 ≤ ai ≤ 9) is i-th number A  imagined and bi (0 ≤ bi ≤ 9) is i-th number B chose.

The input ends with EOF. The number of datasets is less than or equal to 50.

Output

For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space.

Sample Input

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

Output for the Sample Input

1 1
3 0



Sample input:
9 1 8 2
4 1 5 9
4 6 8 2
4 6 3 2


Sample output:
1 1
3 0

Submission status: Accepted

Solution code:
while 1:
    try:
        a = map(int, raw_input().split())
        b = map(int, raw_input().split())
        for i in xrange(3, -1, -1):
            if a[i] == b[i]:
                del a[i]
                del b[i]
        print str(4 - len(a)) + " " + str(len(set(a) & set(b)))
    except:
        break

Submission status: Accepted

Solution code:
while True:
    try:
        ansa=input().split()
        ansb=input().split()
    except:
        break

    hit = sum((1 for a, b in zip(ansa, ansb) if a == b))
    blow = sum((1 for a in ansa if a in ansb))

    print(hit, blow - hit)

Submission status: Accepted

Solution code:
import sys

a = []
for line in sys.stdin:
    a.append(line)

time=0
for n in a:
    if time==0:
        Alist=n.split()
        time=1
    else:
        Blist=n.split()
        hit=0
        blow=0
        for i in range(4):
            if Blist[i]==Alist[i]:
                hit+=1
            else:
                if Blist[i] in Alist:
                    blow+=1
        time=0
        print hit,blow

Submission status: Accepted

Solution code:
import sys

state = True
for s in sys.stdin:
    if state:
        state = not state
        a = list(map(int,s.split()))
    else:
        state = not state
        b = list(map(int,s.split()))
        hit = 0
        for i in range(len(a)):
            if a [i] == b [i]:
                hit += 1
        blow = -hit
        for i in range(10):
            blow += min(a.count(i),b.count(i))
        print(hit,blow)

Submission status: Accepted

Solution code:
import sys

turn = -1
for line in sys.stdin:
    turn += 1
    if turn%2 == 0:
        A = map(int, line.rstrip().split())
        continue
    else:
        B = map(int, line.rstrip().split())

    hit, blow = 0, 0
    for i, b in enumerate(B):
        if A[i] == b:
            hit += 1
        elif b in A:
            blow += 1
    print hit, blow

Submission status: Accepted

Solution code:
import sys

Even = True
for s in sys.stdin:
    if Even:
        Even = False
        a = list(map(int, s.split()))
    else:
        Even = True
        b = list(map(int, s.split()))
        hit = sum(a[i] == b[i] for i in range(4))
        blow = sum(b[i] in a for i in range(4)) - hit
        print(hit, blow)

Submission status: Accepted

Solution code:
import sys

even = True
for s in sys.stdin:
    if even:
        even = False
        a = list(map(int, s.split()))
    else:
        even = True
        b = list(map(int, s.split()))
        hit = sum(a[i] == b[i] for i in range(4))
        blow = sum(b[i] in a for i in range(4)) - hit
        print(hit, blow)

Submission status: Accepted

Solution code:
while True:
    try:
        hit = 0
        brow = 0
        Anum = list(map(int,input().split()))
        Bnum = list(map(int,input().split()))
        for i in range(4):
            if Anum[i] == Bnum[i]:
                hit += 1
            elif Bnum[i] in Anum:
                brow +=1
        print(hit,brow)
                
                       
    except EOFError:
        break

Submission status: Accepted

Solution code:
import sys
while(True):
    try:
        hit=0
        blow=0
        a=[int(i) for i in input().split()]
        b=[int(i) for i in input().split()]
        for i in range(len(a)):
            for j in range(len(b)):
                if a[i]==b[j]:
                    if i==j:
                        hit+=1
                    else:
                        blow+=1
                    break
        print(hit,blow)
    except EOFError:
        sys.exit()

Submission status: Accepted

Solution code:
import sys

if __name__ == '__main__':
    data = []
    for line in sys.stdin:
        data.append([int(x) for x in line.strip().split(' ')])
        if len(data) == 2:
            choice_a = data[0]
            choice_b = data[1]
            data = []

            #print(choice_a)
            #print(choice_b)

            # hit&blow?????????
            hit = 0
            blow = 0
#            for i, d in enumerate(choice_a):
#                if d in choice_b:
#                    if choice_a[i] == choice_b[i]:
#                        hit += 1
#                    else:
#                        blow += 1


            for i, d in enumerate(choice_a):
                if d in choice_b:
                    if d == choice_b[i]:
                        hit += 1
                    else:
                        blow += 1

            # ???????????¨???
            print('{0} {1}'.format(hit, blow))

Submission status: Accepted

Solution code:
while True:
    try:
        a = list(map(int, input().split()))
        b = list(map(int, input().split()))
        hit = sum(1 for x, y in zip(a, b) if x == y)
        hits = [x for x, y in zip(a, b) if x == y]
        blow = sum(1 for x in a if x in b and x not in hits)
        print(hit, blow)
    except:
        break

Submission status: Accepted

Solution code:
while True:
    try:
        a=[int(i) for i in input().split()]
        b=[int(i) for i in input().split()]
    except:
        break
    hit,blow=0,0
    for i,j in zip(a,b):
        if i==j:
            hit+=1
        elif j in a:
            blow+=1
    print(hit,blow)

Submission status: Accepted

Solution code:
def hit_blow(a,b):
    hit = 0
    blow = 0
    for i in range(4):
        if a[i] == b[i]:
            hit += 1
    for i in range(4):
        for j in range(4):
            if a[i] == b[j]:
                blow += 1
    blow -= hit
    print(hit,blow)
    return 0

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

Submission status: Accepted

Solution code:
while 1:
    try:a=list(map(int,input().split()))
    except:break
    b=list(map(int, input().split()))
    h=0
    for i in range(4):
        if a[i]==b[i]: h+=1
    print(h,len(set(a)&set(b))-h)

Submission status: Accepted

Solution code:
while 1:
    try:a=list(map(int,input().split()))
    except:break
    b=list(map(int, input().split()))
    h=0
    for i,j in zip(a,b):h+=i==j
    print(h,len(set(a)&set(b))-h)

Submission status: Accepted

Solution code:
import sys

while True:
  a = sys.stdin.readline()
  if not a: break

  a = a.rstrip().split(" ")
  b = raw_input().rstrip().split(" ")

  hit=0
  for i in range(len(a)):
    if a[i] == b[i]:
      hit+=1
      a[i] = -1

  blow=0
  for e in b:
    if e in a:
      blow+=1

  print("{} {}").format(hit, blow)

Submission status: Accepted

Solution code:
while True:
    try:
        hit = 0
        blow = 0
        hit_idx = []
        s = list(map(int, input().split()))
        t = list(map(int, input().split()))
        for i in range(4):
            if s[i] == t[i]:
                hit_idx.append(i) 
        hit = len(hit_idx)                                
        for i in hit_idx[::-1]:     # reverse order
            s = s[:i] + s[(i+1):]
            t = t[:i] + t[(i+1):]
        for c in s:
            if c in t:
                blow += 1
                                
        print("%d %d" % (hit,blow)) 
    except:
        break

Submission status: Accepted

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

        hit = 0
        blow = 0

        for i in range(4):
            if a[i] == b[i]:
                hit += 1
            elif a[i] in b:
                blow += 1

        print(hit,blow)

    except EOFError:
        break

Submission status: Accepted

Solution code:
import sys
array = []
for i in sys.stdin.readlines():
    array.append(i.rstrip().split())
for i in range(0,len(array),2):
    hit = 0
    blow = 0
    for i2 in range(4):
        if array[i][i2] == array[i+1][i2]:
            hit += 1
        for i3 in range(4):
            if array[i][i2] == array[i+1][i3]:
                if i2 == i3:
                    continue
                blow += 1
    print(str(hit)+" "+str(blow))

Submission status: Accepted

Solution code:
import sys

v = None
for i in sys.stdin:
    if v:
        h = 0
        for j, n in enumerate(i.split()):
            if n == v[j]:
                h += 10
            elif n in v:
                h += 1
        v = None
        print(h // 10, h % 10)
    else:
        v = i.split()

Submission status: Accepted

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

import sys
import os
import math

lines = sys.stdin.readlines()
game_num = len(lines) // 2

for i in range(game_num):
    s0 = lines[2 * i].strip()
    s1 = lines[2 * i + 1].strip()

    A = list(map(int, s0.split()))
    B = list(map(int, s1.split()))

    hit = 0
    blow = 0
    for j in range(4):
        if A[j] == B[j]:
            hit += 1
        elif A[j] in B:
            blow += 1
    print(hit, blow)

Submission status: Accepted

Solution code:
while True :
    try :
        a = [int(_) for _ in input().split()]
        b = [int(_) for _ in input().split()]
        hit, blow = 0, 0
        for _ in range(4) :
            if a[_] == b[_] : hit += 1
            elif b[_] in a : blow += 1
        print(hit, blow)
    except : break

Submission status: Accepted

Solution code:
while True:
    try:
        a, b = list(map(int,input().split())), list(map(int, input().split()))
        print(sum([1 for i in range(4) if a[i] == b[i]]),
              sum([1 for i in range(4) for j in range(4) if i != j and a[i] == b[j]]))
    except:
        break

Submission status: Accepted

Solution code:
def HB(A,B):
    hit=0
    blow=0
    for i in range(4):
        for j in range(4):
            if A[i]==B[j]:
                if i==j:
                    hit+=1
                else:
                    blow+=1
    return [hit,blow]
while True:
    try:
        A=input().split()
        B=input().split()
        print(HB(A,B)[0] , HB(A,B)[1] )
    except:
        break

Submission status: Accepted

Solution code:
try:
    while True:
        l1 = list(map(int, input().split()))
        l2 = list(map(int, input().split()))
        hit = blow = 0
        for i in l1:
            for s in l2:
                if i == s:
                    if l1.index(i) == l2.index(s):
                        hit += 1
                    else:
                        blow += 1
        print(hit, blow)
except:
    pass

Submission status: Accepted

Solution code:
try:
 while True:
  l1=list(map(int,input().split()))
  l2=list(map(int,input().split()))
  hit=blow=0
  for i in l1:
    for s in l2:
     if i==s:
      if l1.index(i)==l2.index(s):
        hit+=1
      else:
        blow+=1
  print(hit,blow)
except:
  pass

Submission status: Accepted

Solution code:
while True:
    try:
        A = list(map(int, input().split()))
        B = list(map(int, input().split()))
    except EOFError:
        break
    hit = sum(1 for i in range(4) if A[i] == B[i])
    blow = sum(1 for i in range(4) if A[i] in B) - hit
    print(hit, blow)

Submission status: Accepted

Solution code:
while True:
    try:
        a = list(map(int, input().split()))
        b = list(map(int, input().split()))
    except:
        break
    print(sum(x == y for x, y in zip(a, b)),  sum(a[i] != b[i] and a[i] in b for i in range(4)))

Submission status: Accepted

Solution code:
while True:
    try:
        a = list(map(int, input().split()))
        b = list(map(int, input().split()))
    except:
        break
    print(sum(x == y for x, y in zip(a, b)), sum(a[i] != b[i] and a[i] in b for i in range(4)))

Submission status: Accepted

Solution code:
import sys

for user in sys.stdin:
    hit = 0
    blow = 0
    a = list(map(int, user.split()))
    user = input()
    b = list(map(int, user.split()))
    for i in range(4):
        for j in range(4):
            if b[i] == a[j]:
                if i == j:
                    hit += 1
                else:
                    blow += 1

    print(hit, blow)

Submission status: Accepted

Solution code:
import sys
for line in sys.stdin:
    hit = 0
    blow = 0
    if line == "\n":
        break
    A = line.split()
    B = [n for n in input().split()]
    for i in B:
        if i in A:
            if A.index(i) == B.index(i):
                hit += 1
            else:
                blow += 1
    print(hit, blow)

Submission status: Accepted

Solution code:
import sys
def main():
    for line in sys.stdin:
        a = list(map(int, line.split()))
        b = list(map(int, input().split()))

        hi, bl = 0, 0
        for x in range(4):
            for y in range(4):
                if a[x] == b[y]:
                    if x == y:
                        hi += 1
                    else:
                        bl += 1

        print(hi, bl)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# Aizu Problem 0025: Hit and Blow
#
import sys, math, os

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


def hit_and_blow(A, B):
    hit, blow = 0, 0
    for k in range(4):
        if A[k] == B[k]:
            hit += 1
        elif A[k] in B:
            blow += 1
    return hit, blow


while True:
    try:
        A = [int(_) for _ in input().split()]
    except EOFError:
        break
    B = [int(_) for _ in input().split()]
    hit, blow = hit_and_blow(A, B)
    print(hit, blow)

Submission status: Accepted

Solution code:
def check(collect, answer):
    hit = sum(1 for a, c in zip(answer, collect) if a is c)
    blow = len(set(collect) & set(answer)) - hit
    return (hit, blow)

while True:
    try:
        print(*check(input().split(), input().split()))
    except EOFError:
        break

Submission status: Accepted

Solution code:
# coding=utf-8


def hit_and_blow(answer: list, expect: list) -> tuple:
    hit, blow = 0, 0
    for (i, j) in zip(answer, expect):
        if i == j:
            hit += 1
    answer_set = set(answer)
    expect_set = set(expect)
    blow_set = answer_set & expect_set
    blow = len(blow_set) - hit
    return hit, blow


if __name__ == '__main__':
    while True:
        try:
            answer_number = list(map(int, input().split()))
            expected_number = list(map(int, input().split()))
        except EOFError:
            break
        h, b = hit_and_blow(answer_number, expected_number)
        print(h, b)

Submission status: Accepted

Solution code:
while True:
    try:
        a = list(map(int, input().split()))
        b = list(map(int, input().split()))
    except:
        break
    hit = 0
    blow = 0
    for i, n in enumerate(a):
        if b[i] == n:
            hit += 1
        elif n in b:
            blow += 1
    print(hit, blow)

Submission status: Accepted

Solution code:
while 1:
    try:
        a =[int(i) for i in input().split()]
        b =[int(i) for i in input().split()]
        hit=0
        bro=0
        for i in range(4):
            if a[i]==b[i]:
                hit=hit+1
            for j in range(4):
                if a[i]==b[j]:
                    bro=bro+1
        print(hit,bro-hit)
    except:break

Submission status: Accepted

Solution code:
while True:
  try:
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]
    hit = blow = 0
    for i in range(len(A)):
      if A[i] == B[i]:
        hit += 1
    print(hit, end=" ")
    for b in B:
      if A.count(b) > 0:
        blow += 1
    print(blow - hit)
  except:
    break

Submission status: Accepted

Solution code:
def main():
    while True:
        try:
            A = list(map(int,input().split()))
            B = list(map(int,input().split()))
            hit_count = 0
            blow_count = 0
            for i in range(4):
                for j in range(4):
                    if A[i] == B[i]:
                        hit_count += 1
                        break
                    if A[i] == B[j]:
                        blow_count += 1
                        break
            print(str(hit_count)+ " " + str(blow_count))
        except EOFError:
            break




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
while True:
    try:
        a = list(map(int, input().split()))
        b = list(map(int, input().split()))
        hit  = 0
        blow = 0
        for i in range(4):
            if a[i] == b[i]:
                hit += 1
            elif a[i] in b:
                blow += 1
        print(hit, blow)
    except:
        break

Submission status: Accepted

Solution code:
while True:
    try:
        Hflag,Bflag=0,0
        a = map(int,raw_input().split())
        b = map(int,raw_input().split())
        for i in range(4):
            if a[i] == b[i]:
                Hflag += 1
            else:
                continue
        for j in range(4):
            for k in range(4):
                if a[j] == b[k]:
                    Bflag += 1
                else:
                    continue
        Bflag = Bflag - Hflag
        print Hflag, Bflag
    except:
        break

Submission status: Accepted

Solution code:
while True:
    hit=0
    bro=0
    try:
        a = [int(i) for i in input().split()]
        b= [int(j) for j in input().split()]
        for g in range(4):
            for p in range(4):
                if a[g]==b[p]:
                    bro+=1
        for l in range(4):
            if a[l]==b[l]:
                hit+=1
                bro-=1
        print(hit,bro)
    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(0,len(N),2):
    a = [int(i) for i in N[l].split()]
    b = [int(i) for i in N[l+1].split()]

    hit = 0
    blow = 0
    for i in range(len(a)):
        for j in range(len(b)):
            if a[i] == b[j]:
                if i == j:
                    hit = hit+1
                else:
                    blow = blow+1
    print(hit,blow)

Submission status: Accepted

Solution code:
import sys
e=iter(map(lambda a:a.split(),sys.stdin))
for a,b in zip(e,e):
 h=sum([1 for i in range(4)if a[i]==b[i]])
 w=4-len(set(a)-set(b))-h
 print(h,w)

Submission status: Accepted

Solution code:
import sys
e=iter(map(lambda a:a.split(),sys.stdin))
for a,b in zip(e,e):
 h=sum([1 for i in range(4)if a[i]==b[i]])
 print(h,4-len(set(a)-set(b))-h)

Submission status: Accepted

Solution code:
import sys
e=iter(map(lambda a:a.split(),sys.stdin))
for a,b in zip(e,e):
 h=0
 for s,t in zip(a,b):h+=s==t
 print(h,4-len(set(a)-set(b))-h)

Submission status: Accepted

Solution code:
import sys
e=iter(sys.stdin)
for a,b in zip(e,e):
 a,b,h=a.split(),b.split(),0
 for s,t in zip(a,b):h+=s==t
 print(h,4-len(set(a)-set(b))-h)

Submission status: Accepted

Solution code:
while True:
    try:
        a=[int(i) for i in input().split()]
        b=[int(i) for i in input().split()]
    except:break
    hit=sum([1 for i in range(4) if a[i]==b[i]])
    blow=8-len(set(a)|set(b))-hit
    print("{0} {1}".format(hit,blow))

Submission status: Accepted

Solution code:
while 1:
	hit = blow = 0
	try: a = list(map(int,input().split()))
	except: break
	b = list(map(int,input().split()))
	for i in range(4):
		if a[i] == b[i]:
			hit += 1
		elif a[i] in b:
			blow += 1
	print(hit, blow)

Submission status: Accepted

Solution code:
import sys

a = []
for line in sys.stdin:
    a.append(line.strip())
ita = iter(a)

for a, b in zip(ita, ita):
    hit = 0
    blow = 0
    a = a.split(' ')
    b = b.split(' ')
    for a_, b_ in zip(a, b):
        if a_ == b_:
            hit += 1
        elif a_ in b:
            blow += 1
    print(hit, blow)

Submission status: Accepted

Solution code:
while True:
    try:
        a = list(map(int, input().split()))
        b = list(map(int, input().split()))
    except:
        break
    hit = 0
    blow = 0
    for i in range(4):
        try:
            if i == a.index(b[i]):
                hit += 1
            else:
                blow += 1
        except:
            pass
    print("{} {}".format(hit, blow))

Submission status: Accepted

Solution code:
import sys
count = 0
for line in sys.stdin:
    if count % 2 == 0:
        a = list(map(int, line.split()))
    else:
        b = list(map(int, line.split()))
        hit, brow = 0, 0
        for i in range(4):
            if a[i] == b[i]:
                hit += 1
            elif a[i] in b:
                brow += 1
        print(hit, brow)
    count += 1

Submission status: Accepted

Solution code:
import sys
res=[]

for (l,text) in enumerate(sys.stdin):
    if not l%2:
        a=list(map(int,text.split()))
    else:
        h=0
        b=0
        for (i,j) in enumerate(map(int,text.split())):
            if a[i]==j:
                h=h+1
            elif j in a:
                b=b+1
        res.extend([[h,b]])
[print(i[0],i[1]) for i in res]

Submission status: Accepted

Solution code:
while True:
  try:
    alst = input().split()
    blst = input().split()

    hit = brow = 0

    for i in range(4):
      for j in range(4):
        if alst[i] == blst[j]:
          if i == j:
            hit += 1
          else:
            brow += 1

    print(hit, brow)

  except EOFError:
    break

Submission status: Accepted

Solution code:
# AOJ 0025 Hit and Blow
# Python3 2018.6.16 bal4u

while True:
	try:
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
	except: break
	
	hit = blow = 0
	for i in range(4):
		if a[i] == b[i]:
			hit += 1
			b[i] = -1
	for i in range(4):
		if b[i] >= 0:
			if b[i] in a: blow += 1
	print(hit, blow)

Submission status: Accepted

Solution code:
ans = []
while True:
    try:
        a = map(int,raw_input().split())
    except EOFError:
        break
    b = map(int,raw_input().split())

    n = 0
    m = 0

    for i in range(4):
        if a[i] == b[i]:
            n += 1

    for i in range(0,4):
        for j in range(0,4):
            if a[i] == b[j]:
                m += 1
    m -= n

    ans.append(str(n)+' '+str(m))

for i in ans:
    print i

Submission status: Accepted

Solution code:
while True:
  try:
    hit=0
    brow=0
    a = map(int,raw_input().split())
    a1,b1,c1,d1 = a[0],a[1],a[2],a[3]
    b = map(int,raw_input().split())
    a2,b2,c2,d2 = b[0],b[1],b[2],b[3]
    for c in range(4):
      if a[c] == b[c]: hit +=1
      for d in range(4):
        if a[c]==b[d]:
          if c == d:
            break
          brow += 1

    print hit,brow
  except EOFError:
    break

Submission status: Accepted

Solution code:
while True:
  try:
    hit=0
    blow =0
    a,b = raw_input(),raw_input()
    for x in range(0,7,2):
      for y in range(0,7,2):
        if a[x] == b[y]:
          if x == y: hit+=1
          else: blow +=1
    print hit,blow
  except EOFError:
      break

Submission status: Accepted

Solution code:
import sys

def calc(listA, listB):
    hit = 0
    for i, j in zip(listA, listB):
        if i == j:
            hit += 1
    brow = len(set(listA) & set(listB))
    return (hit, brow-hit)

listA = list()
listB = list()

for i, line in enumerate(sys.stdin.readlines()):
    line = line.strip()
    if i % 2 == 0:
        listA = map(int, line.split())
    else:
        listB = map(int, line.split())
        print "{0:d} {1:d}".format(*calc(listA, listB))

Submission status: Accepted

Solution code:
import sys
line=sys.stdin.readlines()
for A,B in zip(line[0::2],line[1::2]):
    a=map(int,A.strip().split())
    b=map(int,B.strip().split())
    hit,blow=0,0
    for i in xrange(4):
        if a[i]==b[i]:hit+=1
        elif a[i] in b : blow+=1
    print hit,blow

Submission status: Accepted

Solution code:

while True:
    try:
        listA = map(str,raw_input().split(' '))
        listB = map(str,raw_input().split(' '))

        hit=0
        blw=0
        for tB in listB:
            if (tB in listA) and (listB.index(tB) == listA.index(tB)):
                hit += 1
            elif (tB in listA) and (listB.index(tB) != listA.index(tB)):
                blw += 1
        print hit,blw

    except EOFError:
        break

Submission status: Accepted

Solution code:
while True:
    try:
        a = raw_input().split()
        b = raw_input().split()
        hit = reduce(lambda x,y:x+y,map(lambda x,y:x==y,a,b))
        blow = reduce(lambda x,y:x+y,map(lambda x:x in b,a)) - hit
        print hit, blow
    except EOFError:
        break

Submission status: Accepted

Solution code:
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

while True:
    a = stdin.readline().strip()
    if not a:
        break
    b = stdin.readline().strip()
    if a == b:
        print('4 0')
        continue
    hit = sum(int(a[i] == b[i]) for i in xrange(0, 7, 2))
    blow = sum(int(b[i] in a) for i in xrange(0, 7, 2)) - hit
    print(hit, blow)

Submission status: Accepted

Solution code:
while True:
    try:
        a=map(int,raw_input().split())
        b=map(int,raw_input().split())
        c1=0
        c2=0
        for i,e in enumerate(b):
            if e in a:
                if e==a[i]: c1+=1
                else: c2+=1
        print c1, c2
    except:
        break

Submission status: Accepted

Solution code:
while True:
    try:
        a = map(int, raw_input().split())
        b = map(int, raw_input().split())
        hit,blow = 0,0
        for i in range(4):
            if a[i] == b[i]:
                hit += 1
            else:
                for j in range(4):
                    if a[i] == b[j]:
                        blow += 1
        print hit, blow
    except EOFError:
        break

Submission status: Accepted

Solution code:
import sys

while True:
    try:
        a = map(int, raw_input().strip().split())
        b = map(int, raw_input().strip().split())

        hit = 0
        blow = 0

        for i in xrange(len(b)):
            if b[i] in a:
                blow += 1
            if b[i] == a[i]:
                hit += 1

        blow -= hit

        print "%d %d" % (hit, blow)

    except EOFError:
        break

Submission status: Accepted

Solution code:
while 1:
	try:
		a = map(int,raw_input().split())
		b = map(int,raw_input().split())
		c,d = 0,0
		for i in enumerate(b):
			if i[1] in a:
				if a[i[0]] == i[1]:
					c += 1
				else:
					d += 1
		print c,d
	except:
		exit()

Submission status: Accepted

Solution code:
while True:
    try:
        a = map(int, raw_input().split())
        b = map(int, raw_input().split())
        hit = 0; brow = 0
        for i in range(len(b)) :
            brow += a.count(b[i])
            if a[i] == b[i] :
                hit += 1
                brow -= 1
        print hit, brow

    except:
        break

Submission status: Accepted

Solution code:
import sys
f=0
for s in sys.stdin:
    f=1-f
    b=map(int,s.split())
    if f:
        a=b
        continue
    c1=0
    c2=0
    for i,e in enumerate(b):
        if e==a[i]: c1+=1
        elif e in a: c2+=1
    print c1, c2

Submission status: Accepted

Solution code:
import sys
f=1
for s in sys.stdin:
    b=map(int,s.split())
    if f:
        a=b
        f=0
        continue
    c1=0
    c2=0
    for i,e in enumerate(b):
        if e==a[i]: c1+=1
        elif e in a: c2+=1
    print c1, c2
    f=1

Submission status: Accepted

Solution code:
while True:
	try:
		a = map(int, raw_input().split())
		b = map(int, raw_input().split())
		hit = 0
		blow = 0
		for na, nb in zip(a, b):
			if na == nb: hit += 1
			if nb in a: blow += 1
		blow = blow - hit
		print "{} {}".format(hit, blow)
	except EOFError:
		break

Submission status: Accepted

Solution code:
while 1:
    try:
        A = map(int, raw_input().split())
        B = map(int, raw_input().split())
        hit = sum(1 for i in range(4) if A[i] == B[i])
        blow = len(set(A) & set(B)) - hit
        print hit, blow
    except:
        break

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding:utf-8 -*-
#from __future__ import print_function
import time
import sys
import io
import re
import math
start = time.clock()
while 1:
    try:
        a=map(int, raw_input().split())
        b=map(int, raw_input().split())
        j=k=0
        for i in range(4):
            if b[i]==a[i]:
                j+=1
            elif b[i] in a:
                k+=1
        print j,k
    except:
        break

Submission status: Accepted

Solution code:
try:
    while True:
        a = map(int, raw_input().split())
        b = map(int, raw_input().split())
        p = q = 0
        for i in range(len(b)):
            if a[i] == b[i]:
                p += 1
            elif a.count(b[i]) != 0:
                q += 1
        print p, q
except:
    pass

Submission status: Accepted

Solution code:
import sys

lists=[]
for str in sys.stdin:
	lists+=[tuple(str.rstrip().split(' '))]

for i in range(0,len(lists),2):
	hit=0
	blow=0
	for j in range(4):
		if lists[i][j]==lists[i+1][j]:
			hit+=1
	for c in lists[i]:
		if c in lists[i+1]:
			blow+=1
	print '%d %d' % (hit,blow-hit)

Submission status: Accepted

Solution code:
import sys

lists = []
for str in sys.stdin:
  lists+=[tuple(str.rstrip().split(' '))]

for i in range(0, len(lists), 2):
  hit = brow = 0
  for j in range(4):
    if lists[i][j] == lists[i+1][j]:
      hit += 1
  for c in lists[i]:
    if c in lists[i+1]:
      brow += 1
  print "%d %d"%(hit, brow-hit)

Submission status: Accepted

Solution code:
import sys

state = True
for s in sys.stdin:
    if state:
        state = not state
        a = list(map(int, s.split()))
    else:
        state = not state
        b = list(map(int, s.split()))
        hit = sum(a[i] == b[i] for i in range(4))
        blow = sum(b[i] in a for i in range(4)) - hit
        print(hit, blow)

Submission status: Accepted

Solution code:
while True:
    try:
        data1 = list(map(int, input().split()))
        #print(data1)
        data2 = list(map(int,input().split()))
        #print(data2)
    except:
        break
    
    h = 0
    b = 0
    for i in range(4):
        try:
            if i == data1.index(data2[i]):
                h = h + 1
            else:
                b = b + 1
        except:
            pass
    print('{} {}'. format(h, b))