Harryxun/stf_run huggingface dataset:
import io,sys
sys.setrecursionlimit(10**6)

def prime(n):
    nums = [True]*n
    primes = []
    for i in range(2,n):
        if nums[i]:
            primes.append(i)
            for j in range(2*i,n,i):
                nums[j] = False
    return primes

def main():
    from collections import Counter
    from collections import deque
    import bisect
    n = int(input())
    num = Counter([])

    primes = prime(int(n**0.5+1))+[n]
    primes = deque(primes)

    while n !=1:
        while True:
            p = primes.popleft()
            q = primes.pop()
            if n%p==0:
                num[p]+=1
                n = n//p
                primes.appendleft(p)
                break
            elif n%q==0:
                num[q]+=1
                n = n//q
                primes.append(q)
                break

    m = max(num.values())
    N = [i*(i+1)//2 for i in range(1,int((2*m)**0.5)+1)]
    ans = 0
    for i in num.values():
        k = bisect.bisect_right(N,i)
        ans+=k
    print(ans)
main()

### FIXED CODE ###

def prime(n):
    nums = [True]*n
    primes = []
    for i in range(2,n):
        if nums[i]:
            primes.append(i)
            for j in range(2*i,n,i):
                nums[j] = False
    return primes

def prime_fac(n):
    fac = {}
    primes = prime(int(n**0.5)+1)
    for p in primes:
        while n%p==0:
            fac[p] = fac.get(p,0)+1
            n//=p
    if n > 1:
        fac[n] = 1
    return fac

def main():
    n = int(input())
    fac = prime_fac(n)

    ans = 0
    for i in fac.values():
        ct = 1
        while i >= ct*(ct+1)//2:
            ct += 1
            ans+=1
    print(ans)
main()
import collections

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

def primes(n):
    sieve = [True] * (n//2)
    for i in range(3,int(n**0.5)+1,2):
        if sieve[i//2]:
            sieve[i*i//2::i] = [False] * ((n-i*i-1)//(2*i)+1)
    return [1, 2] + [2*i+1 for i in range(1,n//2) if sieve[i]]

a, b = map(int, input().split())
l = [i for i, j in collections.Counter(make_divisors(a) + make_divisors(b)).items() if j > 1]
p = {}
if not l:
    print(0)
    exit()
for i in primes(l[-1]+1): p[i] = 1
print(len([x for x in l if p.get(x)]))

### FIXED CODE ###

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

a, b = map(int, input().split())
print(len(set(prime_factorize(a)) & set(prime_factorize(b)))+1)
from scipy.misc import comb
N = int(input())
K = int(input())
n = len(str(N))
ans = comb(n - 1, K) * 9 ** K
for i in range(K):
    ans += comb(n - 1 - i, K - 1 - i) * 9 ** (K - 1 - i) * (int(str(N)[i]) - 1)
    ans += comb(n - 1 - i, K - 2 - i) * 9 ** (K - 1 - i) * (int(str(N)[i + 1]) - 1)

 
print(ans + 1)

### FIXED CODE ###

def comb(a, b):
    ans = 1
    for i in range(b):
        ans *= (a - i)
    for i in range(2, b + 1):
        ans //= i
    return ans

def solve_k1(N):
    ans = 0
    N = str(N)
    len_N = len(N)
    ans += 9 * (len_N - 1)
    ans += int(N[0])
    return ans

def solve_k2(N):
    ans = 0
    N = str(N)
    len_N = len(N)
    if len_N < 2:
        return 0
    ans = comb((len_N - 1), 2) * 9 ** 2 + (int(N[0]) - 1) * ((len_N - 1) * 9) + solve_k1(int(N[1:]))
    return ans

def solve_k3(N):
    ans = 0
    N = str(N)
    len_N = len(N)
    if len_N < 3:
        return 0
    ans = comb(len_N - 1, 3) * 9 ** 3 + (int(N[0]) - 1) * comb(len_N - 1, 2) * 9 ** 2 + solve_k2(int(N[1:]))
    return ans

N = int(input())
K = int(input())
ans = 0
if K == 1:
    ans = solve_k1(N)
elif K == 2:
    ans = solve_k2(N)
else:
    ans = solve_k3(N)
print(ans)
import sys
A = sys.stdin.readline()
B = sys.stdin.readline()

a = int(A.rstrip())
b = int(B.rstrip())
s1 = a+b
s2 = a-b
s3 = a*b

print(max(s1,s2,s3))

### FIXED CODE ###

import sys
A = sys.stdin.readline()
a = A.rstrip()
s = a.split(' ')
s1 = int(s[0]) + int(s[1])
s2 = int(s[0]) - int(s[1])
s3 = int(s[0]) * int(s[1])

print(max(s1,s2,s3))
X, Y, R, G, N = map(int, input().split())
r = [int(x) for x in input().split()]
g = [int(x) for x in input().split()]
n = [int(x) for x in input().split()]
r = sorted(r)[R-X:]
g = sorted(g)[G-Y:]
n = sorted(n, reverse=True)

nr = 0; ng = 0; nn = 0
for i in range(N):
    if n[nn] <= min(r[nr], g[ng]):
        break
    if ng < G and r[nr] > g[ng]:
        g[ng] = n[nn]
        ng += 1
    elif nr < R and r[nr] <= g[ng]:
        r[nr] = n[nn]
        nr += 1
    nn += 1

print(sum(r) + sum(g))

### FIXED CODE ###

X, Y, R, G, N = map(int, input().split())
r = [int(x) for x in input().split()]
g = [int(x) for x in input().split()]
n = [int(x) for x in input().split()]
r = sorted(r)[R-X:]
g = sorted(g)[G-Y:]
n = sorted(n, reverse=True)

nr = 0; ng = 0; nn = 0
for i in range(N):
    if n[nn] <= min(r[nr], g[ng]):
        break
    if r[nr] < g[ng]:
        r[nr] = n[nn]
        nr += 1
        if nr == X:
            nr = X-1
    else:
        g[ng] = n[nn]
        ng += 1
        if ng == Y:
            ng = Y-1
    nn += 1

print(sum(r) + sum(g))
list = S.split("/")
y = int(list[0])
m = int(list[1])
d = int(list[2])

if (y > 2019):
    print("TBD")
elif (y < 2019):
    print("Heisei")
elif (m > 4):
    print("TBD")
elif (m < 4):
    print("Heisei")
elif (d > 30):
    print("TBD")
else:
    print("Heisei")

### FIXED CODE ###

list = input().split("/")
y = int(list[0])
m = int(list[1])

if (y>=2019 and m>=5):
    print("TBD")
else:
    print("Heisei")
HA = input()

HA = HA.split(" ")

H = HA[0]
A = HA[1]

hit = 0

while H < 0:
  H = H - A
  hit = hit + 1

print(hit)

### FIXED CODE ###

S = input().split(" ") #標準入力

H = int(S[0]) #モンスターのHP
A = int(S[1]) #サーバルの攻撃力

atCount = 0 #攻撃回数

while H > 0:
  H = H - A
  atCount = atCount + 1

print(atCount)
i = 0
while 1:
    i+=1
    x = raw_input()
    if x == '0':
       break
    print ('Case {}: {}'.format(i,v))

### FIXED CODE ###

i = 0
while 1:
    i+=1
    x = raw_input()
    if x == '0':
       break
    print ('Case {}: {}'.format(i,x))
l = list(map(int, input().split()))                     
                                                        
N = l[0]                                                
Y = l[1]                                                
ans = [-1,-1,-1]                                        
                                                        
if Y/10000 < N:                                         
    for i in range(int(Y/10000)+1):                     
a = i                                           
n = N - a                                       
Y1 = Y - (a * 10000)                            
if Y1/5000 < n:                                 
for j in range(int(Y1/5000)+1):             
b = j                                   
c = n - j                               
if 10000 * a + 5000 * b + 1000 * c == Y:
ans = [a,b,c]                       
                                                        
print(ans)

### FIXED CODE ###

l = list(map(int, input().split()))

N = l[0]
Y = l[1]
ans = [-1,-1,-1]

if Y/10000 <= N:
    for i in range(int(Y/10000)+1):
        a = i
        n = N - a
        Y1 = Y - (a * 10000)
        if Y1/5000 <= n:
            for j in range(int(Y1/5000)+1):
                b = j
                c = n - j
                if 10000 * a + 5000 * b + 1000 * c == Y:
                    ans = [a,b,c]

print(ans[0],ans[1],ans[2])
N, X, T  = map(int,input))
ans = (N//X + N%X)*T
print(ans)

### FIXED CODE ###

N, X, T  = map(int,input().split())
if N%X == 0:
  print( N//X *T )
else:
  print( ( N//X + 1)*T )
n = int(input())
if (n%7)%4==0:
  print('Yes')
  break
elif (n%4)%7==0:
  print('Yes')
  break
else:
  print('No')

### FIXED CODE ###

n = int(input())
kouho = []
for i in range(26):
    for j in range(15):
        kouho.append(i*4+j*7)
if n in kouho:
    print('Yes')
else:
    print('No')
pi = 3.14159265359
r = int(input())
area = pi*pi*r
length = pi*r*2

print('{:.5f}'.format(area),'{:5f}'.format(length))


### FIXED CODE ###

pi = 3.14159265359 
r = float(input()) 
area = r*r*pi 
length = 2*r*pi 

print('{:.6f}'.format(area),'{:.6f}'.format(length))
N,K = map(int,input().rstrip().split())
A = list(map(int,input().rstrip().split()))
sum =0
while len(A)>=2:
    sum+=1
    A.insert(K,min(A[:K]))
    print(A)
    del A[0:K]
print(sum)

### FIXED CODE ###

import math
N,K = map(int,input().rstrip().split())
print(math.ceil((N-1)/(K-1)))
a=int(input())
b=int(input())
c=int(input())
k=int(input())

ans="no"
for i in range(k+1):
  if a<b<c:
    ans="yes"
  else:
    if a>=b:
      b*=2
    elif b>=c:
      c*=2
    else:
      c*=2

print(ans)


### FIXED CODE ###

a,b,c=map(int, input().split())
k=int(input())

ans="No"
for i in range(k+1):
  if a<b<c:
    ans="Yes"
  else:
    if a>=b:
      b*=2
    elif b>=c:
      c*=2


print(ans)
"""Even Relation
https://atcoder.jp/contests/abc126/tasks/abc126_d
"""
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000)


class Node:
    def __init__(self, node_id, color):
        self.node_id = node_id
        self.color = color
        self.edges = []

class Edge:
    def __init__(self, to, length):
        self.to = to
        self.length = length


def dfs(node, p):
    for edge in node.edges:
        # 親への枝は何もしない
        if edge.to == p:
            continue
        # 枝が偶数なら子を同じ色で塗る
        if edge.length % 2 == 0:
            graph[edge.to].color = node.color
        else:
            if node.color == 1:
                graph[edge.to].color = 0
            else:
                graph[edge.to].color = 1

        dfs(graph[edge.to], node.node_id)


N = int(input())

# グラフ初期化
graph = [Node(node_id=i, color=-1) for i in range(N + 1)]
for i in range(N - 1):
    u, v, w = map(int, input().split())
    graph[u].edges.append(Edge(v, w))
    graph[v].edges.append(Edge(u, w))

# 最初は0始まり
graph[1].color = 0

dfs(graph[1], -1)


for i in range(1, N + 1):
    print(graph[i].color)


### FIXED CODE ###

"""Even Relation
https://atcoder.jp/contests/abc126/tasks/abc126_d
"""
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 5 + 1)


class Node:
    def __init__(self, node_id, color):
        self.node_id = node_id
        self.color = color
        self.edges = []

class Edge:
    def __init__(self, to, length):
        self.to = to
        self.length = length


def dfs(node, p):
    for edge in node.edges:
        # 親への枝は何もしない
        if edge.to == p:
            continue
        # 枝が偶数なら子を同じ色で塗る
        if edge.length % 2 == 0:
            graph[edge.to].color = node.color
        else:
            if node.color == 1:
                graph[edge.to].color = 0
            else:
                graph[edge.to].color = 1

        dfs(graph[edge.to], node.node_id)


N = int(input())

# グラフ初期化
graph = [Node(node_id=i, color=-1) for i in range(N + 1)]
for i in range(N - 1):
    u, v, w = map(int, input().split())
    graph[u].edges.append(Edge(v, w))
    graph[v].edges.append(Edge(u, w))

# 最初は0始まり
graph[1].color = 0

dfs(graph[1], -1)


for i in range(1, N + 1):
    print(graph[i].color)
n , k = map(int, input().split())
a = list(map(int, input().split()))
neg = []
pos = []
mod = 10**9+7
for i in range(n):
    if a[i] >= 0:
        pos.append(a[i])
    else:
        neg.append(a[i])
neg.sort()
pos.sort(reverse = True)
min_num = -1
good_num = -1
if k % 2 == 1 and len(pos) == 0:
    ans = 1
    neg.sort(reverse = True)
    for i in range(k):
        ans *= neg[i]
        ans %= mod
    print(ans)
else:
    #最大化するとき
    for i in range(0,k+1,2):
        #i個だけnegから取る。
        if i > len(neg) or k - i > len(pos):
            continue
        m = 0
        if i != 0:
            m = abs(neg[i-1])
        m = min(m, pos[k-i-1])
        if m > min_num:
            min_num = m
            good_num = i
    ans = 1
    for i in range(good_num):
        ans *= neg[i]
        ans %= mod
    for i in range(k - good_num):
        ans*= pos[i]
        ans %= mod
    print(ans % mod)



### FIXED CODE ###

n , k = map(int, input().split())
a = list(map(int, input().split()))
neg = []
pos = []
mod = 10**9+7
for i in range(n):
    if a[i] >= 0:
        pos.append(a[i])
    else:
        neg.append(a[i])
neg.sort()
pos.sort(reverse = True)
if (len(pos) == 0 and k % 2 == 1) or n == k:
    ans = 1
    a.sort(reverse = True)
    for i in range(k):
        ans *= a[i]
        ans %= mod
    print(ans % mod)
else:
    #最大化するとき
    from collections import deque
    ans = 1
    neg_new = []
    for i in range(0, len(neg)//2):
        neg_new.append(neg[2*i] * neg[2*i+1])
    neg_new = deque(sorted(neg_new, reverse = True))
    pos = deque(pos)
    if k % 2 == 1:
        k -= 1
        ans = pos.popleft()
    else:
        ans = 1
    while k > 0:
        if len(pos) >= 2 and len(neg_new) >= 1:
            if pos[0] * pos[1] > neg_new[0]:
                ans *= pos.popleft() * pos.popleft()
            else:
                ans *= neg_new.popleft()
        elif len(pos) >= 2:
            ans *= pos.popleft() * pos.popleft()
        else:
            ans *= neg_new.popleft()
        k -= 2
        ans %= mod
    print(ans % mod)
N = int(input())
h = list(map(int, input().split()))
dp = [10**6 for i in range(N)]
def rec(n):
    if dp[n] == 10**6:
        if n == 0:
            dp[n] = 0
        elif n == 1:
            dp[n] = abs(h[1]-h[0])
        else:
            dp[n] = min(rec(n-2)+abs(h[n]-h[n-2]), rec(n-1)+abs(h[n]-h[n-1]))
    return dp[n]
print(rec(N-1))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)
N = int(input())
h = list(map(int, input().split()))
dp = [-1 for i in range(N)]
def rec(n):
    if dp[n] == -1:
        if n == 0:
            dp[n] = 0
        elif n == 1:
            dp[n] = abs(h[1]-h[0])
        else:
            dp[n] = min(rec(n-2)+abs(h[n]-h[n-2]), rec(n-1)+abs(h[n]-h[n-1]))
    return dp[n]
rec(N-1)
print(dp[N-1])
N=int(input())
t=[0]*100001
x=[0]*100001
y=[0]*100001

for i in range(1,N+1):
    t[i],x[i],y[i]=map(int, input().split())
count=0

for i in range(1,N+1):
    dt=(t[i])-(t[i-1])
    dist=abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
    if dist>dt:
        break
    else:
        pass
    if dist%2==dt%2:
        pass
    else:
        break
    count+=1
if count==N:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

a,b=map(int, input().split())

if a*b%2==0:
    print("Even")
else:
    print("Odd")
t=list(input())
for i in range(len(t)):
    if t[i]=="?":
        if i==0:
            if t[1]=="D":
                t[0]="P"
            else:
                t[0]="D"
        elif i==len(t)-1:
            t[i]="D"
        else:
            if t[i-1]=="P":
                t[i]="D"
            elif t[i+1]=="D":
                t[i]="P"
            elif t[i+1]=="?":
              t[i]="P"
              t[i+1]="D"
            else:
                t[i]="D"
print("".join(t))

### FIXED CODE ###

import sys
t=list(input())
for i in range(len(t)):
    if t[i]=="?":
        if len(t)==1:
            print("D")
            sys.exit()
        else:
            if i==0:
                if t[1]=="D":
                    t[0]="P"
                else:
                    t[0]="D"
            elif i==len(t)-1:
                t[i]="D"
            else:
                if t[i-1]=="P":
                    t[i]="D"
                elif t[i+1]=="D":
                    t[i]="P"
                elif t[i+1]=="?":
                    t[i]="P"
                    t[i+1]="D"
                else:
                    t[i]="D"
print("".join(t))
def main():
  from collections import deque
  s=input()
  q=int(input())
  turn = 2
  d=deque(s)

  for _ in [0]*q:
      query = input()
      if query[0] == "1":
          t = int(query)
          turn = 3 - turn
      else:
          t,f,c = map(str,query.split())
          if (int(f) + turn)% 2  == 0:
              d.append(c)
          else:
              d.appendleft(c)
  if turn == 2:
      print("".join(d))
  else:
      print("".join(d[::-1]))
main()


### FIXED CODE ###

def main():
  from collections import deque
  s=input()
  q=int(input())
  turn = 2
  d=deque(s)

  for _ in [0]*q:
      query = input()
      if query[0] == "1":
          t = int(query)
          turn = 3 - turn
      else:
          t,f,c = map(str,query.split())
          if (int(f) + turn)% 2  == 0:
              d.append(c)
          else:
              d.appendleft(c)
  if turn == 2:
      print("".join(d))
  else:
      print("".join(list(d)[::-1]))
main()
S = input()
K = int(input())
cost = [ord("z") - ord(s) + 1 for s in S]

ans = ""
for i in range(len(S)):
    if cost[i] <= K:
        K -= cost[i]
        ans += "a"
    else:
        ans += S[i]

ans = ans[:-1] + chr(ord(ans[-1]) + K)
print(ans)


### FIXED CODE ###

S = input()
K = int(input())
cost = [(ord("z") - ord(s) + 1) % 26 for s in S]
A = [chr(ord("a") + i) for i in range(26)]

ans = ""
for i in range(len(S)-1):
    if cost[i] <= K:
        K -= cost[i]
        ans += "a"
    else:
        ans += S[i]

ans += A[(A.index(S[-1]) + K) % 26]
print(ans)
def solve(string):
    n, *l = map(int, string.split())
    l = sorted(l)
    return "Yes" if sum(l[:-1]) > l[-1] else "No"


if __name__ == '__main__':
    print(solve("\n".join[input(), input()]))


### FIXED CODE ###

def solve(string):
    l = map(int, string.split())
    l= sorted(l)
    return "Yes" if sum(l[:len(l)-1]) > l[-1] else "No"


if __name__ == '__main__':
    input()
    print(solve(input()))
import math

def solve():
    A, B, C, D = map(int, input().split())
    gcd = (C * D) // math.gcd(C, D)
    ans_sub = A-1 - ((A-1) // C + (A-1) // D - (A+1) // gcd)
    ans = B - (B // C + B // D - B // gcd) - ans_sub
    print(ans)

if __name__ == '__main__':
    solve()

### FIXED CODE ###

import fractions

def solve():
    A, B, C, D = map(int, input().split())
    gcd = (C * D) // fractions.gcd(C, D)
    ans_sub = A-1 - ((A-1) // C + (A-1) // D - (A-1) // gcd)
    ans = B - (B // C + B // D - B // gcd) - ans_sub
    print(ans)

if __name__ == '__main__':
    solve()
from sys import stdin, stdout
import sys
import bisect
INF=1e9
def get_int(): return int(stdin.readline().strip())
def get_ints(): return map(int,stdin.readline().strip().split()) 
def get_array(): return list(map(int,stdin.readline().strip().split()))
def get_string(): return stdin.readline().strip()
def op(c): return stdout.write(c)
#from collections import defaultdict 
#for _ in range(int(stdin.readline())):
x=get_array()
for i in range(len(x):
    if x[i]==0:
        print(i+1)

### FIXED CODE ###

from sys import stdin, stdout
import sys
import bisect
INF=1e9
def get_int(): return int(stdin.readline().strip())
def get_ints(): return map(int,stdin.readline().strip().split()) 
def get_array(): return list(map(int,stdin.readline().strip().split()))
def get_string(): return stdin.readline().strip()
def op(c): return stdout.write(c)
#from collections import defaultdict 
#for _ in range(int(stdin.readline())):
x=get_array()
for i in range(len(x)):
    if x[i]==0:
        print(i+1)
k=input()
pair=0
for i in range(1,k+1):
     for j in range (2,k+1)
          if i%2==0 and j%2!=0:
              pair+=1
         ELIF i%2!=0 and j%2==0 :
               pair+=1
         
print(pair)

### FIXED CODE ###

import math

n = int( input())

print( math.ceil(n/2) * math.floor(n/2))
NX = input()
NX = "".join(NX).split(" ")
NX = [int(s) for s in NX]
D = NX[0]-NX[1]
if NX[0] ==0 or NX[1]==0:
	print(str(0))
if NX[1]<D:
	Mod = D%NX[1]
	if Mod!=0:
		print(int(2*NX[1]+NX[1]+(D-NX[1]/2)*3))
	else:
		print(int(NX[1]*4+D))
elif NX[1]==D:
	print(int(3*NX[1]))
elif NX[1]>D:	
	Mod = NX[1]%D
	if Mod!=0:
		print(int(NX[1]+(Mod*3)+D+(D*2*int(NX[1]/D))))
	else:
		print(int(NX[1]+int((NX[1]/D))*2*D))

### FIXED CODE ###

N = int(input())
K = input()
K = "".join(K).split(" ")
K = [int(s) for s in K]
K.sort()
ans=0
for s in range(N):
	if int(K[-1])> int(K[-2]):
		ans+=int(K[-2])
	else:
		ans+=int(K[-1])
	del K[-2:]

print(ans)
n=int(input())
edge=[[] for _ in range(n)]
dist=[-1]*n
for i in range(n-1):
    x,y,z=map(int,input().split())
    edge[x-1].append([y-1,z])
    edge[y-1].append([x-1,z])
def dfs(node,d):
    dist[node]=d
    for i in edge[node]:
        if dist[i[0]]==-1:
            dfs(i[0],d+i[1])
dfs(0,0)
print(*[i%2 for i in dist],sep='\n')

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
n=int(input())
edge=[[] for _ in range(n)]
dist=[-1]*n
for i in range(n-1):
    x,y,z=map(int,input().split())
    edge[x-1].append([y-1,z])
    edge[y-1].append([x-1,z])
def dfs(node,d):
    dist[node]=d
    for i in edge[node]:
        if dist[i[0]]==-1:
            dfs(i[0],d+i[1])
dfs(0,0)
print(*[i%2 for i in dist],sep='\n')
a=list(map(int,split().input()))
print(max(0,a[2]-(a[0]-a[1])))

### FIXED CODE ###

a = list(map(int, input().split()))
print(max(0, a[2]-(a[0]-a[1])))
import itertools
D,G=map(int,input().split())
p=[0 for i in range(D)]
c=[0 for i in range(D)]
for i in range(D):
    p[i],c[i]=map(int,input().split())

S=list(itertools.product(range(2),repeat=D))
ans=sum(p)
for seq in S:
    score=0
    prove=0
    for i in range(D):
        if seq[i]==1:
            score+=(p[i]*100*(i+1)+c[i])
            prove+=p[i]
    if score>G:
        continue
    j=-1
    for i in range(D):
        if seq[i]==0:
            j=i
    if (p[j]*100*(j+1)+c[j]+score<G):
        continue
    if (p[j]*100*(j+1)+score<G):
        continue
    k=(score-G)//(-(j+1)*100)
    prove+=k
    score+=k*100*(j+1)
    if ans>prove:
        ans=prove
print(ans)


### FIXED CODE ###

import itertools
D,G=map(int,input().split())
p=[0 for i in range(D)]
c=[0 for i in range(D)]
for i in range(D):
    p[i],c[i]=map(int,input().split())

S=list(itertools.product(range(2),repeat=D))
ans=sum(p)
for seq in S:
    score=0
    prove=0
    for i in range(D):
        if seq[i]==1:
            score+=(p[i]*100*(i+1)+c[i])
            prove+=p[i]
    if score>=G:
        if ans>prove:
            ans=prove
        continue
    j=-1
    for i in range(D):
        if seq[i]==0:
            j=i
    for k in range(p[j]):
        prove+=1
        score+=100*(j+1)
        if G<=score:
            break
    if G>score:
        continue
    if ans>prove:
        ans=prove
print(ans)
x, y = gets.split.map(&:to_i)
def rating_try(x, y)
  if x < 10
     y+(100*(10-x))
  else
     y
  end
end
puts rating_try(x, y)


### FIXED CODE ###

x, y = map(int, input().split())
if x >= 10:
    print(y)
else:
    print(y+100*(10-x))
import sys
sys.setrecursionlimit(10**6)
MOD = 1000000007

k = int(input())
number = 9

ans = 0
for i in range(10,10**6):
    check = 'OK'
    l = len(str(i))
    keta = list(str(i))
    for j in range(l-1):
        if abs(int(keta[j]) - int(keta[j+1])) <= 1:
            pass
        else:
            check = 'NG'
    if check == 'OK':
        number += 1
        if number == k:
            ans = i%MOD
            break
if k <= 9:
    print(k)
else:
    print(ans%MOD)


### FIXED CODE ###

x,y,z = map(int,input().split())
print(z,x,y)
def max_vote(places):
  max_index = places.index(max(places))
  places[max_index] = -1
  return max_index + 1, places

while 1:
  N, M = map(int, raw_input().split())
  if N ==0 and M ==0: break
  places = []
  for m in  range(M):
    places.append(0)
  for n in N:
    votes = map(int, raw_input().split())
    count = 0
    for vote in votes:
      if vote == 1:
        places[count] += 1
      else:
        pass
      count += 1 
  for m in range(M):
    answer, places = max_vote(places)
    print answer,

### FIXED CODE ###

while 1:
    n,m=map(int,raw_input().split())
    if n+m==0:
        break
    a = dict(zip(range(m),[0]*m))
    for i in range(n):
        c=map(int,raw_input().split())
        for j in range(m):
            a[j]+=c[j]
    for k,v in sorted(a.items(),key=lambda x:x[1],reverse=1):
        print k+1,
    print