Problem:


How many ways?

  Write a program which identifies the number of combinations of three integers which satisfy the following conditions:

  
You should select three distinct integers from 1 to n.

  
A total sum of the three integers is x.

  For example, there are two combinations for n = 5 and x = 9.

1 + 3 + 5 = 9

2 + 3 + 4 = 9

Input

  The input consists of multiple datasets. For each dataset, two integers n and x are given in a line.

  The input ends with two zeros for n and x respectively. Your program should not process for these terminal symbols.

Constraints

  
3 ≤ n ≤ 100

  
0 ≤ x ≤ 300

Output

  For each dataset, print the number of combinations in a line.

Sample Input

5 9
0 0

Sample Output

2

Note

      解説      

	


Sample input:
5 9
0 0


Sample output:
2

Submission status: Wrong Answer

Solution code:
import sys

a = 0
m = sys.stdin.readlines()
for i in range(len(m)):
	n,x = map(int,m[i].split())
	if n+x!=0:
		for i in range(1,n+1):
			for j in range(1,n+1):
				if i!=j:
					for k in range(1,n+1):
						if i!=k and j!=k:
							if i+j+k!=x:
								a+=0
							else:
								a+=1
						else:
							break
				else:
					break
		print a
	elif n+x==0:
		break

Submission status: Wrong Answer

Solution code:
cnt=0
while True:
	n,x = map(int,input().split())
	if n == x == 0:
		break
	for a in range(1,x//3):
		for b in range(a+1,x//2):
			c=x-a-b
			if b<c<=n:
				cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys

p = sys.stdin.readlines()
q = []
r = 0
for i in p:
	n,x = map(int,i.split())
	if n==0 and x==0:
		break
	else:
		for a in range(1,n+1):
			for b in range(1,n+1):
				if a==b:
					break
				else:
					for c in range(1,n+1):
						if a==c or b==c:
							break
						elif a+b+c==x:
							r+=1
	print r

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

while True:
    n, x = map(int, raw_input().split())
    if n == x == 0:
        break
    count = 0
    for a in range(1, n/3+2):
        for b in range(a+1, 2*n/3+2):
            for c in range(b+1, n+1):
                if a+b+c == x:
                    count += 1
                    break
    print count

Submission status: Wrong Answer

Solution code:
import itertools
while 1:
    n,x=map(int,raw_input().split())
    if n==0 and x==0:
        break
    else:
        answer=0
        l=range(1,n+1)
        for ele in itertools.combinations(l,3):
            if sum(ele)==9:
                answer+=1
        print answer

Submission status: Wrong Answer

Solution code:
# 12-Structured_Program_II-How_many_ways.py

# ????????????????????°
# 1 ?????? n ?????§?????°?????????????????????????????§???????????°?????????????????????????¨???? x ??¨??????
# ????????????????????°????±???????????????°?????????????????????????????????
# ????????°???1 ?????? 5 ?????§?????°???????????????????????§????????????????¨???? 9 ??¨???????????????????????????

# 1 + 3 + 5 = 9
# 2 + 3 + 4 = 9
# ??????????????????????????????

# Input
# ?????°??????????????????????????\?????¨???????????????????????????
# ???????????????????????§??????????????§??????????????? n???x ??? 1 ???????????????????????????

# n???x ?????¨?????? 0 ?????¨?????\?????????????????¨????????????
# n ??? 3 ??\??? 100?????\?????¨????????????

# Output
# ????????????????????????????????????????????????????????°????????????????????????????????????

# Sample Input
# 5 9
# 0 0
# Sample Output
# 2

count=0
n,x=map( int,input().split() )

for n1 in range(1,n+1-2):
	for n2 in range(n1+1, n+1-1):
		for n3 in range(n2+1, n+1):
			sum = n1+n2+n3
			if sum == x:
				count+=1

print(count)

Submission status: Wrong Answer

Solution code:
# 12-Structured_Program_II-How_many_ways.py

# ????????????????????°
# 1 ?????? n ?????§?????°?????????????????????????????§???????????°?????????????????????????¨???? x ??¨??????
# ????????????????????°????±???????????????°?????????????????????????????????
# ????????°???1 ?????? 5 ?????§?????°???????????????????????§????????????????¨???? 9 ??¨???????????????????????????

# 1 + 3 + 5 = 9
# 2 + 3 + 4 = 9
# ??????????????????????????????

# Input
# ?????°??????????????????????????\?????¨???????????????????????????
# ???????????????????????§??????????????§??????????????? n???x ??? 1 ???????????????????????????

# n???x ?????¨?????? 0 ?????¨?????\?????????????????¨????????????
# n ??? 3 ??\??? 100?????\?????¨????????????

# Output
# ????????????????????????????????????????????????????????°????????????????????????????????????

# Sample Input
# 5 9
# 0 0
# Sample Output
# 2

result = []
n=[]
x=[]

while 1:
	temp = input().split() 
	if temp[0]=="0" and temp[1]=="0":
		break;
	else:
		n.append( int( temp[0] ))
		x.append( int( temp[1] ))

# for i in range( len(n) ):
# 	count =0
# 	for n1 in range(1,n[i]+1-2):
# 		for n2 in range(n1+1, n[i]+1-1):
# 			for n3 in range(n2+1, n[i]+1):
# 				sum = n1+n2+n3
# 				if sum == x[i]:
# 					count+=1
# 	result.append(count)

# for i in range( len(result)-1 ):
# 	print("{0} ".format(result[i]), end="")

# print(result[i+1])

Submission status: Wrong Answer

Solution code:
# 12-Structured_Program_II-How_many_ways.py

# ????????????????????°
# 1 ?????? n ?????§?????°?????????????????????????????§???????????°?????????????????????????¨???? x ??¨??????
# ????????????????????°????±???????????????°?????????????????????????????????
# ????????°???1 ?????? 5 ?????§?????°???????????????????????§????????????????¨???? 9 ??¨???????????????????????????

# 1 + 3 + 5 = 9
# 2 + 3 + 4 = 9
# ??????????????????????????????

# Input
# ?????°??????????????????????????\?????¨???????????????????????????
# ???????????????????????§??????????????§??????????????? n???x ??? 1 ???????????????????????????

# n???x ?????¨?????? 0 ?????¨?????\?????????????????¨????????????
# n ??? 3 ??\??? 100?????\?????¨????????????

# Output
# ????????????????????????????????????????????????????????°????????????????????????????????????

# Sample Input
# 5 9
# 0 0
# Sample Output
# 2

result = []
n=[]
x=[]

while 1:
	temp = input().split() 
	if temp[0]=="0" and temp[1]=="0":
		break;
	else:
		n.append( int( temp[0] ))
		x.append( int( temp[1] ))

for i in range( len(n) ):
	count =0
	for n1 in range(1,n[i]+1-2):
		for n2 in range(n1+1, n[i]+1-1):
			for n3 in range(n2+1, n[i]+1):
				sum = n1+n2+n3
				if sum == x[i]:
					count+=1
	result.append(count)

# for i in range( len(result)-1 ):
# 	print("{0} ".format(result[i]), end="")

# print(result[i+1])

Submission status: Wrong Answer

Solution code:
# 12-Structured_Program_II-How_many_ways.py

# ????????????????????°
# 1 ?????? n ?????§?????°?????????????????????????????§???????????°?????????????????????????¨???? x ??¨??????
# ????????????????????°????±???????????????°?????????????????????????????????
# ????????°???1 ?????? 5 ?????§?????°???????????????????????§????????????????¨???? 9 ??¨???????????????????????????

# 1 + 3 + 5 = 9
# 2 + 3 + 4 = 9
# ??????????????????????????????

# Input
# ?????°??????????????????????????\?????¨???????????????????????????
# ???????????????????????§??????????????§??????????????? n???x ??? 1 ???????????????????????????

# n???x ?????¨?????? 0 ?????¨?????\?????????????????¨????????????
# n ??? 3 ??\??? 100?????\?????¨????????????

# Output
# ????????????????????????????????????????????????????????°????????????????????????????????????

# Sample Input
# 5 9
# 0 0
# Sample Output
# 2

result = []
n=[]
x=[]

while 1:
	temp = input().split() 
	if temp[0]=="0" and temp[1]=="0":
		break;
	else:
		n.append( int( temp[0] ))
		x.append( int( temp[1] ))

for i in range( len(n) ):
	count =0
	for n1 in range(1,n[i]+1-2):
		for n2 in range(n1+1, n[i]+1-1):
			for n3 in range(n2+1, n[i]+1):
				sum = n1+n2+n3
				if sum == x[i]:
					count+=1
	result.append(count)

for i in range( len(result)-1 ):
	print("{0} ".format(result[i]), end="")

# print(result[i+1])

Submission status: Wrong Answer

Solution code:
# 12-Structured_Program_II-How_many_ways.py

# ????????????????????°
# 1 ?????? n ?????§?????°?????????????????????????????§???????????°?????????????????????????¨???? x ??¨??????
# ????????????????????°????±???????????????°?????????????????????????????????
# ????????°???1 ?????? 5 ?????§?????°???????????????????????§????????????????¨???? 9 ??¨???????????????????????????

# 1 + 3 + 5 = 9
# 2 + 3 + 4 = 9
# ??????????????????????????????

# Input
# ?????°??????????????????????????\?????¨???????????????????????????
# ???????????????????????§??????????????§??????????????? n???x ??? 1 ???????????????????????????

# n???x ?????¨?????? 0 ?????¨?????\?????????????????¨????????????
# n ??? 3 ??\??? 100?????\?????¨????????????

# Output
# ????????????????????????????????????????????????????????°????????????????????????????????????

# Sample Input
# 5 9
# 0 0
# Sample Output
# 2

result = []
n=[]
x=[]

while 1:
	temp = input().split() 
	if temp[0]=="0" and temp[1]=="0":
		break;
	else:
		n.append( int( temp[0] ))
		x.append( int( temp[1] ))

for i in range( len(n) ):
	count =0
	for n1 in range(1,n[i]+1-2):
		for n2 in range(n1+1, n[i]+1-1):
			for n3 in range(n2+1, n[i]+1):
				sum = n1+n2+n3
				if sum == x[i]:
					count+=1
	result.append(count)

for i in range( len(result) ):
	print("{0} ".format(result[i]), end="")
	if i == len(result)-1:
		print(result[i])

Submission status: Wrong Answer

Solution code:
# 12-Structured_Program_II-How_many_ways.py

# ????????????????????°
# 1 ?????? n ?????§?????°?????????????????????????????§???????????°?????????????????????????¨???? x ??¨??????
# ????????????????????°????±???????????????°?????????????????????????????????
# ????????°???1 ?????? 5 ?????§?????°???????????????????????§????????????????¨???? 9 ??¨???????????????????????????

# 1 + 3 + 5 = 9
# 2 + 3 + 4 = 9
# ??????????????????????????????

# Input
# ?????°??????????????????????????\?????¨???????????????????????????
# ???????????????????????§??????????????§??????????????? n???x ??? 1 ???????????????????????????

# n???x ?????¨?????? 0 ?????¨?????\?????????????????¨????????????
# n ??? 3 ??\??? 100?????\?????¨????????????

# Output
# ????????????????????????????????????????????????????????°????????????????????????????????????

# Sample Input
# 5 9
# 0 0
# Sample Output
# 2

result = []
n=[]
x=[]

while 1:
	temp = input().split() 
	if temp[0]=="0" and temp[1]=="0":
		break;
	else:
		n.append( int( temp[0] ))
		x.append( int( temp[1] ))

for i in range( len(n) ):
	count =0
	for n1 in range(1,n[i]+1-2):
		for n2 in range(n1+1, n[i]+1-1):
			for n3 in range(n2+1, n[i]+1):
				sum = n1+n2+n3
				if sum == x[i]:
					count+=1
	result.append(count)

print( len(result) ) 
for i in range( len(result) ):
	if i == len(result)-1:
		print(result[i])
	else:
		print("{0} ".format(result[i]), end="")

Submission status: Wrong Answer

Solution code:
# 12-Structured_Program_II-How_many_ways.py

# ????????????????????°
# 1 ?????? n ?????§?????°?????????????????????????????§???????????°?????????????????????????¨???? x ??¨??????
# ????????????????????°????±???????????????°?????????????????????????????????
# ????????°???1 ?????? 5 ?????§?????°???????????????????????§????????????????¨???? 9 ??¨???????????????????????????

# 1 + 3 + 5 = 9
# 2 + 3 + 4 = 9
# ??????????????????????????????

# Input
# ?????°??????????????????????????\?????¨???????????????????????????
# ???????????????????????§??????????????§??????????????? n???x ??? 1 ???????????????????????????

# n???x ?????¨?????? 0 ?????¨?????\?????????????????¨????????????
# n ??? 3 ??\??? 100?????\?????¨????????????

# Output
# ????????????????????????????????????????????????????????°????????????????????????????????????

# Sample Input
# 5 9
# 0 0
# Sample Output
# 2

result = []
n=[]
x=[]

while 1:
	temp = input().split() 
	if temp[0]=="0" and temp[1]=="0":
		break;
	else:
		n.append( int( temp[0] ))
		x.append( int( temp[1] ))

for i in range( len(n) ):
	count =0
	for n1 in range(1,n[i]+1-2):
		for n2 in range(n1+1, n[i]+1-1):
			for n3 in range(n2+1, n[i]+1):
				sum = n1+n2+n3
				if sum == x[i]:
					count+=1
	result.append(count)

for i in range( len(result) ):
	if i == len(result)-1:
		print(result[i])
	else:
		print("{0} ".format(result[i]), end="")

Submission status: Wrong Answer

Solution code:
# 13-Structured_Program_II-Spreadsheet.py

# ??¨?¨????
# ??¨?¨??????????????°???????????????°???????????????????????????
# ??¨????????°r??¨?????°c???r ?? c ???????´????????????¨?????????????????§???
# ????????¨??????????¨?????????\????????°????????¨???????????????????????°?????????????????????????????????

# Input
# ???????????????r??¨c????????????????????§?????????????????????
# ?¶????r??????????????????c????????´??°????????????????????§?????????????????????

# Output
# (r+1) ?? (c+1) ?????°????????¨???????????????????????????
# ???????????£???????????´??°????????????????????§????????£??????????????????????????????????????¨??????????????????????¨?????????????????????????????????¨??????????????????????¨?????????????????????????????????¨??¨??????????¨????????????\??????????????????

# Constraints
# 1 ??? r, c ??? 100
# 0 ??? ????´? ??? 100
# Sample Input
# 4 5
# 1 1 3 4 5
# 2 2 2 4 5
# 3 3 0 1 1
# 2 3 4 4 6
# Sample Output
# 1 1 3 4 5 14
# 2 2 2 4 5 15
# 3 3 0 1 1 8
# 2 3 4 4 6 19
# 8 9 9 13 17 56

# ??? Aizu??§numpy ??????????????£??????
#---------------------------------------------------------------
# import numpy as np

# r,c = map( int,input().split() )

# data = np.zeros((r,c))

# for i in range(r):
# 	data[i] = np.array( input().split() )

# data=data.astype("int")
# print("data",data)

# for i in range( r ):
# 	for j in range(c):
# 		print("{0} ".format(data[i][j]), end="")
# 	print( np.sum(data[i]) )

# for j in range(c):
# 	print("{0} ".format( np.sum(data, axis=0)[j] ), end="" )

# print( np.sum(data) )
#---------------------------------------------------------------


r,c = map( int,input().split() )

data = []
csum = [0]*c

# for i in range(r):
# 	data.append(  list(map( int,input().split() ))  )

# print(data)

# for i in range( r ):
# 	for j in range(c):
# 		print("{0} ".format(data[i][j]), end="")
# 		csum[j] +=data[i][j]
# 	print( sum(data[i]) )

# for j in range(c):
# 	print("{0} ".format( csum[j] ), end="" )

# print( sum(csum) )

Submission status: Wrong Answer

Solution code:
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
    result = 0
    for a in range(1, x // 3):
        for b in range(a + 1, x // 2):
            c = x - a - b
            if b < c <= n:
                result += 1
        print(result)

Submission status: Wrong Answer

Solution code:
c=0

while 1:
	n,x=map(int,raw_input().split())
	if(n==0 and x==0):
		break
	for i in range(1,n+1):
		for j in range(i+1,n+1):
			for k in range(j+1,n+1):
				if(i+j+k==x):
					c+=1
print c

Submission status: Wrong Answer

Solution code:
c=0

while 1:
	n,x=map(int,raw_input().split())
	if(n==0 and x==0):
		break
	for i in range(1,n+1):
		for j in range(i+1,n+1):
			for k in range(j+1,n+1):
				if(i+j+k==x):
					c+=1
	print c

Submission status: Wrong Answer

Solution code:
y=map(int,raw_input().split(" "))
kizyun=y[0]
final=y[1]
ct=0

a=kizyun+1
b=0
c=0
while True:
	a-=1
	target=final-a
	#60    100   40
	if a+a+a<final:
		print ct
		break
#target wo bc de


	b=target-1
	c=1
	while b>c:
		if a>b>c:
			ct+=1
		else:
			pass
		b-=1
		c+=1

Submission status: Wrong Answer

Solution code:
k=map(int,raw_input().split(" "))
ct=0
a=0
b=0
c=0

max=k[0]
sum=k[1]
a=max+1

while True:
#a=40,39,38...
	a-=1
	b=a-1
	c=sum-a-b
	if not a>b>c:
		print ct
		break
	while a>b>c:
		if a>b>c>0:
			ct+=1
		b-=1
		c+=1

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
while True:
    n,x = [int(i) for i in input().split(' ')]
    count=0
    if n+x ==0:
        break
    for i in range(n):
        for j in range(n):
            for k in range(n):
                if i + j + k == x:
                    count +=1
    print(count)
    count=0

Submission status: Wrong Answer

Solution code:

i=0
while(True):
    a=list(map(int,input().split()))
    if(a[0]==0 and a[1]==0):
        break
    for x in range(2,a[0]):
        sum=a[1]-x
        for y in range(2,x):
            if (sum-y<a[0]):
                i+=1
    print(i)

Submission status: Wrong Answer

Solution code:
i=0
while(True):
    a=list(map(int,input().split()))
    if(a[0]==0 and a[1]==0):
        break
    for x in range(2,a[0]):
        sum=a[1]-x
        for y in range(1,x):
            if (sum-y<a[0]+1 and sum-y>x):
                i+=1
    print(i)

Submission status: Wrong Answer

Solution code:

while(True):
    i=0
    a=list(map(int,input().split()))
    if(a[0]==0 and a[1]==0):
        break
    for x in range(2,a[0]):
        sum=a[1]-x
        for y in range(1,x):
            if (sum-y<a[0]+1 and sum-y>x):
                print ("x:"+str(x)+",y:"+str(y)+",sum:"+str(sum))
                i+=1
    print(i)

Submission status: Wrong Answer

Solution code:
def solve(n,x):
    count = 0
    for i in range(1,n+1):
        for j in range(1,n+1):
            if i == j :
                continue
            for k in range(1,n+1):
                if j == k or i == k:
                    continue
                if i+j+k == x:
                    print(i,j,k)
                    count += 1
    return count//6

while True:
    n,x = map(int,input().split())
    if n == x == 0:
        break;
    print(solve(n,x))

Submission status: Wrong Answer

Solution code:
import itertools
while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0:
        break
    print([1 if sum(nums) == x else 0 for nums in itertools.combinations(range(1, n + 1), 3)])

Submission status: Wrong Answer

Solution code:
import itertools
while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0:
        break
    print([1 if sum(i) == x else 0 for i in itertools.combinations(range(1, n + 1), 3)])

Submission status: Wrong Answer

Solution code:
while True:
    n, x = [int(i) for i in input().split()]

    if n == x == 0:
        break
    
    count = 0
    for s in range(1, n // 2 + 1):
        for e in range(n, n // 2 + 1, -1):
            m = x - s - e
            if m != s and m != e and m <= n:
                count += 1

    print(count)

Submission status: Wrong Answer

Solution code:
while True:
    n, x = [int(i) for i in input().split()]

    if n == x == 0:
        break

count = 0
for s in range(1, n// 2 + 1):
    for e in range(n, n // 2, -1):
        m = x - s - e
        if m != s and e != e and m <= n:
            count += 1

print(count)

Submission status: Wrong Answer

Solution code:
while True:
    n, x = [int(i) for i in input().split()]

    if n == x == 0:
        break

    count = 0
    for s in range(1, n // 2 + 1):
        for e in range(n, n // 2, -1):
            m = x - s - e
            if m != s and m != e and m > s and m < e and m <= n:
                print(s, m, e)
                count += 1

    print(count)

Submission status: Wrong Answer

Solution code:
n, x = [int(i) for i in input().split()]

count = 0
for s in range(1, n // 2 + 1):
    for e in range(n, n // 2, -1):
        m = x - s - e
        if m != s and m != e and m > e and m  <= n:
            print(s, m, e)
            count += 1

    print(count)

Submission status: Wrong Answer

Solution code:
while True:
    n, x = [int(i) for i in input().split()]

    if n == x == 0:
        break
    count = 0
    for s in range(1, n // 2 + 1):
        for e in range(1, n // 2 + 1):
            m = x - s - e
            if m  != s and m != e and m > s and m < e and m <= n:
                count += 1
    print(count)

Submission status: Wrong Answer

Solution code:
while True:
    n,x = [int(i) for i in input().split()]
    if n == x == 0:
        break
    count = 0
    for s in range(1, n//2+1):
        for e in range(n, n//2, -1):
            m = x - s -e
            if m != s and m != e and m > s and m < e and m <= n:
                count += 1

    print(count)

Submission status: Wrong Answer

Solution code:
while True:
    n, x = [int(i) for i in input().split()]

    if n == x == 0:
        break

    count = 0
    for s in range(1, n// 2 + 1):
        for e in range(n, n // 2, -1):
            m = x - s - e
            if m != s and e != e and m > s and m < e and m <= n:
                print(s, m, e)
                count += 1

    print(count)

Submission status: Wrong Answer

Solution code:
while True:
    n, x = [int(i) for i in input().split()]

    if n == x == 0:
        break

    count = 0
    for s in range(1, n // 2 + 1):
        for e in range(n, n // 2 + 1, -1):
            m = x - s - e
            if m != s and m != e and m > s and m < e and m <= n:
                count += 1

    print(count)

Submission status: Wrong Answer

Solution code:
while True:
    n, x = [int(i) for i in input().split()]

    if n == x == 0:
        break

    count = 0
    for s in range(1, n // 2 + 1):
        for e in range(n, n // 2, -1):
            m = x - s - e
            if m != s and m != e and m > s and m < e and m <= n:
                count += 1

    print(count)

Submission status: Wrong Answer

Solution code:
while True:
    n, x = [int(i) for i in input().split()]

    if n == x == 0:
        break

    count = 0
    for s in range(1, n// 2 + 1):
        for e in range(n, n // 2, -1):
            m = x - s - e
            if m != s and e != e and m < m < e and m < e and m <= n:
                print(s, m, e)
                count += 1

    print(count)

Submission status: Wrong Answer

Solution code:
while True:
    n, x = [int(i) for i in input().split()]

    if n == x == 0:
        break

    count = 0
    for s in range(1, n // 2 + 1):
        for e in range(n, n // 2, -1):
            m = x - s - e
            if m != s and m != e and m > s and m < e and m <= n:
                count += 1
                
    print(count)

Submission status: Wrong Answer

Solution code:
while True:
    n,x = [int(i) for i in input().split()]
    if n == x == 0:
        break
    count = 0
    for s in range(1, n//2+1):
        for e in range(n, n//2, -1):
            m = x - s -e
            if m != s and m != e and m > s and m < e and m < n:
                count += 1

    print(count)

Submission status: Wrong Answer

Solution code:
while True:
    n,x = [int(i) for i in input().split()]
    if n == x == 0:
        break
    count = 0
    for s in range(1, n//2+1):
        for e in range(n, n//2 -1):
            m = x - s -e
            if m != s and m != e and m > s and m < e and m <= n:
                count += 1

    print(count)

Submission status: Wrong Answer

Solution code:
while True:
    n, x = [int(i) for i in input().split()]

    if n == x == 0:
        break

    count = 0
    for s in range(1, n // 2):
        for e in range(n, n // 2, -1):
            m = x - s - e
            if m != s and m != e and m > s and m < e and m <= n:
                count += 1

    print(count)

Submission status: Wrong Answer

Solution code:
while True:
    n, x = [int(i) for i in input().split()]

    if n == x == 0:
        break

    count = 0
    for s in range(1, n // 2 + 1):
        for e in range(n, n // 2, -1):
            m = x - s - e
            if m != s and m != e and m > s and m < e and m <= n:
                count -= 1
                
    print(count)

Submission status: Wrong Answer

Solution code:
while True:
    n, x = [int(i) for i in input().split()]


    if n == x == 0:
        break

    count = 0
    for s in range(1, n - 1):
        for m in range(s+1, n):
            for e in range(m+1, n+1):
                if n < x:
                    break
                if x == sum([s, m, e]):
                    count += 1

    print(count)

Submission status: Wrong Answer

Solution code:
while True:
    n, x = [int(i) for i in input().split()]


    if n == x == 0:
        break

    count = 0
    for s in range(1, n - 1):
        for m in range(s+1, n):
            for e in range(m+1, n+1):
                if n > x:
                    break
                if x == sum([s, m, e]):
                    count += 1

    print(count)

Submission status: Wrong Answer

Solution code:
count = 0
while True:
    x, y= [int(i) for i in input().split()]
    if x == 0 and y ==0:
        break
    else:
        for k in range(1,x-1):
            for h in range(k+1,x):
                for g in range(h+1,x+1):
                    if k + h + g == y:
                        count = count + 1
print(count)

Submission status: Wrong Answer

Solution code:
while True:
	n,m = map(int, input().split())
	if n == 0 and m == 0:
		break
	cnt = 0
	
	for i in range(1, n+1):
		for j in range(i+1, n+1):
			for k in range(j+1, n+1):
				if i + j + k == m:
					cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
while True:
    n,x=[int(x) for x in input().split()]
    if [n,x]==[0,0]:
        break
    count=0
    if 3*(n-1)>=x:
        a_max=x//3-1
        if 2*n-1<x:
            a_min=x-(2*n-1)
        else:
            a_min=1
        for a in range(a_min,a_max+1):
            b_max=(x-a-1)//2
            b_min=(x-a)-n
            b_min=b_min if b_min>a+1 else a+1
            count+=b_max-b_min+1
print(count)

Submission status: Wrong Answer

Solution code:
while True:
    a = input().split(' ')
    if a[0] and a[1] == '0':
        break
    b = 0
    s = []
    c = [number+1 for number in range(int(a[0]))]
    for i in c:
        for e in c:
            for f in c:
                if i + e + f == int(a[1]) and not (i*e*f in s):
                    if not (i==e or e==f or f==i):
                        s.append(i*e*f)
                        b += 1
    print(b)

Submission status: Wrong Answer

Solution code:
def func(x, y):
    temp = 0
    for i in range(x-1, x/2, -1):
        if i < y and x-i >0:
            temp += 1
    return temp

while(1):
    ans = 0
    n, x = map(int, raw_input().split())
    if n == 0 and x == 0:
        break
    else:
        for i in range(n, n/2, -1):
            if x-i < 3:
                ans = 0
            else:
                ans += func(x-i, i)
    print ans

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import itertools

while True:
 n, x = map(int, raw_input().split())
 if n==0 and x==0: break
 count = 0
 for a, b, c in itertools.combinations(range(1, n+1), 3):
  if a+b+c==x:
   count += 1
   print "a, b, c = {0}, {1}, {2}".format(a, b, c)
 print count

Submission status: Wrong Answer

Solution code:
while 1:
 n, x = map(int, input().split())
 if n == 0 and x == 0:
  break
 counter = 0
 for a in range(1, n+1):
  for b in range(1, n-1):
   for c in range(1, n-2):
    if a+b+c == x:
     counter += 1
 print(counter)

Submission status: Wrong Answer

Solution code:
while 1:
 n, x = map(int, input().split())
 if n == 0 and x == 0:
  break
 counter = 0
 for a in range(3, n+1):
  for b in range(2, n-1):
   if b >= a:
    break
   for c in range(1, n-2):
    if c >= b:
     break
    if (a+b+c) == 0: 
     counter += 1
     break
 print(counter)

Submission status: Wrong Answer

Solution code:
while 1:
 n, x = map(int, input().split())
 if n == 0 and x == 0:
  break
 counter = 0
 for a in range(3, n+1):
  for b in range(2, n-1):
   if b >= a:
    break
   for c in range(1, n-2):
    if c >= b:
     break
    if (a+b+c) == x: 
     counter += 1
     break
 print(counter)

Submission status: Wrong Answer

Solution code:
while 1:
 n, x = map(int, input().split())
 counter = 0
 if n == 0 and x == 0:
  break
 # y + (y-1) + (y-2) = x 
 y = (x+3) // 3
 for a in range(y, n+1):
  for b in range(y-1, n):
   if b >= a:
    break
   if (x-a-b) in list(range(1, b)):
   	counter += 1
 print(counter)

Submission status: Wrong Answer

Solution code:
while 1:
 n, x = map(int, input().split())
 counter = 0
 if n == 0 and x == 0:
  break
 # y + (y-1) + (y-2) = x 
 y = (x+3) // 3
 for a in range(y, n+1):
  for b in range(y-1, n):
   if b >= a:
    break
   counter += 1
 print(counter)

Submission status: Wrong Answer

Solution code:
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
    count = 0
    for i in range(1,n):
        for j in range(1,n):
            for k in range(1,n):
                if i+j+k ==x:
                    count += 1
    print(count)

Submission status: Wrong Answer

Solution code:
def get_num(n, m):
    ans = 0
    for x in range(n, 2, -1):
        if m - x < 3:
            return 0
        if 3 * x - 2 < m:
            return ans
        for y in range(x - 1, 1, -1):
            if x + 2 * y - 1 < m:
                break
            for z in range(y - 1, 0, -1):
                s = x + y + z
                if s == m:
                    ans += 1
                    break
    return ans


while True:
    [n, m] = [int(x) for x in raw_input().split()]
    if [n, m] == [0, 0]:
        break
    print(get_num(n, m))

Submission status: Wrong Answer

Solution code:
def get_num(n, m):
    ans = 0
    for x in range(min(n, m), (m + 2) / 3, -1):
        for y in range(x - 1, (m - x + 1) / 2, -1):
            if x + 2 * y - 1 < m:
                break
            for z in range(y - 1, 0, -1):
                s = x + y + z
                if s == m:
                    ans += 1
                    break
    return ans


while True:
    [n, x] = [int(m) for m in raw_input().split()]
    if [n, x] == [0, 0]:
        break
    print(get_num(n, x))

Submission status: Wrong Answer

Solution code:
while True:
    n, x = map(int, input().split())
    if (n, x) == (0, 0): break
    ans = []
    end_point = (n//2)+1
    for i in (n, end_point, -1):
        for j in range(1, end_point):
            tmp = x-(j+i)
            if tmp > 0 and i > 0 and j > 0:
                if tmp != j and tmp != i:
                    pmt = sorted([i, j, tmp])
                    if not pmt in ans: ans.append(pmt)
    print(len(ans))

Submission status: Wrong Answer

Solution code:
while True:
    n, x = map(int, input().split())
    if (n, x) == (0, 0): break
    ans = []
    for i in range(n, 1, -1):
        for j in range(1, n):
            tmp = x-(j+i)
            if tmp > 0 and i > 0 and j > 0:
                if tmp != j and tmp != i and i != j:
                    pmt = sorted([i, j, tmp])
                    if not pmt in ans: ans.append(pmt)
    print(len(ans))

Submission status: Wrong Answer

Solution code:
num_list = []
while True:
    values = [int(x) for x in input().split()]
    if 0 == values[0] and 0 == values[1]:
        break
    num_list.append(values)

for n, t in num_list:
    ret = ''.join(str(x + y + z) for x in range(1, n + 1) for y in range(x + 1, n + 1) for z in range(y + 1, n + 1))
    print(ret.count(str(t)))

Submission status: Wrong Answer

Solution code:
c = 0
while True:
    n,x = map(int, input().split())
    if n == 0 and x == 0:
        break
    for i in range(1, n//3+2):
        for j in range(i+1, n+1):
            if x-i-j > n:
                continue
            c += 1
            break
print(c)

Submission status: Wrong Answer

Solution code:
while(True):
	a,b=list(map(int,input().split()))
	if a==0 and b==0:
		break
	c=0
	for i in range(a):
		for j in range(i):
			for k in range(j):
				if i+j+k==b:
					c+=1
	print(c)

Submission status: Wrong Answer

Solution code:
n, x = map(int, input().split())
li = []
for i in range(1,x//3):
    y = x - i
    li.append((y-1)//2 - max(i, y-n-1))
print(sum([comb for comb in li if comb > 0]))

Submission status: Wrong Answer

Solution code:
c = 0
while True:
    [n,x] = map(int,input().split())
    if n==0 and x==0: break
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i+j+k == x:
                    c += 1
    print(c)