Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

S = [int(e) for e in input().split()]
list_a =  [int(e) for e in input().split()]
list_b =  [int(e) for e in input().split()]

dis_list = []

for i in range(S[2]):
    dis_list.append([int(e) for e in input().split()])

cost_list = []
min_num = min(list_a) + min(list_b)

for i in list_a:
    for j in list_b:
        cost_list.append(i+j)


for l in dis_list:
    if (cost_list[S[0]*(l[0]-1)+l[1]-1] - l[2]) < min_num:
        min_num = cost_list[S[0]*(l[0]-1)+l[1]-1] - l[2]

print(min_num)

### FIXED CODE ###

S = [int(e) for e in input().split()]
list_a =  [int(e) for e in input().split()]
list_b =  [int(e) for e in input().split()]

dis_list = []

for i in range(S[2]):
    dis_list.append([int(e) for e in input().split()])

min_num1 = min(list_a) + min(list_b)

min_num2_list = []

for l in dis_list:
    min_num2_list.append(list_a[l[0]-1] + list_b[l[1]-1] - l[2])

min_num2 = min(min_num2_list)

if min_num1 > min_num2:
    print(min_num2)
else:
    print(min_num1)
### BUGGY CODE ###

from collections import deque

N,M = map(int, input().split())

es_lang = [[] for _ in range(M+1)] # 各言語の番号がidxで、それを話せる人が中身
es_p = [[] for _ in range(N+1)] # 各人の番号がidxで、その人の話せる言語が中身
for i in range(N):
    KL = list(map(int, input().split()))
    es_p[i+1].extend(KL[1:])
    for j in KL[1:]:
        es_lang[j].append(i+1)

checked_lang = [False] * (M+1)
checked_p = [False] * (N+1)

#人１からスタートする
stack_p = [1]
checked_p[1] = True
while len(stack_p) > 0:
    for p in stack_p:
        #p = stack_p.pop() # 調べる人を取り出す
        checked_p[p] = True
        stack_lang = []
        for lang in es_p[p]: #人ｐが話せる言語について調べる
            if checked_lang[lang] == False: # まだその言語を調査してないとき
                stack_lang.append(lang)
                checked_lang[lang] = True

        # 人pの持つ言語をだれが話せるか調べる
        new_stack_p = []
        for lang in stack_lang:
            for pp in es_lang[lang]:
                if checked_p[pp] == False:
                    new_stack_p.append(pp)
                    checked_p[pp] = True

    if all(checked_p[1:]):
        print("YES")
        exit()
    if len(new_stack_p) > 0:
        stack_p = new_stack_p



print("NO")


### FIXED CODE ###

from collections import deque

N,M = map(int, input().split())

es_lang = [[] for _ in range(M+1)] # 各言語の番号がidxで、それを話せる人が中身
es_p = [[] for _ in range(N+1)] # 各人の番号がidxで、その人の話せる言語が中身
for i in range(N):
    KL = list(map(int, input().split()))
    es_p[i+1].extend(KL[1:])
    for j in KL[1:]:
        es_lang[j].append(i+1)

checked_lang = [False] * (M+1)
checked_p = [False] * (N+1)

#人１からスタートする
stack_p = [1]
checked_p[1] = True
while len(stack_p) > 0:
    new_stack_p = [] # この次のループで調べる人の集合
    for p in stack_p:
        checked_p[p] = True
        stack_lang = []
        for lang in es_p[p]: #人ｐが話せる言語について調べる
            if checked_lang[lang] == False: # まだその言語を調査してないとき
                stack_lang.append(lang)
                checked_lang[lang] = True

        # 人pの持つ言語をだれが話せるか調べる
        for lang in stack_lang:
            for pp in es_lang[lang]: # 人ｐの話せる言語を話せる人について調べる
                if checked_p[pp] == False: # まだその人を調べてないなら次のループで調べる人に入れる
                    new_stack_p.append(pp)
                    checked_p[pp] = True

    if all(checked_p[1:]):
        print("YES")
        exit()
    if len(new_stack_p) > 0:
        stack_p = new_stack_p
    else:
        break



print("NO")
### BUGGY CODE ###

N = int(input())
A = [int(input()) for i in range(N)]

for i in range(N):
    max = 0
    for j in range(N):
        if i != j and A[j] > max:
            max = A[j]
    print(max)


### FIXED CODE ###

N = int(input())
A = [int(input()) for i in range(N)]

No1 = 0
No2 = 0
for i in range(N):
    if A[i] > No1:
        No2 = No1
        No1 = A[i]
    elif A[i] > No2:
        No2 = A[i]

for i in range(N):
    if A[i] == No1:
        print(No2)
    else:
        print(No1)
### BUGGY CODE ###

N,M= map(int,input().split())
LRlis = [list(map(int, input().split())) for i in range(M)]
A = list(range(LRlis[0][0],LRlis[0][1]+1))
for i in range(M):
  B = list(range(LRlis[i][0],LRlis[i][1]+1))
  C = list(set(A) & set(B))

print(len(C))

### FIXED CODE ###

N,M= map(int,input().split())
LRlis = [list(map(int, input().split())) for i in range(M)]
maxL = 0
minR = 10**5
for i in range(M):
  maxL = max(LRlis[i][0],maxL)
  minR = min(LRlis[i][1],minR)

ans = minR-maxL    
if ans>=0:
  print(ans+1)
else:
  print(0)
### BUGGY CODE ###

mod = 10**9+7
s = input()
N = len(s)

dp = [[0]*13 for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
    for j in range(13):
        if s[i] == '?':
            for x in range(10):
                dp[i+1][(10*j+x)%13] += dp[i][j]
                dp[i+1][(10*j+x)%13] %= mod
        else:
            x = int(s[i])
            dp[i+1][(10*j+x)%13] += dp[i][j]
            dp[i+1][(10*j+x)%13] %= mod

print(dp[N][5])

### FIXED CODE ###

mod = 10**9+7
s = input()
N = len(s)

dp = [[0]*13 for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
    for j in range(13):
        if s[i] == '?':
            for x in range(10):
                dp[i+1][(10*j+x)%13] += dp[i][j]
                dp[i+1][(10*j+x)%13] %= mod
        else:
            x = int(s[i])
            dp[i+1][(10*j+x)%13] += dp[i][j]
            dp[i+1][(10*j+x)%13] %= mod

print(dp[N][5])
### BUGGY CODE ###

class UnionFindTree:
    def __init__(self):
        self.p = {}
        self.rank = {}

    def make(self, x):
        self.p[x] = x
        self.rank[x] = 0

    def find(self, x):
        if x in self.p:
            if self.p[x] != x:
                # 経路圧縮
                self.p[x] = self.find(self.p[x])
            return self.p[x]
        return None

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        return self._unite(self.find(x), self.find(y))

    def _unite(self, x, y):
        if self.rank[x] < self.rank[y]:
            self.p[x] = y
            return y
        else:
            self.p[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            return x


N, K, L = map(int, input().split())

utf1 = UnionFindTree()
utf2 = UnionFindTree()
for i in range(N):
    utf1.make(i+1)
    utf2.make(i+1)

for i in range(K):
    p, q = map(int, input().split())
    utf1.unite(p, q)
for i in range(L):
    r, s = map(int, input().split())
    utf2.unite(r, s)

ans = [0]*N
for i in range(1, N+1):
    for j in range(1, N+1):
        a = utf1.same(i, j)
        b = utf2.same(i, j)
        if a and a == b:
            ans[i-1] += 1
print(" ".join([str(_) for _ in ans]))


### FIXED CODE ###

from collections import Counter


class UnionFindTree:
    def __init__(self):
        self.p = {}
        self.rank = {}

    def make(self, x):
        self.p[x] = x
        self.rank[x] = 0

    def find(self, x):
        if x in self.p:
            if self.p[x] != x:
                # 経路圧縮
                self.p[x] = self.find(self.p[x])
            return self.p[x]
        return None

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        return self._unite(self.find(x), self.find(y))

    def _unite(self, x, y):
        if self.rank[x] < self.rank[y]:
            self.p[x] = y
            return y
        else:
            self.p[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            return x


N, K, L = map(int, input().split())

utf1 = UnionFindTree()
utf2 = UnionFindTree()
for i in range(N):
    utf1.make(i+1)
    utf2.make(i+1)

for i in range(K):
    p, q = map(int, input().split())
    utf1.unite(p, q)
for i in range(L):
    r, s = map(int, input().split())
    utf2.unite(r, s)

pairs = [(utf1.find(i+1), utf2.find(i+1)) for i in range(N)]
counts = Counter(pairs)
print(" ".join([str(counts[k]) for k in pairs]))
### BUGGY CODE ###

N,K,C =map(int,input().rstrip().split(" "))
S = input()
kinmu = 0
niti = 0
for i in range(N):
  if S[i] == "o":
    kinmu = 0
    niti = 0
    while kinmu < K and niti < N:
      if S[niti] == "o" and niti != i:
        kinmu += 1
        niti += C
      niti += 1
    if niti >= N and kinmu < K:
      print(i + 1)

### FIXED CODE ###

N,K,C =map(int,input().rstrip().split(" "))
S = input()
kinmu = 0
niti = 0
f = []
b = []
kinmu = 0
niti = 0
while kinmu < K and niti < N:
  if S[niti] == "o":
    f.append(niti)
    kinmu += 1
    niti += C
  niti += 1
kinmu = 0
niti = N -1
while kinmu < K and niti >= 0:
  if S[niti] == "o":
    b.append(niti)
    kinmu += 1
    niti -= C
  niti -= 1
b.reverse()
for i in range(K):
  if f[i] == b[i]:
    print(f[i] + 1)
### BUGGY CODE ###

from itertools import combinations

N = int(input())
A = list(map(int, input().split()))
ref = list(combinations(A, 2))
res = 0

for i in range(len(ref)):
  a, b = ref[i]
  res += (a * b)
print(res % (10 ** 9 + 7))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))

res = 0
sums = sum(A)
for i in range(len(A)):
  sums = sums - A[i]
  a = A[i]
  res += ((a * sums) % (10 ** 9 + 7))
print(res % (10 ** 9 + 7))
### BUGGY CODE ###

from collections import defaultdict
n,x,y=map(int,input().split())
d=defaultdict(list)
for i in range(1,n):
    for j in range(i+1,n+1):
        r=min(abs(i-j),abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i))
        d[r].append((i,j))
for i in range(1,n):
    print(len(d[i]))


### FIXED CODE ###

n,x,y=map(int,input().split())
l=[0]*(n-1)
for i in range(1,n):
    for j in range(i+1,n+1):
        l[(min(abs(i-j),abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i)))-1]+=1
for i in l:
    print(i)
### BUGGY CODE ###

import copy 
def search(A):
  B = list(set(A))
  B.sort(reverse=True)
  if len(A)-len(B) < 2: return (0,0)
  else:
    a1,a2 = 0,0
    for a in copy.deepcopy(B):
      A.pop(A.index(a))
      if a in A:
        A.pop(A.index(a))
        a1 = a
        break
      else:
        B.pop(B.index(a))

    if a1 > 0:
      B = list(set(A))
      B.sort(reverse=True)
      if len(A)-len(B) == 0: return (a1,0)
      for a in copy.deepcopy(B):
        if a in A: A.pop(A.index(a))
        if a in A:
          A.pop(A.index(a))
          a2 = a
          break
        else:
          B.pop(B.index(a))
  return (a1,a2)

N = int(input())
A = map(int, input().split())
A = [a for a in A]
A.sort(reverse=True)
a1, a2 = search(A)
if a1 > 0 and a2 > 0: print(a1*a2)
else: print(0)


### FIXED CODE ###

import numpy as np

def search(A):
  B = list(set(A))
  B.sort(reverse=True)
  if len(A)-len(B) == 0: return 0 

  a1 = 0
  An = np.array(A)
  for n,(i, j) in enumerate(zip(An[0:-1], An[1:])):
    if i == j:
      a1 = i
      break
  del(A[:n+2])

  return a1

N = int(input())
A = map(int, input().split())
A = [a for a in A]
A.sort(reverse=True)
a1 = search(A)
a2 = search(A)
if a1 > 0 and a2 > 0: print(a1*a2)
else: print(0)
### BUGGY CODE ###

n = int(input())

a = []
b = []

for i in range(n):
    aa, bb = map(int, input().split(' '))
    a.append(aa)
    b.append(bb)

order = list(range(n))
tmp_b = b[:]

while(True):
    ok = False
    for i in range(n - 1):
        ok = False
        if tmp_b[i] > tmp_b[i + 1]:
            tmp = tmp_b[i]
            tmp_b[i] = tmp_b[i + 1]
            tmp_b[i + 1] = tmp

            tmp = order[i]
            order[i] = order[i + 1]
            order[i + 1] = tmp
            break
        ok = True
    if ok:
        break

available = False

for i in range(n):

    margin = [0 for i in range(n)]
    now_time = 0
    for i in range(n):
        j = order[i]
        margin[j] = b[j] - (now_time + a[j])
        now_time += a[j]
    
    if min(margin) >= 0:
        available = True
        break
    else:
        min_index = margin.index(min(margin))
        max_index = margin.index(max(margin))

        tmp = order[min_index]
        order[min_index] = order[max_index]
        order[max_index] = tmp


if available:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

n = int(input())

a = []
b = []

for i in range(n):
    aa, bb = map(int, input().split(' '))
    a.append(aa)
    b.append(bb)

order = sorted(range(len(b)), key=lambda k: b[k])

available = False


margin = [0 for i in range(n)]
now_time = 0
for i in range(n):
    j = order[i]
    margin[j] = b[j] - (now_time + a[j])
    now_time += a[j]

if min(margin) >= 0:
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

def main():
    n = int(input())
    a = list(map(int, input().split()))
    ret = 0
    for i in range(n):
        for j in range(i):
            ret += a[i] * a[j]
            ret %= 10 ** 9 + 7
    print(ret)

if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    n = int(input())
    a = list(map(int, input().split()))
    ret = 0
    sum_list = [None] * n + [0]
    for i in range(n-1, -1, -1):
        sum_list[i] = sum_list[i+1] + a[i]
    for i in range(n):
        ret += a[i] * sum_list[i+1]
        ret %= 1000000007
    print(ret)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

n = []
while True:
    try:
        tmp = int(input())
        if tmp == 0:
            break
        else:
            n.append(tmp)
    except EOFError:
        break

for i in range(len(n)):
    f = 1
    for j in range(1,n[i]+1):
        f *= j
    k = 0
    while True:
        if f % (10 ** k) != 0:
            print(k-1)
            break
        else:
            k += 1

### FIXED CODE ###

n = []
while True:
    try:
        tmp = int(input())
        if tmp == 0:
            break
        else:
            n.append(tmp)
    except EOFError:
        break

for i in range(len(n)):
    c = 0
    d = 5
    for j in range(1,n[i]+1):
        while d <= n[i]:
            c += (n[i]//d)
            d *= 5
    print(c)
### BUGGY CODE ###

N=int(input())
S=['']*N
s=['']*N
count=0

for i in range(N):
    S[i]=input()
    if not(S[i] in s):
        count+=1
    s[i]=S[i]

print(count)

### FIXED CODE ###

N=int(input())
S=['']*N
count=0

for i in range(N):
    S[i]=input()

# s=collections.Counter(S)
# print(len(s))
print(len(set(S)))
### BUGGY CODE ###

import numpy as np
N,M = map(int,input().split())
A = np.zeros(M,dtype=int)
B = np.zeros(M,dtype=int)
for i in range(M):
    A[i],B[i] = map(lambda x:int(x)-1,input().split())

def check_connect(connect,cnt,A,B):
    a = cnt[A]
    b = cnt[B]
    if a==-1 and b==-1:
        connect.append([A,B])
        cnt[A] = len(connect)-1
        cnt[B] = cnt[A]
        return connect,1,cnt
    if a == b:
        return connect,0,cnt
    if a==-1 or b==-1:
        if a==-1:
            a = b
            A,B = B,A
        connect[a] += [B]
        cnt[B] = a
        return connect,len(connect[a])-1,cnt
        
    tmp1 = len(connect[a])
    tmp2 = len(connect[b])
    if tmp2 > tmp1:
        a,b = b,a
    connect[a] = connect[a] + connect[b]
    for i in connect[b]:
        cnt[i] = a
    tmp3 = tmp1+tmp2
    connect[b] = []
    return connect,(tmp3*(tmp3-1)-tmp1*(tmp1-1)-tmp2*(tmp2-1))//2,cnt

connect = []
cnt = -np.ones(N,dtype=int)
dfubensa = np.zeros(M,dtype=int)
for i in range(M-1,-1,-1):
    connect,dfubensa[i],cnt = check_connect(connect,cnt,A[i],B[i])

fubensa = dfubensa[0]
print(fubensa)
for i in range(1,M):
    fubensa = fubensa+ dfubensa[i]
    print(fubensa)

### FIXED CODE ###

N,M = map(int,input().split())
A = [0]*M
B = [0]*M
for i in range(M):
    A[i],B[i] = map(lambda x:int(x)-1,input().split())

def check_connect(A,B):
    a = cnt[A]
    b = cnt[B]
    if a==-1 and b==-1:
        connect.append([A,B])
        cnt[A] = len(connect)-1
        cnt[B] = cnt[A]
        return 1
    if a == b:
        return 0
    if a == -1:
        a,b,A,B = b,a,B,A
    if b==-1:
        connect[a] += [B]
        cnt[B] = a
        return len(connect[a])-1
        
    tmp1 = len(connect[a])
    tmp2 = len(connect[b])
    if tmp2 > tmp1:
        a,b = b,a
    connect[a] += connect[b]
    for i in connect[b]:
        cnt[i] = a
    tmp3 = tmp1+tmp2
    connect[b] = []
    return (tmp3*(tmp3-1)-tmp1*(tmp1-1)-tmp2*(tmp2-1))//2

connect = []
cnt = [-1]*N
dfubensa = [0]*M
for i in range(M-1,-1,-1):
    dfubensa[i] = check_connect(A[i],B[i])

fubensa = dfubensa[0]
print(fubensa)
for i in range(1,M):
    fubensa += dfubensa[i]
    print(fubensa)
### BUGGY CODE ###

n = int(input())
a = sorted(map(int,input().split()))

while a[-2] != 0:
    for i in range(n):
        if a[i] != 0:
            w = a[i]
            wi = i
            break
    
    for i in range(n):
        if i != wi:
            a[i] %= w
            
        a = sorted(a)
        
print(a[-1])

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
a.append(0)
a = sorted(a)

while len(a) > 2:
    for i in range(2,n):
        a[i] %= a[1]
        
    a = sorted(set(a))
    n = len(a)
    
print(a[1])
### BUGGY CODE ###

S = input()
N = len(S)
nox_S = S.replace('x','')
if nox_S == nox_S[::-1]:
  si, ei = 0, -1
  ans = 0
  while si <= N+ei:
    if (S[si] == 'x' and S[ei] != 'x'):
      ans += 1
      si += 1
      ei -= 1
      N += 1
      S = S + 'x'
    elif (S[si] != 'x' and S[ei] == 'x'):
      ans += 1
      si += 1
      ei -= 1
      N += 1
      S = 'x' + S
    else:
      si += 1
      ei -= 1
  print(ans)
else:
  print(-1)
  


### FIXED CODE ###

S = input()
N = len(S)
si, ei = 0, N-1
cnt = 0
while si<ei:
  if S[si] != S[ei]:
    if S[si] == 'x':
      si += 1
      cnt+=1
    elif S[ei] == 'x':
      ei -= 1
      cnt+=1
    else:
      print(-1)
      exit()
  else:
    si += 1
    ei -= 1
print(cnt)
### BUGGY CODE ###

import collections
N = int(input())
S = sorted([input() for i in range(N)])
list1 = []
count = 1

for s in S:
  
  c = S.count(s)
  if c == count:
    list1.append(s)
  elif c > count:
    list1 = [s]
    count = c
  #while s in S:
   #   S.remove(s)
  
cc = collections.Counter(list1)
for i in cc:  
  print(i)

### FIXED CODE ###

N = int(input())
dic = {}

for i in range (N):
  s = input()
  if s in dic:
    dic[s] += 1
  else:
    dic[s] = 1

sai = max(dic.values())

for j in sorted(k for k in dic if dic[k] == sai):
  print(j)
### BUGGY CODE ###

import copy

n, p = list(map(int, input().split()))
s = input()


memo = {}
ans = 0
for i in range(n):
    memo2 = {int(s[i]) % p: 1}
    for j in memo:
        if (j * 10 + int(s[i])) % p not in memo2:
            memo2[(j * 10 + int(s[i])) % p] = memo[j]
        else:
            memo2[(j * 10 + int(s[i])) % p] += memo[j]
    memo = copy.deepcopy(memo2)
    if 0 in memo:
        ans += memo[0]
print(ans)


### FIXED CODE ###

n, p = map(int, input().split())
s = input()

ans = 0
if p == 2:
    for i, char in enumerate(s):
        if int(char) % 2 == 0:
            ans += i + 1
    print(ans)

elif p == 5:
    for i, char in enumerate(s):
        if int(char) % 5 == 0:
            ans += i + 1
    print(ans)

else:
    a = [0] * (n + 1)
    for i in range(n):
        a[i + 1] = a[i] + int(s[n - i - 1]) * pow(10, i, p)
        a[i + 1] %= p
    memo = {}
    for i in range(n + 1):
        if a[i] not in memo:
            memo[a[i]] = 1
        else:
            memo[a[i]] += 1
    for i in memo:
        ans += memo[i]* (memo[i] - 1) // 2
    print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))

bit = [0] * 60
mod = 10 ** 9 + 7
ans = 0
for i in range(60):
    c = 0
    for j in range(n):
        c += int(a[j] & 1)
        a[j] >>= 1
    ans = (ans + c * (n - c) * (1 << i)) % mod

print(ans)

### FIXED CODE ###

import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))

bit = [0] * 60
mod = 10 ** 9 + 7
ans = 0
for i in range(60):
    n1 = np.count_nonzero((a >> i) & 1)
    n0 = n - n1
    ans += (2 ** i) * n1 * n0 % mod
print(ans % mod)
### BUGGY CODE ###

H,W = list(map(int,input().split()))

M = []
for i in range(H):
    M.append(list(input()))

from collections import deque

out = 0
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

for sx in range(0,W):
    for gx in range(0,W):
        for sy in range(0,H):
            for gy in range(0,H):
                if M[sy][sx]=="#":
                    continue
                if (sx==gx)and(sy==gy):
                    continue
                d = [[10**4] * W for i in range(H)]
                que = deque([])
                que.append((sy, sx))
                d[sy][sx] = 0
                while que:
                    p = que.popleft()
                    if p[0] == gy and p[1] == gx:
                        break
                    for i in range(4):
                        ny = p[0] + dy[i]
                        nx = p[1] + dx[i]
                        if (0<=nx<W)and(0<=ny<H)and(M[ny][nx]!="#")and(d[ny][nx]==10**4):
                            que.append((ny, nx))
                            d[ny][nx] = d[p[0]][p[1]] + 1
                if out < d[gy][gx] and M[gy][gx]!="#":
                    out=d[gy][gx]
print(out)

### FIXED CODE ###

H,W = list(map(int,input().split()))

M = []
for i in range(H):
    M.append(list(input()))

from collections import deque

out = 0
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

for sx in range(0,W):
    for sy in range(0,H):
        if M[sy][sx]=="#":
            continue
        d = [[10**4] * W for i in range(H)]
        que = deque([])
        que.append((sy, sx))
        d[sy][sx] = 0
        while que:
            p = que.popleft()
            for i in range(4):
                ny = p[0] + dy[i]
                nx = p[1] + dx[i]
                if (0<=nx<W)and(0<=ny<H)and(M[ny][nx]!="#")and(d[ny][nx]==10**4):
                    que.append((ny, nx))
                    d[ny][nx] = d[p[0]][p[1]] + 1
                    out = max(d[ny][nx],out)
print(out)
### BUGGY CODE ###

N, Y = map(int, input().split())
count = 0
yen = [0] * 3

for i in reversed(range(Y // 10000 + 1)):
    yen[0] = i
    for j in range(Y // 5000 + 1):
        yen[1] = j
        yen[2] = N - i - j
        if Y - 10000 * i - 5000 * j < 0:
            break
        elif Y - 10000 * i - 5000 * j == 1000 * yen[2]:
            print(' '.join(map(str, yen)))
            exit()
        else:
            continue
print('-1 -1 -1')

### FIXED CODE ###

N, Y = map(int, input().split())
count = 0
yen = [0] * 3

for i in reversed(range(Y // 10000 + 1)):
    yen[0] = i
    for j in range(Y // 5000 + 1):
        yen[1] = j
        yen[2] = N - i - j
        if Y - 10000 * i - 5000 * j < 0 or yen[2] < 0:
            break
        elif Y - 10000 * i - 5000 * j == 1000 * yen[2]:
            print(' '.join(map(str, yen)))
            exit()
        else:
            continue
print('-1 -1 -1')