Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = input().split()
num = [0 for i in range(len(n))]
for i in range(len(n)):
    num[i] = int(n[i])
for i in reversed(range(len(num))):
    for j in range(i):
    ¦   if num[j] > num[j + 1]: 
    ¦   ¦   tmp = num[j]
    ¦   ¦   num[j] = num[j + 1]  
    ¦   ¦   num[j + 1] = tmp 
for i in range(len(n)):
    print(str(num[i]),end=" ")


Fixed submission:
n = input().split()
num = [0 for _ in range(len(n))]
for i in range(len(n)):
    num[i] = int(n[i])
for i in (reversed(range(len(n)))):
    for j in range(i):
        if num[j] > num[j + 1]:
            tmp = num [j + 1]
            num[j + 1] = num[j]
            num[j] = tmp
print(str(num[0])+" "+str(num[1])+" "+str(num[2]))
Buggy python submission (verdict: Runtime Error):
i = 1
while True:
    case = input()
    print("Case "+str(i)+":"+case)
    if case == None: 
        print("Case "+str(i)+":"+case)
        break
    i += 1



Fixed submission:
i = 1
while True:
    case = input()
    if case == "0": 
        break
    print("Case "+str(i)+": "+case)
    i += 1
Buggy python submission (verdict: Runtime Error):
import numpy as np
r = float(input())
print("%f %f" % (np.pi * r * r, np.pi * 2 * r))



Fixed submission:
import math as np
r = float(input())
print("%f %f" % (np.pi * r * r, np.pi * 2 * r))
Buggy python submission (verdict: Runtime Error):
print(int(input()) ***3)

Fixed submission:
s = int(input())
print(s**3)
Buggy python submission (verdict: Runtime Error):
print(a*b)
print(2(a+b))


Fixed submission:
a,b=map(int,input().split())
print(a*b,2*(a+b))

Buggy python submission (verdict: Runtime Error):
print(a*b 2(a+b))


Fixed submission:
a,b=map(int,input().split())
print(a*b,2*(a+b))

Buggy python submission (verdict: Runtime Error):
a=int(input(''))
b=int(input(''))
pritn(a*b 2(a+b))


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

if a>b:
print('a > b')

elif a<b:
print('a < b')

else :
print('a=b')


Fixed submission:
a,b=map(int,input().split())
if a > b:
    print("a > b")
elif a < b :
    print("a < b")
else:
    print("a == b")

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

if a > b :
    print('a > b')
elif a < b :
    print('a < b')
else :
    print('a == b')


Fixed submission:
a,b=map(int,input().split())
if a > b:
    print("a > b")
elif a < b :
    print("a < b")
else:
    print("a == b")

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

if a > b :
    print('a > b')
elif a < b :
    print('a < b')
else :
    print('a == b')


Fixed submission:
a,b=map(int,input().split())
if a > b:
    print("a > b")
elif a < b :
    print("a < b")
else:
    print("a == b")
Buggy python submission (verdict: Runtime Error):
table=list(map(int,input().split()))
i=2
k=0
if k < i :
    while table[k] > table[k+1] :
        table[k],table[k+1]=table[k+1],table[k]
        k+=1
print(table[0],table[1],table[2])


Fixed submission:
a,b,c=map(int,input().split())
if a > b :
    tmp=a
    a=b
    b=tmp
if b > c :
    tmp=b
    b=c
    c=tmp
if a > b:
    tmp=a
    a=b
    b=tmp
print(a,b,c)

Buggy python submission (verdict: Time Limit Exceeded):
table= list(map(int,input().split()))
for i in range(2,0,-1):
    k=0
    while k < i :
        if table[k] > table[k+1] :
            table[k],table[k+1]=table[k+1],table[k]
            k+=1
print(table[0],table[1],table[2])


Fixed submission:
a,b,c=map(int,input().split())
if a > b :
    tmp=a
    a=b
    b=tmp
if b > c :
    tmp=b
    b=c
    c=tmp
if a > b:
    tmp=a
    a=b
    b=tmp
print(a,b,c)
Buggy python submission (verdict: Runtime Error):
a,op,b=map(str,input().split())
a=int(a)
b=int(b)

print("%d %d %0.5f",a/b,a%b,a/b)


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

print("%d %d %0.5f"%(a/b,a%b,a/b))
Buggy python submission (verdict: Runtime Error):
imporot math
r=float(input())

print("%0.5f %0.5f" %(r*r*math.pi,2*r*math.pi))


Fixed submission:
import math
r=float(input())

print("%.5f %.5f" %(r*r*math.pi,2*r*math.pi))
Buggy python submission (verdict: Runtime Error):
while True:
    a,op,b=map(istr,input().split())
    a=int(a)
    b=int(b)
    if op=="?":
        break
    if op=="+":
        print(a+b)
    elif op=="-":
        print(a-b)
    elif op=="*":
        print(a*b)
    else:
        print(int(a/b))




Fixed submission:
while True:
    a,op,b=map(str,input().split())
    a=int(a)
    b=int(b)
    if op=="?":
        break
    if op=="+":
        print(a+b)
    elif op=="-":
        print(a-b)
    elif op=="*":
        print(a*b)
    else:
        print(int(a/b))
Buggy python submission (verdict: Runtime Error):
while True:
    H,W=map(int,input().split())
    for i in range(H):
        pirnt("W"*#)


Fixed submission:
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    for i in range(H):
            print(W*"#")
    print("")

Buggy python submission (verdict: Runtime Error):
while True:
    H,W=map(int,input().split())
    for i in range(H):
        pirnt(W*"#")
    print("")


Fixed submission:
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    for i in range(H):
            print(W*"#")
    print("")

Buggy python submission (verdict: Runtime Error):
while True:
    H,W=map(int,input().split())
    for i in range(H):
        print(W*"#")
    print("")


Fixed submission:
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    for i in range(H):
            print(W*"#")
    print("")

Buggy python submission (verdict: Runtime Error):
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        for i in range(H):
            print(W*"#")
    print("")


Fixed submission:
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    for i in range(H):
            print(W*"#")
    print("")

Buggy python submission (verdict: Runtime Error):
#include<iostream>
using namespace std;

int main(){
    int H,W;
    while(cin >> H >> W && (H!=0 || W!=0)){
        for (int i = 0; i < H; i += 1){
            cout << "#"*W << endl;
        }
    }
    return 0;
}


Fixed submission:
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    for i in range(H):
            print(W*"#")
    print("")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input().rstrip())
R = [0 for _ in range(n)]
for i in range(n):
    R[i] = int(input().rstrip())

max_margin = 1 - 10**9
for i in range(n):
    for j in range(i+1, n):
        margin = R[j] - R[i]
        if margin > max_margin:
            max_margin = margin

print(max_margin) 


Fixed submission:
n = int(input().rstrip())
R = [0 for _ in range(n)]
for i in range(n):
    R[i] = int(input().rstrip())

margin = - 10**9
min_R = R[0]
for j in range(1, n):
    margin = max(margin, R[j] - min_R)
    min_R = min(min_R, R[j])

print(margin)
Buggy python submission (verdict: Runtime Error):
#include<iostream>

int selection_sort(int A[], int N) {
  int i, j, tmp, sw = 0, min_i;
  for (i = 0; i < N-1; i++) {
    min_i = i;
    for (j = i+1; j < N; j++) {
      if (A[j] < A[min_i]) min_i = j;
    }
    tmp = A[i];
    A[i] = A[min_i];
    A[min_i] = tmp;
    if (i != min_i) sw++;
  }
  return sw;
}

int main() {
  int A[100], i, N, sw;

  std::cin >> N;
  for (i = 0; i < N; i++) std::cin >> A[i];

  sw = selection_sort(A, N);
  
  for (i = 0; i < N; i++) {
    if (i > 0) std::cout << ' ';
    std::cout << A[i];
  }
  std::cout << std::endl;
  std::cout << sw << std::endl;

  return 0;
}


Fixed submission:
def selection_sort(A, N):
    cnt = 0
    for i in range(N):
        min_j = i
        for j in range(i, N):
            if A[j] < A[min_j]:
                min_j = j
        if i != min_j:
            A[i], A[min_j] = A[min_j], A[i]
            cnt += 1        
    return A, cnt


N = int(input().rstrip())
A = list(map(int, input().rstrip().split()))

A, cnt = selection_sort(A, N)
string = list(map(str, A))
print(' '.join(string))
print(cnt)
Buggy python submission (verdict: Runtime Error):
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g) {
  for (int i = g; i < n; i++) {
    int v = A[i];
    int j = i - g;
    while (j >= 0 && A[j] > v) {
      A[j+g] = A[j];
      j -= g;
      cnt++;
    }
    A[j+g] = v;
  }
}

void shellSort(int A[], int n) {
  for (int h = 1; ;) {
    if (h > n) break;
    G.push_back(h);
    h = 3 * h + 1;
  }

  for (int i = G.size() - 1; i >= 0; i--) {
    insertionSort(A, n, G[i]);
  }
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%d", &A[i]);
  cnt = 0;

  shellSort(A, n);
  cout << G.size() << endl;
  for (int i = G.size() - 1; i >= 0; i--) {
    printf("%d", G[i]);
    if (i) printf(" ");
  }

  printf("\n");
  printf("%lld\n", cnt);
  for (int i = 0; i < n; i++) printf("%d\n", A[i]);

  return 0;
}



Fixed submission:
def insertion_sort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            cnt += 1
            j -= g
        A[j+g] = v

    return A, cnt


def shell_sort(A, n):
    cnt = 0
    g = 1
    G = []
    while g <= n:
        G.append(g)
        g = 3 * g + 1
    G.reverse()
    m = len(G)

    for g in G:
        A, cnt = insertion_sort(A, n, g, cnt)

    return m, G, cnt, A


n = int(input().rstrip())
A = []
for _ in range(n):
    A.append(int(input().rstrip()))

m, G, cnt, A = shell_sort(A, n)

print(m)
print(' '.join(list(map(str, G))))
print(cnt)
print('\n'.join(list(map(str, A))))
Buggy python submission (verdict: Time Limit Exceeded):
def fib(n):
    if n == 0:
        return 1
    elif n == 1:
        return 1

    return fib(n - 1) + fib(n - 2)

n = int(input())
print(fib(n))



Fixed submission:
def memolize(f):
    cache = {}

    def helper(x):
        if x not in cache:
            cache[x] = f(x)
        return cache[x]
    return helper

@memolize
def fib(n):
    if n == 0:
        return 1
    elif n == 1:
        return 1

    return fib(n - 1) + fib(n - 2)

n = int(input())
print(fib(n))

Buggy python submission (verdict: Runtime Error):
def memolize(f):
    cache = {}

    def helper(x):
        if x not in cache:
            cache[x] = f(x)
         return cache[x]
    return helper

@memolize
def fib(n):
    if n == 0:
        return 1
    elif n == 1:
        return 1

    return fib(n - 1) + fib(n - 2)

n = int(input())
print(fib(n))



Fixed submission:
def memolize(f):
    cache = {}

    def helper(x):
        if x not in cache:
            cache[x] = f(x)
        return cache[x]
    return helper

@memolize
def fib(n):
    if n == 0:
        return 1
    elif n == 1:
        return 1

    return fib(n - 1) + fib(n - 2)

n = int(input())
print(fib(n))
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    numbers = [int(input()) for i in range(n)]
    count = shellSort(numbers, n)

    print(count)
    [print(i) for i in numbers]

def shellSort(numbers, n):
    count = 0
    m = 1
    g = []
    while m <= n :
        g.append(m)
        m = 3 * m + 1

    for i in range(len(g), -1, -1):
        count += insertionSort(numbers, n, g[i])

    print(len(g))
    print(' '.join(map(str, g)))

    return count

def insertionSort(numbers, n, h):
    count = 0
    for i in range(h, n, 1):
        v = numbers[i]
        j = i - h
        while (j >= 0) & (numbers[j] > v):
            numbers[j + h] = numbers[j]
            j -= h
            count += 1

        numbers[j + h] = v

    return count

if __name__ == '__main__':
    main()



Fixed submission:
def main():
    n = int(input())
    numbers = [int(input()) for i in range(n)]
    count = shellSort(numbers, n)

    print(count)
    [print(i) for i in numbers]

def shellSort(numbers, n):
    count = 0
    m = 1
    g = []
    while m <= n :
        g.append(m)
        m = 3 * m + 1
    g.reverse()
    for h in g:
        count += insertionSort(numbers, n, h)

    print(len(g))
    print(' '.join(map(str, g)))

    return count

def insertionSort(numbers, n, h):
    count = 0
    for i in range(h, n, 1):
        v = numbers[i]
        j = i - h
        while (j >= 0) & (numbers[j] > v):
            numbers[j + h] = numbers[j]
            j -= h
            count += 1

        numbers[j + h] = v

    return count

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))
count = 0
for a in t:
    left = 0
    right = n - 1
    while left <= right:
        mid = (right + left) // 2
        if a == s[mid]:
            count += 1
            break
        elif a < s[mid]:
            right = mid
        else :
            left = mid + 1

print(count)



Fixed submission:
n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))
count = 0
for a in t:
    left = 0
    right = n
    while left < right:
        mid = (right + left) // 2
        if a == s[mid]:
            count += 1
            break
        elif a < s[mid]:
            right = mid
        else :
            left = mid + 1

print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())
numbers = list(map(int, input().split()))

def main() :
    x = numbers[n - 1]
    i = 0
    for j in range(n) :
        if numbers[j] <= x :
            numbers[i], numbers[j] = numbers[j], numbers[i]
            i += 1

    [print(numbers[j] if j != i - 1 else '['+str(numbers[j])+']', end = ' ' if j != n - 1 else '\n') for j in range(n)]

if __name__ == '__main__':
    main()



Fixed submission:
def main() :
    n = int(input())
    cards = [Card(*input().split()) for i in range(n)]
    stableCards = sorted(cards[:], key=lambda c: c.number)
    quickSort(cards, 0, n - 1)
    print(isStable(cards, stableCards, n))
    list(map(lambda i : i.print_card(), cards))

def quickSort(cards, p, r) :
    if p < r:
        q = partion(cards, p, r)
        quickSort(cards, p, q - 1)
        quickSort(cards, q + 1, r)

def partion(cards, p, r) :
    x = cards[r]
    i = p
    for j in range(p, r + 1) :
        if int(cards[j].number) <= int(x.number) :
            cards[i], cards[j] = cards[j], cards[i]
            i += 1
    return i - 1

def isStable(a, b, n):
    for i in range(n):
        if a[i].prefix != b[i].prefix:
            return 'Not stable'

    return 'Stable'

class Card():
    def __init__(self, prefix, number):
        self.prefix = prefix
        self.number = number

    def print_card(self):
        print(self.prefix, self.number)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
aN = int(input())
A = list(map(int, input().split()))
mN = int(input())
M = list(map(int, input().split()))

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

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


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

def memorize(f) :
    cache = {}
    def helper(*args) :
        if args not in cache :
            cache[args] = f(*args)
        return cache[args]
    return helper

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

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

Buggy python submission (verdict: Runtime Error):
aN = int(input())
A = list(map(int, input().split()))
mN = int(input())
M = list(map(int, input().split()))

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

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


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

def memorize(f) :
    cache = {}
    def helper(*args) :
        if args not in cache :
            cache[args] = f(*args)
        return cache[args]
    return helper

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

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

Buggy python submission (verdict: Runtime Error):
aN = int(input())
A = list(map(int, input().split()))
mN = int(input())
M = list(map(int, input().split()))

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

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


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

def memorize(f) :
    cache = {}
    def helper(*args) :
        if args not in cache :
            cache[args] = f(*args)
        return cache[args]
    return helper

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

for m in M:
    print("yes" if solve(0, m) else "no")
Buggy python submission (verdict: Runtime Error):
# 1: top, 2: front, 3: right,
# 4: left, 5: back, 6: bottom

class Dice:
    def __init__(self, nums):
        self.top, self.front, self.right, self.left, self.back, self.bottom = nums

    def roll(self, direction):
        if direction == 'E':
            self.top, self.right, self.left, self.bottom = self.left, self.top, self.bottom, self.right
            return

        if direction == 'N':
            self.top, self.front, self.back, self.bottom = self.front, self.bottom, self.top, self.back
            return

        if direction == 'S':
            self.top, self.front, self.back, self.bottom = self.back, self.top, self.bottom, self.front
            return

        if direction == 'W':
            self.top, self.right, self.left, self.bottom = self.right, self.bottom, self.top, self.left
            return

    def get_top(self):
        return self.top

if __name__ == '__main__':
    nums = [int(i) for i in input().split()]
    directions = input()

    d = Dice(nums)
    for i in len(directions):
        d.roll(directions[i])

    print(d.get_top())

Fixed submission:
# 1: top, 2: front, 3: right,
# 4: left, 5: back, 6: bottom

class Dice:
    def __init__(self, nums):
        self.top, self.front, self.right, self.left, self.back, self.bottom = nums

    def roll(self, direction):
        if direction == 'E':
            self.top, self.right, self.left, self.bottom = self.left, self.top, self.bottom, self.right
            return

        if direction == 'N':
            self.top, self.front, self.back, self.bottom = self.front, self.bottom, self.top, self.back
            return

        if direction == 'S':
            self.top, self.front, self.back, self.bottom = self.back, self.top, self.bottom, self.front
            return

        if direction == 'W':
            self.top, self.right, self.left, self.bottom = self.right, self.bottom, self.top, self.left
            return

    def get_top(self):
        return self.top

if __name__ == '__main__':
    nums = [int(i) for i in input().split()]
    directions = input()

    d = Dice(nums)
    for i in range(len(directions)):
        d.roll(directions[i])

    print(d.get_top())
Buggy python submission (verdict: Runtime Error):
def to_str(symbol, num):
    return '{0} {1}'.format(symbol, num)

if __name__ == '__main__':
    symbols = ['S','H','C','D']
    cards = [to_str(x,y) for x in symbols for y in range(1,14)]
    n = int(input())
    if n == 52: break
    for i in range(n):
        cards.remove(input())
    print('\n'.join(cards))

Fixed submission:
import sys

def to_str(symbol, num):
    return '{0} {1}'.format(symbol, num)

if __name__ == '__main__':
    symbols = ['S','H','C','D']
    cards = [to_str(x,y) for x in symbols for y in range(1,14)]
    n = int(input())
    if n == 52: sys.exit()
    for i in range(n):
        cards.remove(input())
    print('\n'.join(cards))

Buggy python submission (verdict: Runtime Error):
def to_str(symbol, num):
    return '{0} {1}'.format(symbol, num)

if __name__ == '__main__':
    symbols = ['S','H','C','D']
    cards = [to_str(x,y) for x in symbols for y in range(1,14)]
    n = int(input())
    if n == 52: return None
    for i in range(n):
        cards.remove(input())
    print('\n'.join(cards))

Fixed submission:
import sys

def to_str(symbol, num):
    return '{0} {1}'.format(symbol, num)

if __name__ == '__main__':
    symbols = ['S','H','C','D']
    cards = [to_str(x,y) for x in symbols for y in range(1,14)]
    n = int(input())
    if n == 52: sys.exit()
    for i in range(n):
        cards.remove(input())
    print('\n'.join(cards))
Buggy python submission (verdict: Runtime Error):
if __name__ == '__main__':
    s = input()
    q = int(input())
    for i in range(q):
        code = input().split()
        op, a, b = code[0], int(code[1]), int(code[2])
        if op == 'print':
            print(s[a:b+1])
        elif op == 'reverse':
            s = s[:a] + s[a:b+1][::-1] + s[b+1:]
        elif op == 'replace':
            s = s[:a] + p + s[b+1:]

Fixed submission:
if __name__ == '__main__':
    s = input()
    q = int(input())
    for i in range(q):
        code = input().split()
        op, a, b = code[0], int(code[1]), int(code[2])
        if op == 'print':
            print(s[a:b+1])
        elif op == 'reverse':
            s = s[:a] + s[a:b+1][::-1] + s[b+1:]
        elif op == 'replace':
            s = s[:a] + code[3] + s[b+1:]
Buggy python submission (verdict: Time Limit Exceeded):
def Fibonacci(n):
	if n==0 or n==1 : return 1
	return Fibonacci(n-1)+Fibonacci(n-2)

print( Fibonacci( int(input()) ) )

Fixed submission:
def Fibonacci(n, a1, a2):
	if n<1 : return a1
	return Fibonacci(n-1,a1+a2,a1)

print( Fibonacci( int(input()), 1, 0 ) )
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import heapq

heap = []
while True:
	input_line = sys.stdin.readline()
	input_line = input_line.strip().split(' ')
	if input_line[0][0] == 'i' :
		heapq.heappush(heap,-int(input_line[1]))
		heapq.heapify(heap)
	elif input_line[0][1] == 'x' :
		print(-int(heapq.heappop(heap)))
	else :
		break

Fixed submission:
import sys
import heapq

heap = []
while True:
	input_line = sys.stdin.readline()
	input_line = input_line.strip().split(' ')
	if input_line[0][0] == 'i' :
		heapq.heappush(heap,-int(input_line[1]))
	elif input_line[0][1] == 'x' :
		print(-int(heapq.heappop(heap)))
	else :
		break
Buggy python submission (verdict: Time Limit Exceeded):
import sys

num_list = int(sys.stdin.readline())
lines = sys.stdin.readlines()
nums = map(int, lines)

max_diff = -sys.maxint -1
for i in range(num_list) :
    for j in range(i+1, num_list) :
        diff = nums[j] - nums[i]
        if diff > max_diff :
            max_diff = diff

print max_diff

Fixed submission:
import sys

num_list = int(sys.stdin.readline())
lines = sys.stdin.readlines()
nums = map(int, lines)

max_diff = -sys.maxint - 1
min_val = nums.pop(0)
for num in nums :
    diff = num - min_val
    if diff > max_diff :
        max_diff = diff
    if num < min_val :
        min_val = num

print max_diff