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:
def main():
    while True:
        n, x = map(int, input().split())
        if n == x == 0:
            break
        number = 0
        for i in range(n):
            j = i + 1
            if x - j > n*2 - 1:
                continue
            elif x - j <= j:
                break
            else:
                for k in range(x - j):
                    m = k + 1
                    if k < j:
                        continue
                    elif (x - j - m) >= m and x - j - m <= n:
                        number += 1
                        break
                    else:
                        continue
        print(number)
    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
ele_and_tar = []
rs = []
flag1 = 1
flag2 = 0
while flag1:
    data = [int(x) for x in input().split()]
    if data == [0,0]:
        flag1 = 0
    else:
        ele_and_tar.append(data)
        
for i in range(len(ele_and_tar)):
    rs.append(0)
for math in ele_and_tar:
    for i in range(1,math[0]+1):
        for j in range(i+1,math[0]+1):
            for k in range(j+1,math[0]+1):
                if (i + j + k) == math[1]:
                    rs[flag2] = rs[flag2] + 1
    flag2 = flag2 + 1

Submission status: Wrong Answer

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

while n != 0 and x != 0:
    test = [[i,j,k] 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]
    print(len(test))
    n, x = [int(i) for i in input().split()]

Submission status: Wrong Answer

Solution code:
# coding: utf-8
while True:
    n, x = map(int, input().split())
    comb = 0
    
    if n == 0 and x == 0:
        exit()

    for i in range(1, n+1):
        for j in range(i+1, n+1):
            for k in range(j+1, n+1):
                print('{} {} {}'.format(i, j, k))
                if i + j + k == x:
                    comb += 1
    print(comb)

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(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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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)

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: Wrong Answer

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

print(s)

Submission status: Wrong Answer

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(i,x):
            k = x - i - j
            if i<=n and j<=n and k<=n:
                cou += 1
    print(cou)

Submission status: Wrong Answer

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//2):
        for j in range(i+1,x//2):
            k = x - i - j
            if i<=n and j<=n and k<=n:
                cou += 1
    print(cou)

Submission status: Wrong Answer

Solution code:
data_set=[]
while True:
    s=input().split()
    data_set.append(s)
    if ["0","0"] in data_set:
        break
data_set=data_set[:-1]
count=0
import itertools
for i in data_set:
    n=int(i[0])
    x=int(i[1])
    num=list(itertools.combinations(range(1,n+1),3))
    for j in num:
        if sum(j)==x:
            count+=1
print(count)

Submission status: Wrong Answer

Solution code:
def a():
    data_set=[]
    while True:
        s=input().split()
        data_set.append(s)
        if ["0","0"] in data_set:
            break
    data_set=data_set[:-1]
    import itertools
    for i in data_set:
        count=0
        n=int(i[0])
        x=int(i[1])
        num=list(itertools.combinations(range(1,n+1),3))
        for j in num:
            if sum(j)==x:
                count+=1
        print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import stdin

while True:
    n, x = [int(x) for x in stdin.readline().rstrip().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-2):
                if j < x-i-j <= n:
                    count += 1
        else:
            print(count)

Submission status: Wrong Answer

Solution code:
from sys import stdin

while True:
    n, x = [int(x) for x in stdin.readline().rstrip().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):
                if j < x-i-j <= n:
                    count += 1
        else:
            print(count)

Submission status: Wrong Answer

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
    break
print(combNum)

Submission status: Wrong Answer

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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, x = map(int, input().split())
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: Wrong Answer

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: Wrong Answer

Solution code:
ans=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:
          ans=ans+1
print(ans)

Submission status: Wrong Answer

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=ans+1
print(ans)

Submission status: Wrong Answer

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(count)
        pos = pos+1

for i  in count_a:
    print(i)

Submission status: Wrong Answer

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

Solution code:
while True:
    e,a = map(int,input().split())
    if e ==0 and a ==0:
        break
    cnt = 0
    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: Wrong Answer

Solution code:
while True:
    e,a = map(int,input().split())
    if e ==0 and a ==0:
        break
    cnt = 0
    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("%d"%(cnt))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    from sys import stdin
    from itertools import combinations

    while True:
        n, x = (int(n) for n in stdin.readline().rstrip().split())

        if n == x == 0:
            break

        a = range(max(1, (x - n) // 2 - 1), min(n + 1, x - 2))
        l = tuple(filter(lambda _: sum(_) == x, combinations(a, 3)))

        print(len(l))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
while True:
    num = list(map(int,input().split()))
    if(num[0] == 0 and num[1] == 0): break
    c = 0
    for i in range(1,num[0]+1):
        for j in range(i+1,num[0]+1):
            if j <= i:
                continue
            k = num[1]-(i+j)
            if k > j and k <= num[1]:
                c+= 1
    print(c)

Submission status: Wrong Answer

Solution code:
while True:
    num = list(map(int,input().split()))
    if(num[0] == 0 and num[1] == 0): break
    c = 0
    for i in range(1,num[0]+1):
        for j in range(1,num[0]+1):
            if j <= i:
                continue
            k = num[1]-(i+j)
            if k > j and k <= num[1]:
                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
  else:
    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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
while True:
   n,x = 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):
          if(j< x-1-j < n+1):
             ans += 1
   print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
i = 0
while True:
    n,x = map(int,raw_input().split())
    if n == x == 0:
        break
    for a in range(1,n+1):
        for b in range(1,a+1):
            for c in range(1,b+1):
                if not a == b == c and not a == b and not a == c and not b == c:
                    if a+b+c == x:
                        i = i + 1
print i

Submission status: Wrong Answer

Solution code:
i = 0
while True:
    n,x = map(int,raw_input().split())
    if n == x == 0:
        break
    for a in range(1,n+1):
        for b in range(1,a+1):
            for c in range(1,b+1):
                if not a == b == c and not a == b and not a == c and not b == c:
                    if a+b+c == x:
                        i = i + 1
    print i

Submission status: Wrong Answer

Solution code:
while True:
    count=0
    n, s = tuple([int(x) for x in raw_input().split(" ")])

    if n==0 and s==0:
        break
    
    for i in range(1, n+1):
        for j in range(1, n+1):
            if j==i:
                continue
            if i+j==s:
                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 i in range(n-2):
  for k in range(i+1,n-1):
   for j in range(k+1,n):
     if i+k+j==x :
       count = 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 i in range(n-1):
  for k in range(i+1,n):
   for j in range(k+1,n+1):
     if i+k+j==x :
       count = 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 a in range(x, 0, -1):
        for b in range(a - 1, 0, -1):
            if sum([a,b]) > x:
                break
            for c in range(b - 1, 0, -1):
                if sum([a,b,c]) == x:
                    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 i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            for k in range(j + 1, n + 1):
                if x - i + j + k == 0:
                    count += 1
                if x - i + j + k < 0:
                    break
    print(count)

Submission status: Wrong Answer

Solution code:
#coding:utf-8
#1_7_B 2015.4.5
while True:
    n,x = map(int,input().split())
    if n == x == 0:
        break
    count = 0
    
    for i in range(1 , n + 1):
        for j in range(1 , n + 1):
            if (x - i - j) < n and i < j < (x - i -j):
                count += 1
    print(count)

Submission status: Wrong Answer

Solution code:
while True:
    n, x = map(int, raw_input().split())
    if (n, x) == (0, 0):
        break
    ans = 0
    for a in xrange(1, n+1):
        for b in xrange(a+1, n+1):
            for c in xrange(b+1, n+1):
                if a + b + c == x:
                    print a, b, c
                    ans += 1
    print ans

Submission status: Wrong Answer

Solution code:
import itertools

while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
    result = 0
    for i in itertools.combinations(range(1, n + 1), 3):
        if sum(i) == 9:
            result += 1
    print(result)

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 i in range(n - 1):
    for j in range(n):
      for k in range(n + 1):
        if i + j + k == x: 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

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

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

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

Submission status: Wrong Answer

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

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

    print(goukei)

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 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:
                    print(i + j + k)
                    count += 1
    print(count)

Submission status: Wrong Answer

Solution code:
n = 100
for a in range(1,9):
  for b in range(1,10):
    for c in range(1,11):

     print(a + b + c)

Submission status: Wrong Answer

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

    if n == x == 0:
        break

    list = [int(i) for i in range(1, n + 1)]
    S = 0
    for a in range(1, n + 1):
        for b in range(a + 1, n + 2):
            for c in range(b + 2, n + 3):
                if a + b + c == x:
                    S += 1

    print(S)

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

Submission status: Wrong Answer

Solution code:
n = 5
count = 0
for a in range(1,4):
    for b in range(a+1,5):
        for c in range(b+1, 6):
            if a + b + c == 9:
                count += 1
print(count)

Submission status: Wrong Answer

Solution code:
n = [int(i) for i in input().split()]
count = 0
for a in range(1,4):
    for b in range(a+1,5):
        for c in range(b+1, 6):
            if a + b + c == 9:
                count += 1
print(count)

Submission status: Wrong Answer

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

    goukei = 0
    for i in range(1,n):
        for j in range(1,n):
            for k in range(1,n):
                if i+j+k == x and (not i==j==k):
                    goukei += 1

    print(goukei)

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 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 == 9:
                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 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 == 9:
                    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 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: Wrong Answer

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

    c = 0
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            c = i + j
            tmp = x - c
            if (tmp <= n) & (tmp > j):
                c += 1

    print c

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
while True :
	n,x=map(int,raw_input().split())
	if not( n==0 and x==0) :
		p_count = 0
		i,j,k = [1,2,3]
		while i <= n-2 :
			j = i+1
			while j <= n-1:
				k = j+1
				while k <= n:
					if (i+j+k)==x :
						p_count += 1
						print '%d + %d + %d = %d' %(i,j,k,x)
						k += 1
						break
					else :
						k += 1
				j += 1
			i += 1
		print(p_count)
 	else :
 		break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
while True:
    n, x = map(int, raw_input().split(" "))
    if n==x==0:
        break
    ans = 0
    for a in range(1, n-1):
        for b in range(a+1, n):
            for c in range(b+1, n+1):
                if a+b+c == 9:
                    ans += 1
                    break
    print ans

Submission status: Wrong Answer

Solution code:
ans = 0
def do(nlist,x,c,index):
    global ans
    if x == 0:
        # print "detect!"
        ans +=1
        return
    elif x < 0:
        return
    if c == 3:
        return
    if index < 0:
        return
    for i in reversed(xrange(0,index)):
        x -= nlist[i]
        # print x
        do(nlist,x,c+1,index-1)
    return

while True:
    n,x = map(int,raw_input().split())
    if n==0 and x == 0:
        break
    nlist = [i for i in xrange(1,n+1)]
    # print nlist
    do(nlist,x,0,len(nlist))
    print ans

Submission status: Wrong Answer

Solution code:
ans = 0
def do(nlist,x,c,index):
    global ans
    if x == 0:
        print "detect!"
        ans +=1
        return
    elif x < 0:
        return
    if c == 3:
        return
    if index < 0:
        return
    for i in reversed(xrange(0,index)):
        x -= nlist[i]
        print x
        do(nlist,x,c+1,index-1)
    return

while True:
    n,x = map(int,raw_input().split())
    if n==0 and x == 0:
        break
    nlist = [i for i in xrange(1,n+1)]
    print nlist
    do(nlist,x,0,len(nlist))
    print "ans : "+str(ans)
    # print ans
    ans = 0

Submission status: Wrong Answer

Solution code:
ans = 0
def do(nlist,x,c,index):
    global ans
    if x == 0:
        ans +=1
        return
    elif x < 0:
        return
    if c == 3:
        return
    if index < 0:
        return
    for i in reversed(xrange(0,index)):
        x -= nlist[i]
        do(nlist,x,c+1,index-1)
    return

while True:
    n,x = map(int,raw_input().split())
    if n==0 and x == 0:
        break
    nlist = [i for i in xrange(1,n+1)]
    do(nlist,x,0,len(nlist))
    print ans
    ans = 0

Submission status: Wrong Answer

Solution code:
max,sum=map(int,input().split())
cnt=0
for i in range(1,max+1):
    for j in range(i+1,max+1):
        for k in range(j+1,max+1):
            if i+j+k==sum:
                cnt+=1
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,x = [int(i) for i in input().split()]
if n!=0 and x!=0:
    print(len([(i,j,k) 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]))

Submission status: Wrong Answer

Solution code:
n,x = [int(i) for i in input().split()]
if n!=0 and x!=0:
    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: Wrong Answer

Solution code:
# coding: utf-8

import itertools

data_set = []

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

counter = 0

for d in data_set:
    num = list(range(d[0] + 1))[1:]
    for i in itertools.combinations(num, 3):
        if (sum(i) == d[1]):
            counter += 1

print(counter)

Submission status: Wrong Answer

Solution code:
while True:
    n, x = [int(a) for a in input().split()]
    if n == x == 0:
        break
    cnt = 0
    for i in range(1, n):
        flag = False
        for j in range(i + 1, n):
            if flag:
                break
            for k in range(j + 1, n + 1):
                if (i + j + k) == x:
                    cnt += 1
                    flag = True

    print(cnt)

Submission status: Wrong Answer

Solution code:
while True:
    n, x = [int(a) for a in input().split()]
    if n == x == 0:
        break
    cnt = 0
    for i in range(1, n):
        for j in range(i + 1, n):
            flag = False
            for k in range(j + 1, n + 1):
                if flag:
                    break
                if (i + j + k) == x:
                    cnt += 1
                    print("{0} + {1} + {2}".format(i, j, k))
                    flag = True

    print(cnt)

Submission status: Wrong Answer

Solution code:
m,x = map(int,raw_input().split())
count = 0
for i in range(m):
    for j in range(m -1):
        for k in range(m - 2):
            if ((i + j + k + 3) == x) and (i != j != k):
                count += 1

print count / 3

Submission status: Wrong Answer

Solution code:
count = []

while True:
    sub_count = 0
    n,x = map(int,raw_input().split())
    if n == x == 0:
        break
    
    for i in range(n):
       for j in range(n):
           for k in range(n):
               if ((i + j + k + 3) == 9) and ((i != j != k != i) == True):
#                   print i,j,k
                   sub_count += 1
    count.append((sub_count / 6))


for i in range(len(count)):
    print count[i]

Submission status: Wrong Answer

Solution code:
count = []

while True:
    sub_count = 0
    n,x = map(int,raw_input().split())
    if n == x == 0:
        break
    
    for i in range(n):
       for j in range(n):
           for k in range(n):
               if ((i + j + k + 3) == x) and ((i != j != k != i) == True):
                   print i,j,k
                   sub_count += 1
    count.append((sub_count / 6))


for i in range(len(count)):
    print count[i]