ZhenlongDai/ACPR huggingface dataset:
Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
while True :
    n, x = map(int, input().split())
    if (n == x == 0) :
        break

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

Failing test case input:
19 22
0 0

Expected output:
30


Actual output:
0


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

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

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
def counter(n, x):
    count = 0
    for i in range(n-2):
        for j in range(1, n-1):
            for k in range(2, n):
                if i + j + k == x:
                    count += 1
    return count

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

Failing test case input:
12 13
0 0

Expected output:
8


Actual output:
63


Fixed submission (verdict: Accepted):
def counter(n, x):
    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:
                    count += 1
    return count

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

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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())


Failing test case input:
19 35
0 0

Expected output:
36


Actual output:
21


Fixed submission (verdict: Accepted):
n, x = map(int, input().split())

while n != 0 or x != 0:
	cnt = 0
	i = 1
	while i <= n - 2:
		j = i + 1
		if i >= x:
			break
		while j <= n - 1:
			k = j + 1
			if i + j >= x:
				break
			while k <= n:
				if i + j + k > x:
					break
				if i + j + k == x:
					cnt += 1
				k += 1
			j += 1
		i += 1
	print(cnt)
	n, x = map(int, input().split())
Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
while True:
    n,x = list(map(int, input().split()))
    if n == x == 0:
        break

    num_set = []
    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:
                    li = [i,j,k]
                    sorted_list = sorted(li)
                    if not sorted_list in num_set:
                        num_set.append(sorted_list)

    print(len(num_set))

Failing test case input:
23 36
0 0

Expected output:
61


Actual output:
72


Fixed submission (verdict: Accepted):
while True:
    n,x = list(map(int, input().split()))
    if n == x == 0:
        break

    num_set = []
    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:
                    li = [i,j,k]
                    if not li in num_set:
                        num_set.append(li)
    print(len(num_set))

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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 (2, n) :
            for c in range (3, n) :
                Sum = a + b + c
                if (Sum == x) :
                    count += 1
    print(count)

Failing test case input:
10 9
0 0

Expected output:
3


Actual output:
10


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

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

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
N,M = map(int, input().split())
ans = 0
while not (N == 0 and M == 0):
 for i in range(1, N+1):
  for j in range(1, N+1):
   k = M - i - j
   if ( i==j or i==k or j==k or k > M-3): pass
   elif (i + j + k == M): ans += 1
 N,M = map(int, input().split())
print(ans)

Failing test case input:
6 11
0 0

Expected output:
3


Actual output:
24


Fixed submission (verdict: Accepted):
N,M = map(int, input().split())
ans = 0
while not (N == 0 and M == 0):
 for i in range(1, N+1):
  for j in range(i+1, N+1):
   k = M - i - j
   if ( k > N): pass
   elif  k <= j : break
   else: ans += 1
 print(ans)
 ans = 0
 N,M = map(int, input().split())
Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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()



Failing test case input:
13 14
0 0

Expected output:
10


Actual output:
4


Fixed submission (verdict: Accepted):
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

        print(number)
    return


if __name__ == '__main__':
    main()

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
while True:
    n, x = map(int, input().split())
    if (n, x) == (0, 0): break
    ans = []
    for i in range(n, 1, -1):
        for j in range(1, n):
            tmp = x-(j+i)
            if tmp > 0 and i > 0 and j > 0:
                if tmp != j and tmp != i and i != j:
                    pmt = sorted([i, j, tmp])
                    if not pmt in ans: ans.append(pmt)
    print(len(ans))

Failing test case input:
5 25
0 0

Expected output:
0


Actual output:
10


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

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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)


Failing test case input:
6 13
0 0

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
while 1:
    n, x = map(int, 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
    print(cnt)
Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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)

Failing test case input:
4 5
0 0

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
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)

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
n, x = map(int, input().split())

while n != 0 and x != 0:
	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(count)
	n, x = map(int, input().split())

Failing test case input:
5 0
0 0

Expected output:
0


Actual output:

Fixed submission (verdict: Accepted):
n, x = map(int, input().split())

while n != 0 or x != 0:
	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(count)
	n, x = map(int, input().split())

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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)


Failing test case input:
3 6
0 0

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
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):
                if j < x-i-j <= n:
                    count += 1
        else:
            print(count)
Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
def counter(n, x):
    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:
                    count += 1
                    print("{0} {1} {2}".format(i, j ,k))
    return count

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

Failing test case input:
37 49
0 0

Expected output:
151


Actual output:
1 11 37
1 12 36
1 13 35
1 14 34
1 15 33
1 16 32
1 17 31
1 18 30
1 19 29
1 20 28
1 21 27
1 22 26
1 23 25
2 10 37
2 11 36
2 12 35
2 13 34
2 14 33
2 15 32
2 16 31
2 17 30
2 18 29
2 19 28
2 20 27
2 21 26
2 22 25
2 23 24
3 9 37
3 10 36
3 11 35
3 12 34
3 13 33
3 14 32
3 15 31
3 16 30
3 17 29
3 18 28
3 19 27
3 20 26
3 21 25
3 22 24
4 8 37
4 9 36
4 10 35
4 11 34
4 12 33
4 13 32
4 14 31
4 15 30
4 16 29
4 17 28
4 18 27
4 19 26
4 20 25
4 21 24
4 22 23
5 7 37
5 8 36
5 9 35
5 10 34
5 11 33
5 12 32
5 13 31
5 14 30
5 15 29
5 16 28
5 17 27
5 18 26
5 19 25
5 20 24
5 21 23
6 7 36
6 8 35
6 9 34
6 10 33
6 11 32
6 12 31
6 13 30
6 14 29
6 15 28
6 16 27
6 17 26
6 18 25
6 19 24
6 20 23
6 21 22
7 8 34
7 9 33
7 10 32
7 11 31
7 12 30
7 13 29
7 14 28
7 15 27
7 16 26
7 17 25
7 18 24
7 19 23
7 20 22
8 9 32
8 10 31
8 11 30
8 12 29
8 13 28
8 14 27
8 15 26
8 16 25
8 17 24
8 18 23
8 19 22
8 20 21
9 10 30
9 11 29
9 12 28
9 13 27
9 14 26
9 15 25
9 16 24
9 17 23
9 18 22
9 19 21
10 11 28
10 12 27
10 13 26
10 14 25
10 15 24
10 16 23
10 17 22
10 18 21
10 19 20
11 12 26
11 13 25
11 14 24
11 15 23
11 16 22
11 17 21
11 18 20
12 13 24
12 14 23
12 15 22
12 16 21
12 17 20
12 18 19
13 14 22
13 15 21
13 16 20
13 17 19
14 15 20
14 16 19
14 17 18
15 16 18
151


Fixed submission (verdict: Accepted):
def counter(n, x):
    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:
                    count += 1
    return count

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

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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)

Failing test case input:
3 6
0 0

Expected output:
1


Actual output:
0


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

    count = 0
    for a in range(1, x 
        for b in range(a + 1, x 
            for c in range(b + 1, n + 1):
                Sum = a + b + c
                if (Sum == x):
                    count += 1 
    print(count)
Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
while 1:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    a =[]
    for i in range(1, n + 1):
        for j in range(2, n + 1):
            for k in range(3, n + 1):
                if i + j + k == x:
                    if i != j:
                        if j != k:
                            a.append([i, j, k])
    
    for i in range(len(a)):
        for j in range(2):
            if a[i][j] > a[i][j+1]:
                t = a[i][j]
                a[i][j] = a[i][j+1]
                a[i][j+1] = t
                
    t = 0
    c = 0
    for i in a:
        if t != i:
            t = i
            c += 1
    print(c)

Failing test case input:
33 32
0 0

Expected output:
70


Actual output:
342


Fixed submission (verdict: Accepted):
while 1:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    a =[]
    for i in range(1, n + 1):
        for j in range(2, n + 1):
            for k in range(3, n + 1):
                if i + j + k == x:
                    if i != j:
                        if j != k:
                            if i != k:
                                a.append([i, j, k])
    b = []
    for i in a:
        b.append(sorted(i))

    c = []
    c = sorted(b)

    if len(c) == 0:
        cnt = 0
    else:
        cnt = 1
        t = c[0]
        for i in c:
            if t != i:
                cnt += 1
                t = i
    print(cnt)

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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 (2, n) :
            c = x - a - b
            if (b < c <= n) :
                count += 1
    print(count)

Failing test case input:
12 22
0 0

Expected output:
14


Actual output:
41


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

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

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
def counter(n, x):
    count = 0
    for i in range(n-1):
        for j in range(i+1, n):
            for k in range(j+1, n+1):
                if i + j + k == x:
                    count += 1
    return count

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

Failing test case input:
8 14
0 0

Expected output:
6


Actual output:
7


Fixed submission (verdict: Accepted):
def counter(n, x):
    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:
                    count += 1
    return count

while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
    print(counter(n, x))
Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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)


Failing test case input:
6 13
0 0

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
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]):
            for k in range(j+1,num[0]+1):
                if(i+j+k == num[1]): c += 1
    
    print(c)

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
N,M = map(int, input().split())
ans = 0
while not (N == 0 and M == 0):
 for i in range(1, N+1):
  for j in range(1, N+1):
   k = M - i - j
   if ( i==j or i==k or j==k): pass
   elif (i + j + k == M): ans += 1
 N,M = map(int, input().split())
print(ans)

Failing test case input:
5 9
0 0

Expected output:
2

Actual output:
16


Fixed submission (verdict: Accepted):
N,M = map(int, input().split())
ans = 0
while not (N == 0 and M == 0):
 for i in range(1, N+1):
  for j in range(i+1, N+1):
   k = M - i - j
   if ( k > N): pass
   elif  k <= j : break
   else: ans += 1
 print(ans)
 ans = 0
 N,M = map(int, input().split())

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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


Failing test case input:
9 2
0 0

Expected output:
0


Actual output:

Fixed submission (verdict: Accepted):
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 == x:
                sum+= 1
    print(sum)
Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):



























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

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

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






Failing test case input:
22 48
0 0

Expected output:
27


Actual output:

Fixed submission (verdict: Accepted):



























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

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

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

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

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
while True:
    n, x = input().split()
    n = int(n)
    x = int(x)
    if n == x:
        break


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

Failing test case input:
2 2
0 0

Expected output:
0


Actual output:

Fixed submission (verdict: Accepted):
while True:
    n, x = input().split()
    n = int(n)
    x = int(x)
    if n == 0 and x == 0:
        break


    count = 0
    for i in range(1,n-1):
        for j in range(i+1, n):
            
            k = x - (i+j)
            if k < j+1: 
                break
            if k <= n:
                count += 1
    print(count)
Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):

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

Failing test case input:
33 32
0 0

Expected output:
70


Actual output:
x:2,y:1,sum:30
x:3,y:1,sum:29
x:3,y:2,sum:29
x:4,y:1,sum:28
x:4,y:2,sum:28
x:4,y:3,sum:28
x:5,y:1,sum:27
x:5,y:2,sum:27
x:5,y:3,sum:27
x:5,y:4,sum:27
x:6,y:1,sum:26
x:6,y:2,sum:26
x:6,y:3,sum:26
x:6,y:4,sum:26
x:6,y:5,sum:26
x:7,y:1,sum:25
x:7,y:2,sum:25
x:7,y:3,sum:25
x:7,y:4,sum:25
x:7,y:5,sum:25
x:7,y:6,sum:25
x:8,y:1,sum:24
x:8,y:2,sum:24
x:8,y:3,sum:24
x:8,y:4,sum:24
x:8,y:5,sum:24
x:8,y:6,sum:24
x:8,y:7,sum:24
x:9,y:1,sum:23
x:9,y:2,sum:23
x:9,y:3,sum:23
x:9,y:4,sum:23
x:9,y:5,sum:23
x:9,y:6,sum:23
x:9,y:7,sum:23
x:9,y:8,sum:23
x:10,y:1,sum:22
x:10,y:2,sum:22
x:10,y:3,sum:22
x:10,y:4,sum:22
x:10,y:5,sum:22
x:10,y:6,sum:22
x:10,y:7,sum:22
x:10,y:8,sum:22
x:10,y:9,sum:22
x:11,y:1,sum:21
x:11,y:2,sum:21
x:11,y:3,sum:21
x:11,y:4,sum:21
x:11,y:5,sum:21
x:11,y:6,sum:21
x:11,y:7,sum:21
x:11,y:8,sum:21
x:11,y:9,sum:21
x:12,y:1,sum:20
x:12,y:2,sum:20
x:12,y:3,sum:20
x:12,y:4,sum:20
x:12,y:5,sum:20
x:12,y:6,sum:20
x:12,y:7,sum:20
x:13,y:1,sum:19
x:13,y:2,sum:19
x:13,y:3,sum:19
x:13,y:4,sum:19
x:13,y:5,sum:19
x:14,y:1,sum:18
x:14,y:2,sum:18
x:14,y:3,sum:18
x:15,y:1,sum:17
70


Fixed submission (verdict: Accepted):

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

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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)


Failing test case input:
3 18
0 0

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
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(s<=n and j<i and i<s):
                num += 1
    print(num)
Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
(n, x), c = map(int, input().split()), 0
for i in range(1,n-1):
    for j in range(i,n):
        for k in range(j, n+1):
            s = i + j + k
            if s == x:
                c += 1
            if s > x:
                break
        if s > x:
            break
    if s > x:
        break
print(c)

Failing test case input:
6 14
0 0

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):
while True:
    (n, x) = map(int, input().split())
    if n == 0 and x == 0:
        break
    c = 0
    for i in range(1,n - 1):
        xi = x - i
        for j in range(i+1,n):
            if xi - j - j <= 0:
                break
            if xi - j <= n:
                c += 1
    print(c)

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
N,M = map(int, input().split())
ans = 0
while not (N == 0 and M == 0):
 for i in range(1, N+1):
  for j in range(1, N+1):
   k = M - i - j
   if ( i==j or i==k or j==k or k < j or k > N): pass
   elif (i + j + k == M): ans += 1
 N,M = map(int, input().split())
print(ans)

Failing test case input:
23 17
0 0

Expected output:
16


Actual output:
48


Fixed submission (verdict: Accepted):
N,M = map(int, input().split())
ans = 0
while not (N == 0 and M == 0):
 for i in range(1, N+1):
  for j in range(i+1, N+1):
   k = M - i - j
   if ( k > N): pass
   elif  k <= j : break
   else: ans += 1
 print(ans)
 ans = 0
 N,M = map(int, input().split())

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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)

Failing test case input:
10 10
0 0

Expected output:
4


Actual output:
0


Fixed submission (verdict: Accepted):
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)

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
while 1 :
    n,x=[int(i) for i in input().split()]
    count=0
    if n==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:
                    print(i,j,k)
                    count=count+1
    print(count)

Failing test case input:
12 22
0 0

Expected output:
14


Actual output:
1 9 12
1 10 11
2 8 12
2 9 11
3 7 12
3 8 11
3 9 10
4 6 12
4 7 11
4 8 10
5 6 11
5 7 10
5 8 9
6 7 9
14


Fixed submission (verdict: Accepted):
while 1 :
    n,x=[int(i) for i in input().split()]
    count=0
    if n==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:
                    count=count+1
    print(count)
Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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)




Failing test case input:
5 0
0 0

Expected output:
0


Actual output:

Fixed submission (verdict: Accepted):
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)

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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)

Failing test case input:
11 6
0 0

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):
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) == x:
            result += 1
    print(result)

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):

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

Failing test case input:
19 35
0 0

Expected output:
36


Actual output:
207


Fixed submission (verdict: Accepted):

while True:
    count=0
    n,x = [int(a)for a in 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:
                    count += 1
    print(count)

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
def counter(n, x):
    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
    return count

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

Failing test case input:
15 19
0 0

Expected output:
20


Actual output:
24


Fixed submission (verdict: Accepted):
def counter(n, x):
    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:
                    count += 1
    return count

while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
    print(counter(n, x))
Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
N,M = map(int, input().split())
ans = 0
while not (N == 0 and M == 0):
 for i in range(1, N+1):
  for j in range(1, N+1):
   k = M - i - j
   if ( i==j or i==k or j==k or k > 0): pass
   elif (i + j + k == M): ans += 1
 N,M = map(int, input().split())
print(ans)

Failing test case input:
5 10
0 0

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
N,M = map(int, input().split())
ans = 0
while not (N == 0 and M == 0):
 for i in range(1, N+1):
  for j in range(i+1, N+1):
   k = M - i - j
   if ( k > N): pass
   elif  k <= j : break
   else: ans += 1
 print(ans)
 ans = 0
 N,M = map(int, input().split())

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
while(True):
	a,b=list(map(int,input().split()))
	if a==0 and b==0:
		break
	c=0
	for i in range(a):
		for j in range(i):
			for k in range(j):
				if i+j+k==b:
					c+=1
	print(c)

Failing test case input:
5 11
0 0

Expected output:
1


Actual output:
0


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

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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)

Failing test case input:
14 7
0 0

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
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
            if k <= j:
                break
            elif k <= n:
                c += 1
    print(c)

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):



while True:
	N, x = map(int,input().split())
	if N == 0 and x == 0:
		break
	
	ctr = 0
	
	for i in range(1, N+1):
		for j in range(i+1, N+1):
			k = x - i -j
			if k <= N and i != k and j != k:
				ctr += 1
			

Failing test case input:
2 7
0 0

Expected output:
0


Actual output:

Fixed submission (verdict: Accepted):




while True:
	N, x = map(int,input().split())
	if N == 0 and x == 0:
		break
	
	ctr = 0
	
	for i in range(1, N+1):
		for j in range(i+1, N+1):
			k = x - i -j
			if k <= j:
				break
			elif k <= N and j < k:
				ctr += 1
				
			
	print(ctr)
Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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)

Failing test case input:
12 22
0 0

Expected output:
14


Actual output:
18


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

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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)

Failing test case input:
3 6
0 0

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
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)

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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)


Failing test case input:
8 11
0 0

Expected output:
5


Actual output:
9


Fixed submission (verdict: Accepted):
def countCombinations(n, x, size=3):
    dp = [[0 for j in range(x + 1)] for i in range(size + 1)]
    dp[0][0] = 1
    for i in range(1, n + 1):
        for row in range(size - 1, -1, -1):
            for col in range(x + 1 - i):
                dp[1+row][i+col] += dp[row][col]
    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)
Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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)

Failing test case input:
8 12
0 0

Expected output:
6


Actual output:
3


Fixed submission (verdict: Accepted):
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
            if k <= j:
                break
            elif k <= n:
                c += 1
    print(c)

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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))



Failing test case input:
7 9
0 0

Expected output:
3


Actual output:
0


Fixed submission (verdict: Accepted):
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))

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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)

Failing test case input:
11 6
0 0

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
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)

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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)


Failing test case input:
7 15
0 0

Expected output:
3


Actual output:
0


Fixed submission (verdict: Accepted):
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 - i - j < n + 1):
                ans += 1
    print(ans)
Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
num_list = []
while True:
    values = [int(x) for x in input().split()]
    if 0 == values[0] and 0 == values[1]:
        break
    num_list.append(values)

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

Failing test case input:
7 5
0 0

Expected output:
0


Actual output:
3


Fixed submission (verdict: Accepted):
num_list = []
while True:
    values = [int(x) for x in input().split()]
    if 0 == values[0] and 0 == values[1]:
        break
    num_list.append(values)

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

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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)


Failing test case input:
2 3
0 0

Expected output:
0


Actual output:

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

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
N,M = map(int, input().split())
ans = 0
while not (N == 0 and M == 0):
 for i in range(1, N+1):
  for j in range(i+1, N+1):
   k = M - i - j
   if ( i==j or i==k or j==k): pass
   elif (i + j + k == M): ans += 1
 N,M = map(int, input().split())
print(ans)

Failing test case input:
5 0
0 0

Expected output:
0


Actual output:
10


Fixed submission (verdict: Accepted):
N,M = map(int, input().split())
ans = 0
while not (N == 0 and M == 0):
 for i in range(1, N+1):
  for j in range(i+1, N+1):
   k = M - i - j
   if ( k > N): pass
   elif  k <= j : break
   else: ans += 1
 print(ans)
 ans = 0
 N,M = map(int, input().split())
Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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)

Failing test case input:
10 10
0 0

Expected output:
4


Actual output:
2


Fixed submission (verdict: Accepted):
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
                    flag = True

    print(cnt)

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
while (1) :
    n, x = map(int, input().split())
    if (n == x == 0) :
        break
    count = 0
    for a in range (1, n) :
        for b in range (2, n) :
            for c in range (3, n) :
                Sum = a + b + c
                if (Sum == x) :
                    count += 1
    print(count)

Failing test case input:
12 22
0 0

Expected output:
14


Actual output:
68


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

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

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
N,M = map(int, input().split())
ans = 0
while not (N == 0 and M == 0):
 for i in range(1, N+1):
  for j in range(1, N+1):
   k = M - i - j
   if ( i==j or i==k or j==k or (k > 0 and k < N)): pass
   elif (i + j + k == M): ans += 1
 N,M = map(int, input().split())
print(ans)

Failing test case input:
3 18
0 0

Expected output:
0


Actual output:
6


Fixed submission (verdict: Accepted):
N,M = map(int, input().split())
ans = 0
while not (N == 0 and M == 0):
 for i in range(1, N+1):
  for j in range(i+1, N+1):
   k = M - i - j
   if ( k > N): pass
   elif  k <= j : break
   else: ans += 1
 print(ans)
 ans = 0
 N,M = map(int, input().split())

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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')
       

Failing test case input:
16 22
0 0

Expected output:
26


Actual output:
count


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

  print(count)
Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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)


Failing test case input:
12 6
0 0

Expected output:
1


Actual output:
6


Fixed submission (verdict: Accepted):
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+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)

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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 (2, n, 1) :
            for c in range (3, n, 1) :
                Sum = a + b + c
                if (Sum == x) :
                    count += 1
    print(count)

Failing test case input:
12 22
0 0

Expected output:
14


Actual output:
68


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

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

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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)


Failing test case input:
10 10
0 0

Expected output:
4


Actual output:
0


Fixed submission (verdict: Accepted):
while 1:
    n, x = map(int, 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
    print(cnt)
Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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 (2, n) :
            for c in range (3, n) :
                Sum = a + b + c
                if (Sum == x) :
                    count += 1
    print(count)

Failing test case input:
19 35
0 0

Expected output:
36


Actual output:
191


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

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

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):




while True:
	N, x = map(int,input().split())
	if N == 0 and x == 0:
		break
	
	n = x 
	ctr = 0
	
	for i in range(1, n):
		for j in range(i+1, n+1):
			k = x - i -j
			if k <= N and i != k and j != k:
				ctr += 1
				print("{} {} {}".format(i, j, k))
	
	print(ctr)

Failing test case input:
1 4
0 0

Expected output:
0


Actual output:
1 3 0
1 4 -1
2 3 -1
2 4 -2
3 4 -3
5


Fixed submission (verdict: Accepted):




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

Problem: p02412
Buggy submission (Python3, verdict: Wrong Answer):
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


Failing test case input:
3 7
0 0

Expected output:
0


Actual output:

Fixed submission (verdict: Accepted):
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
    
for out in rs:
    print(out)