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:
while True :
    n, x = map(int, input().split())
    if (n == x == 0) :
        break

    count = 0
    for a in range(1, n, 1) :
        for b in range((a+1), n, 1) :
            for c in range((b+1), n, 1) :
                Sum = a + b + c
                if (Sum == x) :
                    count += 1
    print(count)

Submission status: Wrong Answer

Solution code:
while True :
    n, x = map(int, input().split())
    if (n == x == 0) :
        break

    count = 0
    for a in range(1, (x // 3), 1) :
        for b in range((a+1), (x // 2), 1) :
            for c in range((b+1), x, 1) :
                Sum = a + b + c
                if (Sum == x) :
                    count += 1
    print(count)

Submission status: Wrong Answer

Solution code:
while True :
    n, x = map(int, input().split())
    if (n == x == 0) :
        break

    count = 0
    for a in range(1, (x // 3), 1) :
        for b in range((a+1), (x // 2), 1) :
            for c in range((b+1), n, 1) :
                Sum = a + b + c
                if (Sum == x) :
                    count += 1
    print(count)

Submission status: Wrong Answer

Solution code:
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break

    count = 0
    for a in range(1, (x // 3), 1):
        for b in range((a+1), (x // 2), 1):
            for c in range((b+1), n, 1):
                Sum = a + b + c
                if Sum == x:
                    count += 1
    print(count)

Submission status: Wrong Answer

Solution code:
while True :
    n, x = map(int, input().split())
    if (n == x == 0) :
        break

    count = 0
    for a in range(1, (x // 3)) :
        for b in range((a+1), (x // 2)) :
            for c in range((b+1), n) :
                Sum = a + b + c
                if (Sum == x) :
                    count += 1
    print(count)

Submission status: Wrong Answer

Solution code:
while True :
    n, x = map(int, input().split())
    if (n == x == 0) :
        break

    count = 0
    for a in range(1, x // 3) :
        for b in range(a + 1, x // 2) :
            for c in range(b + 1, n) :
                Sum = a + b + c
                if (Sum == x) :
                    count += 1
    print(count)

Submission status: Wrong Answer

Solution code:
while True :
    n, x = map(int, input().split())
    if (n == x == 0) :
        break

    count = 0
    for a in range(1, n) :
        for b in range(a + 1, n) :
            for c in range(b + 1, n) :
                Sum = a + b + c
                if (Sum == x) :
                    count += 1
    print(count)

Submission status: Wrong Answer

Solution code:
import math
while True:
    n,x=list(map(int,input().split()))
    if n==x==0: break
    c=0
    for i in range(1,x//3):
        if i>n: break
        for j in range(i+1,x//3+1):
            if j>n: break
            k=x-i-j
            if not (n<k or k<=i):
                c+=1
    print(c)

Submission status: Wrong Answer

Solution code:
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break

    c = 0
    for i in range(1, x-n):
        for j in range(i+1, x-n):
            for k in range(j+1, x):
                if k > n:
                    break
                elif i + j + k == x:
                    c += 1
                    break
                elif i + j + k > x:
                    break
    print(c)

Submission status: Wrong Answer

Solution code:
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break

    c = 0
    for i in range(1, int(x/3)+1):
        for j in range(i+1, int(x/2)+1):
            k = x - i - j
            if k <= j or k > n:
                break
            else:
                c += 1
    print(c)

Submission status: Wrong Answer

Solution code:
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break

    c = 0
    for i in range(1, int(x/3)+2):
        for j in range(i+1, int(x/2)+2):
            k = x - i - j
            print('',i,j,k)
            if k <= j:
                break
            elif k <= n:
                c += 1
    print(c)

Submission status: Wrong Answer

Solution code:
a=[]
w=""
while(w!="0 0"):
    w=input()
    a.append(w)
a.pop()
for st in a:
    s=st.split()
    n=int(s[0])
    x=int(s[1])
    count=0
    for a in range(1,x//3+1):
        for b in range(a+1,(x-a)//2+1):
            if (x-a-b)<=n and b<(x-a-b):
                count+=1
                print("{0} {1} {2}".format(a,b,x-a-b))
    print("{0}".format(count))

Submission status: Wrong Answer

Solution code:
while 1:
 n,x=map(int,input().split())
 if n+x==0:break
 print(len([1 for i in range(1,n-2)for j in range(i+1,n)if j<x-i-j<=n]))

Submission status: Wrong Answer

Solution code:
while 1:
 n,x=map(int,input().split())
 if n+x==0:break
 print(sum([(x-a-1)//2-max(a,x-a-1-n)for a in range(1,x//3)]))

Submission status: Wrong Answer

Solution code:
while True:
    n, x = map(int, input().split())

    if(n == 0 and x == 0):
        break

    ot = 0
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            for k in range(j + 1, n + 1):
                print(i, j, k)
                if i + j + k == x:
                    ot += 1

    print(ot)

Submission status: Wrong Answer

Solution code:
while True:
    n, x = map(int, input().split())
    a = list(range(1, n + 1))
    ans=0
    n1=1
    n2=2
    if n == 0 and x == 0:
        break
    elif  a[-1] + a[-2] + a[-3] < x:
        ans=0
    for i in range(n-3):
        n2=n1+1
        for u in range(n-2):
            n3=x-n1-n2
            if n2<n3<=n:
                ans+=1
            n2+=1
        n1+=1
    print(ans)

Submission status: Wrong Answer

Solution code:
while True:
    n, x = map(int, input().split())
    a = list(range(1, n + 1))
    ans=0
    n1=1
    n2=2
    if n == 0 and x == 0:
        break
    elif  a[-1] + a[-2] + a[-3] < x:
        ans=0
    for i in range(n-3):
        n2=n1+1
        for u in range(n-2):
            n3=x-n1-n2
            if n2<n3<=n:
                ans+=1
            n2+=1
        n1+=1
    print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import combinations as comb

def get_ans():
	m, n = (int(x) for x in input().split())
	if m==0 and n==0:
		quit()
	ans = 0
	for nums in comb(list(range(1, min(m,n-3))), 3):
		if sum(nums) == n:
			ans += 1
	print(ans)
	
while True:
	get_ans()

Submission status: Wrong Answer

Solution code:
from itertools import combinations as comb
def get_ans(m, n):
	ans = 0
	for nums in comb(list(range(1, min(m+1,n-2))), 3):
		print(nums)
		if sum(nums) == n:
			ans += 1
	print(ans)
	
while True:
	m, n = (int(x) for x in input().split())
	if m==0 and n==0:
		quit()
	get_ans(m, n)

Submission status: Wrong Answer

Solution code:
while True:
  (n, x) = input().rstrip('\r\n').split(' ')
  n = int(n)
  x = int(x)

  if n == 0 and x == 0:
    break

  a = []
  for ii in range(n):
    a.append(ii + 1)

  c = 0
  for ii in range(len(a)):
    for jj in range(ii + 1, len(a)):
      for kk in range(jj + 1, len(a)):
        if a[ii] + a[jj] + a[kk] == x:
          c += 1
print(c)

Submission status: Wrong Answer

Solution code:
from itertools import combinations as comb
def get_ans(m, n):
    ans = sum(1 for nums in comb(list(range(1, min(m+1,n-2))), 3) if sum(nums)==n)
    return ans
     
while True:
    m, n = (int(x) for x in input().split())
    if m==0 and n==0:
        quit()
    ans = get_ans(m, n)
    print(abs)

Submission status: Wrong Answer

Solution code:
from itertools import combinations

inputs = []
n,x = map(int,input().split())
while n != 0 or x != 0:
     inputs.append((n,x))
     n,x = map(int,input().split())

result = 0
for n,x in inputs:
    result += len([c for c in combinations(range(1,n+1),3) if sum(c) == x])

print(result)

Submission status: Wrong Answer

Solution code:
def countCombinations(n, x, size=3):
    dp = [[0 for i in range(size + 1)] for j in range(x + 1)]
    dp[0][0] = 1
    for i in range(1, n + 1):
        for j in range(x + 1 - i):
            for k in range(size + 1 - 1):
                dp[i+j][1+k] += dp[j][k]
    return dp[-1][-1]


while True:
    m, n = (int(x) for x in input().split())
    if m==0 and n==0:
        quit()
    ans = countCombinations(m, n)
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
while True:
    n,x = map(int,input().split())
    if n == x == 0:
        break

    c = 0
    for i in range(math.ceil(x/3), x-3):
        for j in range(math.ceil(i/2), i):
            k = i - j
            if x == i + j + k:
                #print(x, i, j, k)
                c += 1
    print(c)

Submission status: Wrong Answer

Solution code:
NX=input().split()
n=int(NX[0])
x=int(NX[1])

answer=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==x:
                answer+=1
            else:
                pass

print(answer)

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,n+1):
        for b in range(a+1,n+1):
            for c in range(b+1,n+1):
                cnt += 1 if a+b+c==x else 0
    print(cnt)

Submission status: Wrong Answer

Solution code:
n, x = map(int, input().split())

while n != 0 or x != 0:
	cnt = 0
	i = 1
	while i <= x - 2:
		j = i + 1
		if i >= n:
			break
		while j <= x - 1:
			k = j + 1
			if i + j >= n:
				break
			while k <= x:
				if i + j + k > n:
					break
				if i + j + k == n:
					cnt += 1
				k += 1
			j += 1
		i += 1
	print(cnt)
	n, x = map(int, input().split())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
num,pat,sum=[],[],[]
i=int(0)
N=int(0)
while 1:
    num=list(map(int,input().split(' ')))
    pat.append(num[0])
    sum.append(num[1])
    if(pat[i]==0 and sum[i]==0):
        break
    i=i+1
    N=N+1
i=0
s=0
while(i<N):
    for k in range(1,pat[i]+1):
        for l in range(k+1,pat[i]+1):
            for m in range(l+1,pat[i]+1):
                if(sum[i]==k+l+m):
                    s=s+1
    print(s)
    i=i+1

Submission status: Wrong Answer

Solution code:
n = []
x = []
sum = []
while(True):
    N,X = map(int,input().split())
    if N ==0 and X == 0:
        break
    else:
        n.append(N)
        x.append(X)
for l in range(len(n)):
    for i in range(1,n[l]+1):
        for j in range(1,n[l]+1):
            for k in range(1,n[l]+1):
                if i==j or j==k or i==k:break
                sum.append(i+j+k)
    print(int(sum.count(x[l])/2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
x,n = tuple(int(i) for i in input().split())
r = 0

def transnum(int: n):
    if n % 3 != 0:
        return n + 3 - n % 3
    else:
        return n

amin = n // 3 + 1
amax = 2 * transnum(n) // 3
if amax > x:
    amax = x

A = [j for j in range(amin, amax+1)]

#print(A)

for a in A:
    bmin = (n-a) // 3 + 1
    bmax = 2 * transnum(n-a) // 3
    if bmax > a:
        bmax = a

    B = [j for j in range(bmin, bmax) if j+j != n-a]
    #print(B)
    for b in B:
        cmin = (n-a-b) // 3 + 1
        cmax = 2 * transnum(n-a-b) // 3
        if cmax > b:
            cmax = b
        C = [k for k in range(cmin, cmax) if k == n-a-b]
        #print(C)
        r += len(C)
        C.clear()
    B.clear()
    
print(r)

Submission status: Wrong Answer

Solution code:
while True:
    n, x = map(int, input().split())

    if n == 0 and x == 0:
        break
    count = 0
    for i in range(1, n):
        for j in range(2, n):
            for k in range(3, n):
                if x == i + j + k:
                    count += 1
    print(count//3)

Submission status: Wrong Answer

Solution code:
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    s = set([])
    for i in range(1, n+1):
        if i > n//3:
            break 
        for j in range(1, n+1):
            if i == j:
                continue
            for k in range(1, n+1):
                if k == j or k == i:
                    continue
                if x == i + j + k:
                    s.add((i, j, k))
    print(len(s))

Submission status: Wrong Answer

Solution code:
while True :
    num = 0
    n,x = map(int,input().split())
    if(n==0 and x==0): break
    for i in range (n) :
        s = x - n - i
        if(i<s<x):
            num += 1
    print(num)

Submission status: Wrong Answer

Solution code:
while True :
    num = 0
    n,x = map(int,input().split())
    if(n==0 and x==0): break
    for i in range (1,n) :
        for j in range(1,i):
            s = x - j - i
            if(j<i and i<s):
                num += 1
    print(num)

Submission status: Wrong Answer

Solution code:
while True:
	n,x = map(int,input().split())
	if (n*x == 0):
		break
	sum =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 == x:
					sum+=1
	print(sum)

Submission status: Wrong Answer

Solution code:
B=[]
q=0
while True:
    l=input().split()
    n=int(l[0])
    x=int(l[1])
    if n==0 and x==0:
        break
    else:
        a=list(range(1,n+1))
        b=0
        for i in a:
            for p in a:
                for m in a:
                    if i+p+m==x and i!=p and p!=m and m!=i:
                        b+=1
                    else:
                        pass
        B.append(int(b/6))
        q+=1
v=1
Ans=str(B[0])
while v<q:
    Ans=Ans+" "+str(B[v])
    v+=1
print(Ans)

Submission status: Wrong Answer

Solution code:
# AOJ ITP1_7_B

def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    while True:
        a = numinput()
        n = a[0]; x = a[1]
        if n == 0 and x == 0: break
        # 1からnまでの異なる3つの数の和がxになる数の組の個数。
        count = 0
        for i in range(1, n + 1):
            for j in range(i + 1, (x // 3) + 1):
                if j < x - i - j: count += 1
        if i > (x // 3): break
        print(count)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# AOJ ITP1_7_B

def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    while True:
        a = numinput()
        n = a[0]; x = a[1]
        if n == 0 and x == 0: break
        # 1からnまでの異なる3つの数の和がxになる数の組の個数。
        count = 0
        for i in range(1, (x // 3) + 1):
            for j in range(i + 1, (x // 3) + 1):
                if j < x - i - j <= n: count += 1
        if i > (n // 3): break
        print(count)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# AOJ ITP1_7_B

def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    while True:
        a = numinput()
        n = a[0]; x = a[1]
        if n == 0 and x == 0: break
        # 1からnまでの異なる3つの数の和がxになる数の組の個数。
        count = 0
        for i in range(1, (x // 3) + 1):
            for j in range(i + 1, (x // 3) + 1):
                if j < x - i - j <= n: count += 1
            if i > (n // 3): break
        print(count)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# AOJ ITP1_7_B

def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    while True:
        a = numinput()
        n = a[0]; x = a[1]
        if n == 0 and x == 0: break
        # 1からnまでの異なる3つの数の和がxになる数の組の個数。
        count = 0
        for i in range(1, (x // 3) + 1):
            for j in range(i + 1, (x // 3) + 1):
                if j < x - i - j <= n: count += 1
        print(count)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
while True:
    n, x = map(int,input().split())
    if(n==0, x==0):
        break
    nlist = []
    for i in range(1,n+1):
        nlist.append(i)
    count = 0
    for i1 in range(n-2):
        for i2 in range(i1+1,n-1):
            for i3 in range(i2+1,n):
                y = nlist[i1]+nlist[i2]+nlist[i3]
                if(y == x):
                    count += 1
    print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
while 1:
        p=0
        e=map(int,raw_input().split())
        if e[0]==e[1]==0:
                break
        for i in range(e[0]):
                for j in range (e[0]):
                        for k in range (e[0]):
                                if i+j+k+3==e[1] and i!=j and j!=k and i<j<k:
                                        print i,j,k
                                        p+=1
        print p

Submission status: Wrong Answer

Solution code:
while True:
    n, x = map(int, raw_input().split())
    if n == 0 and x == 0:
        break

    count = 0
    for i in range(1, n-2):
        for j in range(i, n-1):
            for k in range(j, n):
                if i+j+k == x:
                    count += 1
    print count

Submission status: Wrong Answer

Solution code:
while True:
    n, x = map(int, raw_input().split())
    if n == 0 and x == 0:
        break

    count = 0
    for i in range(n-2):
        for j in range(i, n-1):
            for k in range(j, n):
                if i+j+k == x:
                    count += 1
    print count

Submission status: Wrong Answer

Solution code:
while True:
    n, x = map(int, raw_input().split())
    if n == 0 and x == 0:
        break

    count = 0
    for i in range(n-2):
        for j in range(n-1):
            for k in range(n):
                if i+j+k == x:
                    if i != j and i != k:
                        count += 1
    print count

Submission status: Wrong Answer

Solution code:
while True:
    n, x = map(int, raw_input().split())
    if n == 0 and x == 0:
        break

    count = 0
    for i in range(n):
        for j in range(n):
            for k in range(n):
                if i+j+k == x:
                    if i != j and i != k:
                        count += 1
    print count

Submission status: Wrong Answer

Solution code:
while True:
    n, x = map(int, raw_input().split())
    if n == 0 and x == 0:
        break

    count = 0
    for i in range(n-2):
        for j in range(i,n-1):
            for k in range(j,n):
                if i+j+k == x:
                    if i != j and i != k:
                        count += 1
    print count

Submission status: Wrong Answer

Solution code:
while True:
    n, x = map(int, raw_input().split())
    if n == 0 and x == 0:
        break

    count = 0
    for i in range(n-2):
        for j in range(i+1,n-1):
            for k in range(j+1,n):
                if i+j+k == x:
                    count += 1
    print count

Submission status: Wrong Answer

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def dfs(i, j, s):
    if j == 3 and s == x:
        ans.append(1)

    for k in range(1, i):
        dfs(k, j + 1, s + k)

ans = []
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break

    for i in range(1, n + 1):
        dfs(i, 1, i)

print(sum(ans))

Submission status: Time Limit Exceeded

Solution code:
def dfs(i, j, s):
    if j == 3 and s == x:
        ans.append(1)

    for k in range(1, i):
        if s + k > x:
            break
        dfs(k, j + 1, s + k)

ans = []
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break

    for i in range(3, n + 1):
        dfs(i, 1, i)

print(sum(ans))

Submission status: Time Limit Exceeded

Solution code:
def dfs(i, j, s):
    if j > 3:
        return
    if j == 3 and s == x:
        ans.append(1)

    for k in range(1, i):
        dfs(k, j + 1, s + k)

while True:
    ans = []
    n, x = map(int, input().split())
    if n == x == 0:
        break

    for i in range(1, n + 1):
        dfs(i, 1, i)

    print(sum(ans))

Submission status: Time Limit Exceeded

Solution code:
def dfs(i, j, s):
    if j > 3:
        return
    if j == 3 and sum(s) == x:
        res.append(1)

    for k in range(1, i):
        if k not in s:
            dfs(k, j + 1, s + [k])

ans = []
while True:
    res = []
    n, x = map(int, input().split())
    if n == x == 0:
        break
    for i in range(3, n + 1):
        dfs(i, 1, [i])

    ans.append(sum(res))

print("\n".join(map(str, ans)))

Submission status: Time Limit Exceeded

Solution code:
def dfs(i, j, s):
    if j > 3:
        return
    if j == 3 and sum(s) == x:
        res.append(1)

    for k in range(1, i):
        if sum(s) + k > x:
            break
        if k not in s:
            dfs(k, j + 1, s + [k])

ans = []
while True:
    res = []
    n, x = map(int, input().split())
    if n == x == 0:
        break
    for i in range(3, n + 1):
        dfs(i, 1, [i])

    ans.append(sum(res))

print("\n".join(map(str, ans)))

Submission status: Time Limit Exceeded

Solution code:
combNum = 0
calcResult = 0
n,x = map(int, input().split())
numList1 = list(range(1,n+1,1))
numList2 = list(range(1,n+1,1))
numList3 = list(range(1,n+1,1))
while True:
    if n is x is 0:
        break
    else:
        for index1 in range(n):
            for index2 in range(n):
                for index3 in range(n):
                    #index = [numList1[index1], numList2[index2], numList3[index3]]
                    if numList1[index1] is numList2[index2] or numList1[index1] is numList3[index3] or numList2[index2] is numList3[index3] or numList1[index1] is numList2[index2] is numList3[index3]:
                    #if index.count(numList1[index1])>1 or index.count(numList1[index2])>1 or index.count(numList1[index3])>1:
                        pass                
                    else:
                        if numList1[index1]<numList2[index2]<numList3[index3]:
                            calcResult = numList1[index1] + numList2[index2]+numList3[index3]
                            if calcResult == x:
                                combNum =combNum+1
                        else:
                            pass
print(combNum)

Submission status: Time Limit Exceeded

Solution code:
combNum = [0]*100
inNum = 0
while True:
    n,x = map(int, input().split())
    calcResult = 0
    numList1 = list(range(1,n+1,1))
    numList2 = list(range(1,n+1,1))
    numList3 = list(range(1,n+1,1))
    if n is x is 0:
        break
    else:
        
        for index1 in range(n):
            for index2 in range(n):
                for index3 in range(n):
                    #index = [numList1[index1], numList2[index2], numList3[index3]]
                    if numList1[index1] is numList2[index2] or numList1[index1] is numList3[index3] or numList2[index2] is numList3[index3] or numList1[index1] is numList2[index2] is numList3[index3]:
                    #if index.count(numList1[index1])>1 or index.count(numList1[index2])>1 or index.count(numList1[index3])>1:
                        pass                
                    else:
                        if numList1[index1]<numList2[index2]<numList3[index3]:
                            calcResult = numList1[index1] + numList2[index2]+numList3[index3]
                            if calcResult == x:
                                combNum[inNum] =combNum[inNum]+1
                                
                        else:
                            pass
        inNum = inNum+1
for index in range(inNum):
    print(combNum[index])

Submission status: Time Limit Exceeded

Solution code:
combNum = [0]*10000
inNum = 0
while True:
    n,x = map(int, input().split())
    calcResult = 0
    numList1 = list(range(1,n+1,1))
    numList2 = list(range(1,n+1,1))
    numList3 = list(range(1,n+1,1))
    if n is x is 0:
        break
    else:
        
        for index1 in range(n):
            for index2 in range(n):
                for index3 in range(n):
                    #index = [numList1[index1], numList2[index2], numList3[index3]]
                    if numList1[index1] is numList2[index2] or numList1[index1] is numList3[index3] or numList2[index2] is numList3[index3] or numList1[index1] is numList2[index2] is numList3[index3]:
                    #if index.count(numList1[index1])>1 or index.count(numList1[index2])>1 or index.count(numList1[index3])>1:
                        pass                
                    else:
                        if numList1[index1]<numList2[index2]<numList3[index3]:
                            calcResult = numList1[index1] + numList2[index2]+numList3[index3]
                            if calcResult == x:
                                combNum[inNum] =combNum[inNum]+1
                                
                        else:
                            pass
        inNum = inNum+1
for index in range(inNum):
    print(combNum[index])

Submission status: Time Limit Exceeded

Solution code:
def make_excluded(data, indices=[]):
    return [x for i, x in enumerate(data) if i not in indices]


while True:
    n, x = map(int, input().split())
    data = [i for i in range(1, n+1)]
    ans = 0
    if n != 0 and x != 0:
        result = []
        for i in range(len(data)):
            for j in range(i, len(data) - 1):
                for k in range(j, len(data) - 2):
                    jData = make_excluded(data, [i])
                    kData = make_excluded(jData, [j])
                    result.append([data[i], jData[j], kData[k]])
        for i in result:
            if sum(i) == x:
                ans += 1

        print(ans)

    else:
        break

Submission status: Time Limit Exceeded

Solution code:
n,x = -1,-1
table = []
while n != 0 or x != 0:
  n,x = (int(x) for x in input().split())
  table.append([n,x])

for t in table:
  n = t[0]
  x = t[1]
  if n == 0 and x == 0:
    break
  i = 1
  s = 0
  while i < n:
    if x - i > n + (n - 1):
      continue
    else:
      j = i + 1
      while j < n:
        if x - i - j <= n and x - i - j > j:
#          print (str(i) + "," + str(j) + "," + str(x - i - j))
          s += 1
        j += 1
    i += 1
  print (s)

Submission status: Time Limit Exceeded

Solution code:
count_a = []
pos = 0
while True:
    n, x = list(map(int, input().split()))
    count = 0
    if n == x == 0:
        break
    else:
        for i in range(1, (n+1)):
            for j in range(1, (n+1)):
                for k in range(1, (n+1)):
                    if (i != j) and (j != k) and (i != k):
                        if (i+j+k) == x:
                            count += 1
        count_a.append(int(count/6))
        pos = pos+1

for i  in count_a:
    print(i)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
e,a = map(int,input().split())
cnt = 0
while True:
    if e ==0 and a ==0:
        break
    else:
        for i in range(1,a+1):
            for j in range(1,a+1):
                if i<j:
                    continue
                else:
                    X = a - (i + j)
                    if X > 0:
                        cnt +=1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
e,a = map(int,input().split())
cnt = 0
while True:
    if e ==0 and a ==0:
        break
    for i in range(1,a+1):
        for j in range(1,a+1):
            if j<=i:
                continue
            
            X = a - (i + j)
            if X > j and X <=a:
                cnt +=1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
e,a = map(int,input().split())
cnt = 0
while True:
    if e ==0 and a ==0:
        break
    for i in range(1,a+1):
        for j in range(1,a+1):
            if j<=i:
                continue
            
            X = a - (i + j)
            if X > j and X <=a:
                cnt +=1
    print(cnt)