peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
N = int(input())
W = list(map(int,input().split()))
m = sum(W)

for j in range(N-1):
    W1 = W[:j+1]
    W2 = W[j+1:N]
    print(W1, W2)
    s = abs(sum(W1) - sum(W2))
    m = min(m, s)

print(m)
# Judge status: Accepted
a = int(input())
l = list(map(int,input().split()))
MOD = 998244353
dp = [0]*a
for i in l:
    dp[i]+=1
res = 1
# print(dp)
if dp[0] != 1 and l[0]!=0:
    print(0)
    exit()

for i in l[1:]:
    # print(i)
    res*=dp[i-1]
    res%=MOD

print(res)
# Judge status: Accepted
n=int(input())
p=list(map(int,input().split()))
cnt=0
for i in range(1,n-1):
            if p[i-1]<p[i]<p[i+1] or p[i-1]>p[i]>p[i+1]:
                        cnt+=1
print(cnt)
# Judge status: Accepted
A, B = map(int, input().split())
print("Possible" if (A + B) % 3 == 0 or A % 3 == 0 or B % 3 == 0 else "Impossible")
# Judge status: Wrong Answer
x = int(input())
double, rest = divmod(x, 11)
if rest <= 6:
    add = 1
elif rest > 6:
    add = 2
else:
    add = 0
ans = double * 2 + add
print(ans)
# Judge status: Accepted
n=int(input())
risok = float('inf')
for _ in range(5):
    a = int(input())
    risok = min(risok, a)
#print(risok)

if n%risok==0 and risok < n:
    print(4+n//risok)
else:
    print(5+n//risok)
# Judge status: Accepted
n,x=map(int,input().split())
*l,=map(int,input().split())
t=[0]
for i in range(n):
    d=l[i]+t[-1]
    t.append(d)
ans=[j for j in t if j <= x]
print(len(ans))
# Judge status: Wrong Answer
def main():
    N, x = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    if sum(a) <= x:
        print(N)
        return
    for i in range(N):
        x -= a[i]
        if x < 0:
            break
    ans = i
    print(ans)

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
import fractions

num = int(input())
A = [int(s) for s in input().split()]
ans = A[0]
for i in range(1,num):
    ans = ans * A[i]//fractions.gcd(ans,A[i])
B = [ans//A[s] for s in range(num)]
print(B)
print(sum(B)%(10**(9)+7))
# Judge status: Wrong Answer
s = input()
ans = 'Yes'
n = 0
w = 0
sow = 0
e = 0
#print(s)
for i in range(len(s)):
    if s[i] == 'N':
        n += 1
    elif s[i] == 'W':
        w += 1
    elif s[i] == 'S':
        sow += 1
    else:
        e += 1



if (n == 0 and w != 0) or (n != 0 and w == 0):
    ans = 'No'
if (sow == 0 and e != 0) or (sow != 0 and e == 0):
    ans = 'NO'
print(ans)
# Judge status: Accepted
n,l = (int(i) for i in input().split())
x = 0
if l >= 0:
  pass
elif l+n-1 <= 0:
  x = n-1
else:
  x = -l
ans = l*(n-1) + n*(n-1)//2 - x
print(ans)
# Judge status: Accepted
x,n=map(int,input().split())
p=list(map(int,input().split()))
p=sorted(p)
c=0
z=0
a=[]
for i in range(n):
    a.append(p[i]-x)
for i in range(100):
    if a.count(-i)==0:
        z=-c
        break
    elif a.count(i)==0:
        z=c
        break
    else:
        c+=1
print(x+z)
# Judge status: Accepted
n=int(input())
ans = ""
for c in input():
  ans+= chr((ord(c)-ord('A')+n)%26+ord('A'))
print(ans)
# Judge status: Accepted
S = input()

a = 0
b = 0
c = 0

for si in S:
    if si == 'a':
        a += 1
    elif si == 'b':
        b += 1
    else:
        c += 1


if max(a, b, c) - min(a, b, c) <= 1:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
n, m = map(int, input().split())
City = sorted([tuple(map(int, input().split())) + (i, ) for i in range(m)])

Ans = [None] * m
pre_p = City[0][0]
cnt = 1
for p, y, i in City:
    if pre_p != p:
        cnt = 1
        pre_p = p
    Ans[i] = '0'*(6 - len(str(p))) + str(p) + '0'*(6 - len(str(cnt))) + str(cnt)
    cnt += 1
print(*Ans, sep='\n')
# Judge status: Accepted
k, x = map(int,input().split())
lst = []
for i in range(x - k + 1, x + k):
  if (-1000000 <= i <= 1000000):
    lst.append(i)
for i in range(len(lst)):
    print(lst[i], end = '')
    if (i != len(lst) - 1):
      print(" ", end = '')
print()
# Judge status: Accepted
def solve(a, b, c, d):
    while True:
        c -= b
        if c <= 0:
            return 'Yes'
        a -= d
        if a <= 0:
            return 'No'
A, B, C, D = map(int, input().split()) 
print(solve(A, B, C, D))
# Judge status: Accepted
N, M = list(map(int, input().split()))
A = {i: 0 for i in range(N+1)}
mod = 10 ** 9 + 7
for _ in range(M):
    A[int(input())] = 1
 
dp = [0 for _ in range(N+1)]
dp[0] = 1
 
for i in range(N+1):
    if A.get(i+1) == 0:
        dp[i + 1] += dp[i]
    if A.get(i+2) == 0:
        dp[i + 2] += dp[i]
 
print(dp[N]%mod)
# Judge status: Accepted
n,m = list(map(int,input().split()))
a = list(map(int,input().split()))

a.sort(reverse = True)

x = sum(a) * (1 / (4 * m))

if a[m-1] >= x:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    print(N*(N+1)//2)

if __name__ == '__main__':
    main()
# Judge status: Accepted
n=int(input())
a=list(sorted(map(int,input().split())))
d=[0 for i in range(a[-1]+1)]
c=0
for i in range(len(a)):
  if d[a[i]]:
    continue
  if i==len(a)-1 or a[i]!=a[i+1]:
    c+=1
  for j in range(a[i],a[-1]+1,a[i]):
    d[j]=1
print(c)
# Judge status: Accepted
N = list(map(int, list(input())))[::-1]
dp0 = [float('inf')] * (len(N)+1)
dp1 = [float('inf')] * (len(N)+1)
dp0[0] = 0
dp1[0] = 1
for i in range(len(N)):
    dp0[i+1] = min(dp0[i] + N[i], dp1[i] + 10 - N[i])
    dp1[i+1] = min(dp0[i] + N[i] + 1, dp1[i] + 9 - N[i])
print(dp0[-1])
# Judge status: Wrong Answer
import random
for i in range(26):
  print(random.randint(1,26))
# Judge status: Wrong Answer
a = list(map(int, input().split()))
for i in range(4):
  if a[i] ==0:
    print(i+1)
# Judge status: Wrong Answer
s = input()
n = len(s)
ans = list(s)
cnt = 0
for i in range(n)[::-1]:
    if ans[i] == '?':
        if i == n-1:
            ans[i] = 'D'
        else:
            if ans[i+1] == 'P':
                ans[i] = 'D'
            else:
                ans[i] = 'P'
            
print(''.join(ans))
# Judge status: Accepted
def main():
    n=int(input())
    a=map(int,input().split())
    b=list(map(int,input().split()))
    c=list(map(int,input().split()))
    m = 0
    prev = -100
    for i in (x-1 for x in a):
        m += b[i]
        if prev + 1 == i:
            m += c[prev]
        prev = i
    return m

if __name__ == "__main__":
    print(main())
# Judge status: Accepted
n = int(input())
if n<1000:
    print('ABC')
else:
    print('ABD')
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
h = 0
for i in range(1,n):
  if a[i] != i+1-h:
    h += 1
if h == n:
  print(n)
else:
  print(h)
# Judge status: Accepted
N=int(input())
cnt=0
for i in range(1,N):
  cnt+=(N-1)//i
print(cnt)
# Judge status: Accepted
s = input()

min_v = 9999
for i in range(len(s) - 2):
    # print(s[i:i + 3])
    n = int(s[i:i + 3])
    min_v = min(min_v, abs(753 - n))
    
print(min_v)
# Judge status: Wrong Answer
n = int(input())
A=list(map(int, input().split()))

ans="No"
c2=c4=0
for a in A:
    if a%4==0:
        c4+=1
    elif a%2==0:
        c2+=1

if (n-c2)//2<=c4 :
    ans="Yes"
else:
    ans="No"

print( ans )
# Judge status: Accepted
n, k = map(int, input().split())
s = input()

ans = 0
for i in range(len(s)-1):
  if s[i] == s[i+1]:
    ans += 1
    
ans = min(n-1, ans + k*2)

print(ans)
# Judge status: Accepted
def all_nine_check(num):
    for i in range(1, len(num)):
        if num[i] == '9':
            pass
        else:
            return False
    return True

n = input()
if all_nine_check(n):
    ans = int(n[0]) + 9 * (len(n) - 1)
else:
    ans = int(n[0]) - 1 + 9 * (len(n) - 1)
print(ans)
# Judge status: Wrong Answer
A,B=map(int,input().split())
K=(A+B)/2
Kint=int(K)
if (K==Kint):
  print (K)
else:
  print ('IMPOSSIBLE')
# Judge status: Accepted
import sys
input = sys.stdin.buffer.readline

def main():
    A,B,C = map(int,input().split())
    if A%2 == 0 or B%2 == 0 or C%2 == 0:
        print(0)
    else:
        print(min(A*B,B*C,C*A))

if __name__ == "__main__":
    main()
# Judge status: Accepted
N, *A = map(int, open(0).read().split())

cnt = [0] * (N + 1)
cnt[0] = 1
for i in range(N):
    cnt[i + 1] = (cnt[i] - A[i]) * 2

ans = 0
cur = 0
for i in reversed(range(N + 1)):
    cur += A[i]
    ans += min(cnt[i], cur)
        
if all(cnt[i] >= A[i] for i in range(N + 1)):
    print(ans)
else:
    print(-1)
# Judge status: Accepted
a, b, c = list(map(int, input().split()))
if b - a == c - b:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
ans = 10**18
for i in range(1,n):
    j = n-i
    s = str(i).rjust(6,"0")[::-1]
    t = str(j).rjust(6,"0")[::-1]
    res = 0
    for i,j in zip(s,t):
        res += int(i)+int(j)
    ans = min(res,ans)

print(ans)
# Judge status: Accepted
n = int(input())
x = [int(i) for i in input().split()]
y = sorted(x)
a , b = y[n//2-1], y[n//2]
for i in x:
    if i > a:
        print(a)
    else:
        print(b)
# Judge status: Wrong Answer
n, a, b, c, d = map(int, input().split())
s = input()
for i in range(a, c):
    if s[i-1:i+1] == '##':
        print('No')
        exit()
for i in range(b, d):
    if s[i-1:i+1] == '##':
        print('No')
        exit()
if c > d:
    for i in range(b, d-1):
        if s[i-1:i+2] == '...':
            print('Yes')
            exit()
    print('No')
else:
    print('Yes')
# Judge status: Wrong Answer
n, k = map(int, input().split())
a = list(map(int, input().split()))

ind = a.index(1)
cnt = k - 1
ans = 0
for i in reversed(range(ind)):
    cnt -= 1
    if cnt == 0:
        ans += 1
        cnt = k - 1

for i in range(ind, n):
    cnt -= 1
    if cnt == 0:
        ans += 1
        cnt = k - 1

print(ans)
# Judge status: Wrong Answer
s = input()
t = input()

ans = 0
i = 0
while i < len(s):
	if s[i] == t[i]:
		ans += 1
	i += 1

print(ans)
# Judge status: Accepted
A,B,C = list(map(int,input().split()))
if (A<=C<=B) or (A>=C>=B):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N=int(input())
print(int(N*(N+1)/2))
# Judge status: Accepted
n = int(input())
n = str(n)
if (n[0] == n[1] == n[2]) or (n[1] == n[2] == n[3]):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import sys
N = int(input())
for n in range(1, N + 1):
    if int(n * 1.08) == N:
        print(n)
        sys.exit()
print(":(")
# Judge status: Accepted
sl = list(input())
ans = []
for s in sl:
    if s != 'B':
        ans.append(s)
    else:
        if len(ans) != 0:
            ans.pop(-1)

print(*ans, sep='')
# Judge status: Wrong Answer
#146A

#1.入力をちゃんと受け取ること
s=input()
#2.結果を出力する
if s=='SUN' :
    print('7')
elif s=='MAN':
    print('6')
elif s=='TUE':
    print('5')
elif s=='WED':
    print('4')
elif s=='THU':
    print('3')
elif s=='FRI':
    print('2')
elif s=='SAT':
    print('1')
# Judge status: Wrong Answer
s=input()
if s[-1]==s:
  print(s+'es')
else:
  print(s+'s')
# Judge status: Accepted
N, M = map(int, input().split())

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

A_sort = sorted(A, reverse=True)
ALL = sum(A_sort)
cnt = 0
for c in A_sort:
    if c < ALL / (4 * M):
        break

    cnt += 1
if cnt >= M:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
# coding: utf-8
# Your code here!
A,B,C=input().split()
max=int(A)+int(B+C)
if int(C)+int(A+B)>max:
    max=int(C)+int(A+B)
    
print(max)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

pm = sum(A)
e = 1
te = 1
for i in A:
    pm -= i
    e = min((e-i) * 2,pm)
    if e < 0:
        break
    te += e
if e < 0:
    print(-1)
else:
    print(te)
# Judge status: Accepted
X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
integer = [i for i in range(102)]
for i in range(N):
   integer.remove(p[i])
l = len(integer)
ans = -200
for i in range(l):
   if abs(ans) > abs(integer[i]-X):
      ans = integer[i] - X
print(ans + X)
# Judge status: Wrong Answer
W,a,b = map(int,input().split())

if a+W >= b and a < b:
  print(0)
elif a >= b+W and a > b:
  print(a-(b+W))
else:
  print(b-(a+W))
# Judge status: Wrong Answer
H = int(input())
W = int(input())
N = int(input())


if N % max(H, W) == 0:
    print(round(N / max(H, W)))
else:
    print(round(N / max(H, W) + 1))
# Judge status: Accepted
n,m=map(int,input().split())
ab=[[int(j) for j in input().split()] for i in range(n)]
cd=[[int(j) for j in input().split()] for i in range(m)]
for a,b in ab:
    l=[abs(a-c)+abs(b-d) for c,d in cd]
    print(l.index(min(l))+1)
# Judge status: Wrong Answer
import fractions
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
lcm = A[0]
ans = 0

for i in range(1, N):
    gcd = fractions.gcd((A[i]), lcm)
    lcm = (lcm * (A[i])) // gcd

if M >= lcm // 2:

    M -= lcm//2
    ans = 1+(M//lcm)
# print(lcm_half)
print(ans)
# Judge status: Accepted
N, M = map(int, input().split())

food = []
for x in range(N):
    ka = list(map(int, input().split()))
    a = ka[1:]
    if x == 0:
        food = a
    else:
        food = list(set(food) & set(a))
print(len(food))
# Judge status: Wrong Answer
import math

A,B,H,M = list(map(float,input().split()))

hm = H + M / 60
h = hm * 30
m = M * 6

sa = abs(h - m)
if sa >= 180:
    sa = sa - 180

ans = (A**2 + B**2 - A * B * math.cos(math.radians(sa)) * 2) ** 0.5

if int(sa) == 0:
    if int(h) == int(m):
        ans = abs(A - B)
    else:
        ans = A + B

print(ans)
# Judge status: Accepted
import math

N = int(input())
x = int(math.ceil(N / 1.08))

if int(x * 1.08) == N:
    print(x)
else:
    print(":(")
# Judge status: Wrong Answer
s = input()
l = len(s)
ans = 0

for i in range(l // 2):
    if s[i]!=s[-i]:
        ans += 1

print(ans)
# Judge status: Accepted
n = int(input())
s = [0]*n

for i in range(n):
  s[i] = input()
ans = 0
s.sort()
for i in range(n-1):
  if s[i] != s[i+1]:
    ans += 1
    
print(ans+1)
# Judge status: Accepted
from collections import deque
N, M = map(int, input().split())
G = [deque() for _ in range(N+1)]
ans = [0]*(N+1)
for _ in range(M):
  a, b = map(int, input().split())
  G[a].append(b)
  G[b].append(a)
memo = [False]*(N+1)
q = deque()
q.append(1)
while q:
  x = q.popleft()
  if not memo[x]:
    memo[x] = True
    for y in G[x]:
      if ans[y] == 0:
        ans[y] = x
        q.append(y)
print("Yes")
print("\n".join([str(x) for x in ans[2:]]))
# Judge status: Accepted
d={s:1 for s in [4,6,9,11]}
for i in [1,3,5,7,8,10,12]:
    d[i]=0
d[2]=2
a,s=map(int,input().split())
print("Yes")if d[a]==d[s] else print("No")
# Judge status: Accepted
s=input()
t=input()
print('Yes' if sorted(s)<sorted(t,reverse=True) else 'No')
# Judge status: Accepted
from fractions import gcd
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
left = [A[0]] * N
right = [A[-1]] * N
for i in range(1, N):
    left[i] = gcd(left[i-1], A[i-1])
for i in range(1, N)[::-1]:
    right[i-1] = gcd(right[i], A[i])
ans = max(right[0], left[-1])
for i in range(1, N-1):
    ans = max(ans, gcd(left[i], right[i]))
print(ans)
# Judge status: Accepted
N = int(input())
k = 1
while 26**k <= N:
    N -= 26**k
    k += 1

def itoc(i):
    return chr(ord('a') + i)

N -= 1
ans = ''
for _ in range(k):
    N,i = divmod(N,26)
    ans += itoc(i)

if all(c=='z' for c in ans):
    print(ans[:-1])
else:
    print(ans[::-1])
# Judge status: Wrong Answer
x = int(input())
for i in range(-120, 120):
  for j in range(-120, 120):
    if i**5-j**5 == x:
        print(i, j)
        break
# Judge status: Accepted
n=int(input())
s=input()
c=0
for i in range(1,len(s)):
    l=set(s[:i])
    r=set(s[i:])
    c=max(c,len(l&r))
print(c)
# Judge status: Wrong Answer
N,M=map(int,input().split())
if N%2!=0:
    for i in range(M):
        print((N//2)-i,(N//2)+1+i)
else:
    if (N//2)%2==0:
        for i in range(M):
            print((N//2)-i,(N//2)+i+1)
    else:
        for i in range(M//2):
            print((N//2)-i,(N//2)+1+i)
        for i in range(M//2):
                print(2+i,N-i)
# Judge status: Accepted
C=input()
print(chr(ord(C)+1))
# Judge status: Wrong Answer
A, B, C = map(int, input().split())
ans = A*B*C
if (A*B*C)%2==0:
  print(ans//2)
else:
  cnt = float('inf')
  for i in [A,B,C]:
    if i%2==1 and i<cnt:
      cnt = i
  print(ans//i)
# Judge status: Wrong Answer
N = int(input())
S = str(input())
S = list(S)
c = 0

for i in range(N):
    if S[i] == '#':
        for j in range(N-i-1):
            if S[i+j+1] == '.':
                c += 1
    break
                
print(c)
# Judge status: Accepted
def main():
    import sys
    input = sys.stdin.readline

    JUDGE = 'AC', 'WA', 'TLE', 'RE'

    ctr = dict()
    for case in JUDGE:
        ctr[case] = 0

    N = int(input())
    for _ in range(N):
        s = input().rstrip()
        ctr[s] += 1

    for case in JUDGE:
        print(case, 'x', ctr[case])


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
from collections import deque
ans = deque()

for i in range(n-1):
    for j in range(i+1,n):
        ans.append(abs(a[i]-a[j]) - (j-i))

ans = list(ans)
print(ans.count(0)-1)
# Judge status: Wrong Answer
W, H ,x ,y = map(int,input().split())

a = x * H
b = (W - x)*H
c = W * y
d = W * (H - y)
def f(m ,n):
    if m == 0 or n ==0:
        return 0
    else:
        return min(m,n)

ans = max(f(a,b),f(c,d))
bool = 1
if f(a,b) == f(c,d):
    bool =1
else:
    bool = 0
print(ans, bool)
# Judge status: Accepted
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
    
k = int(input())
ans = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            ans += gcd(gcd(a,b),c)
print(ans)
# Judge status: Accepted
n = int(input())
if n % 1000 == 0:
  print(0)
else:
  print(1000 - n % 1000)
# Judge status: Wrong Answer
import collections
n = int(input())
s = [input() for i in range(n)]
s.sort()
t = collections.Counter(s)
maxv = max(t.values())
for key,value in t.items():
    if value == maxv:
        print(key)
# Judge status: Wrong Answer
n = int(input())
a = [input() for i in range(n)] 
ans = 1
s = []
s.append(a[0])
for i in a[1:]:
    for j in s:
        if i == j:
            break
        else:
            ans +=1
            s.append(i)
            break
            
print(ans)
# Judge status: Accepted
import heapq
n,m = map(int, raw_input().split(' '))

# I am given n pieces
if n >= m:
	print 0
else:
	xis = map(int, raw_input().split())
	xis.sort()


	distances = [v- u for u,v in zip(xis,xis[1:])]
	distances.sort(key = lambda x:-x)
	print sum(distances[n-1:] or [0])
# Judge status: Accepted
N , M = map(int,input().split())
lst = []
AC_list = [False] * N
WA_cnt_list = [0] * N
for _ in range(M):
    r , judge = input().split()
    question_num = int(r) - 1
    if AC_list[question_num]:
        continue
    elif judge == "WA":
        WA_cnt_list[question_num] += 1
    elif judge == "AC":
        AC_list[question_num] = True
wa_cnt = 0
for i in range(N):
    if AC_list[i]:
        wa_cnt += WA_cnt_list[i]
print(sum(AC_list) , wa_cnt)
# Judge status: Wrong Answer
from collections import Counter
S=input()
N=len(S)
n=N/3+1
S_n=Counter(S)

if len(S)==1:
    print('YES')
elif len(S)==2:
    if len(S_n)==1:
        print('NO')
    else:
        print('YES')
else:
    if len(S_n)<=2:
        print('NO')
    else:
        if S_n['a']<=n and S_n['b']<=n and S_n['c']<=n:
            print('YES')
        else:
            print('NO')
# Judge status: Wrong Answer
N = int(input())

answer = (N + 1 ) * N / 2

print(answer)
# Judge status: Wrong Answer
S=input("What's your name?");
Nickname=S[0:2];
print(Nickname);
# Judge status: Accepted
L = sorted(map(int, input().split()))
 
ans = 'YES' if L == [5, 5, 7] else 'NO'
print(ans)
# Judge status: Wrong Answer
S = list(input())

res = True

if "N" in S:
    if not "S" in S:
        res = False

if "W" in S:
    if not "E" in S:
        res = False

if res:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import sys,math
input = sys.stdin.readline

N = int(input())
CSF = [[0,0,0]]
for i in range(1,N):
    CSF.append(list(map(int,input().split())))
for i in range(1,N+1):
    nowtime = 0
    for j in range(i,N):
        if nowtime <=CSF[j][1]:
            depT =CSF[j][1]
        else:
            depT =CSF[j][1] + math.ceil((nowtime-CSF[j][1])/CSF[j][2])*CSF[j][2]

        nowtime = depT+CSF[j][0]
        #print(nowtime,depT)
    print(nowtime)
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))
c = 0

for i in range(n):
    if p[i] != i + 1:
        c = c + 1

if c == 2 or c == 0:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
S=input()
count=0
s=list(S)
for i in range(len(S)):
    if (i+1)%2!=0:
        if s[i]=='R' or s[i]=='U' or s[i]=='D':
            count+=1
    else:
        if s[i]=='L' or s[i]=='U' or s[i]=='D':
            count+=1
if count==len(S):
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n,m = map(int,input().split())
l = [list(map(int,input().split())) for i in range(m)]

a = []
b = []
for i in l:
    if i[0] == 1:
        a.append(i[1])
    if i[1] == n:
        b.append(i[0])

print("Possible" if len(set(a)&set(b)) > 0 else "Impossible")
# Judge status: Accepted
X = int(input())
count = 0
if X >= 500:
    count += X // 500 * 1000
    X = X%500
if X>=5:
    count += X // 5 * 5
print(count)
# Judge status: Accepted
s = str(input())
tmp = {}
for i in range(4):
    tmp.setdefault(s[i],0)
    tmp[s[i]]+=1
if len(tmp)==2 and max(tmp.values())==2:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
S=input("Enter 6 letters: ")
if S[2]==S[3] and S[4]==S[5] :
    print("Yes")
elif len(S)<=5:
    print("No")
else:
    print("No")
# Judge status: Accepted
n=int(input())

n_a=n//4
n_b=n//7

ans="No"
for i in range(n_a+1):
    for j in range(n_b+1):
        if 4*i+7*j==n:
            ans="Yes"
            break
        
print(ans)
# Judge status: Accepted
def solve():
    a, b, k = map(int, input().split())
    ans = list()
    for i in range(a, min(a+k, b+1), 1):
        ans.append(i)
    for i in range(b, max(b-k,a), -1):
        ans.append(i)
    ans = list(set(ans))
    ans.sort()
    for i in ans:
        print(i)
    return 0

if __name__ == "__main__":
    solve()
# Judge status: Accepted
n=int(input())

i=1
sum=1
ans=[1]
while sum<n:
  i+=1
  sum+=i
  ans.append(i)

sa=sum-n
if sa!=0:
  ans.remove(sa)

for i in ans:
  print(i)
# Judge status: Accepted
side = [int(i) for i in input().split()]
side.sort()
print(side[0]*side[1] if side[2]&1 else 0)
# Judge status: Wrong Answer
from math import sqrt
X = int(input())

for x in reversed(range(1, X+1)):
  flag = False
  for i in range(2,12):
    t = x**(1/i)
    if t.is_integer():
      print(x)
      flag = True
      break
  if flag:
    break
# Judge status: Accepted
s=input()
if s[0]==s[1] or s[1]==s[2] or s[2]==s[3]:
    print("Bad")
else:
    print("Good")
# Judge status: Wrong Answer
N,M=map(int,input().split())
listH=list(map(int,input().split()))
listN=list(range(N))
for i in range(M):
  A,B=map(int,input().split())
  if listH[A-1]>listH[B-1]:
    listN[B-1]=-1
  if listH[A-1]<listH[B-1]:
    listN[A-1]=-1
  else:
    listN[A-1]=-1
    listN[B-1]=-1 
ans=0    
for i in listN:
  if i>=0:
    ans+=1
print(ans)
# Judge status: Accepted
k = int(input())
a, b = map(int, input().split())

for i in range(a,b+1):
    if i%k==0:
        print("OK")
        quit()
print("NG")
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))
b = min(A)
s = A.index(b)
while True:
	c = 0
	for i in range(len(A)):
		if i == s: continue
		else: 
			A[i] %= b
			if A[i] == 0:
				c += 1
			elif A[i] < b:
				b = A[i]
				s = A.index(b)
	if c == n-1:
		print(max(A))
		break
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
a = [[i+1, a[i]] for i in range(n)]
a = sorted(a, key=lambda x: x[1])
for a_ in a:
  print(a_[0], end=' ')
print()
# Judge status: Accepted
s,t=map(str,input().split())
a,b=map(int,input().split())
u=input()

if u==s:
    print(a-1,b)
else:
    print(a,b-1)