Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
while True:
    m,n = map(int,raw_input().split())
    a = list(str(m + n))
    print len(a)

Fixed submission:
import sys
for i in sys.stdin: print len(list(str(sum(map(int,i.split())))))

Buggy python submission (verdict: Runtime Error):
while True:
try:
	m,n = map(int,raw_input().split())
	a = list(str(m + n))
	print len(a)
except EOFError: 
	break

Fixed submission:
import sys
for i in sys.stdin: print len(list(str(sum(map(int,i.split())))))

Buggy python submission (verdict: Runtime Error):
while True:
   try:
        m,n = map(int,raw_input().split())
        a = list(str(m + n))
        print len(a)
    except: 
        break

Fixed submission:
import sys
for i in sys.stdin: print len(list(str(sum(map(int,i.split())))))

Buggy python submission (verdict: Runtime Error):
import sys
for i in sys.stdin:
    print len(list(str(sum(map(int,raw_input().split())))))
	

Fixed submission:
import sys
for i in sys.stdin: print len(list(str(sum(map(int,i.split())))))

Buggy python submission (verdict: Runtime Error):
import sys
for i in sys.stdin: print len(list(str(sum(map(int,raw_input().split())))))
	

Fixed submission:
import sys
for i in sys.stdin: print len(list(str(sum(map(int,i.split())))))
Buggy python submission (verdict: Time Limit Exceeded):
def fib(n):
  if n ==1 or n == 0:
    return 1
  else:
    return fib(n-1) + fib(n-2)
  
print(fib(int(input())))

Fixed submission:
n = int(input())

fib = [1]*(n+1)

for i in range(2,n+1):
    fib[i] = fib[i-1]+fib[i-2]
    
print(fib[n])
Buggy python submission (verdict: Time Limit Exceeded):
T = list(input())
P = list(input())
for i in range(len(T)):
    try:
        if P[0] == T[i]:
            for j in range(len(P)):
                if P[j] == T[i + j]:
                    pass
                else: break
            else: print(i)
    except:pass

Fixed submission:
T = input()
P = input()
lenp = len(P)
for i in range(len(T)-len(P)+1):
    t = T[i : i+lenp]
    if t == P:
        print(i)

Buggy python submission (verdict: Time Limit Exceeded):
T = list(input())
P = list(input())
for i in range(len(T)-len(P)+1):
        if P[0] == T[i]:
            for j in range(len(P)):
                if P[j] == T[i + j]:
                    pass
                else: break
            else: print(i)

Fixed submission:
T = input()
P = input()
lenp = len(P)
for i in range(len(T)-len(P)+1):
    t = T[i : i+lenp]
    if t == P:
        print(i)

Buggy python submission (verdict: Time Limit Exceeded):
T = list(input())
P = input()
for i in range(len(T)-len(P)+1):
    t = "".join(T[i : i+len(P)])
    if t == P:
        print(i)

Fixed submission:
T = input()
P = input()
lenp = len(P)
for i in range(len(T)-len(P)+1):
    t = T[i : i+lenp]
    if t == P:
        print(i)
Buggy python submission (verdict: Runtime Error):
N = input()
n = list(map(int,input().split()))
for i in range(1,int(N)):
    v = n[i]
    j = i - 1
    while j >= 0 and v < n[j]:
        n[j+1] = n[j]
        j = j - 1
    n[j+1] = v
    print(n)

Fixed submission:
def insertsort(array):
    for i in range(1,len(array)):
        print(" ".join(list(map(str,array))))
        temp = array[i]
        j = i-1
        while j >= 0 and temp < array[j]:
            array[j+1] = array[j]
            j -= 1
        array[j+1] = temp
    return array

input()
a = insertsort(list(map(int,input().split())))
print(" ".join(list(map(str,a))))

Buggy python submission (verdict: Runtime Error):
N = input()
n = list(map(int,raw_input().split()))

for i in range(1,int(N)):
    v = n[i]
    j = i - 1
    while j >= 0 and v < n[j]:
        n[j+1] = n[j]
        j = j - 1
    n[j+1] = v
    print(n.replace("[","").replace(",","").replace("]","")))

Fixed submission:
def insertsort(array):
    for i in range(1,len(array)):
        print(" ".join(list(map(str,array))))
        temp = array[i]
        j = i-1
        while j >= 0 and temp < array[j]:
            array[j+1] = array[j]
            j -= 1
        array[j+1] = temp
    return array

input()
a = insertsort(list(map(int,input().split())))
print(" ".join(list(map(str,a))))

Buggy python submission (verdict: Runtime Error):
N = input()
n = list(map(int,raw_input().split()))

for i in range(1,int(N)):
    v = n[i]
    j = i - 1
    while j >= 0 and v < n[j]:
        n[j+1] = n[j]
        j = j - 1
    n[j+1] = v
    print(n.replace("[","").replace(",","").replace("]",""))

Fixed submission:
def insertsort(array):
    for i in range(1,len(array)):
        print(" ".join(list(map(str,array))))
        temp = array[i]
        j = i-1
        while j >= 0 and temp < array[j]:
            array[j+1] = array[j]
            j -= 1
        array[j+1] = temp
    return array

input()
a = insertsort(list(map(int,input().split())))
print(" ".join(list(map(str,a))))
Buggy python submission (verdict: Runtime Error):
x,y = map(int,raw_input().split())
cd = 1

while True:
    a = x
    for i in range(2,int(min(x,y)) + 1):
        if x%i == 0:
            if y%i == 0:
                x /= i
                y /= i
                cd *= i
                break
    if a == x:
        break
print(cd)
		

Fixed submission:
def lcd(a,b): ##return least common multiple of a and b
    if a > b:
        return lcd(a-b,b)
    elif a < b:
        return lcd(b-a,a)
    elif a == b:
        return a

a,b = map(int,input().split())
print(lcd(a,b))

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

x,y = map(int,input().split())
b = int(min(x,y))
a = int(max(x,y))

def gcd(a,b):
    if a % b != 0:
        r = a % b
        return gcd(b,r)
    else:
        print(b)

gcd(a,b)
		

Fixed submission:
def lcd(a,b): ##return least common multiple of a and b
    if a > b:
        return lcd(a-b,b)
    elif a < b:
        return lcd(b-a,a)
    elif a == b:
        return a

a,b = map(int,input().split())
print(lcd(a,b))

Buggy python submission (verdict: Time Limit Exceeded):
a,b = map(int,input().split())
gcd = 1
for i in range(2,min(a,b)+1):
    if a%i == 0 and b%i == 0:
        gcd = i
print(gcd)
    

Fixed submission:
def lcd(a,b): ##return least common multiple of a and b
    if a > b:
        return lcd(a-b,b)
    elif a < b:
        return lcd(b-a,a)
    elif a == b:
        return a

a,b = map(int,input().split())
print(lcd(a,b))

Buggy python submission (verdict: Time Limit Exceeded):
a,b = map(int,input().split())
gcd = 1

while True:
    for i in range(2,min(a,b)+1):
        if a%i == 0 and b%i ==0:
            gcd *= i
            a = int(a/i)
            b = int(b/i)
            break
    else: break
print(gcd)
    
    

Fixed submission:
def lcd(a,b): ##return least common multiple of a and b
    if a > b:
        return lcd(a-b,b)
    elif a < b:
        return lcd(b-a,a)
    elif a == b:
        return a

a,b = map(int,input().split())
print(lcd(a,b))

Buggy python submission (verdict: Time Limit Exceeded):
a,b = map(int,input().split())
gcd = 1

i = 2
while True:
    c = i
    for i in range(c,min(a,b)+1):
        if a%i == 0 and b%i ==0:
            gcd *= i
            a = int(a/i)
            b = int(b/i)
            break
    else: break
print(gcd)
    

Fixed submission:
def lcd(a,b): ##return least common multiple of a and b
    if a > b:
        return lcd(a-b,b)
    elif a < b:
        return lcd(b-a,a)
    elif a == b:
        return a

a,b = map(int,input().split())
print(lcd(a,b))

Buggy python submission (verdict: Runtime Error):
def lcd(a,b): ##return least common multiple of a and b
    if a > b:
        return lcd(a-b,b)
    elif a < b:
        return lcd(b-a,a)
    elif a == b:
        return a

a,b = input().split()
print(lcd(a,b))

Fixed submission:
def lcd(a,b): ##return least common multiple of a and b
    if a > b:
        return lcd(a-b,b)
    elif a < b:
        return lcd(b-a,a)
    elif a == b:
        return a

a,b = map(int,input().split())
print(lcd(a,b))
Buggy python submission (verdict: Runtime Error):
import math
n = input()
c = 0


for i in range(int(n)):
    x = int(input())
    if x == 1:
        x = 0
    for j in range(2,math.floor(math.sqrt(float(x)))+ 1):
        if x % j == 0:
            x = 0
            break
        if x != 0:
            c += 1	
print(c)

Fixed submission:
import math
n = int(input())
count = 0
for i in range(n):
    a = int(input())
    for j in range(2,int(math.sqrt(a) + 1)):
        if a % j == 0:
            break
    else:
        count += 1  
print(count)

Buggy python submission (verdict: Runtime Error):
import math
n = input()
c = 0

for i in range(n):
    x = input()
    if x == 1:
        x = 0
    for j in range(2,math.floor(math.sqrt(x))+ 1):
        if x % j == 0:
            x = 0
            break
        if x != 0:
            c += 1	
print(c)

Fixed submission:
import math
n = int(input())
count = 0
for i in range(n):
    a = int(input())
    for j in range(2,int(math.sqrt(a) + 1)):
        if a % j == 0:
            break
    else:
        count += 1  
print(count)

Buggy python submission (verdict: Runtime Error):
import math
n = input()
c = 0

for i in range(n):
    x = input()
    if x == 1:
        x = 0
    for j in range(2,math.floor(math.sqrt(x))+ 1):
        if x % j == 0:
            x = 0
            break
    if x != 0:
        c += 1	
print(c)

Fixed submission:
import math
n = int(input())
count = 0
for i in range(n):
    a = int(input())
    for j in range(2,int(math.sqrt(a) + 1)):
        if a % j == 0:
            break
    else:
        count += 1  
print(count)

Buggy python submission (verdict: Runtime Error):
import math
n = input()
c = 0

for i in range(n):
    x = input()
    if x == 1:
        x = 0
    for j in range(2,math.floor(math.sqrt(float(x)))+ 1):
        if x % j == 0:
            x = 0
            break
    if x != 0:
        c += 1	
print(c)

Fixed submission:
import math
n = int(input())
count = 0
for i in range(n):
    a = int(input())
    for j in range(2,int(math.sqrt(a) + 1)):
        if a % j == 0:
            break
    else:
        count += 1  
print(count)
Buggy python submission (verdict: Runtime Error):
n = input()
m = []
for i in range(n):
    m.append(input())

interest = [m[1]-m[0]]
for i in range(n):
    for j in range(i+1,n):
        if interest[-1] < m[j]-m[i]
        interest.append(m[j]-m[i])
print(interest[-1])
 

Fixed submission:
n = int(input())
a = [0 for i in range(n)]
for i in range(n):
    a[i] = int(input())
minimum = a[0]
profit = a[1]-a[0]

for i in range(1,n):
    if profit < a[i]- minimum:
        profit = a[i] - minimum
    if minimum > a[i]:
        minimum = a[i]
        
print(profit)

Buggy python submission (verdict: Runtime Error):
n = input()
m = []
for i in range(n):
    m.append(input())

interest = [m[1]-m[0]]
for i in range(n):
    for j in range(i+1,n):
        if interest[-1] < m[j]-m[i]:
        interest.append(m[j]-m[i])
print(interest[-1])
 

Fixed submission:
n = int(input())
a = [0 for i in range(n)]
for i in range(n):
    a[i] = int(input())
minimum = a[0]
profit = a[1]-a[0]

for i in range(1,n):
    if profit < a[i]- minimum:
        profit = a[i] - minimum
    if minimum > a[i]:
        minimum = a[i]
        
print(profit)

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
m = []
for i in range(n):
    m.append(input())

interest = [m[1]-m[0]]
for i in range(n):
    for j in range(i+1,n):
        if interest[-1] < m[j]-m[i]:
            interest.append(m[j]-m[i])
print(interest[-1])
 

Fixed submission:
n = int(input())
a = [0 for i in range(n)]
for i in range(n):
    a[i] = int(input())
minimum = a[0]
profit = a[1]-a[0]

for i in range(1,n):
    if profit < a[i]- minimum:
        profit = a[i] - minimum
    if minimum > a[i]:
        minimum = a[i]
        
print(profit)

Buggy python submission (verdict: Runtime Error):
n = input()
m = []
for i in range(n):
    m.append(input())

interest = [m[1]-m[0]]
for i in range(n):
    M = max(m[i+1:])
    if interest[-1] <M-m[i]:
        interest.append(M-m[i])
print(interest[-1])
 

Fixed submission:
n = int(input())
a = [0 for i in range(n)]
for i in range(n):
    a[i] = int(input())
minimum = a[0]
profit = a[1]-a[0]

for i in range(1,n):
    if profit < a[i]- minimum:
        profit = a[i] - minimum
    if minimum > a[i]:
        minimum = a[i]
        
print(profit)

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
m = []
for i in range(n):
    m.append(input())

interest = [m[1]-m[0]]
for i in range(n-1):
    M = max(m[i+1:])
    if interest[-1] <M-m[i]:
        interest.append(M-m[i])
print(interest[-1])
 

Fixed submission:
n = int(input())
a = [0 for i in range(n)]
for i in range(n):
    a[i] = int(input())
minimum = a[0]
profit = a[1]-a[0]

for i in range(1,n):
    if profit < a[i]- minimum:
        profit = a[i] - minimum
    if minimum > a[i]:
        minimum = a[i]
        
print(profit)
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
f = 1 
c = 0
while f == 1:
    f = 0
    for j in range(n-1,0,-1):
	if A[j] < A[j-1]:
            inc = A[j]
	    A[j] = A[j-1] 
	    A[j-1] = inc
	    f = 1
	    c += 1
print(" ".join(map(str,A)))
print(c)

Fixed submission:
def bubblesort(a):
    count = 0
    swap = True
    while swap:
        swap = False
        for j in range(1,len(a))[::-1]:
            if a[j] < a[j-1]:
                ret = a[j]
                a[j] = a[j-1]
                a[j-1] = ret
                count += 1
                swap = True           
    print(" ".join(map(str,a)))
    print(count)
    
n = int(input())
a = list(map(int,input().split()))
bubblesort(a)

Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
f = 1 
c = 0
while f == 1:
    f = 0
    for j in range(n-1,0,-1):
        if A[j] < A[j-1]:
        inc = A[j]
        A[j] = A[j-1] 
        A[j-1] = inc
        f = 1
        c += 1
print(" ".join(map(str,A)))
print(c)

Fixed submission:
def bubblesort(a):
    count = 0
    swap = True
    while swap:
        swap = False
        for j in range(1,len(a))[::-1]:
            if a[j] < a[j-1]:
                ret = a[j]
                a[j] = a[j-1]
                a[j-1] = ret
                count += 1
                swap = True           
    print(" ".join(map(str,a)))
    print(count)
    
n = int(input())
a = list(map(int,input().split()))
bubblesort(a)
Buggy python submission (verdict: Runtime Error):
from collections import deque
n = int(input())

Q = deque()
for i in range(n):
    command = input().split()
    if command[0] == "insert":
        Q.appendleft(command[1])
    elif command[0] == "deleteFirst":
        Q.popleft()
    elif command[0] == "deleteLast":
        Q.popright()
    elif command[0] == "delete":
        try:
            Q.remove(command[1])
        except:
            pass
print(" ".join(Q))

Fixed submission:
import sys
from collections import deque
n = int(sys.stdin.readline())
lines = sys.stdin.readlines()

Q = deque()
for i in range(n):
    command = lines[i].split()
    if command[0] == "insert":
        Q.appendleft(command[1])
    elif command[0] == "deleteFirst":
        Q.popleft()
    elif command[0] == "deleteLast":
        Q.pop()
    elif command[0] == "delete":
        try:
            Q.remove(command[1])
        except:
            pass
print(" ".join(Q))
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
S = list(map(int,input().split()))
n = input()
T = list(map(int,input().split()))
count =  0
for i in T:
    if i in S:
        count+= 1
print(count)

Fixed submission:
input()
S = list(map(int,input().split()))
input()
T = list(map(int,input().split()))

def binarySearch(k,a):
    left = 0
    right = len(a)
    while left < right:
        middle = (left + right) // 2
        if a[middle] == k:
            return 1
        elif a[middle] < k:
            left = middle+1
        elif a[middle] > k:
            right = middle 
    return 0


count = 0
for t in T:
    count += binarySearch(t,S)
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
S = list(map(int,input().split()))
n = input()
T = list(map(int,input().split()))
count =  0

def binarySearch(a,b):
    if a == b[-1]:
        return 1
    elif len(b) == 1:
        return 0
    elif a < b[int(len(b)/2)]:
        return binarySearch(a,  b[:int(len(b)/2)])
    elif a >= b[int(len(b)/2)]:
        return binarySearch(a,  b[int(len(b)/2):])

for i in T:
    count += binarySearch(i,S)
print(count)

Fixed submission:
input()
S = list(map(int,input().split()))
input()
T = list(map(int,input().split()))

def binarySearch(k,a):
    left = 0
    right = len(a)
    while left < right:
        middle = (left + right) // 2
        if a[middle] == k:
            return 1
        elif a[middle] < k:
            left = middle+1
        elif a[middle] > k:
            right = middle 
    return 0


count = 0
for t in T:
    count += binarySearch(t,S)
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(map(int,input().split()))
n = int(input())
t = list(map(int,input().split()))
count = 0

def binarySearch(a,b):
    left = 0
    right = len(b)
    while left < right:
        middle = (left + right)//2
        
        if b[middle] == a:
            return 1
        elif b[middle] < a:
            left = middle -1
        elif b[middle] > a:
            right = middle 
    return 0

            
for a in t:
    count += binarySearch(a, s)

print(count)

Fixed submission:
input()
S = list(map(int,input().split()))
input()
T = list(map(int,input().split()))

def binarySearch(k,a):
    left = 0
    right = len(a)
    while left < right:
        middle = (left + right) // 2
        if a[middle] == k:
            return 1
        elif a[middle] < k:
            left = middle+1
        elif a[middle] > k:
            right = middle 
    return 0


count = 0
for t in T:
    count += binarySearch(t,S)
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
diction = []
for i in range(int(input())):
    command = input().split()
    if command[0] == "insert":
        diction.append(command[1])
    else:
        if command[1] in diction:
            print("yes")
        else:
            print("no")

Fixed submission:
import sys
n = int(input())
dictionary = {}

k = sys.stdin.readlines()


for j in k:
    i = j.split()
    if i[0] == "insert":
        dictionary[i[1]] = 0
    else:
        if i[1] in dictionary:
            print("yes")
        else:
            print("no")

Buggy python submission (verdict: Time Limit Exceeded):
import sys
diction = []
n = int(input())
command = sys.stdin.readlines()
for i in range(n):
    a,b = command[i].split()
    if a == "insert":
        diction.append(b)
    else:
        if b in diction:
            print("yes")
        else:
            print("no")

Fixed submission:
import sys
n = int(input())
dictionary = {}

k = sys.stdin.readlines()


for j in k:
    i = j.split()
    if i[0] == "insert":
        dictionary[i[1]] = 0
    else:
        if i[1] in dictionary:
            print("yes")
        else:
            print("no")

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
n = int(input())
command = sys.stdin.readlines()
Q = deque()
for i in range(n):
    a,b = command[i].split()
    if a == "insert":
        Q.append(b)
    else:
        if b in Q:
            print("yes")
        else:
            print("no")

Fixed submission:
import sys
n = int(input())
dictionary = {}

k = sys.stdin.readlines()


for j in k:
    i = j.split()
    if i[0] == "insert":
        dictionary[i[1]] = 0
    else:
        if i[1] in dictionary:
            print("yes")
        else:
            print("no")

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n = int(input())
command = sys.stdin.readlines()
Q = {}
for i in range(n):
    a,b = command[i].split()
    if a == "insert":
        Q[b] = 0
    else:
        if b in set(Q.keys()):
            print("yes")
        else:
            print("no")

Fixed submission:
import sys
n = int(input())
dictionary = {}

k = sys.stdin.readlines()


for j in k:
    i = j.split()
    if i[0] == "insert":
        dictionary[i[1]] = 0
    else:
        if i[1] in dictionary:
            print("yes")
        else:
            print("no")
Buggy python submission (verdict: Runtime Error):
import sys

def binarySearch(t,w,p):
    left = 0
    right = p
    while left < right:
        middle = (left + right) // 2
        if hantei(t,w,middle):
            left = middle + 1
        else:
            right = middle
    return left
            
def hantei(t,w,p):
    track_on = [0]*t
    j = 0
    for i in range(t):
        temp = track_on[i]
        while True:
            temp += w[j]
            if temp > p:
                break
            else:
                if j == len(w):
                    return False
                track_on[i] = temp
                j += 1
    return True


nimotsu, track = map(int,input().split())
weight = list(map(int,sys.stdin.readlines()))


max_p = sum(weight) // track + 1

print(binarySearch(track,weight,max_p))

Fixed submission:
import sys

def binarySearch(t,w):
    left = max(w)
    right = sum(w)
    while left < right:
        middle = (left + right) // 2
        if hantei(t,w,middle):
            right = middle 
        else:
            left = middle + 1
    return left
            
def hantei(t,w,p):
    track_on = 0
    daisu = 1
    for j in range(len(w)):     
        track_on += w[j]
        if track_on > p:
            daisu += 1
            track_on = w[j]
            if daisu > t:
                return False
    return True


nimotsu, track = map(int,input().split())
weight = list(map(int,sys.stdin.readlines()))



print(binarySearch(track,weight))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int,input().split()))
q = int(input())
M = list(map(int,input().split()))

def solve(i,m):
    a = 0
    if a ==m:
        return True
    if i >= n:
        return False
    
    res = solve(i+1,m) or solve(i+1,m-A[i])
    return res 

for k in M:
    print("yes" if solve(0,k) else "no")
        

Fixed submission:
input()
A = list(map(int,input().split()))
input()
M = list(map(int,input().split()))

def makeSum(A,i,T):
    if i == len(A):
        T[sum(A)] = 0
    else:
        makeSum(A,i+1,T)
        ret = A[i]
        A[i] = 0
        makeSum(A,i+1,T)
        A[i] = ret

T = {}
makeSum(A,0,T)
for m in M:
    if m in T:
        print("yes")
    else:
        print("no")

Buggy python submission (verdict: Time Limit Exceeded):
input()
A = list(map(int,input().split()))
input()
M = list(map(int,input().split()))

def solve(i,m):
    a = 0
    if a ==m:
        return True
    if i >= len(A):
        return False
    
    res = solve(i+1,m) or solve(i+1,m-A[i])
    return res 

for k in M:
    print("yes" if solve(0,k) else "no")
        

Fixed submission:
input()
A = list(map(int,input().split()))
input()
M = list(map(int,input().split()))

def makeSum(A,i,T):
    if i == len(A):
        T[sum(A)] = 0
    else:
        makeSum(A,i+1,T)
        ret = A[i]
        A[i] = 0
        makeSum(A,i+1,T)
        A[i] = ret

T = {}
makeSum(A,0,T)
for m in M:
    if m in T:
        print("yes")
    else:
        print("no")