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: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
while True:
    sum=0
    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):
            for k in range(j+1,N+1):
                if i+j+k==x:
                    sum+=1
                    break
    print(sum)

Submission status: Accepted

Solution code:
while True:

    n,x = map(int,input().split())
    if n == 0 and x ==0:
        break
    
    ans = 0
    
    for a in range(1,n+1):
        for b in range(1,n+1):
            if b <= a:
                continue
            c = x-(a + b)
            
            if c <= n and c > b and c != 0:
                ans += 1
        
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


def count_ways(n, x):
    count = 0
    for i in range(1, n - 1):
        for j in range(i + 1, n):
            rest = x - i - j
            if j < rest <= n:
                count += 1
    return count


for line in sys.stdin:
    n, x = map(int, line.strip().split())
    if n == x == 0:
        break
    print(count_ways(n, x))

Submission status: Accepted

Solution code:
while True:
    line = input()
    if line == "0 0":
        break
    lst = list(map(int, line.split()))
    n = lst[0]
    x = lst[1]
    #print(n, x)
    count = 0
    for i in range(1, n-1):
        for j in range(1, n):
            for k in range(1, n+1):
                if i != j != k:
                    if i < j < k:
                        if (i + j + k) == x:
                            count += 1
    print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

while True:
    count = 0
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    l = [i for i in range(1, n + 1)]
    for j in itertools.combinations(l, 3):
        if sum(j) == x:
            count += 1
    print(count)

Submission status: Accepted

Solution code:
def main():
	while True:
		n, x = (int(a) for a in input().split())
		answer = 0
		if n == 0 and x == 0:
			break
		for a in range(1, n + 1):
			for b in range(a + 1, n + 1):
				c = x - a - b
				if b >= c:
					break
				if  0 < c <= n and a != c and b != c:
					answer += 1
			if a >= c:
				break
		print(answer)

main()

Submission status: Accepted

Solution code:
num=list(map(int,input().split()))
num_set=[]

while num[0]!=0 or num[0]!=0:
    num[0]=[i for i in range(1,num[0]+1)]
    num_set.append(num)
    num=list(map(int,input().split()))

for i in range(len(num_set)):
    n=num_set[i][0]
    x=num_set[i][1]
    x_count=0
    for j in range(len(n)-2):
        for k in range(j+1,len(n)-1):
            for l in range(k+1,len(n)):
                wa=n[j]+n[k]+n[l]
                if wa==x:
                    x_count=x_count+1
    print(x_count)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

f_in = []
while True:
  n,x = map(int,input().split())
  if n == 0 and x == 0:
    break
  else:
    f_in.append([n,x])

for step in range(len(f_in)):
  counter = 0
  for i in range(1,f_in[step][0]):
    for j in range(i+1,f_in[step][0]):
      check = f_in[step][1] - (i+j)
      if j < check and check <= f_in[step][0]:
        counter += 1
  print(counter)

Submission status: Accepted

Solution code:
while True:
    cnt = 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(i+1,n):
            for k in range(j+1,n+1):
                if ( (i+j+k ) == x ):
                    cnt += 1
                    break
    print (cnt)

Submission status: Accepted

Solution code:
import sys
for i in range(sys.maxsize):
    c=0
    n,x=map(int,input().split())
    if n==0 and x==0:
        break
    else:
        for j in range(1,n+1):
            for k in range(j+1,n+1):
                for l in range(k+1,n+1):
                    if  j+k+l==x:
                        c+=1
    print(c)

Submission status: Accepted

Solution code:
list = [0 for i in range(50)]
listcounter = 0
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    counter = 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:
                    counter += 1
    list[listcounter] = counter
    listcounter += 1
for i in range(listcounter):
    print(list[i])

Submission status: Accepted

Solution code:
nlist = []
xlist = []

while(1):
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    nlist.append(n)
    xlist.append(x)

for n, x in zip(nlist, xlist):
    cnt = 0
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            k = x - i - j
            if j < k <= n:
                cnt += 1
    print(cnt)

Submission status: Accepted

Solution code:
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    else:
        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):
                    if i + j + k == x:
                        count += 1
    print(int(count))

Submission status: Accepted

Solution code:

def subset_sum(n,a,s):
	cnt=0
	for i in range(n):
		r=s-a[i]
		j=i+1
		k=n-1
		while j<k:
			t=a[j]+a[k]
			if t<r:
				j+=1
			elif t>r:
				k-=1
			else:
				cnt+=1
				j+=1
				k-=1
	return cnt

while True:
	n,s=map(int,input().split())
	if n==0 and s==0:
		break
	a=[0]*n
	for i in range(n):
		a[i]=i+1
	print(subset_sum(n,a,s))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

while not (n+x==0):
    if (x < 6) or ((n*3 -3) < x):
        print(0)
    else:
        answer = 0
        a = 1
        if n*2-1 < x:
            a = x-n*2+1
        for i in range(a, x//3):
            if (x-i >= n):
                if (x-i-n) > i:
                    answer += math.ceil((n*2-x+i)/2)
                else:
                    answer += math.ceil((x-i*3-2)/2)
            else:
                answer += math.ceil((x-i*3-2)/2)
        print(answer)
    n, x = map(int, input().split())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
while True:
    (n,total)=map(int,input().split())
    
    if (n,total) == (0,0):
        break
    
    # copmb: number of combinations
    comb = 0

    if total<=(n+(n-1)+(n-2)):
        for biggest in range(n,2,-1):
            for smallest in range(1,n-1,1):
                if (total-biggest-smallest)>smallest and (total-biggest-smallest)<biggest:
                    comb = comb+1
    print(comb)

Submission status: Accepted

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

Submission status: Accepted

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

    w = 0

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

Submission status: Accepted

Solution code:
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
    nL = [i for i in range(1, n+1)]
    m = 0
    for a in nL:
        nL_1 = nL[a:]
        for b in nL_1:
            nL_2 = nL[b:]
            for c in nL_2:
                if a + b + c == x:
                    m += 1
    print(m)

Submission status: Accepted

Solution code:
while True:
    n, x = map(int, input().split())
    if n == 0 and 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):
                if a + b + c == x:
                    count += 1
    print(count)

Submission status: Accepted

Solution code:
import itertools

while True:

    n, x = map(int, input().split())
    if n==x==0:
        break
    a=0

    for ii in itertools.combinations([i+1 for i in range(n)], 3):
        if sum(ii)==x:
            a += 1

    print(a)

Submission status: Accepted

Solution code:
while True:
	count=0
	num=list(map(int,input().split()))
	if num[0]==0 and num[1]==0:
		break
	else:
		for i in range(1,num[0]):
			for j in range(i+1,num[0]+1):
				for k in range(j+1,num[0]+1):
					if i+j+k==num[1] and i!=j and j!=k and k!=i:
						count+=1
	print(int(count))

Submission status: Accepted

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

while (n or x):
    count = 0
    for i in range(n, 0, -1):
        for j in range(1, i):
            k = x - i - j
            if (k > j and k < i):
                count += 1
    result.append(count)
    n, x = map(int, input().split())

for i in result:
    print(i)

Submission status: Accepted

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

    for i1 in range(0,n-1):
        for i2 in range(i1, n):
            n3 = x - i1 - i2
            if (n3 != i2)and(i2 != i1)and(0 < i1 < i2 < n3)and(0 < n3 <= n):
                tmp += 1
    
    print(tmp)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

# ITP1_7_B


# 小中大の順に
# a<b<cとする

import math

def compare(num,duplicate_num):
    a_b=list()
    # 1234
    for i in range(1,num):
        j = num - i
        if j <= i:
            break
        if j == duplicate_num:
            continue
        if j > 0:
            # print("i:"+str(i)+"j:"+str(j))
            a_b.append([i,j,duplicate_num])
    return a_b

while(True):
    c,sum=map(int,input().split())
    
    if c==0 and sum==0:
        break
    
    a_b_c=list()
    count = 0
    
    for i in reversed(range(c+1)):
        # if i <= math.ceil(c/3):
        #     break
        a_b_c.append(compare(sum-i,i))
    
    
    for result in a_b_c:
        for r in result:
            if r==sorted(r):
                # print(" ".join(list(map(str,r))))
                count+=1;
    
    print(count)
    



        
    # print(sorted(result))

Submission status: Accepted

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

Submission status: Accepted

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

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

  ans = 0

  for i in range(1,n+1):
    for j in range(i+1,n+1):
      k = x-(i+j)
      if k >= 1 and k <= n and k > j:
        ans += 1

  print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

for result in results:
    print(result)

Submission status: Accepted

Solution code:
import itertools

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

    y = [0] * n
    for i in range(n):
        y[i] = i + 1
    kumiawase = list(itertools.combinations(y,3))
    count = 0
    for i in kumiawase:
        if i[0] + i[1] + i[2] == x:
            count += 1
    print(count)

Submission status: Accepted

Solution code:
n=1
while n:
 n,x=map(int,raw_input().split())
 if n:print sum(max(0,min(n-i,x-2*i-1,i-1,n-x+2*i))for i in range(n))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python

def comb(n, x):
    if x > n*3-3 or x < 6:
        return []

    c = []
    for i in range(1, n-1):
        if i > x/3:
            break
        for j in range(i+1, n):
            if j > (x-i)/2:
                break
            rem = x-(i+j)
            if rem > j and rem <= n:
                c += [(i, j, rem)]
    return c

if __name__=='__main__':
    while True:
        n, x = map(int, raw_input().split())

        if [n, x] == [0, 0]:
            break
        print len(comb(n, x))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sss = input()
while not sss == '0 0':
	n,x = map(int, sss.split(' '))
	counter = 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: counter += 1
	print(counter)
	sss = input()

Submission status: Accepted

Solution code:
data = []
for looop in range(1,10000):
    n,x = map(int, input().split())
    if n == 0 and x ==0:
        break
    else:
        num = 0
        for i in range(3,n+1):
            for j in range(2,i):
                for k in range(1,j):
                    if i + j + k == x:
                        num += 1
        data.append(num)
for x in range(len(data)):
    print(data[x])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
while True:
    combNum = 0
    calcResult = 0
    numList1 = list(range(1,n+1,1))
    numList2 = list(range(1,n+1,1))
    numList3 = list(range(1,n+1,1))
    n,x = map(int, input().split())
    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: Runtime Error

Solution code:
while True:
    combNum = 0
    calcResult = 0
    numList1 = list(range(1,n+1,1))
    numList2 = list(range(1,n+1,1))
    numList3 = list(range(1,n+1,1))
    n,x = map(int, input().split())
    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: Runtime Error

Solution code:
combNum = [0]*100
resultNum = 0
while True:
    calcResult = 0
    numList1 = list(range(1,n+1,1))
    numList2 = list(range(1,n+1,1))
    numList3 = list(range(1,n+1,1))
    n,x = map(int, input().split())
    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+1
                                resultNum +=1
                        else:
                            pass
for index in range(resultNum)
    print(combNum[index])

Submission status: Runtime Error

Solution code:
combNum = [0]*100
resultNum = 0
while True:
    calcResult = 0
    numList1 = list(range(1,n+1,1))
    numList2 = list(range(1,n+1,1))
    numList3 = list(range(1,n+1,1))
    n,x = map(int, input().split())
    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+1
                                resultNum +=1
                        else:
                            pass
for index in range(resultNum):
    print(combNum[index])

Submission status: Runtime Error

Solution code:
combNum = [0]*100
inNum = 0
while True:
    calcResult = 0
    numList1 = list(range(1,n+1,1))
    numList2 = list(range(1,n+1,1))
    numList3 = list(range(1,n+1,1))
    n,x = map(int, input().split())
    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: Runtime Error

Solution code:
while True:
    n,x=map(int,input().split())
    if n=0 and x=0:break
    ans =0
    for a in range(1,n+1):
        for b in range(1,n+1):
            if b<=a:continue
            c=x-(a+b)
            if c>b and c<=n:ans+1
    print("%d"%(ans))

Submission status: Runtime Error

Solution code:
while True:
    n,x=map(int,input().split())
    if n=0 and x=0:break
    ans =0
    for a in range(1,n+1):
        for b in range(1,n+1):
            if b<=a:continue
            c=x-(a+b)
            if c>b and c<=n:ans+=1
    print("%d"%(ans))

Submission status: Runtime Error

Solution code:
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(1,i):
            for k in range(1,j):
                if i+j+k==x:a+=1
    print(a)

Submission status: Runtime Error

Solution code:
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(1,i):
            for k in range(1,j):
                if i+j+k==x:a+=1
    print(a)

Submission status: Runtime Error

Solution code:
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(1,i):
            for k in range(1,j):
                if i+j+k==x:ans+=1
    print(ans)

Submission status: Runtime Error

Solution code:
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(1,i):
            for k in range(1,j):
                if i+j+k==x :a=a+1
    print(a)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:


BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
 
 
while True:
    N,X = map(int,input().split())
    if N == 0 and X == 0:
        break
    ans = 0
    for a in range(1,N+1):
        for b in range(1,N+1):
            if b <= a:
                continue
            c = X-(a+b)
            if c > b and c <= N:
                ans += 1
    print("%d"%(ans))

Compile Error Logs:

Status
Judge: 4/4 	Python3 	CPU: 00:07 sec 	Memory: 5608 KB 	Length: 369 B 	2019-05-27 14:40
Results for testcases
Case # 	Verdict 	CPU Time 	Memory 	In 	Out 	Case Name
Case #1	: Accepted	00:02	5604	8	2	testcase_00
Case #2	: Accepted	00:03	5604	28	10	testcase_01
Case #3	: Accepted	00:02	5608	85	36	testcase_02
Case #4	: Accepted	00:07	5600	297	163	testcase_03
< prev | 		/ 		| next > 	  		
 
Judge Input #  ( | ) 		Judge Output #  ( | )

Submission status: Runtime Error

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(i+1, (n+1)):
                for k in range(j+s1, (n+1)):
                    if (i != j) and (j != k) and (i != k):
                        if (i+j+k) == x:
                            count += 1
        count_a.append(count)
        pos = pos+1

for i  in count_a:
    print(i)

Submission status: Runtime Error

Solution code:
e,a = map(int,input().split())
cnt =0
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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

    dataset = []
    for a in range(1, n + 1):
        for b in range(a + 1, n + 1):
            for c in range(b + 1, n + 1):
                if sum([a,b,c]) == x:
                    count += 1

    print(count)

Submission status: Runtime Error

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

    count = 0
    for a in range(x, 0, step=-1):
        for b in range(a - 1, 0, step=-1):
            if sum(a,b) > x:
                break
            for c in range(b - 1, 0, step=-1):
                if sum(a,b,c) == x:
                    count += 1
'''
    limit = n if n < x else x
    for a in range(1, limit + 1):
        for b in range(a + 1, limit + 1):
            for c in range(b + 1, limit + 1):
                if sum([a,b,c]) == x:
                    count += 1

'''
    print(count)

Submission status: Runtime Error

Solution code:
while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 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) == x:
                    cnt += 1
                elif (i + j + K) > x:
                    break
    print cnt

Submission status: Runtime Error

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

  print('count')

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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