Buggy python submission (verdict: Runtime Error):
import sys
data = []
for line in sys.stdin:
	data.append(line.split())

S = []
T = []
ans = []
S = data[1]
T = data[3]

for t in T:
    l = 0
    r = len(S)

    while l < r :
        i = (l + r) / 2
        if int(S[i]) < int(t) :
            l = i + 1
        elif int(S[i]) > int(t):
            r = i
        else :
            print(int(t))
            break


Fixed submission:
import sys

if __name__ == '__main__':
    data = []
    count = 0
    for line in sys.stdin:
        data.append(line.split())
    s = list(map(int, data[1]))
    n = int(data[0][0])
    q = int(data[2][0])
    t = list(map(int, data[3]))
    for i in range(0, q):
        head = 0
        tail = n - 1
        while True:
            if head > tail :
                break
            center = (head + tail)//2
            if s[center] == t[i] :
                count = count + 1
                break
            elif s[center] < t[i]:
                head = center + 1
            else :
                tail = center - 1
    print(count)

Buggy python submission (verdict: Runtime Error):
import sys
data = []
for line in sys.stdin:
	data.append(line.split())

S = []
T = []
ans = []
S = data[1]
T = data[3]

count = 0
for t in T:
    l = 0
    r = len(S)

    while l < r :
        i = (l + r) / 2
        if int(S[i]) < int(t) :
            l = i + 1
        elif int(S[i]) > int(t) :
            r = i
        else :
            count = count + 1
            break

print(count)


Fixed submission:
import sys

if __name__ == '__main__':
    data = []
    count = 0
    for line in sys.stdin:
        data.append(line.split())
    s = list(map(int, data[1]))
    n = int(data[0][0])
    q = int(data[2][0])
    t = list(map(int, data[3]))
    for i in range(0, q):
        head = 0
        tail = n - 1
        while True:
            if head > tail :
                break
            center = (head + tail)//2
            if s[center] == t[i] :
                count = count + 1
                break
            elif s[center] < t[i]:
                head = center + 1
            else :
                tail = center - 1
    print(count)

Buggy python submission (verdict: Runtime Error):
import sys
data = []
for line in sys.stdin:
	data.append(line.split())

S = []
T = []
ans = []
S = data[1]
T = data[3]

count = 0
for t in T:
    l = 0
    r = len(S)

    while l < r :
        i = (l + r) / 2
        if int(S[i]) < int(t) :
            l = i + 1
        elif int(S[i]) > int(t) :
            r = i
        else :
            count = count + 1
            break

print(count)


Fixed submission:
import sys

if __name__ == '__main__':
    data = []
    count = 0
    for line in sys.stdin:
        data.append(line.split())
    s = list(map(int, data[1]))
    n = int(data[0][0])
    q = int(data[2][0])
    t = list(map(int, data[3]))
    for i in range(0, q):
        head = 0
        tail = n - 1
        while True:
            if head > tail :
                break
            center = (head + tail)//2
            if s[center] == t[i] :
                count = count + 1
                break
            elif s[center] < t[i]:
                head = center + 1
            else :
                tail = center - 1
    print(count)

Buggy python submission (verdict: Runtime Error):
import sys

#二分探索法のアルゴリズム構成
#1.真ん中の要素を選ぶ処理
#2.真ん中のデータと目的のデータを比較する処理
#3.探索の範囲を半分に狭める処理


if __name__ == '__main__':
    data = []
    count = 0
    #外部ファイル読み込み
    for line in sys.stdin:
        data.append(line.split())

    n = int(data[0][0])
    s = list(map(int, data[1]))
    q = int(data[2][0])
    t = list(map(int, data[3]))

    for i in range(0, q - 1):
        head = 0
        tail = n

        while True:
            center = len(s) // 2

            if s[center] == t[i] :
                count = count + 1
                print(t[i])
                break
            elif s[center] < t[i]:
                head = center + 1
            else :
                tail = center - 1

            s = s[head : tail + 1]

            if head >= tail :
                break


Fixed submission:
import sys

if __name__ == '__main__':
    data = []
    count = 0
    for line in sys.stdin:
        data.append(line.split())
    s = list(map(int, data[1]))
    n = int(data[0][0])
    q = int(data[2][0])
    t = list(map(int, data[3]))
    for i in range(0, q):
        head = 0
        tail = n - 1
        while True:
            if head > tail :
                break
            center = (head + tail)//2
            if s[center] == t[i] :
                count = count + 1
                break
            elif s[center] < t[i]:
                head = center + 1
            else :
                tail = center - 1
    print(count)

Buggy python submission (verdict: Runtime Error):
import sys

if __name__ == '__main__':
    data = []
    count = 0
    for line in sys.stdin:
        data.append(line.split())

    n = int(data[0][0])
    s = list(map(int, data[1]))
    q = int(data[2][0])
    t = list(map(int, data[3]))

    for i in range(0, q - 1):
        head = 0
        tail = n

        while True:
            center = len(s) // 2

            if s[center] == t[i] :
                count = count + 1
                print(t[i])
                break
            elif s[center] < t[i]:
                head = center + 1
            else :
                tail = center - 1

            s = s[head : tail + 1]

            if head >= tail :
                break


Fixed submission:
import sys

if __name__ == '__main__':
    data = []
    count = 0
    for line in sys.stdin:
        data.append(line.split())
    s = list(map(int, data[1]))
    n = int(data[0][0])
    q = int(data[2][0])
    t = list(map(int, data[3]))
    for i in range(0, q):
        head = 0
        tail = n - 1
        while True:
            if head > tail :
                break
            center = (head + tail)//2
            if s[center] == t[i] :
                count = count + 1
                break
            elif s[center] < t[i]:
                head = center + 1
            else :
                tail = center - 1
    print(count)

Buggy python submission (verdict: Runtime Error):
import sys

if __name__ == '__main__':
    data = []
    count = 0
    for line in sys.stdin:
        data.append(line.split())

    n = int(data[0][0])
    s = list(map(int, data[1]))
    q = int(data[2][0])
    t = list(map(int, data[3]))

    for i in range(0, q - 1):
        head = 0
        tail = n

        while True:
            center = len(s) // 2

            if s[center] == t[i] :
                count = count + 1
                print(t[i])
                break
            elif s[center] < t[i]:
                head = center + 1
            else :
                tail = center - 1

            s = s[head : tail + 1]

            if head >= tail :
                break


Fixed submission:
import sys

if __name__ == '__main__':
    data = []
    count = 0
    for line in sys.stdin:
        data.append(line.split())
    s = list(map(int, data[1]))
    n = int(data[0][0])
    q = int(data[2][0])
    t = list(map(int, data[3]))
    for i in range(0, q):
        head = 0
        tail = n - 1
        while True:
            if head > tail :
                break
            center = (head + tail)//2
            if s[center] == t[i] :
                count = count + 1
                break
            elif s[center] < t[i]:
                head = center + 1
            else :
                tail = center - 1
    print(count)

Buggy python submission (verdict: Runtime Error):
import sys

if __name__ == '__main__':
    data = []
    count = 0
    for line in sys.stdin:
        data.append(line.split())

    n = int(data[0][0])
    s = list(map(int, data[1]))
    q = int(data[2][0])
    t = list(map(int, data[3]))

    for i in range(0, q - 1):
        head = 0
        tail = n

        while True:
            center = len(s) // 2

            if s[center] == t[i] :
                count = count + 1
                print(t[i])
                break
            elif s[center] < t[i]:
                head = center + 1
            else :
                tail = center - 1

            s = s[head : tail + 1]

            if head >= tail :
                break


Fixed submission:
import sys

if __name__ == '__main__':
    data = []
    count = 0
    for line in sys.stdin:
        data.append(line.split())
    s = list(map(int, data[1]))
    n = int(data[0][0])
    q = int(data[2][0])
    t = list(map(int, data[3]))
    for i in range(0, q):
        head = 0
        tail = n - 1
        while True:
            if head > tail :
                break
            center = (head + tail)//2
            if s[center] == t[i] :
                count = count + 1
                break
            elif s[center] < t[i]:
                head = center + 1
            else :
                tail = center - 1
    print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

if __name__ == '__main__':
    data = []
    count = 0
    for line in sys.stdin:
        data.append(line.split())
    n = int(data[0][0])
    q = int(data[2][0])
    t = list(map(int, data[3]))
    for i in range(0, q):
        head = 0
        tail = n - 1
        s = list(map(int, data[1]))
        while True:
            if head > tail :
                break
            center = (head + tail)//2
            if s[center] == t[i] :
                count = count + 1
                break
            elif s[center] < t[i]:
                head = center + 1
            else :
                tail = center - 1
    print(count)



Fixed submission:
import sys

if __name__ == '__main__':
    data = []
    count = 0
    for line in sys.stdin:
        data.append(line.split())
    s = list(map(int, data[1]))
    n = int(data[0][0])
    q = int(data[2][0])
    t = list(map(int, data[3]))
    for i in range(0, q):
        head = 0
        tail = n - 1
        while True:
            if head > tail :
                break
            center = (head + tail)//2
            if s[center] == t[i] :
                count = count + 1
                break
            elif s[center] < t[i]:
                head = center + 1
            else :
                tail = center - 1
    print(count)