Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, p = map(int, input().split())
ps = []
for i in range(n):
    ps.append(input().split())
    ps[i][1] = int(ps[i][1])
t = 0
i = 0
j = 0
while j < n:
    if ps[i][1] > p:
        ps[i][1] -= p
        t += p
    elif ps[i][1] != 0:
        t += ps[i][1]
        ps[i][1] = 0
        print("{0} {1}".format(ps[i][0], t))
        j += 1
    i = (i + 1) % n


Fixed submission:
n, p = map(int, input().split())
ps = []
for i in range(n):
    ps.append(input().split())
    ps[i][1] = int(ps[i][1])
t = 0
while len(ps) > 0:
    if ps[0][1] > p:
        ps.append([ps[0][0], ps[0][1] - p])
        t += p
        ps.pop(0)
    else:
        t += ps[0][1]
        print("{0} {1}".format(ps[0][0], t))
        ps.pop(0)

Buggy python submission (verdict: Runtime Error):
n, p = map(int, input().split())
ps = []
for i in range(n):
    ps.append(input().split())
    ps[i][1] = int(ps[i][1])
t = 0
i = 0
j = 0
while len(ps) > 0:
    if ps[i][1] > p:
        ps[i][1] -= p
        t += p
        i = (i + 1) % n
    elif ps[i][1] != 0:
        t += ps[i][1]
        print("{0} {1}".format(ps[i][0], t))
        ps.pop(i)
        n -= 1


Fixed submission:
n, p = map(int, input().split())
ps = []
for i in range(n):
    ps.append(input().split())
    ps[i][1] = int(ps[i][1])
t = 0
while len(ps) > 0:
    if ps[0][1] > p:
        ps.append([ps[0][0], ps[0][1] - p])
        t += p
        ps.pop(0)
    else:
        t += ps[0][1]
        print("{0} {1}".format(ps[0][0], t))
        ps.pop(0)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
    c = input()
    if c == "deleteFirst":
        a.pop(0)
    elif c == "deleteLast":
        a.pop()
    else:
        c, v = c.split()
        v = int(v)
        if c == "insert":
            a.insert(0, v)
        else:
            a.remove(v)
print(" ".join(map(str, a)))


Fixed submission:
from collections import deque
n = int(input())
a = deque()
for i in range(n):
    c = input()
    if c == "deleteFirst":
        a.popleft()
    elif c == "deleteLast":
        a.pop()
    else:
        c, v = c.split()
        if c == "insert":
            a.appendleft(v)
        else:
            try:
                a.remove(v)
            except:
                pass
print(" ".join(a))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for i in range(n):
    c = input()
    if c == "deleteFirst":
        a.pop(0)
    elif c == "deleteLast":
        a.pop()
    else:
        c, v = c.split()
        v = int(v)
        if c == "insert":
            a.insert(0, v)
        elif v in a:
            a.remove(v)
print(" ".join(map(str, a)))


Fixed submission:
from collections import deque
n = int(input())
a = deque()
for i in range(n):
    c = input()
    if c == "deleteFirst":
        a.popleft()
    elif c == "deleteLast":
        a.pop()
    else:
        c, v = c.split()
        if c == "insert":
            a.appendleft(v)
        else:
            try:
                a.remove(v)
            except:
                pass
print(" ".join(a))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n = int(input())
d = deque()
for i in range(n):
    c, s = input().split()
    if c == "insert":
        d.append(s)
    else:
        if s in d:
            print("yes")
        else:
            print("no")


Fixed submission:
n = int(input())
d = {}
for i in range(n):
    c, s = input().split()
    if c == "insert":
        d[s] = 0
    else:
        if s in d:
            print("yes")
        else:
            print("no")

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
import bisect
n = int(input())
d = []
for i in range(n):
    c, s = input().split()
    if c == "insert":
        d.insert(bisect.bisect_left(d, s), s)
    else:
        j = bisect.bisect_left(d, s)
        if j < len(d) and d[j] == s:
            print("yes")
        else:
            print("no")


Fixed submission:
n = int(input())
d = {}
for i in range(n):
    c, s = input().split()
    if c == "insert":
        d[s] = 0
    else:
        if s in d:
            print("yes")
        else:
            print("no")
Buggy python submission (verdict: Runtime Error):
class Node:
    def __init__(self, parent = -1, left = -1, right = -1, depth = 0):
        self.parent = parent
        self.left = left
        self.right = right
        self.depth = depth
    
def print_node(i):
    global node
    print("node " + str(i) + ": ", end = "")
    print("parent = " + str(node[i].parent) +", ", end = "")
    print("depth = " + str(node[i].depth) + ", ", end = "")
    if node[i].parent == -1:
        print("root, [", end = "")
    elif node[i].left != -1:
        print("internal node, [", end = "")
    else:
        print("leaf, [", end = "")
    if node[i].left != -1:
        print(str(node[i].left), end = "")
        j = node[i].left
        while node[j].right != -1:
            j = node[j].right
            print(", " + str(j), end = "")
    print("]")
            

n = int(input())
node = [Node() for i in range(n)]
def input_depth(i, n):
    global node
    node[i].depth = n
    if node[i].right != -1:
        input_depth(node[i].right, n)
    if node[i].left != -1:
        input_depth(node[i].left, n + 1)

for i in range(n):
    p, k, *c = list(map(int, input().split()))
    if k > 0:
        node[p].left = c[0]
    for j in range(k):
        node[c[j]].parent = p
        if j != k - 1:
            node[c[j]].right = c[j + 1]

for i in range(n):
    if node[i].parent == -1:
        input_depth(i, 0)
        break

for i in range(n):
    print_node(i)

    


Fixed submission:
import sys
sys.setrecursionlimit(1000000)

class Node:
    def __init__(self, parent = -1, left = -1, right = -1, depth = 0):
        self.parent = parent
        self.left = left
        self.right = right
        self.depth = depth
    
def print_node(i):
    global node
    print("node " + str(i) + ": ", end = "")
    print("parent = " + str(node[i].parent) +", ", end = "")
    print("depth = " + str(node[i].depth) + ", ", end = "")
    if node[i].parent == -1:
        print("root, [", end = "")
    elif node[i].left != -1:
        print("internal node, [", end = "")
    else:
        print("leaf, [", end = "")
    if node[i].left != -1:
        print(str(node[i].left), end = "")
        j = node[i].left
        while node[j].right != -1:
            j = node[j].right
            print(", " + str(j), end = "")
    print("]")
            

n = int(input())
node = [Node() for i in range(n)]
def input_depth(i, n):
    global node
    node[i].depth = n
    if node[i].right != -1:
        input_depth(node[i].right, n)
    if node[i].left != -1:
        input_depth(node[i].left, n + 1)

for i in range(n):
    p, k, *c = list(map(int, input().split()))
    if k > 0:
        node[p].left = c[0]
    for j in range(k):
        node[c[j]].parent = p
        if j != k - 1:
            node[c[j]].right = c[j + 1]

for i in range(n):
    if node[i].parent == -1:
        input_depth(i, 0)
        break

for i in range(n):
    print_node(i)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [0] + list(map(int, input().split()))

for i in range(1, n + 1):
    print(f"node {i}: key = {a[i]}," + (f" parent key = {a[int(i / 2)]}," if i != 1: else "") + (f"{ left key = {a[2 * i]}, " if i * 2 <= n: else = "") + (f" right key = {a[2 * i + 1]}," if 2 * i + 1 <= n: else = ""))
    


Fixed submission:
n = int(input())
a = [0] + list(map(int, input().split()))
def pi(i):
    global a, n
    s = f"node {i}: key = {a[i]}, "
    if i != 1:
        s += f"parent key = {a[int(i / 2)]}, "
    if i * 2 <= n:
        s += f"left key = {a[2 * i]}, "
        if i * 2 + 1 <= n:
            s += f"right key = {a[2 * i + 1]}, "
    print(s)

for i in range(1, n + 1):
    pi(i)
Buggy python submission (verdict: Time Limit Exceeded):
d = []
while True:
    s = input()
    if s[2] == "d":
        break
    elif s[0] == "i":
        d.append(int(s[7:]))
    else:
        print(d.pop(d.index(max(d))))


Fixed submission:
from heapq import *
a = []
while True:
    s = input()
    if s[2] == "d":break
    elif s[0] == "i":heappush(a, -int(s[7:]))
    else:print(-heappop(a))

Buggy python submission (verdict: Time Limit Exceeded):
def insert(k):
    a.append(-1)
    heap_increasekey(a, len(a) - 1, k)
def heap_increasekey(a, i, k):
    a[i] = k
    while i > 1 and a[int(i / 2)] < a[i]:
        a[i], a[int(i / 2)] = a[int(i / 2)], a[i]
        i = int(i / 2)
def heap_extractmax(a):
    m = a[1]
    a[1] = a[-1]
    a.pop()
    max_heapify(a, 1)
    return m

def max_heapify(a, i):
    l = 2 * i
    r = 2 * i + 1
    largest = l if l < len(a) and a[l] > a[i] else i
    if r < len(a) and a[r] > a[largest]:
        largest = r
    if largest != i:
        a[largest], a[i] = a[i], a[largest]
        max_heapify(a, largest)
        
a = [0]
while True:
    s = input()
    if s[2] == "d":
        break
    elif s[0] == "i":
        insert(int(s[7:]))
    else:
        print(heap_extractmax(a))



Fixed submission:
from heapq import *
a = []
while True:
    s = input()
    if s[2] == "d":break
    elif s[0] == "i":heappush(a, -int(s[7:]))
    else:print(-heappop(a))
Buggy python submission (verdict: Time Limit Exceeded):
def cs(n, p, c):
    global count, m
    if p >= count:
        return m
    if n % c[0] == 0:
        count = min(count, p + n // c[0])
        return count
    elif c[0] < n:
        return min(cs(n - c[0], p + 1, c), cs(n, p, c[1:]))
    else:
        return cs(n, p, c[1:])

n, m = map(int, input().split())
c = list(map(int, input().split()))
c.sort(reverse = True)
count = n
print(cs(n, 0, c))


Fixed submission:
def cs(n, p, c):
    global count, m
    if n % c[0] == 0:
        count = min(count, p + n // c[0])
        return count
    elif p + n // c[0] >= count:
        return n
    elif c[0] < n:
        return min(cs(n - c[0], p + 1, c), cs(n, p, c[1:]))
    else:
        return cs(n, p, c[1:])

n, m = map(int, input().split())
c = list(map(int, input().split()))
c.sort(reverse = True)
count = n
print(cs(n, 0, c))
Buggy python submission (verdict: Runtime Error):
while True:
    a, b = map(int, input().rstrip().split())
    print(len(str(a + b)))



Fixed submission:
while True:
    try:
        a, b = map(int, input().rstrip().split())
        print(len(str(a + b)))
    except Exception:
        break

Buggy python submission (verdict: Runtime Error):
while True:
    line = input()
    if not line:
        break
    a, b = map(int, line.rstrip().split())
    print(len(str(a + b)))



Fixed submission:
while True:
    try:
        a, b = map(int, input().rstrip().split())
        print(len(str(a + b)))
    except Exception:
        break

Buggy python submission (verdict: Runtime Error):
while True:
    line = input()
    if line == '':
        break
    a, b = map(int, line.rstrip().split())
    print(len(str(a + b)))



Fixed submission:
while True:
    try:
        a, b = map(int, input().rstrip().split())
        print(len(str(a + b)))
    except Exception:
        break
Buggy python submission (verdict: Runtime Error):
for i in range(1, 10):
    for j in range(1, 10):
        print('{}×{}＝'.format(i,j), i*j)
exit()for i in range(1, 10):
    for j in range(1, 10):
        print(str(i)+'×'+str(j)+'='+str(i*j))
exit()


Fixed submission:
for i in range(1, 10):
    for j in range(1, 10):
        print(str(i)+'x'+str(j)+'='+str(i*j))
exit()
Buggy python submission (verdict: Runtime Error):
import sys
def gcd(a,b):
    if a%b==0:
        return b
    return gcd(b,a%b)

r=[map(int,line.split()) for line in sys.stdin]
for i in r:
    o=gcd(i[0],i[i])
    p=i[0]*i[1]/o
    print(o,p)



Fixed submission:
import sys
def gcd(a,b):
    if a%b==0:
        return b
    return gcd(b,a%b)

r=[list(map(int,line.split())) for line in sys.stdin]
for i in r:
    o=gcd(i[0],i[1])
    p=i[0]*i[1]/o
    print(o,int(p))

Buggy python submission (verdict: Runtime Error):
import sys
def gcd(a,b):
    if a%b==0:
        return b
    return gcd(b,a%b)

r=[list(map(int,line.split())) for line in sys.stdin]
for i in r:
    o=gcd(i[0],i[i])
    p=i[0]*i[1]/o
    print(o,p)



Fixed submission:
import sys
def gcd(a,b):
    if a%b==0:
        return b
    return gcd(b,a%b)

r=[list(map(int,line.split())) for line in sys.stdin]
for i in r:
    o=gcd(i[0],i[1])
    p=i[0]*i[1]/o
    print(o,int(p))
Buggy python submission (verdict: Runtime Error):
import sys
S=lambda s:sum([((i*s)**2)*s for i in range(int(600/s))])
[print(S[int(line)]) for line in sys.stdin]



Fixed submission:
import sys
S=lambda s:sum([((i*s)**2)*s for i in range(int(600/s))])
[print(i) for i in [S(int(line)) for line in sys.stdin]]
Buggy python submission (verdict: Time Limit Exceeded):
while 1:
    n=int(input())
    if not n:break
    l=[int(input()) for _ in range(n)]
    print(max(sum(l[j:i]) for i in range(len(l)+1) for j in range(i)))



Fixed submission:
while 1:
    n=int(input())
    if not n:break
    dp=[0 for _ in range(n)]
    dp[0]=int(input())
    for i in range(1,n):
        v=int(input())
        dp[i]=max(dp[i-1]+v,v)
    print(max(dp))

Buggy python submission (verdict: Time Limit Exceeded):
while 1:
    n=int(input())
    if not n:break
    l=tuple([int(input()) for _ in range(n)])
    print(max(sum(l[j:i]) for i in range(len(l)+1) for j in range(i)))



Fixed submission:
while 1:
    n=int(input())
    if not n:break
    dp=[0 for _ in range(n)]
    dp[0]=int(input())
    for i in range(1,n):
        v=int(input())
        dp[i]=max(dp[i-1]+v,v)
    print(max(dp))

Buggy python submission (verdict: Time Limit Exceeded):
while 1:
    m=0
    l=[]
    n=int(input())
    if not n: break
    for i in range(n):
        j=int(input())
        if i==0:
            m+=j
        elif s*j<0:
            l.extend([m])
            m=j
        else:
            m+=j
        s=j
    l.extend([m])
    b=len(l)
    print(max([sum(l[i:j]) for j in range(1,b+1) for i in range(j)]))


Fixed submission:
while 1:
    n=int(input())
    if not n:break
    dp=[0 for _ in range(n)]
    dp[0]=int(input())
    for i in range(1,n):
        v=int(input())
        dp[i]=max(dp[i-1]+v,v)
    print(max(dp))
Buggy python submission (verdict: Runtime Error):
import math
[print(i) for i in [math.ceil(((4.9*(a/9.8)**2)+5)/5) for a in float(input())]]



Fixed submission:
import math,sys
[print(i) for i in [math.ceil(((4.9*(float(a)/9.8)**2)+5)/5) for a in sys.stdin]]
Buggy python submission (verdict: Runtime Error):
import sys
lc=lambda n:int((n**2+n+2)/2)
[print(i) for i in [lc(int(j)) for j in sts.stdin]]


Fixed submission:
import sys
lc=lambda n:int((n**2+n+2)/2)
[print(i) for i in [lc(int(j)) for j in sys.stdin]]
Buggy python submission (verdict: Runtime Error):
import sys
l=[list(map(float,i.split(","))) for i in sys.stdin]
bmi=lambda i:i[1]/(i[2]**2)
[print(int(i[0])) for i in l bmi(i)>=25]


Fixed submission:
import sys
l=[list(map(float,i.split(","))) for i in sys.stdin]
bmi=lambda i:i[1]/(i[2]**2)
[print(int(i[0])) for i in l if bmi(i)>=25]
Buggy python submission (verdict: Runtime Error):
while 1:
    n,m=list(map(int,input().split()))
    if n==0 and m==0:break
    l=range(1,1+n)
    st=m-1
    while len(l)!=1:
        del l[st]
        st+=(m-1)
        while 1:
            if st>=len(l):
                st=st-len(l)
            if st<len(l):break  
    print(l[0])



Fixed submission:
while 1:
    n,m=list(map(int,input().split()))
    if n==0 and m==0:break
    l=list(range(1,1+n))
    st=m-1
    while len(l)!=1:
        del l[st]
        st+=(m-1)
        while 1:
            if st>=len(l):
                st=st-len(l)
            if st<len(l):break  
    print(l[0])
Buggy python submission (verdict: Runtime Error):
import sys,math
f=lambda x:math.factorial(x)
[print(i) for i in [int(f(int(l[:-1])+3)/f(3)/f(int(l[:-1]))) for l in sys.stdin]]



Fixed submission:
import sys
ab=[0 for _ in range(2001)]
for a in range(1001):
    for b in range(1001):
        ab[a+b]+=1
for l in sys.stdin:
    n=int(l[:-1])
    ans=sum(ab[i]*ab[n-i] for i in range(2001) if 0<=n-i<=2000)
    print(ans)

Buggy python submission (verdict: Runtime Error):
import sys,math
f=lambda x:math.factorial(x)
[print(i) for i in [int(f(int(l[:-1])+3)/f(3)/f(int(l[:-1]))) for l in sys.stdin]]



Fixed submission:
import sys
ab=[0 for _ in range(2001)]
for a in range(1001):
    for b in range(1001):
        ab[a+b]+=1
for l in sys.stdin:
    n=int(l[:-1])
    ans=sum(ab[i]*ab[n-i] for i in range(2001) if 0<=n-i<=2000)
    print(ans)
Buggy python submission (verdict: Runtime Error):
import re,sys
def chk(t):
    for i in range(10):
        if eval(re.sub("X",str(i),t)):
            return i
    return 10

l=[chk(i.replace("=","==")) for i in sys.stdin]
[print(i) if i != 10 else print("NA") for i in l]



Fixed submission:
import re,sys
def chk(t):
    for i in range(10):
        e=re.split("[+=]",re.sub("X",str(i),t))
        if (e[0][0]=="0" and len(e[0])>1) or (e[1][0]=="0" and len(e[1])>1) or (e[2][0]=="0" and len(e[2])>1): continue
        if eval(e[0]+"+"+e[1]) == eval(e[2]):
            return i
    return 10

l=[chk(i.strip()) for i in sys.stdin]
[print(i) if i != 10 else print("NA") for i in l]
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
while 1:
    n=int(input())
    if n==0:break
    l=[int(input()) for _ in range(n)]
    print(min(sum([sum(j[:i]) for i in range(1,5)]) for j in itertools.permutations(l,len(l)-1)))


Fixed submission:
import itertools

while 1:
    n=int(input())
    if n==0:break
    l=[int(input()) for _ in range(n)]
    ll=len(l)
    m=sorted(l)[:ll-1]
    print(sum([sum(m[:i]) for i in range(1,ll)]))

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

while 1:
    n=int(input())
    if n==0:break
    l=[int(input()) for _ in range(n)]
    print(sum([sum(sorted(l)[:len(l)-1][:i]) for i in range(1,len(l))]))



Fixed submission:
import itertools

while 1:
    n=int(input())
    if n==0:break
    l=[int(input()) for _ in range(n)]
    ll=len(l)
    m=sorted(l)[:ll-1]
    print(sum([sum(m[:i]) for i in range(1,ll)]))
Buggy python submission (verdict: Runtime Error):
while 1:
    a,p=map(int,input().split())
    if not a and not p:break
    a=str(a).zfill(p)
    b=[a]
    f=lambda l:int("".join(l))

    for j in range(10):
        m=sorted(a)
        a=str(f(m[::-1])-f(m)).zfill(p)
        if a in b:
            i=b.index(a)
            break
        b.append(a)
    print(i,int(a),j+1-i)



Fixed submission:
from itertools import count
while 1:
    a,p=map(int,input().split())
    if not a and not p:break
    a=str(a).zfill(p)
    b=[a]
    f=lambda l:int("".join(l))
    i=0
    for j in count(1):
        m=sorted(a)
        a=str(f(m[::-1])-f(m)).zfill(p)
        if a in b:
            i=b.index(a)
            break
        b.append(a)
    print(i,int(a),j-i)
Buggy python submission (verdict: Runtime Error):
while 1:
    M,T,P,R=map(int,input().split())
    if not M and not T and not P and not R:break
    d={i:[0,0] for i in range(1,T+1)}
    wa=[[0 for _ in range(P)] for _ in range(T)]
    for _ in range(R):
        m,t,p,j=map(int,input().split())
        if j:
            wa[t-1][p-1]+=20
        else:
            d[t][0]+=1
            d[t][1]+=(m+wa[t-1][p-1]) 
    rank=sorted(d.items(),key=lambda x:(x[1][0],-x[1][1]),reverse=True)        
    f=lambda x:"=".join(sorted(x,key=lambda y:int(y),reverse=True))
    l=[]
    b=[]
    for (i,j) in enumerate(rank):
        if i>0 and rank[i][1]!=rank[i-1][1]:
            l.append(f(b))
            b=[]
        b.append(str(j[0]))
    if b:l.append(f(b))
    print ",".join(l)



Fixed submission:
while 1:
    M,T,P,R=map(int,input().split())
    if not M and not T and not P and not R:break
    d={i:[0,0] for i in range(1,T+1)}
    wa=[[0 for _ in range(P)] for _ in range(T)]
    for _ in range(R):
        m,t,p,j=map(int,input().split())
        if j:
            wa[t-1][p-1]+=20
        else:
            d[t][0]+=1
            d[t][1]+=(m+wa[t-1][p-1]) 
    rank=sorted(d.items(),key=lambda x:(x[1][0],-x[1][1]),reverse=True)        
    f=lambda x:"=".join(sorted(x,key=lambda y:int(y),reverse=True))
    l=[]
    b=[]
    for (i,j) in enumerate(rank):
        if i>0 and rank[i][1]!=rank[i-1][1]:
            l.append(f(b))
            b=[]
        b.append(str(j[0]))
    if b:l.append(f(b))
    print(",".join(l))
Buggy python submission (verdict: Runtime Error):
from itertools import cycle as c

n=int(input())
for _ in range(n):
    tt=input()
    l=[]
    t=""
    for (i,j) in enumerate(tt):
        ct=int(j)
        if ct==0 or i==0:
            if i!=0:
                l.extend([t])
                t=""
            kk=[c([".",",","!","?"," "]),
                c(["a","b","c"]),
                c(["d","e","f"]),
                c(["g","h","i"]),
                c(["j","k","l"]),
                c(["m","n","o"]),
                c(["p","q","r","s"]),
                c(["t","u","v"]),
                c(["w","x","y","z"])]
        if ct!=0 :
            t=kk[ct-1].next()
    print("".join(l))


Fixed submission:
from itertools import cycle as c

n=int(input())
for _ in range(n):
  t=input()
  l=[]
  bf=""
  for nn in map(int,t):
    if not nn:
      l.extend([bf])
      bf=""
      continue
    if not bf:
      if nn:
        kl=[
          c(".,!? "),
          c("abc"),
          c("def"),
          c("ghi"),
          c("jkl"),
          c("mno"),
          c("pqrs"),
          c("tuv"),
          c("wxyz")
        ]
        bf=next(kl[nn-1])
    else:
      bf=next(kl[nn-1])
  print("".join(l))
Buggy python submission (verdict: Runtime Error):
f=lambda A,x,B,C:(A*x+B)%C
while 1:
    N,A,B,C,X=map(int,raw_input().split())
    if not N and not A and not B and not C and not X:break
    Y=list(map(int,raw_input().split()))
    T=X
    c=[[] for _ in range(N)]

    sl=0
    for i in range(10005):
        if T==Y[sl]:
            sl+=1
            if sl==N:break
        T=f(A,T,B,C)
    if i>10000:i=-1
    print(i)



Fixed submission:
f=lambda A,x,B,C:(A*x+B)%C
while 1:
    N,A,B,C,X=map(int,input().split())
    if not N and not A and not B and not C and not X:break
    Y=list(map(int,input().split()))
    T=X
    c=[[] for _ in range(N)]

    sl=0
    for i in range(10005):
        if T==Y[sl]:
            sl+=1
            if sl==N:break
        T=f(A,T,B,C)
    if i>10000:i=-1
    print(i)
Buggy python submission (verdict: Runtime Error):
while 1:
    n=int(input())
    if not n:break    
    t=0
    cnt=0
    for i in range(2,n+1):
        o=n//i
        t+=(i-1) 
        p=n-(i*o-t)
        if o+p//i+1-i<1:break
        if p%i==0:cnt+=1
    print cnt



Fixed submission:
while 1:
    n=int(input())
    if not n:break    
    t=0
    cnt=0
    for i in range(2,n+1):
        o=n//i
        t+=(i-1) 
        p=n-(i*o-t)
        if o+p//i+1-i<1:break
        if p%i==0:cnt+=1
    print(cnt)