Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
input_lines = [[int(i) for i in line.split()] for line in sys.stdin.read().splitlines()]
[user_num, rel_num] = input_lines[0]
rel_list = input_lines[1:rel_num+1]
ques_num = input_lines[rel_num+1][0]
ques_list = input_lines[rel_num+2:]
color_list = [-1] * user_num
adja_list = [set() for i in range(user_num)]

def dfs(id, color):
    if color_list[id] == -1:
        color_list[id] = color
        for a_id in adja_list[id]:
            dfs(a_id, color)



for rel in rel_list:
    adja_list[rel[0]].add(rel[1])
    adja_list[rel[1]].add(rel[0])

color = 0
for id in range(user_num):
    dfs(id, color)
    color += 1

for ques in ques_list:
    if color_list[ques[0]] == color_list[ques[1]]:
        print('yes')
    else:
        print('no')



Fixed submission:
import sys
sys.setrecursionlimit(200000)
input_lines = [[int(i) for i in line.split()] for line in sys.stdin.read().splitlines()]
[user_num, rel_num] = input_lines[0]
rel_list = input_lines[1:rel_num+1]
ques_num = input_lines[rel_num+1][0]
ques_list = input_lines[rel_num+2:]
color_list = [-1] * user_num
adja_list = [set() for i in range(user_num)]

def dfs(id, color):
    if color_list[id] == -1:
        color_list[id] = color
        for a_id in adja_list[id]:
            dfs(a_id, color)



for rel in rel_list:
    adja_list[rel[0]].add(rel[1])
    adja_list[rel[1]].add(rel[0])

color = 0
for id in range(user_num):
    dfs(id, color)
    color += 1

for ques in ques_list:
    if color_list[ques[0]] == color_list[ques[1]]:
        print('yes')
    else:
        print('no')
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = [int(i) for i in input().split()]
input()
M = [int(i) for i in input().split()]

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

for m in M:
    if solve(0, m):
        print('yes')
    else:
        print('no')


Fixed submission:
n = int(input())
A = [int(i) for i in input().split()]
input()
M = [int(i) for i in input().split()]

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

for m in M:
    if sum(A) < m:
        print("no")
    elif solve(0, m):
        print('yes')
    else:
        print('no')

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

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

for m in M:
    if solve(0, m):
        print('yes')
    else:
        print('no')


Fixed submission:
n = int(input())
A = [int(i) for i in input().split()]
input()
M = [int(i) for i in input().split()]

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

for m in M:
    if sum(A) < m:
        print("no")
    elif solve(0, m):
        print('yes')
    else:
        print('no')

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

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

for m in M:
    if solve(0, m):
        print('yes')
    else:
        print('no')


Fixed submission:
n = int(input())
A = [int(i) for i in input().split()]
input()
M = [int(i) for i in input().split()]

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

for m in M:
    if sum(A) < m:
        print("no")
    elif solve(0, m):
        print('yes')
    else:
        print('no')
Buggy python submission (verdict: Runtime Error):
package main

import "fmt"

func main(){
	var i int
	fmt.Scan(&i)
	fmt.Println(i*i*i)
}


Fixed submission:
print(int(input()) ** 3)
Buggy python submission (verdict: Runtime Error):
package main

import (
	"fmt"
)

func main(){
	var a, b int
	fmt.Scan(&a, &b)
	fmt.Println(a*b, 2*(a+b))
}


Fixed submission:
a, b = [int(i) for i in input().split()]
print(a*b, 2*(a+b))
Buggy python submission (verdict: Runtime Error):
package main

import (
	"fmt"
)

func main(){
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	if a < b && b < c{
		fmt.Printf("Yes\n")
	}
	else{
		fmt.Printf("No\n")
	}
}


Fixed submission:
(a, b, c) = [int(i) for i in input().split()]
if a < b:
    if b < c:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
package main

import (
	"fmt"
)

func main(){
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	if a < b && b < c{
		fmt.Printf("Yes\n")
	} else {
		fmt.Printf("No\n")
	}
}


Fixed submission:
(a, b, c) = [int(i) for i in input().split()]
if a < b:
    if b < c:
        print('Yes')
    else:
        print('No')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
package main

import (
	"fmt"
)

func main(){
	var w, h, x, y, r int
	fmt.Scan(&w, &h, &x, &y, &r)
	if x + r <= W && x - r >= 0 && y + r <= H && y - r >= 0{
		fmt.Printf("Yes\n")
	} else {
		fmt.Printf("No\n")
	}
>}


Fixed submission:
(W, H, x, y, r) = [int(i) for i in input().split()]
if (x-r) >= 0 and (x+r) <= W and (y-r) >= 0 and (y+r) <= H:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
package main

import (
	"fmt"
)

func main(){
	var w, h, x, y, r int
	fmt.Scan(&w, &h, &x, &y, &r)
	if (x + r) <= w && (x - r) >= 0 && (y + r) <= h && (y - r) >= 0{
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Fixed submission:
(W, H, x, y, r) = [int(i) for i in input().split()]
if (x-r) >= 0 and (x+r) <= W and (y-r) >= 0 and (y+r) <= H:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
package main

import (
	"fmt"
)

func main(){
	var a int
	for i:=1; i<10000; i++{
		fmt.Scan(&a)
		if a == 0{
			break
		}
		fmt.Printf("Case %d: %d", i, a)
	}
}


Fixed submission:
import sys
a = sys.stdin.readlines()[:-1]
for i in range(len(a)):
    print('Case {}: {}'.format(i+1, a[i]), end='')

Buggy python submission (verdict: Runtime Error):
package main

import (
	"fmt"
)

func main(){
	var a int
	for i:=1; ; i++{
		fmt.Scan(&a)
		if a == 0{
			break
		}
		fmt.Printf("Case %d: %d\n", i, a)
	}
}


Fixed submission:
import sys
a = sys.stdin.readlines()[:-1]
for i in range(len(a)):
    print('Case {}: {}'.format(i+1, a[i]), end='')
Buggy python submission (verdict: Runtime Error):
package main

import "fmt"

func main(){
	var a, b int
	for ;;{
		fmt.Scan(&a, &b)
		if a == 0 && b == 0 {
			break
		}
		fmt.Printf("%d %d\n", b, a)
	}
}


Fixed submission:
import sys
input_lines = sys.stdin.readlines()[:-1]
for input_line in input_lines:
    a, b = [int(i) for i in input_line.split()]
    if a > b:
        print('{0} {1}'.format(b, a))
    else:
        print(input_line.rstrip())
Buggy python submission (verdict: Runtime Error):
package main

import (
	"fmt"
)

func main(){
	var h, w, b int
	fmt.Scan(&h, &w)
	A := make([][]int, h)
	for i:=0; i<h; i++{
		i = make([]int, w)
	}
	x := make([]int, w)
	for i:=0; i<h; i++{
		for j:=0; j<w; j++{
			fmt.Scan(&A[i][j])
		}
	}
	for i:=0; i<w; i++{
		fmt.Scan(&x[i])
	}

	for i:=0; i<h; i++{
		b = 0
		for j:=0; j<w; j++{
			b += A[i][j] * x[j]
		}
		fmt.Println(b)
	}
}


Fixed submission:
h, w = [int(i) for i in input().split()]
A = [0] * h
for i in range(h):
    A[i] = [int(j) for j in input().split()]
b = []
for i in range(w):
    b.append(int(input()))
for i in range(h):
    num = 0
    for j in range(w):
        num += A[i][j] * b[j]
    print(num)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

arr = []

for i in range(n):
	arr.append(int(input()))


dp = [0 for i in range(n)]

for i in range(n):
	dp[i] = 1
	for j in range(i):
		if arr[i] > arr[j]:
			dp[i] = max(dp[i], dp[j] + 1)

print max(dp)



Fixed submission:
import bisect
n = int(input())
inf = float("inf")
arr = [int(input()) for _ in xrange(n)]

dp = [inf for _ in xrange(n)]

for i in arr:
	ind = bisect.bisect_left(dp,i)
	dp[ind] = i

print bisect.bisect_left(dp,inf)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,raw_input().split())

arr = []

for i in range(n):
	arr.append(i)

def root(i):
	t = i
	while arr[t] != t:
		t = arr[t]

	return t

for i in range(m):
	query,x,y = map(int,raw_input().split())

	if query == 0:
		arr[root(y)] = x

	else :
		print 1 if root(x) == root(y) else 0


Fixed submission:
n,m = map(int,raw_input().split())

arr = []

for i in range(n):
	arr.append(i)

def root(i):
	t = i
	while arr[t] != t:
		t = arr[t]

	return t

for i in range(m):
	query,x,y = map(int,raw_input().split())

	if query == 0:
		if root(y) == root(x):
			next 
		else :
			arr[root(y)] = root(x)

	else :
		print 1 if root(x) == root(y) else 0
Buggy python submission (verdict: Runtime Error):
n, t = map(int,raw_input().split())

arr = [0 for i in range(t+1)]

for i in range(n):
	start, end = map(int,raw_input().split())
	arr[start] += 1
	arr[end] -= 1
import numpy as np

cs = np.cumsum(arr)

print max(cs)


Fixed submission:
n, t = map(int,raw_input().split())

arr = [0 for i in range(t+1)]

for i in range(n):
	start, end = map(int,raw_input().split())
	arr[start] += 1
	arr[end] -= 1

cs = [arr[0] for i in range(t+1)]

for i in range(1,t+1):
	cs[i] = cs[i-1] + arr[i]

print max(cs)

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

arr = [0 for i in range(t+1)]

for i in range(n):
	start, end = map(int,raw_input().split())
	arr[start] += 1
	arr[end] -= 1
import numpy as np

cs = np.cumsum(arr)

print max(cs)


Fixed submission:
n, t = map(int,raw_input().split())

arr = [0 for i in range(t+1)]

for i in range(n):
	start, end = map(int,raw_input().split())
	arr[start] += 1
	arr[end] -= 1

cs = [arr[0] for i in range(t+1)]

for i in range(1,t+1):
	cs[i] = cs[i-1] + arr[i]

print max(cs)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
r =[]
for i in range(n):
    r.append(int(input()))

max_value = -10**9
for i in range(n):
    for j in range(i+1,n):
        if r[j] - r[i] > max_value:
            max_value = r[j] - r[i]
print(max_value)


Fixed submission:
n = int(input())
max_value = -10**9
min_value = int(input())
for i in range(1,n):
    r = int(input())
    max_value = max(max_value,r-min_value)
    min_value = min(min_value, r)

print(max_value)

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

max_value = -10**9
for i in range(n):
    for j in range(i+1,n):
        rji = r[j] - r[i]
        if rji  > max_value:
            max_value = rji
print(max_value)


Fixed submission:
n = int(input())
max_value = -10**9
min_value = int(input())
for i in range(1,n):
    r = int(input())
    max_value = max(max_value,r-min_value)
    min_value = min(min_value, r)

print(max_value)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(map(int, input().split())) # in演算子を使うためにはsはlistである必要がある。
q = int(input())
t = map(int, input().split())

cnt = 0

for i in t:
    if i in s:
        cnt += 1

print(cnt)


Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 30 11:33:59 2018
ALDS1-4a_r  バイナリサーチ

@author: maezawa
"""

def binary_search(a, key):
    n = len(a)
    left = 0
    right = n
    while left < right:
        #print(left, right)
        mid = (right+left)//2
        if a[mid] == key:
            return mid
        elif a[mid] > key:
            right = mid
        else:
            left = mid + 1
    return n

n = int(input())
s = list(map(int, input().split())) # in演算子を使うためにはsはlistである必要がある。
q = int(input())
t = map(int, input().split())

cnt = 0
for i in t:
    if binary_search(s, i) < n:
        cnt += 1

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 30 13:14:10 2018
ALDS1-4c simple implementation
@author: maezawa
"""

n = int(input())
a = []
for s in range(n):
    cmd, word = input().split()
    if cmd == 'insert':
        a.append(word)
    else:
        if word in a:
            print('yes')
        else:
            print('no')




Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 30 13:14:10 2018
ALDS1-4c  implementation with dictionary
@author: maezawa
"""

n = int(input())
a = dict([])
for s in range(n):
    cmd, word = input().split()
    if cmd == 'insert':
        a[word]=''
    else:
        if word in a:
            print('yes')
        else:
            print('no')
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 30 15:18:29 2018
ALDS1-4c
@author: maezawa
"""
def can_load(w, k, p):
    n = len(w)
    m = 0
    tk = 0
    i = 0
    while tk < k and i < n:
        if m + w[i] <= p:
            m += w[i]
            i += 1
        else:
            m = 0
            tk += 1
    return i


n, k = list(map(int, input().split()))
w = []
tr = [0 for _ in range(k)]

for i in range(n):
    w.append(int(input()))

maxw = max(w)
for p in range(maxw, maxw*n):
    if can_load(w, k, p) == n:
        print(p)
        break



Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 30 15:18:29 2018
ALDS1-4c
@author: maezawa
"""
def can_load(w, k, p):
    n = len(w)
    m = 0
    tk = 0
    i = 0
    while tk < k:
        if m + w[i] <= p:
            m += w[i]
            i += 1
            if i >= n:
                return n+1
        else:
            m = 0
            tk += 1
    return i


n, k = list(map(int, input().split()))
w = []
tr = [0 for _ in range(k)]

for i in range(n):
    w.append(int(input()))

maxw = max(w)
# =============================================================================
# for p in range(maxw, maxw*n):
#     if can_load(w, k, p) == n:
#         print(p)
#         break
# =============================================================================
right = maxw*n
left = maxw
while left<right:
    mid = (right+left)//2
    cl = can_load(w, k, mid)
#    if cl == n:
#        print(mid)
#        break
#    elif cl < n:
    if cl < n:
        left = mid + 1
    else:
        right = mid
print(right)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Thu May  3 22:47:34 2018
ALDS1_6_A
@author: maezawa
"""

n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n+1)]

def counting_sort(a, b, k):
    c = [0 for _ in range(k+1)]
    
    for j in range(n):
        c[a[j]] += 1
    
    for i in range(1, k+1):
        c[i] += c[i-1]
        
    for j in reversed(range(n)):
        #print(j, a[j], c[a[j]])
        b[c[a[j]]] = a[j]
        c[a[j]] -= 1
    
k = max(a)    
counting_sort(a, b, k)
print(b[1],end='')
for i in range(2,n+1):
    print(' {}'.format(b[i]), end='')
print()


Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Thu May  3 22:47:34 2018
ALDS1_6_A
@author: maezawa
"""

n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n+1)]

def counting_sort(a, b, k):
    c = [0 for _ in range(k+1)]
    
    for aj in a:
        c[aj] += 1
    
    for i in range(1, k+1):
        c[i] += c[i-1]
        
    for j in reversed(range(n)):
        #print(j, a[j], c[a[j]])
        b[c[a[j]]] = a[j]
        c[a[j]] -= 1
    
k = max(a)    
counting_sort(a, b, k)
print(b[1],end='')
for i in range(2,n+1):
    print(' {}'.format(b[i]), end='')
print()
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Thu May  3 21:24:25 2018
ALDS1_6_C
@author: maezawa
"""
a = []
n = int(input())
for i in range(n):
    s = input().split()
    a.append([s[0], int(s[1])])
    
a_in = a.copy()

def is_stable(a, b):
    s = True
    for i, card in enumerate(b):
        if b[i+1][1] == b[i][1]:
            j = a.index(card)
            k = a.index(b[i+1])
            if j > k:
                s = False
                return s
    return s
    

def partition(a, p, r):
    x = a[r][1]
    i = p - 1
    for j in range(p, r):
        if a[j][1] <= x:
            i += 1
            temp = a[i]
            a[i] = a[j]
            a[j] = temp
    temp = a[i+1]
    a[i+1] = a[r]
    a[r] = temp
    return i+1
    
def quick_sort(a, p, r):
    if p < r:
        q = partition(a, p, r)
        quick_sort(a, p, q-1)
        quick_sort(a, q+1, r)

quick_sort(a, 0, len(a)-1)
if is_stable(a_in, a):
    print('Stable')
else:
    print('Not stable')
for i in range(len(a)):
    print('{} {}'.format(a[i][0],a[i][1]))




Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Thu May  3 21:24:25 2018
ALDS1_6_C
@author: maezawa
"""
a = []
n = int(input())
for i in range(n):
    s = input().split()
    a.append([s[0], int(s[1])])
    
a_in = a.copy()

def is_stable(a, b):
    s = True
    for i in range(n-1):
        if b[i+1][1] == b[i][1]:
            j = a.index(b[i])
            k = a.index(b[i+1])
            if j > k:
                s = False
                return s
    return s
    

def partition(a, p, r):
    x = a[r][1]
    i = p - 1
    for j in range(p, r):
        if a[j][1] <= x:
            i += 1
            temp = a[i]
            a[i] = a[j]
            a[j] = temp
    temp = a[i+1]
    a[i+1] = a[r]
    a[r] = temp
    return i+1
    
def quick_sort(a, p, r):
    if p < r:
        q = partition(a, p, r)
        quick_sort(a, p, q-1)
        quick_sort(a, q+1, r)

quick_sort(a, 0, len(a)-1)
if is_stable(a_in, a):
    print('Stable')
else:
    print('Not stable')
for i in range(len(a)):
    print('{} {}'.format(a[i][0],a[i][1]))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Sat May 26 12:16:54 2018
DPL-1A
@author: maezawa
"""

n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
c.sort(reverse=True)
dp = [[float('inf') for _ in range(n+1)] for _ in range(m+1)]
dp[m][0] = 0
#print(n,m)
#print(c)
#print(*dp, sep='\n')

def min_number(i,nn):
    if i == m:
        return dp[i][nn]
    if dp[i][nn] != float('inf'):
        return dp[i][nn]
    if nn < c[i]:
        dp[i][nn] = min_number(i+1,nn)
    else:
        temp = []
        j = 0
        while nn >= j*c[i]:
            temp.append(min_number(i+1, nn-j*c[i])+j)
            j += 1
        dp[i][nn] = min(temp)
    return dp[i][nn]

print(min_number(0,n))


Fixed submission:
n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
    
dp = [0] * (n+1)
for i in range(1, n+1):
    dp[i] = min([dp[i - c[j]]+1 for j in range(m) if i-c[j]>=0])

print(dp[n])

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sat May 26 12:16:54 2018
DPL-1A Rec Call Revised
@author: maezawa
"""

n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
c.sort(reverse=True)
dp = [float('inf') for _ in range(n+1)]
dp[0] = 0
#print(n,m)
#print(c)
#print(*dp, sep='\n')

def min_number(nn):
    if dp[nn] != float('inf'):
        return dp[nn]
    temp = []
    for i in range(m):
        if nn < c[i]:
            continue
        else:
            temp.append(min_number(nn-c[i])+1)
    dp[nn] = min(temp)
    return dp[nn]

print(min_number(n))


Fixed submission:
n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
    
dp = [0] * (n+1)
for i in range(1, n+1):
    dp[i] = min([dp[i - c[j]]+1 for j in range(m) if i-c[j]>=0])

print(dp[n])

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sat May 26 12:16:54 2018
DPL-1A Rec Call Revised
@author: maezawa
"""

n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
c.sort(reverse=True)
dp = [float('inf') for _ in range(n+1)]
dp[0] = 0
#print(n,m)
#print(c)
#print(*dp, sep='\n')

def min_number(nn):
    if dp[nn] != float('inf'):
        return dp[nn]
    temp = []
    for i in range(m):
        if nn < c[i]:
            continue
        else:
            temp.append(min_number(nn-c[i])+1)
    dp[nn] = min(temp)
    return dp[nn]

print(min_number(n))


Fixed submission:
n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
    
dp = [0] * (n+1)
for i in range(1, n+1):
    dp[i] = min([dp[i - c[j]]+1 for j in range(m) if i-c[j]>=0])

print(dp[n])
Buggy python submission (verdict: Runtime Error):
a, b =list(map(int,input().split())
print("{} {}".format(a*b,2*(a+b))



Fixed submission:
a, b =list(map(int,input().split()))
print("{} {}".format(str(a*b),str(2*(a+b))))

Buggy python submission (verdict: Runtime Error):
a, b =list(map(int,input().split())
print("{} {}".format(a*b,2*(a+b)))


Fixed submission:
a, b =list(map(int,input().split()))
print("{} {}".format(str(a*b),str(2*(a+b))))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a.reverse()
print(' '.join(a))


Fixed submission:
n = int(input())
a = list(input().split())
a.reverse()
print(' '.join(a))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 24 18:23:54 2018
ITP22A
@author: maezawa
"""

n, q = list(map(int, input().split()))
a = [[] for _ in range(n)]

for i in range(q):
    c = list(map(int, input().split()))
    if c[0] == 0:
        a[c[1]].append(c[2])
    elif c[0] == 1:
        print(a[c[1]][-1])
    else:
        a[c[1]].pop()




Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 24 18:23:54 2018
ITP22A
@author: maezawa
"""

n, q = list(map(int, input().split()))
a = [[] for _ in range(n)]

for i in range(q):
    c = list(map(int, input().split()))
    if c[0] == 0:
        a[c[1]].append(c[2])
    elif c[0] == 1:
        if a[c[1]]:
            print(a[c[1]][-1])
    else:
        if a[c[1]]:
            a[c[1]].pop()

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 24 18:23:54 2018
ITP22A
@author: maezawa
"""

n, q = list(map(int, input().split()))
a = [[] for _ in range(n)]

for i in range(q):
    c = list(map(int, input().split()))
    if c[0] == 0:
        a[c[1]].append(c[2])
    elif c[0] == 1:
        if a[c[1]]:
            print(a[c[1]][-1])
    else:
        a[c[1]].pop()




Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 24 18:23:54 2018
ITP22A
@author: maezawa
"""

n, q = list(map(int, input().split()))
a = [[] for _ in range(n)]

for i in range(q):
    c = list(map(int, input().split()))
    if c[0] == 0:
        a[c[1]].append(c[2])
    elif c[0] == 1:
        if a[c[1]]:
            print(a[c[1]][-1])
    else:
        if a[c[1]]:
            a[c[1]].pop()
Buggy python submission (verdict: Runtime Error):
a, b, c = list(map(int, input().splist()))
print('{} {}'.format(min([a,b,c], max([a,b,c]))))



Fixed submission:
a, b, c = list(map(int, input().split()))
print('{} {}'.format(min([a,b,c]), max([a,b,c])))

Buggy python submission (verdict: Runtime Error):
a, b, c = list(map(int, input().split()))
print('{} {}'.format(min([a,b,c], max([a,b,c]))))



Fixed submission:
a, b, c = list(map(int, input().split()))
print('{} {}'.format(min([a,b,c]), max([a,b,c])))

Buggy python submission (verdict: Runtime Error):
a, b, c = list(map(int, input().split()))
print('{} {}'.format(min([a,b,c], max([a,b,c])))



Fixed submission:
a, b, c = list(map(int, input().split()))
print('{} {}'.format(min([a,b,c]), max([a,b,c])))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split())
m = int(input())
b = list(map(int, input()))

la = len(a)
lb = len(b)
l = min(la, lb)

for i in range(l):
    if a[i] < b[i]:
        print(1)
        break
    elif a[i] > b[i]:
        print(2)
        break
else:
    if la < lb:
        print(1)
    else:
        print(2)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))

la = len(a)
lb = len(b)
l = min(la, lb)

for i in range(l):
    if a[i] > b[i]:
        print(0)
        break
    elif a[i] < b[i]:
        print(1)
        break
else:
    if la >= lb:
        print(0)
    else:
        print(1)