Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
count = 0
def merge(A,left,mid,right):
    n1 = mid- left
    n2 = right - mid
    L = [0 for i in range(n1+1)]
    R = [0 for i in range(n2+1)]

    for i in range(n1):
        L[i]= A[left+i]
    for i in range(n2):
        R[i] = A[mid + i]
    L[n1] = float("INFINITY")
    R[n2] = float("INFINITY")
    i = 0
    j = 0
    for k in range(left,right):
        global count 
        count += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i = i + 1
        else:
            A[k] = R[j]
            j += 1
            
def mergeSort(A,left,right):
    if left + 1 < right:
        mid = (left+ right) //2
        mergeSort(A,left,mid)
        mergeSort(A,mid,right)
        merge(A,left,mid,right)

n = int(input())
A = list(map(int,input().split()))

mergeSort(A,0,n)

print(" ".join(map(str,A)))
print(count)

Fixed submission:
from collections import deque
SENIAL = 10**9
count = 0

def merge(A,left,mid,right):
    L = deque(A[left:mid])
    R = deque(A[mid:right])
    L.append(SENIAL)
    R.append(SENIAL)
    
    global count
    
    for k in range(left,right):
        count +=1
        if L[0] <= R[0]:
            A[k] = L.popleft()
 
        else:
            A[k] = R.popleft()

            
def mergeSort(A,left,right):
    if left + 1 < right:
        middle = (left + right) //2
        mergeSort(A,left,middle)
        mergeSort(A,middle,right)
        merge(A,left,middle,right)
        
input()
l = list(map(int,input().split()))
mergeSort(l,0,len(l))
print(" ".join(map(str,l)))
print(count)

Buggy python submission (verdict: Runtime Error):
from collections import deque
count = 0

def merge(A,left,mid,right):
    L = deque(A[left:mid])
    R = deque(A[mid:right])
    L.append(10**9)
    R.append(10**9)
    
    global count
    
    for k in range(left,right):
        count +=1
        if L[0] <= R[0]:
            A[k] = L.popleft()
 
        else:
            A[k] = R.popleft()

            
def mergeSort(A,left,right):
    if left + 1 < right:
        middle = (left + right) //2
        mergeSort(A,left,middle)
        mergeSort(A,middle,right)
        merge(A,left,middle,right)
        
input()
l = list(map(int,input().split()))
mergeSort(l,0,len(l))
print(" ".join(l))
print(count)            
        

Fixed submission:
from collections import deque
SENIAL = 10**9
count = 0

def merge(A,left,mid,right):
    L = deque(A[left:mid])
    R = deque(A[mid:right])
    L.append(SENIAL)
    R.append(SENIAL)
    
    global count
    
    for k in range(left,right):
        count +=1
        if L[0] <= R[0]:
            A[k] = L.popleft()
 
        else:
            A[k] = R.popleft()

            
def mergeSort(A,left,right):
    if left + 1 < right:
        middle = (left + right) //2
        mergeSort(A,left,middle)
        mergeSort(A,middle,right)
        merge(A,left,middle,right)
        
input()
l = list(map(int,input().split()))
mergeSort(l,0,len(l))
print(" ".join(map(str,l)))
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
def bubbleSort(A):
    count = 0
    for i in range(len(A)):
        for j in range(i+1,len(A))[::-1]:
            if A[j] < A[j-1]:
                ret = A[j]
                A[j] = A[j-1]
                A[j-1] = ret
                count +=1
    return count 
input()
print(bubbleSort(list(map(int,input().split()))))

Fixed submission:
from _collections import deque

SENIAL = 1000000000
def mergeSort(A,left,right):
    if left + 1 < right:
        middle = (left + right) // 2
        mergeSort(A, left, middle)
        mergeSort(A, middle, right)
        merge(A,left,right,middle)
    
def merge(A,left,right,middle):
    global count        
    L = deque(A[left:middle])
    R = deque(A[middle:right])
    L.append(SENIAL)
    R.append(SENIAL)
    for i in range(left,right):
        if L[0] < R[0]:
            A[i] = L.popleft()
        else:
            A[i] = R.popleft()
            count += len(L) -1 
count = 0     
input()
A = list(map(int,input().split()))
mergeSort(A,0,len(A))
print(count)
Buggy python submission (verdict: Runtime Error):
import math
x1,y1,x2,y2 = map(int,input().split())
print(math.sqrt((x1-x2)**2 + (y1-y2)**2))

Fixed submission:
import math
x1,y1,x2,y2 = map(float,input().split())
d = math.sqrt((x1-x2)**2 + (y1-y2)**2)
print(d)

Buggy python submission (verdict: Runtime Error):
import math
x1,y1,x2,y2 = map(int,input().split())
print(math.sqrt((x1-x2)**2 + (y1-y2)**2))

Fixed submission:
import math
x1,y1,x2,y2 = map(float,input().split())
d = math.sqrt((x1-x2)**2 + (y1-y2)**2)
print(d)

Buggy python submission (verdict: Runtime Error):
import math
x1,y1,x2,y2 = map(int,input().split())
d = math.sqrt((x1-x2)**2 + (y1-y2)**2)
print(d)

Fixed submission:
import math
x1,y1,x2,y2 = map(float,input().split())
d = math.sqrt((x1-x2)**2 + (y1-y2)**2)
print(d)
Buggy python submission (verdict: Runtime Error):
import math

while True:
    n = input()
    if n == 0:
        break
    m = map(float,raw_input().split())
    print "5f" %(math.sqrt(sum([(m[i]-(sum(m)/len(m)))**2 for i in range(n)])/n))

Fixed submission:
import math

while True:
    n = input()
    if n == 0:
        break
    m = map(float,raw_input().split())
    ave= sum(m)/len(m)

    print "%5f" %(math.sqrt(sum([(m[i]-(ave))**2 for i in range(n)])/n))
Buggy python submission (verdict: Runtime Error):
def whatIsRight(u,f):	
    r = 0
    if u == 1:
        if f == 2:
            r = 3
        elif f == 3:
            r = 5
        elif f == 4:
            r = 2
        elif f == 5:
            r = 4
        return r
	
    if u == 2:
        if f == 6:
            r = 3
        elif f == 3:
            r = 1
        elif f == 1:
            r = 4
        elif f == 4:
            r = 6
        return r

    if u == 3:
        if f == 5:
            r = 1
        elif f == 1:
            r = 2
        elif f == 2:
            r = 6
        elif f == 6:
            r = 3
        return r
			
    if u == 4:
        if f == 6:
            r = 2
        elif f == 2:
            r = 1
        elif f == 1:
            r = 5
        elif f == 5:
            r = 6 
        return r 
			
    if u == 5:
        if f == 3:
            r = 6
        elif f == 6:
            r = 4
        elif f == 4:
            r = 1
        elif f == 1:
            r = 3
	return r
		
    if u == 6:
        if f == 5:
            r = 3
        elif f == 3:
            r = 2
        elif f == 2:
            r = 4
        elif f == 4:
            r = 5
        return r
			
n = list(map(int,input().split()))
N = int(input())

for i in range(N):
    m = list(map(int,input().split()))
    num = []

    for j in range(len(m)):
        for k in range(len(n)):
            if m[j] == n[k]:
                num.append(k+1)
                break
	
    print(n[whatIsRight(num[0],num[1]) -1])

Fixed submission:
def move(up,bottom,right,left,front,back,direction):
    if direction == "N":
        return (front,back,right,left,bottom,up)
    elif direction == "S":
        return (back,front,right,left,up,bottom)
    elif direction == "E":
        return (left,right,up,bottom,front,back)
    elif direction == "W":
        return (right,left,bottom,up,front,back)
    
def check(up,bottom,right,left,front,back,up_current,front_current):
    if front_current == front and up_current == up:
        print(right)     
    elif front_current == front:
        if left == up_current:
            print(up)
        elif bottom == up_current:
            print(left)
        elif right == up_current:
            print(bottom)
    elif up_current == up:
        if right == front_current:
            print(back)
        elif back == front_current:
            print(left)
        elif left == front_current:
            print(front)
    else:
      
        up,bottom,right,left,front,back = move(up,bottom,right,left,front,back,"S")
        check(up,bottom,right,left,front,back,up_current,front_current)
                
                
                
                
up,front,right,left,back,bottom = input().split()
n = int(input())

for i in range(n):
    up_current,front_current = input().split()
    check(up,bottom,right,left,front,back,up_current,front_current)
Buggy python submission (verdict: Runtime Error):
a = input("x")
a = a ** 3
print("{}".format(a))

b = input("y")
b = b **3
print("{}".format(b))

Fixed submission:
x = input()
y = x**3
print(int(y))

Buggy python submission (verdict: Runtime Error):
a = input("a")
a = a **3
print("{}\n1".format(a))
a = input("a")
a = a **3
print("{}\n1".format(a))
a = input("a")
a = a **3
print("{}\n1".format(a))
a = input("a")
a = a **3
print("{}\n1".format(a))

Fixed submission:
x = input()
y = x**3
print(int(y))

Buggy python submission (verdict: Runtime Error):
x = input()
x = x **3

print(int(x))

Fixed submission:
x = input()
y = x**3
print(int(y))

Buggy python submission (verdict: Runtime Error):
x = input()
x = x **3

print int(x)

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

Fixed submission:
x = raw_input().split()
y = map(int,x)
a = y[0]
b = y[1]

c = a * b
d = (a + b) * 2
print c,d
Buggy python submission (verdict: Runtime Error):
x = raw_input().split()
m = map(int,x)

sort(m)

a = m[0]
b = m[1]
c = m[2]

print a,b,c

Fixed submission:
a = list(map(int,input().split()))
for i in range(len(a)):
    for j in range(i,len(a)):
        if a[i] > a[j]:
            ret = a[i]
            a[i] = a[j]
            a[j] = ret
print(" ".join(list(map(str,a))))

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

m.sort()
a = m[0]
b = m[1]
c = m[2]

print a,b,c

Fixed submission:
a = list(map(int,input().split()))
for i in range(len(a)):
    for j in range(i,len(a)):
        if a[i] > a[j]:
            ret = a[i]
            a[i] = a[j]
            a[j] = ret
print(" ".join(list(map(str,a))))

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

sorted(m)
a = m[0]
b = m[1]
c = m[2]

print a,b,c

Fixed submission:
a = list(map(int,input().split()))
for i in range(len(a)):
    for j in range(i,len(a)):
        if a[i] > a[j]:
            ret = a[i]
            a[i] = a[j]
            a[j] = ret
print(" ".join(list(map(str,a))))

Buggy python submission (verdict: Runtime Error):
x = raw_input().split()
m = map(int,x)
m.sort()
a = m[0]
b = m[1]
c = m[2]

print a,b,c

Fixed submission:
a = list(map(int,input().split()))
for i in range(len(a)):
    for j in range(i,len(a)):
        if a[i] > a[j]:
            ret = a[i]
            a[i] = a[j]
            a[j] = ret
print(" ".join(list(map(str,a))))

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

m.sort()
a = m[0]
b = m[1]
c = m[2]

print a,b,c

Fixed submission:
a = list(map(int,input().split()))
for i in range(len(a)):
    for j in range(i,len(a)):
        if a[i] > a[j]:
            ret = a[i]
            a[i] = a[j]
            a[j] = ret
print(" ".join(list(map(str,a))))
Buggy python submission (verdict: Runtime Error):
x = map(int,input().split())

W = x[0]
H = x[1]
x = x[2]
y = x[3]
r = x[4]

if 0 <= x-r and x+r <= W and 0 <= y-r and y+r <= H:
    print "Yes"
else:
    print "No"

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

W = m[0]
H = m[1]
x = m[2]
y = m[3]
r = m[4]


if 0 <= x-r and x+r <= W and 0 <= y-r and y+r <= H:
    print "Yes"
else:
    print "No"

Buggy python submission (verdict: Runtime Error):
x = map(int,input().split())

W = x[0]
H = x[1]
x = x[2]
y = x[3]
r = x[4]

if 0 <= x-r and x+r <= W and 0 <= y-r and y+r <= H:
    print "Yes"
else:
    print "No"

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

W = m[0]
H = m[1]
x = m[2]
y = m[3]
r = m[4]


if 0 <= x-r and x+r <= W and 0 <= y-r and y+r <= H:
    print "Yes"
else:
    print "No"

Buggy python submission (verdict: Runtime Error):
x = map(int,input().split())

W = x[0]
H = x[1]
x = x[2]
y = x[3]
r = x[4]


if 0 <= x-r and x+r <= W:
    if 0 <= y-r and y+r <= H:
        print "Yes"
print "No"

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

W = m[0]
H = m[1]
x = m[2]
y = m[3]
r = m[4]


if 0 <= x-r and x+r <= W and 0 <= y-r and y+r <= H:
    print "Yes"
else:
    print "No"

Buggy python submission (verdict: Runtime Error):
m = map(int,input().split())

W = m[0]
H = m[1]
x = m[2]
y = m[3]
r = m[4]


if 0 <= x-r and x+r <= W:
    if 0 <= y-r and y+r <= H:
        print "Yes"
print "No"

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

W = m[0]
H = m[1]
x = m[2]
y = m[3]
r = m[4]


if 0 <= x-r and x+r <= W and 0 <= y-r and y+r <= H:
    print "Yes"
else:
    print "No"

Buggy python submission (verdict: Runtime Error):
m = map(int,input().split())

W = m[0]
H = m[1]
x = m[2]
y = m[3]
r = m[4]


if 0 <= x-r and x+r <= W:
    if 0 <= y-r and y+r <= H:
        print "Yes"
print "No"

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

W = m[0]
H = m[1]
x = m[2]
y = m[3]
r = m[4]


if 0 <= x-r and x+r <= W and 0 <= y-r and y+r <= H:
    print "Yes"
else:
    print "No"
Buggy python submission (verdict: Runtime Error):
a = []
while True:
    if n == 0:
        break
    else:
        a.append(input())

for i in range(0,len(a)):
    print "Case"+ i + ":" + a[i]

Fixed submission:
a = []
num = 1

while True:
    n = input()
    if n == 0:
        break
    print ("Case {}: {}".format(num,n))
    num +=1

Buggy python submission (verdict: Runtime Error):
a = []
while True:
    n = input()
    if n == 0:
        break
    else:
        a.append(n)

for i in range(0,len(a)):
    print "Case"+ i + ":" + a[i]

Fixed submission:
a = []
num = 1

while True:
    n = input()
    if n == 0:
        break
    print ("Case {}: {}".format(num,n))
    num +=1
Buggy python submission (verdict: Runtime Error):
m = map(int,raw_input().split())
a = m[0]
b = m[1]

d = a / b
r = a % b
f = l.0 * a / b

print int(d),int(r),long(f)

Fixed submission:
m = map(int,raw_input().split())
a = m[0]
b = m[1]

d = a / b
r = a % b
f = a * 1.0 / b

print '%d %d %f' %(d, r, f)

Buggy python submission (verdict: Runtime Error):
m = map(int,raw_input().split())
a = m[0]
b = m[1]

d = a / b
r = a % b
f = l.0 * a / b

print int(d),int(r),long(f)

Fixed submission:
m = map(int,raw_input().split())
a = m[0]
b = m[1]

d = a / b
r = a % b
f = a * 1.0 / b

print '%d %d %f' %(d, r, f)

Buggy python submission (verdict: Runtime Error):
m = map(int,raw_input().split())
a = m[0]
b = m[1]

d = a / b
r = a % b
f = l.0 * a / b

print int(d),int(r),float(f)

Fixed submission:
m = map(int,raw_input().split())
a = m[0]
b = m[1]

d = a / b
r = a % b
f = a * 1.0 / b

print '%d %d %f' %(d, r, f)
Buggy python submission (verdict: Runtime Error):
x = input().split()
a,op,b = int(x[0]),x[1],int(x[2])
if x[1] == "+":
    print a+b
elif x[1] == "-":
    print a-b
elif x[1] == "*":
    print a*b
elif x[1] == "/":
    print a/b
else:
    break
    
    
    
    

Fixed submission:
while True:
    x = raw_input().split()
    a,op,b = int(x[0]),x[1],int(x[2])
    if op == "+":
        print a+b
    elif op == "-":
        print a-b
    elif op == "*":
        print a*b
    elif op == "/":
        print a/b
    else:
        break

Buggy python submission (verdict: Runtime Error):
x = input().split()
a,op,b = int(x[0]),x[1],int(x[2])
if op == "+":
    print a+b
elif op == "-":
    print a-b
elif op == "*":
    print a*b
elif op == "/":
    print a/b
else:
    break
    
    
    
    

Fixed submission:
while True:
    x = raw_input().split()
    a,op,b = int(x[0]),x[1],int(x[2])
    if op == "+":
        print a+b
    elif op == "-":
        print a-b
    elif op == "*":
        print a*b
    elif op == "/":
        print a/b
    else:
        break

Buggy python submission (verdict: Runtime Error):
x = raw_input().split()
a,op,b = int(x[0]),x[1],int(x[2])
if op == "+":
    print a+b
elif op == "-":
    print a-b
elif op == "*":
    print a*b
elif op == "/":
    print a/b
else:
    break
    
    
    
    

Fixed submission:
while True:
    x = raw_input().split()
    a,op,b = int(x[0]),x[1],int(x[2])
    if op == "+":
        print a+b
    elif op == "-":
        print a-b
    elif op == "*":
        print a*b
    elif op == "/":
        print a/b
    else:
        break
Buggy python submission (verdict: Runtime Error):
n = input()
a = map(int,raw_input().split())
s = 0
m = a[0]
M = a[0]
for i in range(0,n):
    s += a[i]
    if m > a[i]:
        s = a[i]
    if M < a[i]
        M = a[i]
print m,M,s

Fixed submission:
n = int(input())
suretsu = list(map(int,input().split()))

wa = 0
minimum = suretsu[0]
maximum = suretsu[0]

for i in range(n):
    wa += suretsu[i]
    if suretsu[i] > maximum:
        maximum = suretsu[i]
    if suretsu[i] < minimum:
        minimum = suretsu[i]
    
print (minimum,maximum,wa)

Buggy python submission (verdict: Runtime Error):
n = input()
a = input().split()
s = 0
m = a[0]
M = a[0]
for i in range(0,n):
    s = s + a[i]
    if m > a[i]:
        m = a[i]
    if M < a[i]
        M = a[i]
print m,M,s

Fixed submission:
n = int(input())
suretsu = list(map(int,input().split()))

wa = 0
minimum = suretsu[0]
maximum = suretsu[0]

for i in range(n):
    wa += suretsu[i]
    if suretsu[i] > maximum:
        maximum = suretsu[i]
    if suretsu[i] < minimum:
        minimum = suretsu[i]
    
print (minimum,maximum,wa)

Buggy python submission (verdict: Runtime Error):
n = input()
a = input().split()
s = 0
m = a[0]
M = a[0]
for i in range(0,n):
    s = s + a[i]
    if m > a[i]:
        m = a[i]
    if M < a[i]:
        M = a[i]
print m,M,s

Fixed submission:
n = int(input())
suretsu = list(map(int,input().split()))

wa = 0
minimum = suretsu[0]
maximum = suretsu[0]

for i in range(n):
    wa += suretsu[i]
    if suretsu[i] > maximum:
        maximum = suretsu[i]
    if suretsu[i] < minimum:
        minimum = suretsu[i]
    
print (minimum,maximum,wa)
Buggy python submission (verdict: Runtime Error):
while True:
    x = input().split()
    H = x[0]
    W = x[1]
    if H == 0 and W == 0:
        break
    for i in range(0,H):
        print "#"*W

Fixed submission:
while True:
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    a = [["#" for j in range(W)] for i in range(H)]
    b = ["".join(a[i]) for i in range(H)]
    for i in range(H):
        print(b[i])
    print()

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

Fixed submission:
while True:
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    a = [["#" for j in range(W)] for i in range(H)]
    b = ["".join(a[i]) for i in range(H)]
    for i in range(H):
        print(b[i])
    print()
Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,raw_input().split())
h = H/2
hh = H%2
w = W/2
ww = W%2

while True:
    if H == 0 and W == 0:
        break
    for i in range(h):
        print "#."* w + "#"* ww
        print ".#"* w + "."* ww
    if hh == 1:
        print "#."* w + "#"* ww
    print""


         

Fixed submission:
while True:
    H,W = map(int,raw_input().split())
    if H == 0 and W == 0:
        break
    for i in range(0,H/2):
        print ("#."* (W/2) + "#"* (W%2))
        print (".#"* (W/2) + "."* (W%2))
    if H%2 == 1:
        print ("#."* (W/2) + "#"* (W%2))
    print""

Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,raw_input().split())
h = H/2
hh = H%2
w = W/2
ww = W%2

while True:
    if H == 0 and W == 0:
        break
    for i in range(h):
        print ("#."* w + "#"* ww)
        print (".#"* w + "."* ww)
    if hh == 1:
        print ("#."* w + "#"* ww)
    print""


         

Fixed submission:
while True:
    H,W = map(int,raw_input().split())
    if H == 0 and W == 0:
        break
    for i in range(0,H/2):
        print ("#."* (W/2) + "#"* (W%2))
        print (".#"* (W/2) + "."* (W%2))
    if H%2 == 1:
        print ("#."* (W/2) + "#"* (W%2))
    print""

Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,raw_input().split())

while True:
    if H == 0 and W == 0:
        break
    for i in range(0,H/2):
        print ("#."* (W/2) + "#"* (W%2))
        print (".#"* (W/2) + "."* (W%2))
    if H%2 == 1:
        print ("#."* (W/2) + "#"* (W%2))
    print""


         

Fixed submission:
while True:
    H,W = map(int,raw_input().split())
    if H == 0 and W == 0:
        break
    for i in range(0,H/2):
        print ("#."* (W/2) + "#"* (W%2))
        print (".#"* (W/2) + "."* (W%2))
    if H%2 == 1:
        print ("#."* (W/2) + "#"* (W%2))
    print""
Buggy python submission (verdict: Runtime Error):
n = input()
a = map(int,raw_input().split())
b = a.reverse()
print b.replace("[","").replace(","," ").replace("[","")

Fixed submission:
input()
print(" ".join(input().split()[::-1]))
Buggy python submission (verdict: Runtime Error):
n,m = map(int,raw_input().split())
A = [[0 for i in range(m)] for i in range(n)]
B = [ 0 for i in range(m)]


for i in range(n):
    A[i] = map(int,raw_input().split())
for i in range(m):
    B[i] = input()

for i in range(n):
    sum = 0
    for j in range(m):
        sum += A[i][j] * B[j] 
    print sum

Fixed submission:
while True:
    middle,semester,additional = map(int,raw_input().split())
    if middle == -1 and semester == -1 and additional == -1:
        break
    else:
        if middle == -1 or semester == -1 or middle + semester < 30:
            print("F")
        elif middle + semester >= 80:
            print("A")
        elif middle + semester >= 65:
            print("B")
        elif middle + semester >= 50:
            print("C")
        else:
            if additional >= 50:
                print("C")
            else:
                print("D")
Buggy python submission (verdict: Runtime Error):
r,c = map(int,raw_input().split())
matrix = [0 for i in range(r)]
for i in range(r):
    matrix[i] = map(int,raw_input().split())
    a = 0

    for j in range(c):
        a += matrix[i][j]
    matrix[i].append(a)
    for j in range(c+ 1):
        print matrix[i][j],

Fixed submission:
while True:
    n,x = map(int,raw_input().split())
    if n == 0 and x == 0:
        break
    num = 0

    for a in range(1,n-1):
        for b in range(a+1,n):
            for c in range(b+1,n+1):
                if a + b+ c == x:
                    num += 1
    print num