Harryxun/stf_run huggingface dataset:
data=int(input())
count=0

for i in range(10):
  a=i
  c=data%i
  if c==0:
    b=data//i
    if a<=9 and b<=9 :
    count+=1
if count>=1:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

data=int(input())
sum=0

for i in range(9):
  a=data%(i+1)
  b=data/(i+1)
  if a==0 and b<=9:
    sum+=1
if sum>=1:
  print("Yes")
else:
  print("No")
N = int(input())
for _ in range(N):
  a, b, c = map(int, input().split())
  if (100*a+10*b+c)%2:
    print("No")
  else:
    v = (100*a+10*b+c)//2
    
    a1 = min(v//100, a)
    b1 = min((v-100*a1)//10, b)
    c1 = min(v-100*a1-10*b1, c)
    
    d1 = 100*a1+10*b1+c1
    d2 = 100*(a-a1)+10*(b-b1)+(c-c1)
    print("Yes" if d1==d2 else "No")


### FIXED CODE ###

h,w=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(h)]
m=[]

for y in range(h):
  for x in range(w):
    if x<w-1 and l[y][x]%2:
      l[y][x]-=1
      l[y][x+1]+=1
      m.extend([[y+1,x+1,y+1,x+2]])

for x in range(w):
  for y in range(h):
    if y<h-1 and l[y][x]%2:
      l[y][x]-=1
      l[y+1][x]+=1
      m.extend([[y+1,x+1,y+2,x+1]])

print(len(m))
for i in m:
  print(*i,sep=" ")
input_sample=iter("""
1
0 0
""".split("\n")[1:-1])

#問題を解く
N=int(input())
xy=[list(map(int,input().split())) for _ in range(N)]

from collections import Counter
list_=[]

for i in range(N):
    for j in range(i+1,N):
        if xy[i][0]-xy[j][0]<0:
            list_.append((abs(xy[i][0]-xy[j][0]),abs(xy[i][1]-xy[j][1])))
        else:
            list_.append((xy[i][0]-xy[j][0],xy[i][1]-xy[j][1]))

if N==1:
    print(1)
else:
    print(N-Counter(list_).most_common()[0][1])

### FIXED CODE ###

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

if K==1:
    print(0)
else:
    print(N-K)
N, M, Q = list(map(int, input().split()))
a = [0]*Q
b = [0]*Q
c = [0]*Q
d = [0]*Q
for i in range(Q):
  a[i], b[i], c[i], d[i] = list(map(int, input().split()))
li = [1]*12
ans = 0

def countup(l, n, m):
  l[n] += 1
  if l[n] > m:
    l[n] -= 1
    countup(l, n-1, m)
  return

while(li[0]==1):
  pt = 0
  for i in range(Q):
    if (li[b[i]]-li[a[i]]==c[i]):
      pt += d[i]
  ans = max(ans, pt)
  countup(li, N, M)

print(ans)

### FIXED CODE ###

N, M, Q = list(map(int, input().split()))
a = [0]*Q
b = [0]*Q
c = [0]*Q
d = [0]*Q
for i in range(Q):
  a[i], b[i], c[i], d[i] = list(map(int, input().split()))
li = [1]*11
ans = 0

def countup(l, n, m):
  l[n] += 1
  if l[n] > m:
    if n == 0:
      return
    countup(l, n-1, m)
    l[n] = l[n-1]
  return

while(li[0]==1):
  pt = 0
  for i in range(Q):
    if (li[b[i]]-li[a[i]]==c[i]):
      pt += d[i]
  ans = max(ans, pt)
  countup(li, N, M)

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

if len(A)%2 == 0:
    result = 2**(len(A)//2)
    a = np.arange(1, len(A), 2).tolist()
    a = sorted(a+a)
    if a == A:
        pass
    else:
        result = 0
else:
    result = 2**(len(A)//2)
    a = np.arange(2, len(A), 2).tolist()
    a = sorted([0]+a+a)
    if a == A:
        pass
    else:
        result = 0
print(result)

### FIXED CODE ###

import numpy as np

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

if len(A)%2 == 0:
    result = (2**(len(A)//2))%(10**9+7)
    a = np.arange(1, len(A), 2).tolist()
    a = sorted(a+a)
    if a == A:
        pass
    else:
        result = 0
else:
    result = 2**(len(A)//2)%(10**9+7)
    a = np.arange(2, len(A), 2).tolist()
    a = sorted([0]+a+a)
    if a == A:
        pass
    else:
        result = 0
print(result)
N = int(input())
graph = [[] for  _ in range(N)]
now = 0
for _ in range(N-1):
    x,y,w = map(int,input().split())
    x -= 1
    y -= 1
    graph[x].append((y,w))
    graph[y].append((x,w))
    now = x
    
vis = [0 for _ in range(N)]

even = set()
odd = set()

def dfs(now):
    for nv in graph[now]:
        if vis[nv[0]]: continue
        if nv[1] % 2 == 0:
            if nv in even:
                even.add(nv[1])
            else:
                odd.add(nv[1])
        else:
            if nv in even:
                odd.add(nv[1])
            else:
                even.add(nv[1])
        vis[nv[0]] = 1
        dfs(nv[0])
vis[x] = 1
even.add(x)
dfs(x)
for i in range(N):
    if i in even:
        print(1)
    else:
        print(0)



### FIXED CODE ###

N = int(input())
graph = [[] for  _ in range(N)]
now = 0
for _ in range(N-1):
    x,y,w = map(int,input().split())
    x -= 1
    y -= 1
    graph[x].append((y,w))
    graph[y].append((x,w))
    now = x
    
vis = [0 for _ in range(N)]

even = set()
odd = set()
import sys
sys.setrecursionlimit(10000000)


def dfs(now):
    #print(now)
    for nv in graph[now]:
        if vis[nv[0]]: continue
        if nv[1] % 2 == 0:
            if now in even:
                even.add(nv[0])
            else:
                odd.add(nv[0])
        else:
            if now in even:
                odd.add(nv[0])
            else:
                even.add(nv[0])
        vis[nv[0]] = 1
        dfs(nv[0])
vis[x] = 1
even.add(x)
dfs(x)

for i in range(N):
    if i in even:
        print(1)
    else:
        print(0)
item = [int(i) for i in input().split()]
print(item[0]*item[1]+" ")

### FIXED CODE ###

item = [int(i) for i in input().split()]
print(item[0]*item[1],2*(item[0]+item[1]))
import math

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

A = [X]
vis = [-1] * M
vis[X] = 0
for i in range(1, M):
    X = X ** 2 % M
    if vis[X] != -1:
        pref = A[:vis[X]]
        cycle = A[vis[X]:]
        break
    A.append(X)
    vis[X] = i

n_full_period = (N - len(pref)) // len(cycle)
suffix_length = N - len(pref) - n_full_period * len(cycle)

ans = 0
ans += sum(pref)
ans += sum(cycle) * n_full_period
ans += sum(cycle[:suffix_length])
print(ans)

### FIXED CODE ###

'''
Doubling

nxt[i][r] = the value of r mod M after 2 ** i squaring
dp[i][r] = the sum of sequence of lenght 2 ** i starting from r

We split sequence A into multiple disjoint parts, 
where the lengths of each parts are the binary decomposition of N.

e.g.
N = 11 = 1 + 2 + 8
A = A[0:1], A[1:3], A[3:11]
Sum of each parts are:
sum(A[0:1]) = dp[0][A[0] % M]
sum(A[1:3]) = dp[1][A[1] % M]
sum(A[3:11]) = dp[3][A[3] % M]
'''

import math

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

H = math.ceil(math.log2(N)) + 1

nxt = [[0] * M for _ in range(H)]
dp = [[0] * M for _ in range(H)]
nxt[0] = [r ** 2 % M for r in range(M)]
dp[0] = list(range(M))

for i in range(1, H):
    for r in range(M):
        nxt[i][r] = nxt[i - 1][nxt[i - 1][r]]
        dp[i][r] = dp[i - 1][r] + dp[i - 1][nxt[i - 1][r]]

ans = 0
r = X % M
for i in range(H):
    if N & (1 << i):
        ans += dp[i][r]
        r = nxt[i][r]
print(ans)
from sys import stdin

x = int(stdin.readline().rstrip())

fivelist = []

i = 0
while True:
    n = i**5
    #print(i,n)
    if n > 2*(10**9):
        break
    fivelist.append(n)
    i+=1

for i in range(len(fivelist)):
    for j in range(len(fivelist)):
        if x == (fivelist[i] - fivelist[j]):
            a, b = i , j
            break
        if x == (-fivelist[i] - fivelist[j]):
            a, b = -i , j
            break
        if x == (fivelist[i] + fivelist[j]):
            a, b = i , -j
            break
        if x == -(fivelist[i] + fivelist[j]):
            a, b = -i , -j
            break

print("{} {}".format(a,b))


### FIXED CODE ###

from sys import stdin
import random

#a , b = 81,79
#x = a**5 - b**5
'''
while x < 1 or x > 10**9:
    a = random.randint(-100, 100)
    b = random.randint(-100, 100)
    x = a**5 - b**5
'''
#print(a,b,x)
x = int(stdin.readline().rstrip())

fivelist = []

i = 0
while True:
    n = i**5
    # print(i,n)
    if n > 2*(10**15):
        break
    fivelist.append(n)
    i += 1


a = 0
b = 0
ans = False
for i in range(len(fivelist)):
    for j in range(len(fivelist)):
        if x == (fivelist[i] - fivelist[j]):
            a, b = i, j
            ans = True
            break
        if x == (-fivelist[i] - fivelist[j]):
            a, b = -i, j
            ans = True
            break
        if x == (fivelist[i] + fivelist[j]):
            a, b = i, -j
            ans = True
            break
        if x == (-fivelist[i] + fivelist[j]):
            a, b = -i, -j
            ans = True
            break
    if ans:
        break

print("{} {}".format(a, b))
o=list(input())
e=list(input())+[""]
for x,y in zip(x,y):print(x,y,end="") 

### FIXED CODE ###

o=list(input())
e=list(input())+[""]
for x,y in zip(o,e):print(x+y,end="")
from math import atan, degrees
a, b, x = map(int, input().split())
x = x / a ** 2
if x >= b / 2:
    print(degrees(atan(a / (2 * b - 2 * x))))
else:
    print(degrees(atan(2 * a * x / b ** 2)))


### FIXED CODE ###

from math import atan, degrees
a, b, x = map(int, input().split())
if x == a * b * b:
    print(0)
else:
    x = x / a ** 2
    if x >= b / 2:
        print(90-degrees(atan(a / (2 * b - 2 * x))))
    else:
        print(90-degrees(atan(2 * a * x / b ** 2)))
a,b,c,d = map(int, (input().split))
if a < c and b < d:
    print(b-c)
elif c < a and b < d:
    print(b-a)
elif a < c and d < b:
    print(d-c)
elif c < a and d < b:
    print(d-a)
else:
    print(0)

### FIXED CODE ###

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


if a <= c and b <= d and c <= b:
    print(b-c)
elif c <= a and b <= d:
    print(b-a)
elif a <= c and d <= b:
    print(d-c)
elif c <= a and d <= b and a <= d:
    print(d-a)
else:
    print(0)
n,h=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
a=set()
for i in range(n):
  a.add(l[i][0])
maxA=max(a)
b=set()
for i in range(n):
  b.add(l[i][1])
b=sorted(b)
b.reverse()
damage=0
count=0
f=0
for i in range(n):
  if damage>=h:
    f=1
    break
  else:
    if b[i]>max(a):
      damage+=b[i]
      count+=1
    else:
      break
if f==1:
  print(count)
else:
  count+=((h-damage-1)//maxA)+1
  print(count)

### FIXED CODE ###

n,h=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
a=set()
for i in range(n):
  a.add(l[i][0])
maxA=max(a)
b=[]
for i in range(n):
  if l[i][1]>maxA:
    b.append(l[i][1])
b.sort()
b.reverse()
damage=0
count=0
f=0
for i in range(len(b)):
  if damage>=h:
    f=1
    break
  else:
    if b[i]>maxA:
      damage+=b[i]
      count+=1
    else:
      break
if f==1:
  print(count)
else:
  count+=((h-damage-1)//maxA)+1
  print(count)
s = str(input())
c1 = 0
c2 = 0
x = 1
def hen(n):
  if n == 1:
    return 0
  else:
    return 1
for i in range(len(s)):
  si = int(s[i])
  if si == x:
    c1 += 1
  else:
    c2 + = 1
  x = hen(x)
print(min(c1,c2))

### FIXED CODE ###

s = str(input())
c1 = 0
c2 = 0
x = 1
def hen(n):
  if n == 1:
    return 0
  else:
    return 1
for i in range(len(s)):
  si = int(s[i])
  if si == x:
    c1 += 1
  else:
    c2 += 1
  x = hen(x)
print(min(c1,c2))
a = int(input())
b = int(input())
 
if a * b % 2 == 0:
  print("Even")
else:
  print("Odd")

### FIXED CODE ###

a, b = map(int, input().split())
 
if a * b % 2 == 0:
  print("Even")
else:
  print("Odd")
N = int(input())

if N % 2 = 0:
 print(N)
else:
 print(N*2)

### FIXED CODE ###

N = int(input())
if N % 2 == 0:
  print(N)
else:
  print(N * 2)
x = map(int, input().split())

for i in range(5):
    if x[i] == 0:
        print(i+1)


### FIXED CODE ###

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

for i in range(5):
    if x[i] == 0:
        print(i+1)
def bomb(field,x,y):
    rfield = field[:][:]
    rfield[y][x] = 0
    for i in range(-3,4):
        if 0 <= x+i <= 7:
            if rfield[y][x+i] == 1:
                rfield = bomb(rfield,x+i,y)
        if 0 <= y+i <= 7:
            if rfield[y+i][x] == 1:
                rfield = bomb(rfield,x,y+i)
    return rfield


n = int(raw_input())
for data in range(1,n+1):
    # read condition
    field = []
    for line in range(8):
        field.append(map(int, list(raw_input())))
    x = int(raw_input())-1
    y = int(raw_input())-1

    # bombing!
    field = bomb(field,x,y)

    # print result
    print "Data %d:"%(data)
    for i in range(8):
        print "".join(map(str, field[i]))

### FIXED CODE ###

def bomb(f,x,y):
    rf = f[:][:]
    rf[y][x] = 0
    for i in [-3,-2,-1,1,2,3]:
        if 0 <= x+i <= 7:
            if rf[y][x+i] == 1: rf = bomb(rf,x+i,y)
        if 0 <= y+i <= 7:
            if rf[y+i][x] == 1: rf = bomb(rf,x,y+i)
    return rf


n = int(raw_input())
for data in range(1,n+1):
    f = []
    raw_input()
    for line in range(8):
        f.append(map(int, list(raw_input())))
    x = int(raw_input())-1
    y = int(raw_input())-1

    f = bomb(f,x,y)

    print "Data %d:"%(data)
    for i in range(8):
        print "".join(map(str, f[i]))
H, W = map(int, input().split())
S = [input() for _ in range(H)]
M = [(0, 0)]


def dfs(x, y, c):
    cc = float('inf')
    for xx, yy in [(x + 1, y), (x, y + 1), (x - 1, y), (x, y - 1)]:
        if (H, W) == (yy + 1, xx + 1):
            return c + 1
        if 0 <= yy < H and 0 <= xx < W and S[yy][xx] == '.' and \
                (xx, yy) not in M:
            M.append((xx, yy))
            cc = min(cc, dfs(xx, yy, c + 1))
    return cc


def main():
    ans = 0
    for i in range(H):
        ans += S[i].count('.')
    print(ans - dfs(0, 0, 1))


main()


### FIXED CODE ###

H, W = map(int, input().split())
S = [input() for _ in range(H)]


def bfs():
    q = [(0, 0)]
    nq = []
    m = []
    c = 1
    while len(q) > 0:
        while len(q) > 0:
            x, y = q.pop(0)
            for xx, yy in [(x + 1, y), (x, y + 1), (x - 1, y), (x, y - 1)]:
                if (H, W) == (yy + 1, xx + 1):
                    return c + 1
                if 0 <= yy < H and 0 <= xx < W and S[yy][xx] == '.' and \
                        (xx, yy) not in m:
                    m.append((xx, yy))
                    nq.append((xx, yy))
        q = nq
        nq = []
        c += 1
    return -1


def main():
    ans = 0
    for i in range(H):
        ans += S[i].count('.')
    c = bfs()
    if c == -1:
        print(-1)
    else:
        print(ans - c)


main()
n=int(input())
edges=[list(map(int,input().split())) for i in range(n-1)]
e = [[] for i in range(n)]
for a,b in edges:
  a-=1;b-=1
  e[a].append(b);e[b].append(a)
c=sorted(list(map(int,input().split())))
print(sum(c[:-1]))
visited=[False for i in range(n)]
node=[0]*n
cnt=0
def dfs(pos):
  global cnt,node,c
  if visited[pos]:return
  visited[pos]=True
  for p in e[pos]:
    dfs(p)
  node[pos]=c[cnt]
  cnt+=1
dfs(0)
print(' '.join(map(str,node)))

### FIXED CODE ###

import sys
import resource

sys.setrecursionlimit(20000)
n=int(input())
edges=[list(map(int,input().split())) for i in range(n-1)]
e = [[] for i in range(n)]
for a,b in edges:
  a-=1;b-=1
  e[a].append(b);e[b].append(a)
c=sorted(list(map(int,input().split())))
print(sum(c[:-1]))
visited=[False for i in range(n)]
node=[0]*n
cnt=0
def dfs(pos):
  global cnt,node,c
  if visited[pos]:return
  visited[pos]=True
  for p in e[pos]:
    dfs(p)
  node[pos]=c[cnt]
  cnt+=1
dfs(0)
print(' '.join(map(str,node)))
n1, n2  = [int(i) for i in input().split()]

na3 = []

for i4 in range(n1):
    na3.append([int(j) for j in input().split()])

na5 = [0] * n2

for i6 in range(n1):
    for i7 in range(na3[i6][0] + 1):
        if i7 != 0:
            na5[na3[i6][i7 - 1]] += 1
            
r8 = 0
for i9 in range(n2):
    if na5[i9] == n1:
        r8 += 1

print(r8)

### FIXED CODE ###

n1, n2  = [int(i) for i in input().split()]

na3 = []

for i4 in range(n1):
    na3.append([int(j) for j in input().split()])

na5 = [0] * (n2 + 1)

for i6 in range(n1):
    for i7 in range(na3[i6][0] + 1):
        if i7 != 0:
            na5[na3[i6][i7]] += 1

r8 = 0
for i9 in range(n2 + 1):
    if na5[i9] == n1:
        r8 += 1

print(r8)
n = int(input())
a = 1
for i range in (1,n):
    if i % 10 == 3:
        print('{0}'.format(i))
    elif i % 3 == 0:
        if i % 10 == 3:
            continue
        print('{0}'.format(i))
    a = i
    a = a + 1
    


### FIXED CODE ###

n = int(input())
for i in range(1, n+1):
    if i%3 == 0 :
        print(' {}'.format(i),end='')

    elif '3' in str(i):
        print(' {}'.format(i),end='')
print()
time=[]
for i in range(5):
  time.append(input())

num=[]
min=10
  
for list in time:
  if list%10==0:
    num.append(list)
  else:
    num.append(list+(10-list%10))
    if min>list%10:
      min=list%10

print(sum(num)-(10-min))
  
  



### FIXED CODE ###

time=[]
for i in range(5):
  time.append(int(input()))

num=[]
min=10
  
for list in time:
  if list%10==0:
    num.append(list)
  else:
    num.append(list+(10-list%10))
    if min>list%10:
      min=list%10

print(sum(num)-(10-min))
N,M,L = map(int, input().split())
A = [0]*M
B = [0]*M
C = [0]*M
for i in range(M):
    A[i], B[i], C[i] = map(int, input().split())
    
Q = int(input())
qlist = [[int(q) for q in input().split()] for _ in range(Q)]

INF = 10**13
d = [[INF]*N for _ in range(N)]
for i in range(M):
    d[A[i]-1][B[i]-1] = C[i]
    d[B[i]-1][A[i]-1] = C[i]
    d[i][i] = 0
        

# Warshall-Floyd法
# DP
for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][k]+d[k][j])

d2 = [[INF]*N for _ in range(N)]
for i in range(N):
    for j in range(N):
        if i == j:
            d2[i][j] = 0
        elif d[i][j] <= L:
            d2[i][j] = 1
            
for i in range(N):
    for j in range(N):
        for k in range(N):
            d2[i][j] = min(d2[i][j], d2[i][k]+d2[k][j])
                
for i in range(Q):
    s = qlist[i][0]-1
    t = qlist[i][1]-1
    ans = d2[s][t]
    if ans >= INF:
        print(-1)
    else:
        print(ans-1)

### FIXED CODE ###

N,M,L = map(int, input().split())
A = [0]*M
B = [0]*M
C = [0]*M
for i in range(M):
    A[i], B[i], C[i] = map(int, input().split())
    
Q = int(input())
qlist = [[int(q) for q in input().split()] for _ in range(Q)]

INF = 10**18
d = [[INF]*N for _ in range(N)]
for i in range(M):
    d[A[i]-1][B[i]-1] = C[i]
    d[B[i]-1][A[i]-1] = C[i]

for i in range(N):
    d[i][i] = 0
        

# Warshall-Floyd法
# DP
for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][k]+d[k][j])

d2 = [[INF]*N for _ in range(N)]
for i in range(N):
    for j in range(N):
        if i == j:
            d2[i][j] = 0
        elif d[i][j] <= L:
            d2[i][j] = 1
            
for k in range(N):
    for i in range(N):
        for j in range(N):
            d2[i][j] = min(d2[i][j], d2[i][k]+d2[k][j])
                
for i in range(Q):
    s = qlist[i][0]-1
    t = qlist[i][1]-1
    ans = d2[s][t]
    if ans >= INF:
        print(-1)
    else:
        print(ans-1)
import sys
input = sys.stdin.readline
a,b=map(int,input().split())
print("YES" if b<=x<=a+b else "NO")


### FIXED CODE ###

import sys
input = sys.stdin.readline
a,b,x=map(int,input().split())
print("YES" if a<=x<=a+b else "NO")
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
for i in range(M):
    A[-1] //= 2
    for j in range(M):
        if A[j] > A[-1]:
            A[j], A[-1] = A[-1], A[j]
            break
ans = sum(A)
print(ans)

### FIXED CODE ###

import heapq

N, M =map(int, input().split())
A = list(map(int, input().split()))
A.sort()
reversed_A = [n * (-1) for n in A]
heapq.heapify(reversed_A)
for i in range(M):
    max_value = heapq.heappop(reversed_A) * (-1)
    half_value = max_value // 2
    heapq.heappush(reversed_A, (-1)*half_value)

discount_prices = [n * (-1) for n in reversed_A]
ans = sum(discount_prices)
print(ans)
import sys


def start_with(s):
    if s == '':
        print('YES')
        sys.exit(0)

    try:
        if s[0:5] == 'dream':
            start_with(s[5:])
        if s[0:7] == 'dreamer':
            start_with(s[7:])
        if s[0:5] == 'erase':
            start_with(s[5:])
        if s[0:6] == 'eraser':
            start_with(s[6:])
    except IndexError:
        return


S = input()
start_with(S)
print('NO')


### FIXED CODE ###

import sys

sys.setrecursionlimit(1000000)
S = input()


def start_with(i):
    if i == len(S):
        print('YES')
        sys.exit(0)

    try:
        if S[i:i+5] == 'dream':
            start_with(i+5)
        if S[i:i+7] == 'dreamer':
            start_with(i+7)
        if S[i:i+5] == 'erase':
            start_with(i+5)
        if S[i:i+6] == 'eraser':
            start_with(i+6)
        return
    except IndexError:
        return


start_with(0)
print('NO')
import sys

for line in sys.stdin:
    a,b,c,d,e,f= map(int,line .split())
    z=a*e-b*d
    if(z!=0):
        x=(c*e-b*f)/z
        y=(a*f-c*d)/z
    print("{0:.3f} {1:.3f)".format(x+0,y+0))

### FIXED CODE ###

while(True):
        try:
            a,b,c,d,e,f=map(float,input().split(" "))
            z=a*e-b*d
            if(z!=0):
                x=(c*e-b*f)/z
                y=(a*f-c*d)/z
            print("{:.3f} {:.3f}".format(x+0,y+0))
        except:
            break
# https://atcoder.jp/contests/agc034/tasks/agc034_a

import itertools
from collections import Counter
from collections import defaultdict
import bisect
import math
import heapq

def main():
    N, A, B, C, D = map(int, input().split())
    S = input()

    ans = 'Yes'
    if '##' in S[A-1:C] or '##' in S[B-1:D]:
        ans = 'No'

    if D < C:  # 追い越す場所が必要
        if '...' not in S[B-3:D+1]:
            ans = 'No'

    print(ans)


if __name__ == '__main__':
    main()
v

### FIXED CODE ###

# https://atcoder.jp/contests/agc034/tasks/agc034_a

import itertools
from collections import Counter
from collections import defaultdict
import bisect
import math
import heapq

def main():
    N, A, B, C, D = map(int, input().split())
    S = list(input())

    blocks = 0
    for s in range(A - 1, C):
        if S[s] == '.':
            if blocks > 1:
                print('No')
                exit()
            blocks = 0
        else:
            blocks += 1

    blocks = 0
    for s in range(B - 1, D):
        if S[s] == '.':
            if blocks > 1:
                print('No')
                exit()
            blocks = 0
        else:
            blocks += 1

    if D < C:  # 追い越す場所が必要
        can_overtake = False
        for s in range(B - 1, D):
            if S[s-1] == '.' and S[s] == '.' and S[s+1] == '.':
                can_overtake = True
                break

        if not can_overtake:
            print('No')
            exit()

    print('Yes')


if __name__ == '__main__':
    main()
d=int(input())
c=list(map(int,input().split()))
num=[0]*26
ans=[]
for i in range(1,d+1):
    num1=0
    num2=-(10**10)
    num3=[0]*26
    for j in range(26):
        num3[j]=-1*((i-num[i])*c[j])
    num4=sum(num3)
    s=list(map(int,input().split()))
    for j in range(26):
        num5=num4-num3[j]+s[j]
        if num5>num2:
            num1=j+1
            num2=num5
    ans.append(num1)
for i in range(d):
    print(ans[i])


### FIXED CODE ###

d=int(input())
c=list(map(int,input().split()))
num=[0]*26
ans=[]
for i in range(1,d+1):
    num1=1
    num2=-(10**100)
    num3=[0]*26
    for j in range(26):
        num3[j]=-1*((i-num[j])*c[j])
    s=list(map(int,input().split()))
    for j in range(26):
        num5=s[j]-num3[j]
        if num5>num2:
            num1=j+1
            num2=num5
    ans.append(num1)
    num[num1-1]=i
for i in range(d):
    print(ans[i])
def main():
    n=int(input())
    csf=[list(map(int,input().split())) for _ in range(n-1)]
    for i in range(n):
        if i == n-1:
            print(0)
        else:
            t=0
            for c,s,f in csf[i:]:
                t = max(s,t)
                t = math.ceil(t/f)*f+c
                #print("start:", i, t)
            print(t)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import math
def main():
    n=int(input())
    csf=[list(map(int,input().split())) for _ in range(n-1)]
    for i in range(n):
        if i == n-1:
            print(0)
        else:
            t=0
            for c,s,f in csf[i:]:
                t = max(s,t)
                t = math.ceil(t/f)*f+c
                #print("start:", i, t)
            print(t)

if __name__ == "__main__":
    main()