Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#include<iostream>
int main(){
	int a,b;
	while(std::cin>>a>>b){
		std::cout<<a+b<<"\n";
	}
	return 0;
}

Fixed submission:
import sys
for line in sys.stdin:
    if line == None or line == '/n':
        break
    a,b = line.split(" ")
    print( int(a) + int(b) )

Buggy python submission (verdict: Runtime Error):
while (1):
    print(int(input())+int(input()))
##

Fixed submission:
import sys
for line in sys.stdin:
    if line == None or line == '/n':
        break
    a,b = line.split(" ")
    print( int(a) + int(b) )

Buggy python submission (verdict: Runtime Error):
while True:
    pair_num = input("A pair of numbers")
    if pair_num == '':
        break
    a, b = pair_num.split(" ")
    print(int(a) + int(b))


Fixed submission:
import sys
for line in sys.stdin:
    if line == None or line == '/n':
        break
    a,b = line.split(" ")
    print( int(a) + int(b) )

Buggy python submission (verdict: Runtime Error):
def get_input():
    p = input().split()
    return int(p[0]),int(p[1])

while 1:
	a, b = get_input()
	print(a+b)
	if a == "":
		break



Fixed submission:
import sys
for line in sys.stdin:
    if line == None or line == '/n':
        break
    a,b = line.split(" ")
    print( int(a) + int(b) )

Buggy python submission (verdict: Time Limit Exceeded):
x = input()
while x:
    a, b = x.split(" ")
    print(int(a) + int(b))


Fixed submission:
import sys
for line in sys.stdin:
    if line == None or line == '/n':
        break
    a,b = line.split(" ")
    print( int(a) + int(b) )

Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
print(a+b)

# aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa


Fixed submission:
import sys
for line in sys.stdin:
    if line == None or line == '/n':
        break
    a,b = line.split(" ")
    print( int(a) + int(b) )
Buggy python submission (verdict: Runtime Error):
K = '.,!? '
A = 'abc'
D = 'def'
G = 'ghi'
J = 'jkl'
M = 'mno'
P = 'pqrs'
T = 'tuv'
W = 'wxyz'
L = ['', K, A, D, G, J, M, P, T, W]


while 1:
	S = []
	n = input()
	if not '0' in n:
		print('')
	else:
		n = n.split('0')
		for ns in n:
			if ns == '':
				continue
			i = len(ns) % len(L[int(ns[0])])
			S += [[L[int(ns[0])], i-1]]
		for s in S:
			print(s[0][s[1]], end='')
		print('')


Fixed submission:
import sys
K = '.,!? '
A = 'abc'
D = 'def'
G = 'ghi'
J = 'jkl'
M = 'mno'
P = 'pqrs'
T = 'tuv'
W = 'wxyz'
L = ['', K, A, D, G, J, M, P, T, W]
count = int(input())
while count:
	count -= 1
	S = []
	n = input()
	if not '0' in n:
		print('')
		continue
	else:
		n = n.split('0')
		for ns in n:
			if ns == '':
				continue
			i = len(ns) % len(L[int(ns[0])])
			S += [[L[int(ns[0])], i-1]]
		for s in S:
			print(s[0][s[1]], end='')
		print('')
		continue
Buggy python submission (verdict: Runtime Error):
K = int(input())
Is = [input() for i in range(K)]
Ns = [input() for i in range(K)]
atk_I = 0
atk_N = 0
#"mamoru", "tameru", "kougekida"
#"Isono-kun", "Nakajima-kun", "Hikiwake-kun"
for i, n in zip(Is, Ns):
	i_n = [i, n]
	if (i_n.count("mamoru") == 2):
		pass
	elif (i_n.count("mamoru") == 1):
		if (i_n.count("tameru") == 1):
			exec("atk_{} += 1".format(I if i[0] == "t" else N))
			if (atk_I > 5):
				atk_I = 5
			elif (atk_N > 5):
				atk_N = 5
		else:
			if (i[0] == "k"):
				if (atk_I == 5):
					print("Isono-kun")
					exit()
				elif (atk_I == 0):
					print("Nakajima-kun")
					exit()
				else:
					atk_I = 0
			elif (n[0] == "k"):
				if (atk_N == 5):
					print("Nakajima-kun")
					exit()
				elif (atk_N == 0):
					print("Isono-kun")
					exit()
				else:
					atk_N = 0
	else:
		if (i_n.count("kougekida") == 2):
			if (atk_I > atk_N):
				print("Isono-kun")
				exit()
			elif (atk_I == atk_N):
				atk_I = 0
				atk_N = 0
			else:
				print("Nakajima-kun")
				exit()
		elif (i_n.count("kougekida") == 1):
			if (i[0] == "k"):
				if (atk_I == 0):
					print("Nakajima-kun")
					exit()
				else:
					print("Isono-kun")
					exit()
			else:
				if (atk_N == 0):
					print("Isono-kun")
					exit()
				else:
					print("Nakajima-kun")
					exit()
		else:
			atk_I += 1 if atk_I != 5 else 0
			atk_N += 1 if atk_N != 5 else 0
else:
	print("Hikiwake-kun")


Fixed submission:
K = int(input())
Is = [input() for i in range(K)]
Ns = [input() for i in range(K)]
atk_I = 0
atk_N = 0
#"mamoru", "tameru", "kougekida"
#"Isono-kun", "Nakajima-kun", "Hikiwake-kun"
for i, n in zip(Is, Ns):
	i_n = [i, n]
	if (i_n.count("mamoru") == 2):
		pass
	elif (i_n.count("mamoru") == 1):
		if (i_n.count("tameru") == 1):
			exec("atk_{} += 1".format('I' if i[0] == "t" else 'N'))
			if (atk_I > 5):
				atk_I = 5
			elif (atk_N > 5):
				atk_N = 5
		else:
			if (i[0] == "k"):
				if (atk_I == 5):
					print("Isono-kun")
					exit()
				elif (atk_I == 0):
					print("Nakajima-kun")
					exit()
				else:
					atk_I = 0
			elif (n[0] == "k"):
				if (atk_N == 5):
					print("Nakajima-kun")
					exit()
				elif (atk_N == 0):
					print("Isono-kun")
					exit()
				else:
					atk_N = 0
	else:
		if (i_n.count("kougekida") == 2):
			if (atk_I > atk_N):
				print("Isono-kun")
				exit()
			elif (atk_I == atk_N):
				atk_I = 0
				atk_N = 0
			else:
				print("Nakajima-kun")
				exit()
		elif (i_n.count("kougekida") == 1):
			if (i[0] == "k"):
				if (atk_I == 0):
					print("Nakajima-kun")
					exit()
				else:
					print("Isono-kun")
					exit()
			else:
				if (atk_N == 0):
					print("Isono-kun")
					exit()
				else:
					print("Nakajima-kun")
					exit()
		else:
			atk_I += 1 if atk_I != 5 else 0
			atk_N += 1 if atk_N != 5 else 0
else:
	print("Hikiwake-kun")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
Ss = input().replace(" ", '')
part = ""
for n, i in enumerate(Ss):
	if n != 0:
		if i == part[0]:
			Ss_cp = Ss[::1]
			Ss_cp = Ss_cp.replace(part, '')
			if Ss_cp == '':
				print(N//len(part))
				exit()
	part += Ss[n]
else:
	print(1)


Fixed submission:
N = int(input())
Ss = input().split()
res = 1
for t in range(1, N+1):
	if (N%t != 0): continue
	f = False
	for i in range(N-t):
		if (Ss[i] == Ss[i + t]): continue
		f = True
		break
	if (f): continue
	res = N // t
	break

print(res)
Buggy python submission (verdict: Runtime Error):
n=int(input())
A=[int(x) for x in input().split()]

q=int(input())
M=[int(x) for x in input().split()]


def solve(m,AA):
    if len(AA)==0:
        return False
    if m in AA:
        return True
    else:
        for i in range(len(AA)):
            if solve(m-AA[i],AA[:i]+AA[i+1:]):
                return True
                break
        return False
    
    
for m in M:
    if solve(m,A):
        print('yes')
    else:
        print('no')


Fixed submission:
input()
X = [int(x) for x in input().split()]
input()
Y = [int(x) for x in input().split()]

flag = [False]*2000
for j in range(1 << len(X)):
    n = 0
    for i in range(len(X)):
        if 1 & (j >> i) == 1:
            n += X[i]
    flag[n] = True

for m in Y:
    print("yes" if flag[m] else "no")

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)  # set the maximum depth as 10000

n=int(input())
A=[int(x) for x in input().split()]

q=int(input())
M=[int(x) for x in input().split()]


def solve(i,m):
    global n
    global A
    
    if m==0:
        return True
    if i>=n:
        return False
    
    return solve(i+1,m) or solve(i+1,m-A[i])
    
    
for m in M:
    if solve(0,m):
        print('yes')
    else:
        print('no')


Fixed submission:
input()
X = [int(x) for x in input().split()]
input()
Y = [int(x) for x in input().split()]

flag = [False]*2000
for j in range(1 << len(X)):
    n = 0
    for i in range(len(X)):
        if 1 & (j >> i) == 1:
            n += X[i]
    flag[n] = True

for m in Y:
    print("yes" if flag[m] else "no")
Buggy python submission (verdict: Runtime Error):

# -*- coding: utf-8 -*-
# 文字列の入力
import math

n,k = map(int ,input().split())

def comb1(n, r):
    if n == 0 or r == 0: return 1
    return (comb1(n, r-1) * (n-r+1) / r )%1000000007

ans = (comb(k, n))%1000000007
print(ans)


Fixed submission:

# -*- coding: utf-8 -*-
# 文字列の入力
import math

n,k = map(int ,input().split())

def comb(n,k,p):
  """power_funcを用いて(nCk) mod p を求める"""
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p
    
ans = comb(k, n,1000000007)
print(int(ans))
Buggy python submission (verdict: Runtime Error):
N,S = map(int, input().split())
As = list(map(int, input().split()))
i = 0
j = 0
sum = 0
m_l = float('inf')
"""
while True:
	while j < N and sum < S:
		sum += As[j]
		j += 1
	
	if sum < S:
		break
	m_l = min(j-i, m_l)
	sum -= As[i]
	i += 1
	
"""
while j < N:
	sum += As[j]
	j += 1
	if sum < s:
		continue
	while i <= j and sum >= S:
		m_l = min(j-i, m_l)
		sum -= As[i]
		i += 1

print(m_l if m_l != float('inf') else 0)


Fixed submission:
n,s = map(int, input().split())
a = list(map(int, input().split()))
ans = float("inf")
ma = 0
mi = 0
v = 0
for i in range(n):
    v += a[i]
    if v >= s:
        ma = i
        while v >= s:
            v -= a[mi]
            mi += 1
        ans = min(ans, ma-mi+2)
ans = ans if ans != float("inf") else 0
print(ans)
Buggy python submission (verdict: Runtime Error):
a=input()
b=input()
print a*b,2*(a+b)
#jdjdjdjdjdksksowksakslslakslaks

Fixed submission:
a ,b = input().split(" ")

a = int(a)
b = int(b)


area = a*b
perimitar = 2 * (a + b)

print("{} {}".format(area, perimitar))

Buggy python submission (verdict: Runtime Error):
a,b=input().split()
aa=int(a)
bb=int(b)
print aa*bb,2*(aa+bb)

Fixed submission:
a ,b = input().split(" ")

a = int(a)
b = int(b)


area = a*b
perimitar = 2 * (a + b)

print("{} {}".format(area, perimitar))
Buggy python submission (verdict: Runtime Error):
def sum(l):
	s=0
	for i in l:
		s+=i
	return s
r,c=map(int,raw_input().split())
su=[0]*c
for i in range(r):
	l=map(int,raw_input().split())
	for j in l:print j,
	print sum(l)
	for j in range(c):su[j]+=l[j]
for j in su:print j,
	print sum(su)

Fixed submission:
r, c = map(int, input().split())
a = []

for i in range(r):
    a.append(list(map(int, input().split())))
    a[i].append(sum(a[i]))

for i in range(r):
    print(" ".join(list(map(str, a[i]))))

col_sum = []
for j in range(c+1):
    su = 0
    for i in range(r):
        su += a[i][j]
    col_sum.append(su)

print(" ".join(list(map(str, col_sum))))
Buggy python submission (verdict: Time Limit Exceeded):
a=raw_input().lower()
c=0
while 1:
	b=raw_input().lower()
	if b.strip()=='end_of_text':break
	pos=0
	while b.find(a,pos)!=-1:
		pos=b.find(a)+1
		c+=1
print c

Fixed submission:

import sys

w=input()

print(sys.stdin.read().lower().split().count(w))
Buggy python submission (verdict: Time Limit Exceeded):
m,n=map(int,input().split())
print(m**n%1000000007)


Fixed submission:
m,n=[ int(x) for x in input().split()]    
k=1000000007

REM={}

def remainder(i):

    if i in REM.keys():
        return REM[i]

    if i==1:
        re=m%k
        REM[1]=re     
        return re

    if i==2:
        re=(m%k)**2%k
        REM[2]=re        
        return re
    
    left=i//2
    right=i-left
    REM[i]=remainder(left)*remainder(right)%k
    return REM[i]


print(remainder(n))
Buggy python submission (verdict: Runtime Error):
import math
debt = 100000
for i in range(n):
  debt = math.ceil(debt*1.05/1000)*1000
print int(debt)

Fixed submission:
import math
debt = 100000
n = int(raw_input())
for i in range(n):
  debt = math.ceil(debt*1.05/1000)*1000
print int(debt)
Buggy python submission (verdict: Runtime Error):
import sys
for n in sys.stdin: print len([None for a in range(10) for b in range(10) for c in range(10) for d in range(10) if a+b+c+d == N])

Fixed submission:
import sys
for n in sys.stdin: print len([None for a in range(10) for b in range(10) for c in range(10) for d in range(10) if a+b+c+d == int(n)])
Buggy python submission (verdict: Time Limit Exceeded):
LIMIT = 10000000
 
isPrime = [True for _ in range(LIMIT)]

isPrime[0] = isPrime[1] = False
 
for i in range(2, int(LIMIT ** 0.5)+1):
  if isPrime[i]:
    for j in range(i * i, LIMIT, i):
      isPrime[j] = False
 
try:
    while True:
        n = int(input())
        count = 0
        for i in range(n+1):
            if isPrime[i]:
                count += 1
        print(count)
except EOFError:
  pass

Fixed submission:
import sys
ifprime = [1]*(1000000)
ifprime[0] = ifprime[1] = 0
a = 2
while a < 1000000:
  if ifprime[a]:
    b = a*a
    while b < 1000000:
      ifprime[b] = 0
      b += a
  a += 1
for n in sys.stdin:
  print sum(ifprime[:int(n)+1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
for n in sys.stdin:
  num = int(n)
  ifprime = [1]*(num+1)
  ifprime[0] = ifprime[1] = 0
  a = 2
  while a*a <= num:
    if ifprime[a]:
      b = a*a
      while b <= num:
        ifprime[b] = 0
        b += a
    a += 1
  print sum(ifprime)

Fixed submission:
import sys
ifprime = [1]*(1000000)
ifprime[0] = ifprime[1] = 0
a = 2
while a < 1000000:
  if ifprime[a]:
    b = a*a
    while b < 1000000:
      ifprime[b] = 0
      b += a
  a += 1
for n in sys.stdin:
  print sum(ifprime[:int(n)+1])

Buggy python submission (verdict: Runtime Error):
import sys
ifprime = [1]*(1000000)
ifprime[0] = ifprime[1] = 0
a = 2
while a <= num:
  if ifprime[a]:
    ans += 1
    b = a*a
    while b <= num:
      ifprime[b] = 0
      b += a
  a += 1
for n in sys.stdin:
  print sum(ifprime[:int(n)])

Fixed submission:
import sys
ifprime = [1]*(1000000)
ifprime[0] = ifprime[1] = 0
a = 2
while a < 1000000:
  if ifprime[a]:
    b = a*a
    while b < 1000000:
      ifprime[b] = 0
      b += a
  a += 1
for n in sys.stdin:
  print sum(ifprime[:int(n)+1])
Buggy python submission (verdict: Runtime Error):
import sys
for d in sys.stdin:
  print sum([d*x*x for x in range(d,600,d)])

Fixed submission:
import sys
for d in map(int, sys.stdin):
  print sum([d*x*x for x in range(d,600,d)])

Buggy python submission (verdict: Runtime Error):
import sys
for d in int(sys.stdin):
  print sum([d*x*x for x in range(d,600,d)])

Fixed submission:
import sys
for d in map(int, sys.stdin):
  print sum([d*x*x for x in range(d,600,d)])
Buggy python submission (verdict: Runtime Error):
a, b, c, d = sorted(map(int, input().split())
print("YES" if a == b and c == d else "NO")

Fixed submission:
a, b, c, d = sorted(map(int, input().split()))
print("yes" if a == b and c == d else "no")
Buggy python submission (verdict: Runtime Error):
out = []
append = out.append
cnt = int(raw_input())
while cnt > 0:
    trans = {}
    while cnt > 0:
        k,v = raw_input().split(' ')
        trans[k] = v
        cnt -= 1
    cnt = int(raw_input())
    ans = ''
    while cnt > 0:
        load = raw_input()
        if load in trans.keys(): load = trans[load]
        ans += load
        cnt -= 1
    print ans
    cnt = int(raw_iput())

Fixed submission:
out = []
while True:
  n = int(raw_input())
  if n == 0: break
  trans = {}
  for i in range(n):
    k,v = raw_input().split()
    trans[k] = v.rstrip()
  cnt = int(raw_input())
  res = ""
  for j in range(cnt):
    a = raw_input().rstrip()
    if a in trans: a = trans[a]
    res += a
  out.append(res)
for o in out: print o

Buggy python submission (verdict: Runtime Error):
out = []
append = out.append
cnt = int(raw_input())
while cnt > 0:
    trans = {}
    for i in range(cnt):
        k,v = raw_input().split()
        trans[k] = v.rsplit()
    leng = int(raw_input())
    ans = ''
    for i in range(leng):
        load = raw_input().rsplit()
        ans += (load in trans and trans[load]) or load
    print ans
    cnt = int(raw_input())

Fixed submission:
out = []
while True:
  n = int(raw_input())
  if n == 0: break
  trans = {}
  for i in range(n):
    k,v = raw_input().split()
    trans[k] = v.rstrip()
  cnt = int(raw_input())
  res = ""
  for j in range(cnt):
    a = raw_input().rstrip()
    if a in trans: a = trans[a]
    res += a
  out.append(res)
for o in out: print o

Buggy python submission (verdict: Runtime Error):
out = []
while True:
  n = int(raw_input())
  if n == 0: break
  trans = {}
  for i in range(n):
    k,v = raw_input().split()
    trans[k] = v.rstrip()
  cnt = int(raw_input())
  res = ""
  for j in range(n):
    a = raw_input().rstrip()
    if a in trans: a = trans[a]
    res += a
  out.append(a)
for o in out: print o

Fixed submission:
out = []
while True:
  n = int(raw_input())
  if n == 0: break
  trans = {}
  for i in range(n):
    k,v = raw_input().split()
    trans[k] = v.rstrip()
  cnt = int(raw_input())
  res = ""
  for j in range(cnt):
    a = raw_input().rstrip()
    if a in trans: a = trans[a]
    res += a
  out.append(res)
for o in out: print o
Buggy python submission (verdict: Runtime Error):
def fact(a): return a and a*fact(a-1) or 1

n,m,r = map(int,input().split())
r-=n*m
if r < 0:
    print(0)
else:
    print(fact(r+n-1)//fact(n-1)//fact(r))

Fixed submission:
def fact(n):
    res = 1
    for i in range(1, n+1):
        res *= i
    return res
 
def combination(n, k):
    return fact(n)//fact(n-k)//fact(k)
 
n, m, r = list(map(int, input().split()))
 
print(combination(r - n*m + n - 1, n-1))
Buggy python submission (verdict: Runtime Error):
def operate( cmd, text, cur ):
    lentxt = len(text)
    if cmd == "forward char":
        if cur < lentxt: cur += 1
    elif cmd == "backward char":
        if cur > 0: cur -= 1
    elif cmd == "forward word":
        while cur < lentxt and text[cur] == ' ': cur += 1
        while cur < lentxt and text[cur] != ' ': cur += 1
    elif cmd == "backward word":
        while cur > 0 and text[cur - 1] == ' ': cur -= 1
        while cur > 0 and text[cur - 1] != ' ': cur -= 1
    elif cmd == "delete char":
        text = text[:cur] + text[cur + 1:]
    elif cmd == "delete word":
        d = 0
        while cur + d < lentxt and text[cur + d] == ' ': d += 1
        if cur + d == lentxt: break
        while cur + d < lentxt and text[cur + d] != ' ': d += 1
        text = text[:cur] + text[cur + d:]
    else:
        ins = cmd[8:-1]
        text = text[:cur] + ins + text[cur:]
        cur += len(ins)
    return cur, text

if __name__ == "__main__":
    a = int(raw_input())
    for i in range(a):
        text = raw_input()
        cnt = int(raw_input())
        cursor = 0
        for j in range(cnt):
            command = raw_input()
            cursor, text = operate( command, text, cursor )
        print (text[:cursor] + '^' + text[cursor:])

Fixed submission:
def operate( cmd, text, cur ):
    lentxt = len(text)
    if cmd == "forward char":
        if cur < lentxt: cur += 1
    elif cmd == "backward char":
        if cur > 0: cur -= 1
    elif cmd == "forward word":
        while cur < lentxt and text[cur] == ' ': cur += 1
        while cur < lentxt and text[cur] != ' ': cur += 1
    elif cmd == "backward word":
        while cur > 0 and text[cur - 1] == ' ': cur -= 1
        while cur > 0 and text[cur - 1] != ' ': cur -= 1
    elif cmd == "delete char":
        text = text[:cur] + text[cur + 1:]
    elif cmd == "delete word":
        d = 0
        while cur + d < lentxt and text[cur + d] == ' ': d += 1
        if cur + d != lentxt:
            while cur + d < lentxt and text[cur + d] != ' ': d += 1
            text = text[:cur] + text[cur + d:]
    else:
        ins = cmd[8:-1]
        text = text[:cur] + ins + text[cur:]
        cur += len(ins)
    return cur, text

if __name__ == "__main__":
    a = int(raw_input())
    for i in range(a):
        text = raw_input()
        cnt = int(raw_input())
        cursor = 0
        for j in range(cnt):
            command = raw_input()
            cursor, text = operate( command, text, cursor )
        print (text[:cursor] + '^' + text[cursor:])
Buggy python submission (verdict: Runtime Error):
while True:
    n, m, a = map(int, input().split())

    if n + m + a == 0:
        break

    lines = list(reversed(sorted([tuple(map(int, input().split())) for _ in range(m)])))

    replace = list(range(1, n+1))

    for l in lines:
        h, p, q = l

        p -= 1
        q -= 1

        replace[p], replace[q] = replace[q], replace[p]

    a -= 1

    for _ in range(n):
        a = replace[a]

    print(a)

Fixed submission:


while True:
    # num_columns: ????£?????????°
    # num_lines: ?¨??£?????????°(???????????????2????´???????????????°)
    # entry: ????????????????????????????§?????????´????????????
    num_columns, num_lines, entry = map(int, input().split())

    if num_columns == 0 and num_lines == 0 and entry == 0:
        break

    lines = []
    for _ in range(num_lines):
        height, p, q = map(int, input().split())
        lines.append((height, p-1, q-1)) # ????????????0?????????????§????????????§???????????????

    # lines??????????????????????????§???????????????????????????????´?????¨??£???????????????\???????????§
    # ??????????????????????????°??????????????????????????????
    lines.sort()
    lines.reverse()
    # ??????2??????????????§???lines????????????????´??????§?????????????????¶

    result = list(range(1, num_columns+1)) # ??????????§????????????´????????¨????????????

    for line in lines:
        height, p, q = line
        
        # ?????????`replace`???p????????¨q?????????????????????
        result[p], result[q] = result[q], result[p]

    for index, element in enumerate(result):
        if element == entry:
            print(index + 1) # ????????????0?????????????§????????????§???????????????
            break
    # print(result.index(entry) + 1) ??§?????????
Buggy python submission (verdict: Runtime Error):
from sys import stdin

d_num = int(stdin.readline().strip())

graph = [[] for _ in range(d_num+1)]
for _ in range(d_num):
    u, k, *neighbors = map(int, stdin.readline().split())
    for v in neighbors:
        graph[u].append(v)

visited = set()
timestamps = [None for _ in range(d_num+1)]

def dfs(u, stmp):
    visited.add(u)
    entry = stmp

    stmp += 1
    for v in graph[u]:
        if v not in visited:
            stmp = dfs(v, stmp)

    timestamps[u] = entry, stmp
    return stmp+1

dfs(1, 1)

for num, (entry, leave) in enumerate(timestamps[1:], 1):
    print(num, entry, leave)

Fixed submission:
from sys import stdin

d_num = int(stdin.readline().strip())

graph = [[] for _ in range(d_num+1)]
for _ in range(d_num):
    u, k, *neighbors = map(int, stdin.readline().split())
    for v in neighbors:
        graph[u].append(v)

visited = set()
timestamps = [None for _ in range(d_num+1)]

def dfs(u, stmp):
    visited.add(u)
    entry = stmp

    stmp += 1
    for v in graph[u]:
        if v not in visited:
            stmp = dfs(v, stmp)

    timestamps[u] = entry, stmp
    return stmp+1

stmp = 1
for v in range(1, d_num+1):
    if v not in visited: stmp = dfs(v, stmp)

for num, (entry, leave) in enumerate(timestamps[1:], 1):
    print(num, entry, leave)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

def get_prime_list(max_num):
    res = range(2, max_num + 1)
    for i in range(2, max_num/2 + 1):
        res = filter(lambda x: not ((x % i == 0) and (x != i)), res)        
    return res

def is_include(array, num):
    right = len(array) - 1
    left = 0
    while right >= left:
        index = (right + left) / 2
        if array[index] == num:
            return True
        elif array[index] < num:
            left = index + 1
        elif array[index] > num:
            right = index - 1
    return False

if __name__ == "__main__":
    num = int(sys.stdin.readline().strip())
    num_list = [int(sys.stdin.readline().strip()) for i in xrange(0, num)]
    prime_list = sorted(get_prime_list(max(num_list)))
    print len(filter(lambda x: is_include(prime_list, x), num_list))

Fixed submission:
n = int(input())

ans = 0
for x in (int(input()) for _ in range(n)):
    flg = True
    for y in range(2, int(x**0.5+1)):
        if x % y == 0:
            flg = False
            break
    if flg:
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
sec = int(input())
print('{}:{}:{}'.format(sec//3600, (sec//60)%60, sec%60)javascript:void(0)

Fixed submission:
sec = int(input())
print('{}:{}:{}'.format(sec//3600, (sec//60)%60, sec%60))