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: Wrong Answer

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

while True:
    try:
        A, B = input().split(), input().split()
        hit = sum([ 1 for i in range(len(A)) if A[i]==B[i] ])
        blow = sum([ 1 for i in range(len(A)) if B[i] in A ])
        print(str(hit) + ' ' +str(blow))
    except:
        break

Submission status: Wrong Answer

Solution code:
import sys
lists=[]
for x in sys.stdin:
    lists.append(tuple(x.split(" ")))

for x in range(0,len(lists),2):
    hit=0
    for e in range(4):
        if lists[x][e]==lists[x+1][e]:
            hit+=1
    blow=0
    for y in lists[x]:
        if y in lists[x+1]:
            blow+=1
    blow = blow-hit
    print hit,blow

Submission status: Wrong Answer

Solution code:
import sys
lists=[]
for st in sys.stdin:
    lists+=[tuple(st.split(' '))]

for x in range(0,len(lists),2):
    hit=0
    for e in range(4):
        if lists[x][e]==lists[x+1][e]:
            hit+=1
    blow=0
    for y in lists[x]:
        if y in lists[x+1]:
            blow+=1
    blow = blow-hit
    print hit,blow

Submission status: Wrong Answer

Solution code:
while True:
    try:
        data1=map(int,raw_input().split(" "))
        data2=map(int,raw_input().split(" "))
        hit=0
        for i in range(4):
            if data1[i]==data2[i]:
                hit+=1
        blow=0
        for i in range(4):
            if data1[i] in data2:
                blow+=1
        print hit,blow-hit
    except:
        break

Submission status: Wrong Answer

Solution code:
while True:
    try:
        L1=map(int,raw_input().split(" "))
        L2=map(int,raw_input().split(" "))
        blow=0
        hit=0
        for i in range(4):
            if L1[i]==L2[i]:
                hit+=1
        for j in L1:
            print j
            if j in L2:
                blow+=1
        blow=blow-hit
        print str(hit)+" "+str(blow)
    except:
        break

Submission status: Wrong Answer

Solution code:
while True:
    try:
        L1=map(int,raw_input().split(" "))
        L2=map(int,raw_input().split(" "))
        blow=0
        hit=0
        for i in range(4):
            if L1[i]==L2[i]:
                hit+=1
        for j in L1:
            if j in L2:
                blow+=1
        blow=blow-hit
        print str(hit)+" "+str(blow)
    except:
        break

Submission status: Wrong Answer

Solution code:
while True:
    try:
        L1=map(int,raw_input().split(" "))
        L2=map(int,raw_input().split(" "))
        blow=0
        hit=0
        for i in range(4):
            if L1[i]==L2[i]:
                hit+=1
            elif L1[i] in L2:
                blow+=1
        print hit,blow
    except:
        break

Submission status: Wrong Answer

Solution code:
while True:
    try:
        L1=map(int,raw_input().split(" "))
        L2=map(int,raw_input().split(" "))
        blow=0
        hit=0
        for i in range(4):
            blow+=L1.count(L2[i])
            if L1[i]==L2[i]:
                blow-=1
                hit+=1
        print hit,blow
    except:
        break

Submission status: Wrong Answer

Solution code:
while True:
    try:
        L1=map(int,raw_input().split(" "))
        L2=map(int,raw_input().split(" "))
        hit,blow=0,0
        for i in range(4):
            blow+=L1.count(L2[i])
            if L1[i]==L2[i]:
                blow-=1
                hit+=1
        print hit,blow

    except:
        break

Submission status: Wrong Answer

Solution code:
import sys

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

    return [hit, blow]

for s in sys.stdin:
    a = list(map(int, s.split()))
    b = list(map(int, input().split()))

    hit, blow = hitBlow(a, b)

    print(hit, blow)

Submission status: Wrong Answer

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

def main():
    while True:
        try:
            A=input().split()
            B=input().split()

            Hit=0
            Blow=0

            for b in B:
                if b in A:
                    index=B.index(b)
                    print(index)
                    if b==A[index]:
                        Hit+=1

                    else:
                        Blow+=1
            print(Hit,Blow)

        except:
            break
            
    
        
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

for line in sys.stdin:
    a = list(map(int, line.split()))
    b = list(map(int, line.split()))
    hit = 0
    blow = 0
    for i in range(4):
        if b[i] == a[i]:
            hit += 1
        elif b[i] in a:
            blow += 1
    print(hit,blow)

Submission status: Wrong Answer

Solution code:
import sys
inputs = []
for line in sys.stdin:
    inputs.append(line)
n = len(inputs)
for _ in range(n // 2):
    for line in sys.stdin:
        a=list(map(int, sys.stdin[_ * 2].split()))
        b=list(map(int, sys.stdin[_ * 2 + 1].split()))
        hit=0
        blow=0
        for i in range(4):
            if b[i] == a[i]:
                hit += 1
            elif b[i] in a:
                blow += 1
        print(hit, blow)

Submission status: Wrong Answer

Solution code:
import sys
inputs = []
for line in sys.stdin:
    inputs.append(line)
n = len(inputs)
for _ in range(n // 2):
    for line in sys.stdin:
        a = list(map(int, inputs[_ * 2].split()))
        b = list(map(int, inputs[_ * 2 + 1].split()))
        hit = 0
        blow = 0
        for i in range(4):
            if b[i] == a[i]:
                hit += 1
            elif b[i] in a:
                blow += 1
        print(hit, blow)

Submission status: Wrong Answer

Solution code:
while 1:
    try:
        hit=0
    	br=0
        a=map(int,raw_input().split())
        b=map(int,raw_input().split())
    	for i in xrange(4):
    		if a[i]==b[i]:
    			hit+=1
    		br+=b.count(a[i])
    	print hit,br
    except:
    	break

Submission status: Wrong Answer

Solution code:
while 1:
    try:
    	hit=0
    	br=0
        a=map(int,raw_input().split())
        b=map(int,raw_input().split())
    	for i in xrange(4):
    		if a[i]==b[i]:
    			hit+=1
    		br+=a[i].count(b)
    	print hit,br
    except:
    	break

Submission status: Wrong Answer

Solution code:
a = input().split()
b = input().split()
s = 0
v = 0
for i in range(len(a)):
    if a[i] == b[i]:
        s += 1
    elif a[i] in b:
        v += 1

print(*(s, v))

Submission status: Wrong Answer

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


def main(a, b):
    hit = 0
    blow = 0

    for a_e, b_e in zip(a, b):
        if a_e == b_e:
            hit += 1
        elif a_e in b:
            blow += 1

    print(hit, blow, sep=' ')


a = [int(e) for e in input().split()]
b = [int(e) for e in input().split()]

main(a, b)

Submission status: Wrong Answer

Solution code:
ansa=input().split()
ansb=input().split()

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)

Submission status: Wrong Answer

Solution code:
while True:

    try:
        ansa=hoge1.split()
        ansb=hoge2.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: Wrong Answer

Solution code:
import sys

even = True
for s in sys.stdin:
    if even:
        even = not even
        a = list(map(int, s.split()))
    else:
        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: Wrong Answer

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 j in a:
            blow+=1
        if i==j:
            hit+=1

Submission status: Wrong Answer

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 j in a:
            blow+=1
        if i==j:
            hit+=1
    print(hit,blow)

Submission status: Wrong Answer

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: Wrong Answer

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
    print(blow_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: Wrong Answer

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 l in range(4):
            if a[l]==b[l]:
                hit+=1
        for g in range(4):
            for p in range(4):
                if a[g]==a[p]:
                    bro+=1
        bro=bro-hit
        bro-=1
        print(hit,bro)
    except:break

Submission status: Wrong Answer

Solution code:
hit = blow = 0
a = [*map(int,input().split(' '))]
b = [*map(int,input().split(' '))]
for i in range(4):
	if a[i] == b[i]:
		hit += 1
	if a[i] == b[i-1]:
		blow += 1
print(hit, blow)

Submission status: Wrong Answer

Solution code:
hit = blow = 0
a = list(map(int,input().split()))
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: Wrong Answer

Solution code:
import sys
a = list(map(int, input().split()))
for b in sys.stdin:
    b = list(map(int, b.split()))
    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: Wrong Answer

Solution code:
import sys
ans = []
for line in sys.stdin:
    aa = list(map(int,input().split()))
    bb = list(map(int,input().split()))
    hit = 0
    blow = 0
    for one in range(len(aa)):
        if aa[one] == bb[one]:
            hit += 1
            
    for one_a in range(len(aa)):
        ai = aa[one_a]
        for one_b in range(len(bb)):
            bi = bb[one_b]
            if ai== bi and one_a != one_b:
                blow += 1
    one_list = [hit,blow]
    ans.append(one_list)

for i in range(len(ans)):
    print(str(ans[i][0]) + ' ' + str(ans[i][1]))

Submission status: Wrong Answer

Solution code:
import sys
ans = []
for line in sys.stdin:
    aa = list(map(int,input().split()))
    bb = list(map(int,input().split()))
    hit = 0
    blow = 0
    for one_a in range(len(aa)):
        if aa[one_a] == bb[one_a]:
            hit += 1
        for one_b in range(len(bb)):
            bi = bb[one_b]
            if aa[one_a]== bb[one_b] and one_a != one_b:
                blow += 1
    one_list = [hit,blow]
    ans.append(one_list)

for i in range(len(ans)):
    print(str(ans[i][0]) + ' ' + str(ans[i][1]))

Submission status: Wrong Answer

Solution code:
import sys
ans = []
for line in sys.stdin:
    aa = list(map(int,input().split()))
    bb = list(map(int,input().split()))
    hit = 0
    blow = 0
    for one_a in range(len(aa)):
        if aa[one_a] == bb[one_a]:
            hit += 1
        if aa[one_a] in bb:
            blow += 1
    blow = blow - hit
    one_list = [hit,blow]
    ans.append(one_list)

for i in range(len(ans)):
    print(str(ans[i][0]) + ' ' + str(ans[i][1]))

Submission status: Wrong Answer

Solution code:
import sys
ans = []
for line in sys.stdin:
    aa = list(map(int,line.split()))
    bb = list(map(int,line.split()))
    hit = 0
    blow = 0
    for one_a in range(len(aa)):
        if aa[one_a] == bb[one_a]:
            hit += 1
        if aa[one_a] in bb:
            blow += 1
    blow = blow - hit
    one_list = [hit,blow]
    ans.append(one_list)

for i in range(len(ans)):
    print(str(ans[i][0]) + ' ' + str(ans[i][1]))

Submission status: Wrong Answer

Solution code:
import sys
ans = []
for line in sys.stdin:
    aa = list(map(int,line.split()))
    bb = list(map(int,line.split()))
    hit = 0
    blow = 0
    for one_a in range(len(aa)):
        if aa[one_a] == bb[one_a]:
            hit += 1
        if aa[one_a] in bb:
            blow += 1
    blow = blow - hit
    one_list = [hit,blow]
    ans.append(one_list)

for i in range(len(ans)):
    print(str(ans[i][0]) + ' ' + str(ans[i][1]))

Submission status: Wrong Answer

Solution code:
import sys
for line in sys.stdin:
    a = list(map(int, line.split()))
    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)

Submission status: Wrong Answer

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


def hit_and_blow(a, b):
    hits = 0
    blows = 0
    for i in xrange(4):
        if b[i] == a[i]:
            hits += 1
        else:
            for j in xrange(4):
                if j == i:
                    continue
                if b[i] == a[j]:
                    blows += 1
    return hits, blows


def main():
    a = [int(x) for x in raw_input().split(" ")]
    b = [int(x) for x in raw_input().split(" ")]
    print "%d %d" % hit_and_blow(a, b)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def hit_and_blow(a, b):
    hits = 0
    blows = 0
    for i in xrange(4):
        if b[i] == a[i]:
            hits += 1
        else:
            for j in xrange(4):
                if j == i:
                    continue
                if b[i] == a[j]:
                    blows += 1
    return hits, blows


def main():
    try:
        a = [int(x) for x in raw_input().split(" ")]
        b = [int(x) for x in raw_input().split(" ")]
    except EOFError:
        return
    print "%d %d" % hit_and_blow(a, b)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

import sys


def hit_and_blow(a, b):
    hits = 0
    blows = 0
    for i in xrange(4):
        if b[i] == a[i]:
            hits += 1
        else:
            for j in xrange(4):
                if j == i:
                    continue
                if b[i] == a[j]:
                    blows += 1
    return hits, blows


def main():
    a, b = sys.stdin.read().split("\n")[:2]
    a = [int(x) for x in a.split(" ")]
    b = [int(x) for x in b.split(" ")]
    print "%d %d" % hit_and_blow(a, b)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
while True:
	try:
		hit = 0 ; blow = 0
		a = map(int,raw_input().split(' ')) ; b = map(int,raw_input().split(' '))
		for x in xrange(0,4):
			if b[x] in a:
				if b[x]==a[x]: hit += 1
				else: blow += 1
			else: pass
		print hit,blow
	except: break

Submission status: Wrong Answer

Solution code:
import sys
import math


def hit_and_blow(a, b):
    sa = set(a)
    sb = set(b)
    return len(sa.intersection(sb))


def hit(a, b):
    return reduce(hit_number, map((lambda x, y: (x, y)), a, b), 0)


def hit_number(acc, x):
    if x[0] == x[1]:
        return acc + 1
    else:
        return acc


#input_file = open(sys.argv[1], "r")

while True:
    try:
        a = map(int, sys.stdin.readline().split(' '))
        b = map(int, sys.stdin.readline().split(' '))
        hb = hit_and_blow(a, b)
        h = hit(a, b)
        b = hb - h
        print h, b
    except ValueError:
        exit()

Submission status: Wrong Answer

Solution code:

import sys
import math


def hit_and_blow(a, b):
    sa = set(a)
    sb = set(b)
    return len(sa.intersection(sb))


def hit(a, b):
    return reduce(hit_number, zip(a, b), 0)


def hit_number(acc, x):
    if x[0] == x[1]:
        return acc + 1
    else:
        return acc


#input_file = open(sys.argv[1], "r")

while True:
    try:
        a = map(int, sys.stdin.readline().split(' '))
        b = map(int, sys.stdin.readline().split(' '))
        hb = hit_and_blow(a, b)
        h = hit(a, b)
        b = hb - h
        print h, b
    except:
        exit()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import time
import sys
start = time.clock()
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+=i
    elif b[i] in a:
        k+=1
print j,k

Submission status: Wrong Answer

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+=i
            elif b[i] in a:
                k+=1
        print j,k
    except:
        break

Submission status: Time Limit Exceeded

Solution code:
def check():
    count1 = 0
    for i in range(4):
        if A[i] == B[i]:
            count1 += 1
    count2 = 0
    for v in B:
        if v in A:
            count2 += 1
    Hit = count1
    Blow = count2 - count1
    
    print Hit, Blow
    
while True:
    try:
        A = list(raw_input().split())
        B = list(raw_input().split())
        check()
    except EOFError:
        pass

Submission status: Accepted

Solution code:
while True:
    try:
        a = map(int, raw_input().split())
        b = map(int, raw_input().split())
        hit = 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:
        a=list(map(int,input().split()))
        b=list(map(int,input().split()))
        hit,blow=0,0
        ac=0
        for i in a:
            bc=0
            ac +=1
            for j in b:
                bc +=1
                if i==j:
                    if ac==bc:
                        hit +=1
                    else:
                        blow +=1
        print(hit,blow)
    except:break

Submission status: Accepted

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

while True:
    try:
        A, B = input().split(), input().split()
        hit = sum([ 1 for i in range(len(A)) if A[i]==B[i] ])
        blow = sum([ 1 for i in range(len(A)) if B[i] in A ]) - hit
        print(str(hit) + ' ' +str(blow))
    except:
        break

Submission status: Accepted

Solution code:

while True:
  try:
    a_list = map(int, raw_input().strip().split(" "));
    b_list = map(int, raw_input().strip().split(" "));
  except:
    break;
  hit, blow = 0, 0
  for a, b in zip(a_list, b_list):
    if (a == b):
      hit += 1;
    elif(a in b_list):
      blow += 1;
  print hit, blow

Submission status: Accepted

Solution code:
while True:
  try:
    a = map(int, raw_input().split())
    b = map(int, raw_input().split())
  except:
    break
  ab = zip(a, b)
  hit = 0
  blow = 0
  for xa, xb in ab:
    if xa == xb:
      hit  += 1
    elif xa in b:
      blow += 1
  print('%d %d' % (hit, blow))

Submission status: Accepted

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

import sys
import math

tf = True
for s in sys.stdin:
  if tf:
    a = map(int,s.split())
    tf = False
    continue
  else:
    b = map(int,s.split())
    tf = True
  print sum([ 1 for i in range(4) if a[i]==b[i] ]),
  print sum([ 1 for i in range(4) for j in range(4) if i != j and a[i] == b[j] ])

Submission status: Accepted

Solution code:
import sys
lines = [list(map(int, line.split())) for line in sys.stdin]
for i in range(0, len(lines), 2):
    a = lines[i]
    b = lines[i + 1]
    hit = sum(1 for i in range(len(a)) if a[i] == b[i])
    blow = sum(1 for bi in b if bi in a) - hit
    print(hit, blow)

Submission status: Accepted

Solution code:

def Hit(an_list,bn_list):
    n = 0
    for a in enumerate(an_list):
        for b in enumerate(bn_list):
            if a == b:
                n +=1
    return n

def Blow(an_list,bn_list):
    n = 0
    for an in an_list:
        for bn in bn_list:
            if an == bn:
                n +=1
    return n

while True:
    try:
        [a1,a2,a3,a4] = map(int,raw_input().split())
        [b1,b2,b3,b4] = map(int,raw_input().split())
    except EOFError:
        break
    
    an_list = [a1,a2,a3,a4]
    bn_list = [b1,b2,b3,b4]
    hit = Hit(an_list,bn_list)
    blow = Blow(an_list,bn_list)
    
    print "%d %d" % (hit,blow-hit)

Submission status: Accepted

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

# Copyright  : @Huki_Hara
# Created    : 2015-03-05

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):
        if a[i] == b[i]: 
            hit += 1
    for i in range(4):
        for j in range(4):
            if i != j and a[i] == b[j]: blow += 1

    print(str(hit) + " " + str(blow))

Submission status: Accepted

Solution code:
while True:
    try:
        L1=map(int,raw_input().split())
        L2=map(int,raw_input().split())
        hit,blow=0,0
        for i in range(4):
            blow+=L1.count(L2[i])
            if L1[i]==L2[i]:
                blow-=1
                hit+=1
        print hit,blow

    except:
        break

Submission status: Accepted

Solution code:
def check():
    count1 = 0
    for i in range(4):
        if A[i] == B[i]:
            count1 += 1
    count2 = 0
    for v in B:
        if v in A:
            count2 += 1
    Hit = count1
    Blow = count2 - count1
    
    print Hit, Blow
    
while True:
    try:
        A = list(raw_input().split())
        B = list(raw_input().split())
        check()
    except EOFError:
        break

Submission status: Accepted

Solution code:
import sys

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

    return [hit, blow]

for s in sys.stdin:
    a = list(map(int, s.split()))
    b = list(map(int, input().split()))

    hit, blow = hitBlow(a, b)

    print(hit, blow)

Submission status: Accepted

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

def main():
    while True:
        try:
            A=input().split()
            B=input().split()

            Hit=0
            Blow=0

            for b in B:
                if b in A:
                    index=B.index(b)
                    if b==A[index]:
                        Hit+=1

                    else:
                        Blow+=1
            print(Hit,Blow)

        except:
            break
            
    
        
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
while True:
	try:
		s1 = raw_input()
		s2 = raw_input()
		a = map(int, s1.split())
		b = map(int, s2.split())
		hashMap = {}
		hit = 0
		blow = 0
		for i in range(len(a)):
			hashMap[a[i]] = i
		for i in range(len(b)):
			if b[i] in hashMap:
				if hashMap[b[i]] == i:
					hit += 1
				else:
					blow += 1
		print '%s %s' % (hit, blow)
	except (EOFError):
		break

Submission status: Accepted

Solution code:
from math import *
PI = 3.1415926535898
while True:
	try:
		a = map(int, raw_input().strip().split(' '))
		b = map(int, raw_input().strip().split(' '))
		hit = 0
		blow = 0
		for i in range(len(a)):
			if a[i] == b[i]:
				hit += 1
			elif b.count(a[i]) > 0:
				blow += 1
		print "%d %d" % (hit, blow)
	except EOFError:
		break

Submission status: Accepted

Solution code:

import sys
def hit_blow(num):
   hits = 0
   blows = 0
   emp1 = [0,0,0,0]
   emp2 = [0,0,0,0]
   num.append(emp1)
   num.append(emp2)
   for i in range(0,4):
       i = i*2
       for j in range(0,4):
           j = j*2
           if num[0][i] == num[1][j] and num[2][int(i/2)] == 0 and num[3][int(j/2)] == 0:
               if i ==j :
                   hits += 1
               else:
                   blows += 1
               num[2][int(i/2)] = 1
               num[3][int(j/2)] = 1
   print(hits,blows)

flag = 0
num = []
for line in sys.stdin.readlines():
   if flag == 0:
       num.append(line)
       flag = 1
   elif flag == 1:
       num.append(line)
       flag = 2
   if flag == 2:
       flag = 0
       hit_blow(num)
       del num[:]

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
		hit=0
		for i in range(len(A)):
			if A[i]==B[i]:
				hit+=1
		#Blow
		blow=0
		for i in range(len(A)):
			for j in range(len(A)):
				if i!=j:
					if A[i]==B[j]:
						blow+=1

		print(hit,blow)



	except EOFError:
		break

Submission status: Accepted

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

Submission status: Accepted

Solution code:

import sys
hit, brow = 0, 0
a, b = [], []
for i in sys.stdin:
    a.append(map(int, i.split()))

for i in xrange(0,len(a),2):
    for j in xrange(4):
        if a[i][j] == a[i + 1][j]:
            hit += 1
        elif a[i + 1][j] in a[i]:
            brow += 1

    print hit, brow
    brow, hit = 0, 0

Submission status: Accepted

Solution code:
import sys
inputs = []
for line in sys.stdin:
    inputs.append(line)

n = len(inputs)
for _ in range(n // 2):
    a = list(map(int, inputs[_ * 2].split()))
    b = list(map(int, inputs[_ * 2 + 1].split()))
    hit = 0
    blow = 0
    for i in range(4):
        if b[i] == a[i]:
            hit += 1
        elif b[i] in a:
            blow += 1
    print(hit, blow)

Submission status: Accepted

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

import sys

lines = sys.stdin.readlines()
for i in range(len(lines)/2):
    line1 = lines[2*i]
    line2 = lines[2*i+1]
    hit = blow = 0
    A = map(int, line1.split())
    B = map(int, line2.split())
    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
                break
    blow -= hit
    print "%d %d" %(hit, blow)

Submission status: Accepted

Solution code:
import sys
Lines = sys.stdin.readlines()

for i in range(0, len(Lines), 2):
    Anumbers = list(map(int, Lines[i].split()))
    Bnumbers = list(map(int, Lines[i+1].split()))
    Hit = 0    
    for j in range(len(Anumbers)):
        Hit += 1 if (Anumbers[j] == Bnumbers[j]) else 0
    Blow = len(set(Anumbers) & set(Bnumbers)) - Hit
    print(Hit, Blow)

Submission status: Accepted

Solution code:
while 1:
    try:
        a=map(int,raw_input().split())
        b=map(int,raw_input().split())
        hi=0
        bl=0
        for i in xrange(4):
            for j in xrange(4):
                if i==j:
                    if a[i]==b[j]:
                        hi+=1
                else:
                    if a[i]==b[j]:
                        bl+=1
        print hi,bl
    except:
        break

Submission status: Accepted

Solution code:
import sys
for line in sys.stdin:
    arrA,arrB = [],[]
    s = line.split()
    for i in s:
        arrA.append(int(i))
    s = input().split()
    for i in s:
        arrB.append(int(i))
    h,b = 0,0
    for i in range(len(arrA)):
        if arrA[i] == arrB[i]:
            h += 1
        elif arrB.count(arrA[i]) > 0:
                b += 1
    print(h,b)

Submission status: Accepted

Solution code:
try:
    while 1:
        a = input().split()
        b = input().split()
        s = 0
        v = 0
        for i in range(len(a)):
            if a[i] == b[i]:
                s += 1
            elif a[i] in b:
                v += 1

        print(*(s, v))
except:
    pass

Submission status: Accepted

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


def main(a, b):
    hit = 0
    blow = 0

    for a_e, b_e in zip(a, b):
        if a_e == b_e:
            hit += 1
        elif a_e in b:
            blow += 1

    print(hit, blow, sep=' ')

while True:
    try:
        a = [int(e) for e in input().split()]
        b = [int(e) for e in input().split()]
    except:
        break

    main(a, b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
while True:

  try:

    a = map(int, raw_input().split())
    b = map(int, raw_input().split())

    hit = 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:
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
        for j in range(4):
            if i != j and a[i] == b[j]:
                blow += 1
    print(hit, blow)