Harryxun/stf_run huggingface dataset:
A,B=map(int,input().split())
if A=B*2<0:
  print(0)
else:
  print(A-B*2)

### FIXED CODE ###

A,B=map(int,input().split())
if A-B*2<0:
  print(0)
else:
  print(A-B*2)
a,b,c,d,e = map(int,input().split())
k = int(input())
if e-a < k:
  print('Yay!')
else:
  print(':(')

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if e-a <= k:
  print('Yay!')
else:
  print(':(')
n = int(input())
a = [int(i) for i in input().split()]
if a[1] > a[0]:
    temp = 1
elif a[1] < a[0]:
    temp = -1
else:
    temp = 0
ans = 1
for i in range(1, n-1):
    if a[i+1] > a[i]:
        if temp >= 0:
            temp = 1
        elif temp == -1:
            ans += 1
            temp = 0
    elif a[i+1] < a[i]:
        if temp <= 0:
            temp = -1
        elif temp == 1:
            ans += 1
            temp = 0
print(ans)

### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]
if n == 1:
    ans = 1
else:
    if a[1] > a[0]:
        temp = 1
    elif a[1] < a[0]:
        temp = -1
    else:
        temp = 0
    ans = 1
    for i in range(1, n-1):
        if a[i+1] > a[i]:
            if temp >= 0:
                temp = 1
            elif temp == -1:
                ans += 1
                temp = 0
        elif a[i+1] < a[i]:
            if temp <= 0:
                temp = -1
            elif temp == 1:
                ans += 1
                temp = 0
print(ans)
n,q=map(int,input().split())
S=input()
L=[list(map(int,input().split())) for i in range(q)]

s=[0]*(n+1)
for i in range(1,n+1):
    if S[i-1]=='A' and S[i]=='C':
        s[i]=s[i-1]+1
    else:
        s[i]=s[i-1]

#print(s)
for l,r in L:
    ans=s[r]-s[l-1]
    print(ans)

### FIXED CODE ###

#122-C
n,q=map(int,input().split())
s=input()
l=[list(map(int,input().split())) for i in range(q)]
m=[0]*(n+1)
for i in range(len(s)-1):
    
    if s[i]=='A' and s[i+1]=='C':
        m[i+1]=m[i]+1
    else:
        m[i+1]=m[i]

for i in l:
    print(m[i[1]-1]-m[i[0]-1])
import math
n = []
while True:
    try:
        n.append(int(raw_input()))
    except:
        break
 
r = max(n)+1
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
    if p[i]:
        p[2*i+1::i+1] = [0]*range(2*i+1,r,i+1)
           
for i in n:
     print sum(p[:i])

### FIXED CODE ###

import math
n = []
while True:
    try:
        n.append(int(raw_input()))
    except:
        break
  
r = max(n)+1
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
p[3::2] = [0 for x in range(3,r,2)]
for i in range(2,sqrt,2):
    if p[i]:
        p[2*i+1::i+1] = [0 for x in range(2*i+1,r,i+1)] 
  
for i in n:
     print sum(p[:i])
R, C, K=map(int, input().split())
math=[[0]*C for _ in range(R)]
for _ in range(K):
  r, c, v=map(int, input().split())
  math[r-1][c-1]=v
  
dp=[[[0]*C for __ in range(R)] for _ in range(4)]
if math[0][0]>0:
  dp[1][0][0]=math[0][0]+0
  
for j in range(1, C):
  dp[0][0][j]=dp[0][j-1][0]+0
  dp[1][0][j]=max(dp[1][0][j-1], dp[0][0][j-1]+math[0][j])
  dp[2][0][j]=max(dp[2][0][j-1], dp[1][0][j-1]+math[0][j])
  dp[3][0][j]=max(dp[3][0][j-1], dp[2][0][j-1]+math[0][j])
    
for i in range(1, R):
  dp[0][i][0]=max(dp[0][i-1][0], dp[1][i-1][0], dp[2][i-1][0], dp[3][i-1][0])
  dp[1][i][0]=dp[0][i][0]+math[i][0]
  for j in range(1, C):
    dp[0][i][j]=max(dp[0][i][j-1], max(dp[0][i-1][j], dp[1][i-1][j], dp[2][i-1][j], dp[3][i-1][j]))
    dp[1][i][j]=max(dp[1][i][j-1], dp[0][i][j-1]+math[i][j], max(dp[0][i-1][j], dp[1][i-1][j], dp[2][i-1][j], dp[3][i-1][j])+math[i][j])
    dp[2][i][j]=max(dp[2][i][j-1], dp[1][i][j-1]+math[i][j])
    dp[3][i][j]=max(dp[3][i][j-1], dp[2][i][j-1]+math[i][j])
    
print(max(dp[0][-1][-1], dp[1][-1][-1], dp[2][-1][-1], dp[3][-1][-1]))

### FIXED CODE ###

R, C, K=map(int, input().split())
math=[[0]*C for _ in range(R)]
for _ in range(K):
  r, c, v=map(int, input().split())
  math[r-1][c-1]=v
  
dp=[[[0]*C for __ in range(R)] for _ in range(4)]
if math[0][0]>0:
  dp[1][0][0]=math[0][0]+0
  
for j in range(1, C):
  dp[0][0][j]=dp[0][0][j-1]+0
  dp[1][0][j]=max(dp[1][0][j-1], dp[0][0][j-1]+math[0][j])
  dp[2][0][j]=max(dp[2][0][j-1], dp[1][0][j-1]+math[0][j])
  dp[3][0][j]=max(dp[3][0][j-1], dp[2][0][j-1]+math[0][j])
    
for i in range(1, R):
  dp[0][i][0]=max(dp[0][i-1][0], dp[1][i-1][0], dp[2][i-1][0], dp[3][i-1][0])
  dp[1][i][0]=dp[0][i][0]+math[i][0]
  for j in range(1, C):
    dp[0][i][j]=max(dp[0][i][j-1], max(dp[0][i-1][j], dp[1][i-1][j], dp[2][i-1][j], dp[3][i-1][j]))
    dp[1][i][j]=max(dp[1][i][j-1], dp[0][i][j-1]+math[i][j], max(dp[0][i-1][j], dp[1][i-1][j], dp[2][i-1][j], dp[3][i-1][j])+math[i][j])
    dp[2][i][j]=max(dp[2][i][j-1], dp[1][i][j-1]+math[i][j])
    dp[3][i][j]=max(dp[3][i][j-1], dp[2][i][j-1]+math[i][j])
    
print(max(dp[0][-1][-1], dp[1][-1][-1], dp[2][-1][-1], dp[3][-1][-1]))
N=int(input())

S=[]
T=[]
ans=0
f=False
for a in range(N):
  s,t=input().split()
  t=int(t)
  S.append(s)
  T.append(t)
X=int(input())
for a in range(N):
  if(f):ans+=T[a]
  if(S[a]==X):f=True
print(ans)


### FIXED CODE ###

# coding: utf-8
import re
import math
import itertools
from copy import deepcopy
import fractions
import random
from heapq import heappop,heappush
import time
import os
import sys
import datetime
from functools import lru_cache
readline=sys.stdin.readline
sys.setrecursionlimit(2000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
#######################################################################################################
N=int(input())

S=[]
T=[]
ans=0
f=False
for a in range(N):
  s,t=input().split()
  t=int(t)
  S.append(s)
  T.append(t)
X=input()
for a in range(N):
  if(f):ans+=T[a]
  if(S[a]==X):f=True
print(ans)
maps = {'1':'a',
       '2':'b',
       '3':'c',
       '4':'d',
       '5':'e',
       '6':'f',
       '7':'g',
       '8':'h',
       '9':'i',
       '10':'j',
       '11':'k',
       '12':'l',
       '13':'m',
       '14':'n',
       '15':'o',
       '16':'p',
       '17':'q',
       '18':'r',
       '19':'s',
       '20':'t',
       '21':'u',
       '22':'v',
       '23':'w',
       '24':'x',
       '25':'y',
       '26':'z',
       }
n = int(input())
s=''
while True:
  s = maps[str(n%26)] + s
  n //= 26
  if n == 0:
    break
print(s)

### FIXED CODE ###

n = int(input())
s=''
while n!=0:
  n-=1
  tmp=n%26
  s=chr(96+tmp+1)+s
  n//=26
print(s)
class BisectSearch:
    def __init__(self, f, l=0, r=10**9):
        self.f = f
        self.l = l
        self.r = r
    def __call__(self, dist):
        f = self.f
        l = self.l
        r = self.r
        if dist <= f(l):
            return l
        if f(r) <= dist:
            return r
        while r-l > 1:
            n = (r+l) // 2
            if f(n) <= dist:
                l = n
            else:
                r = n
        return l, r

n, k, *A = map(int, open(0).read().split())
print(BisectSearch(lambda x:k+1-sum(ceil(a/x)-1 for a in A), l=1)(0)[1])

### FIXED CODE ###

from math import ceil
n, k, *A = map(int, open(0).read().split())
t = sum(A) / (n+k)
A = [a for a in A if int(a/t) >= 1]
c = k - sum(int(a/t)-1 for a in A)
X = []
for a in A:
    X.append(ceil(a / ceil(a/t)))
    X.append(ceil(a / int(a/t)))
X.sort()
print(X[-c-1])
def dijkstra(s,n,w,cost):
    #始点sから各頂点への最短距離
    #n:頂点数,　w:辺の数, cost[u][v] : 辺uvのコスト(存在しないときはinf)
    d = [float("inf")] * n
    used = [False] * n
    d[s] = 0

    while True:
        v = -1
        #まだ使われてない頂点の中から最小の距離のものを探す
        for i in range(n):
            if (not used[i]) and (v == -1):
                v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
            break
        used[v] = True

        for j in range(n):
            d[j] = min(d[j],d[v]+cost[v][j])
    return tuple(d)

n,x,y = map(int,input().split())

#cost[u][v] : 辺uvのコスト(存在しないときはinf この場合は10**10)
cost = [[float("inf") for i in range(n)] for i in range(n)]

for i in range(n-1):
    cost[i][i+1] = 1
    cost[i+1][i] = 1
cost[x-1][y-1] = 1
cost[y-1][x-1] = 1

ans = [0 for _ in range(n)]
for i in range(n):
    #nは頂点数、wは辺の数
    res = dijkstra(i,n,n,cost)
    for j in range(i+1,n):
        ans[res[j]] += 1

for i in range(1,n):
    print(ans[i])


### FIXED CODE ###

s = input()

if s[2] == s[3] and s[4] == s[5]:
	print('Yes')
else:
	print('No')
n,t=map(int,input().split())
cost_list=[]
for i in range(n):
  cost,time=map(int,input().split())
  if time<=t:
    cost_list+=[cost]
if cost_list!=[]:
  print(min(cost_list))
else:
  print(TLE)

### FIXED CODE ###

if input()=="1":
  print("Hello World")
else:
  print(sum([int(input()) for i in range(2)]))
import sys
xs = [int(x) for x in  sys.stdin.readline().split()]
sort(xs)
for x in xs:
  print x,

### FIXED CODE ###

import sys
xs = [int(x) for x in  sys.stdin.readline().split()]
for x in sorted(xs):
  print x,
N, = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))[::-1]
z=zc=0
Z = []
for i in range(N):
    if X[i]==Y[i]:
        zc += 1
        z = Y[i]
    else:
        Z.append(Y[i])
if zc:
    if zc%2 == 0:
        Z = [z]*(zc//2)+Z+[z]*((zc+1)//2)
    else:
        2/0
for i in range(N):
    if X[i] == Z[i]:
        print("No")
        break
else:
    print("Yes")
    print(*Z)


### FIXED CODE ###

N, = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))[::-1]
on = []
z = 0
for i in range(N):
    if not X[i]-Y[i]:
        on.append(i)
        z = X[i]
for i in range(N):
    if X[i]!=z and Y[i] != z and on:
        j = on.pop()
        Y[i], Y[j] = Y[j], Y[i]
if on:
    print("No")
else:
    print("Yes")
    print(*Y)
s, t = input().split(' ')
a, b = map(int, input().split(' '))
u = input()

d = {
    'red': a,
    'blue': b
}

d[u] -= 1

print(d['red'], d['blue'])

### FIXED CODE ###

s, t = input().split(' ')
a, b = map(int, input().split(' '))
u = input()

d = {}
d[s] = a
d[t] = b
d[u] -= 1

print(d[s], d[t])
import collections
S = input()
cnt = 0

mod = [0]
reverse_S = S[::-1]
for i in range(len(reverse_S)):
  now = int(reverse_S[i]) * pow(10,i,2019)
  mod.append((now + mod[i]) % 2019)


c = collections.Counter(mod)
hindo = sorted(c.values(),reverse=True)
for i in range(hindo.index(1)):
  n = hindo[i]
  cnt += n*(n-1)//2

print(cnt)

### FIXED CODE ###

import collections
S = input()
cnt = 0

mod = [0]
reverse_S = S[::-1]
for i in range(len(reverse_S)):
  now = int(reverse_S[i]) * pow(10,i,2019)
  mod.append((now + mod[i]) % 2019)


c = collections.Counter(mod)
hindo = c.values()
for i in hindo:
  if i != 1:
    cnt += i*(i-1)//2


print(cnt)
n = int(input())
l0 = 2
l1 = 1
for i in range(2, n+1):
    l = l0 + l1
    l0 = l1
    l1 = l
print(l)

### FIXED CODE ###

n = int(input())
l = [2, 1]
for i in range(2, n+1):
    a = l[i-2] + l[i-1]
    l.append(a)
print(l[n])
n, k = map(lambda x: int(x), input().split())

total = [[0, 0]] * k
for i in range(n):
    number, copies = map(lambda x: int(x), input().split())
    total[i] = [number, copies]

total.sort(key=lambda x: x[0])

add = 0
for pair in total:
    add += pair[1]
    if add >= k:
        print(pair[0])
        break

### FIXED CODE ###

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

ab = [[0, 0]] * N
for i in range(N):
    _a, _b = map(int, input().split())
    ab[i] = [_a, _b]
ab.sort(key=lambda x:x[0])

j = 0
index = 0
while j < K:
    j += ab[index][1]
    if j < K:
        index += 1

print(ab[index][0])
N = input("Number:\n")
if(N%2==0):
  res = (N/2)/N
else:
  res = ((N+1)/2)/N
print(res)

### FIXED CODE ###

N = int(input())
if(N%2==0):
  print((N/2)/N)
else:
  print(((N+1)/2)/N)
from sys import stdin
A,B,K=[int(x) for x in stdin.readline().rstrip().split()]
lst = list(range(A,B+1))
for i in lst[:K]:
    print(i)
for j in lst[-K:]:
    print(j)

### FIXED CODE ###

from sys import stdin
A,B,K=[int(x) for x in stdin.readline().rstrip().split()]
ran = range(A,B+1)
for i in sorted(set(ran[:K])|set(ran[-K:])):
    print(i)
rot = ((1,2,4,3),(2,0,3,5),(0,1,5,4))
f = input().split()

for i in range(int(input())):
    t, s = map(f.index, input().split())
    for j in rot:
        if (t in j)*(s in j):
            continue
        d = rot.index(j)
        if (j.index(t) - j.index(s)) %4 == 1:
            d -= 5
    print(f[abs(d)])

### FIXED CODE ###

R = ((1,2,4,3),(2,0,3,5),(0,1,5,4))
f = input().split()

for i in range(int(input())):
    t, s = map(f.index, input().split())
    for j in R:
        if not (t in j)*(s in j):
            continue
        d = R.index(j)
        if (j.index(t) - j.index(s)) %4 == 1:
            d -= 5
    print(f[abs(d)])
s=str(int(input()))[-1]
 
if s in ["2", "4", "5", "7", "9"]:
  print("hon")
else if s == 3:
  print("bon")
else:
  print("pon")

### FIXED CODE ###

S = str(input())[-1]
tmp = ['0', '1', '6', '8']
if S == '3':
    print('bon')
elif S in tmp:
    print('pon')
else:
    print('hon')
N=int(input())

a=N%10

if a==2 or a==4 or a==5 or a==7 or a==9:
  print('hon')
elif a==0 or a==1 or a==6 or a==8:
  print('pon')
else:
  print('bon')

### FIXED CODE ###

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

print(A*B)
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


s = S()
q = I()
queries = SR(q)
for query in queries:
    print(query[0])
    if query[0] == '1':
        if len(s) <= 1:
            continue
        s = s[-1] + s[1:-1] + s[0]
    else:
        _, f, c = query.split()
        if f == '1':
            s = c + s
        else:
            s = s + c
    print(f'{s=}')
print(s)


### FIXED CODE ###

from collections import deque
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


s = S()
q = I()
queries = SR(q)
que = deque(list(s))
top = True  # 先頭の位置 Trueが左（初期位置）
for query in queries:
    if query[0] == '1':
        top = not(top)
    else:
        _, f, c = query.split()
        if f == '1':
            if top:
                que.appendleft(c)
            else:
                que.append(c)
        else:
            if top:
                que.append(c)
            else:
                que.appendleft(c)
if top:
    print(''.join(list(que)))
else:
    print(''.join(list(que))[::-1])
N, T = map(int, input().split())
c = []
t = []
for i in range(N):
    tmp1, tmp2 = map(int, input().split())
    c.append(tmp1)
    t.append(tmp2)

tmp_min = float('inf')

for i in range(N):
    if t[i]<=T and tmp_min>c[i]:
        tmp_min = c[i]

if tmp_min == float('inf'):
    print('TLE')
else tmp_min<=T:
    print(int(tmp_min))


### FIXED CODE ###

n, t = map(int, input().split())
cmin = float("inf")
for i in range(n):
    ci, ti = map(int, input().split())
    if ti <= t and ci < cmin:
        cmin = ci
if cmin == float("inf"):
    print("TLE")
else:
    print(cmin)
x = int(input())
for b in range(x):
	for p in range(x):
		if b >0 and p >=2:
			if b**p > x:
				break
			ans = b ** p
print(ans

### FIXED CODE ###

x = int(input())

ans = 1
for b in range(1,32):
	for p in range(2,10):
		l = b**p
		if l <= x and l > ans:
			ans = l
print(ans)
n=int(input())
p=2
c=0
while n%p==0:
    c+=1
    n//=p
    p*=2
for i in range (3,int(math.sqrt(n))+1,2):
    p=i
    while n%p==0:
        c+=1
        n//=p
        p*=i
t=0
for i in range (2,int(math.sqrt(n))+1):
    if n%i==0:
        t=1
if t==0:
    c+=1
print(c)

### FIXED CODE ###

import math
n=int(input())
p=2
c=0
curr=0
while n%p==0:
    curr+=1
    n//=p
j=0
j=(math.sqrt(1+8*curr)-1)//2
c+=int(j)
#print(j)
for i in range (3,int(math.sqrt(n))+1,2):
    p=i
    curr=0
    while n%p==0:
        curr+=1
        n//=p
    j=0
    j=(math.sqrt(1+8*curr)-1)//2
    c+=int(j)
    #print(j)
if n>2:
    c+=1
print(c)
from math import log,ceil
x=int(input())
p=100
r=0.01

for i in range(1,3760+1):
    c=floor(p*(1.01)**1)
    if c<x:
        p+=c-p
    else:
        break
print(i)

### FIXED CODE ###

from math import floor
x=int(input())
p=100
r=0.01

for i in range(1,3760+1):
    c=floor(p*(1.01)**1)
    if c<x:
        p+=c-p
    else:
        break
print(i)
x = []
y = []
for i in range(5):
    a = int(input())
    if a % 10 != 0:
        y.append(a % 10)
    if a % 10 != 0:
        a = a + (10 - (a % 10))
    x.append(a)

ans = sum(x)
s = 10 - min(y)

ans -= s

print(ans)

### FIXED CODE ###

x = []
y = []
for i in range(5):
    a = int(input())
    if a % 10 != 0:
        y.append(a % 10)
    if a % 10 != 0:
        a = a + (10 - (a % 10))
    x.append(a)

ans = sum(x)
if len(y) != 0:
    s = 10 - min(y)
    ans -= s

print(ans)
n,m=(int(i) for i in input().split(' '))
i=m%n
if m==2147483647:
  print(1)
  exit()
while True:
  if i==1:
    print(i)
    break
  if m%i==0 and m//i>=n:
    print(i)
    break
  else:
    i-=1


### FIXED CODE ###

N = int(input())
if N == 1:
    print('Hello World')
elif N == 2:
    A = int(input(''))
    B = int(input(''))
    print(A + B)
n = int(input())

csf = []

for i in range(n - 1):
    c, s, f = map(int, input().split())
    csf.append([c, s, f])

ans = []
for i in range(n - 1):
    tmp = csf[i][0] + csf[i][1]
    for j in range(i + 1, n - 1):
        if tmp < csf[j][1]:
            tmp = csf[j][0] + csf[j][1]
        elif (tmp - csf[j][1]) % csf[j][2] == 0:
            tmp += csf[j][0]
        else:
            tmp += ((tmp // csf[j][2] + 1) * csf[j][2] + csf[j][0]
    ans.append(tmp)
ans.append(0)

print(*ans, sep="\n")

### FIXED CODE ###

n = int(input())

csf = []

for i in range(n - 1):
    c, s, f = map(int, input().split())
    csf.append([c, s, f])

ans = []
for i in range(n - 1):
    tmp = csf[i][0] + csf[i][1]
    for j in range(i + 1, n - 1):
        if tmp < csf[j][1]:
            tmp = csf[j][0] + csf[j][1]
        elif (tmp - csf[j][1]) % csf[j][2] == 0:
            tmp += csf[j][0]
        else:
            tmp = (tmp // csf[j][2] + 1) * csf[j][2] + csf[j][0]
    ans.append(tmp)
ans.append(0)

print(*ans, sep="\n")
a,b,c,d=map(int,input().split())
s=min(a+b,c+d) - max(a,c)
if s>0:print(s)
else:print(0)


### FIXED CODE ###

n=input()
if n ==  n[::-1]:print("Yes")
else:print("No")
N, K = map(int, input().split())
A = tuple(map(int, input().split()))

if K <= 200000:
  i = 1
  for _ in range(K):
    i = A[i-1]
  print(i)
  exit()

visited = {1}
order = []

i = 1
for count in range(1, 200001):
  i = A[i-1]
  if i in visited:
    break
  else:
    visited.add(i)
  order.append(i)

idx = order.index(i)
order2 = order[idx:]
mod = (K-idx) % len(order2)

print(order2[mod-1])

### FIXED CODE ###

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

if K <= 200000:
  i = 1
  for _ in range(K):
    i = A[i-1]
  print(i)
  exit()

visited = {1}
order = [1]

i = 1
for count in range(1, 200001):
  i = A[i-1]
  if i in visited:
    break
  else:
    visited.add(i)
  order.append(i)

idx = order.index(i)
order2 = order[idx:]
# print(order2)
mod = (K+1-idx) % len(order2)

print(order2[mod-1])
T = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
x = (A[0]-B[0])*T[0]
y = (B[0]-A[0])*T[0] + (B[1]-A[1])*T[1]

if x < 0:
    x *= -1
    y *= -1
if y == 0:
    print('infinity')
ans = -(-x//y)*2-1
if x%y == 0:
    ans -= 1
print(ans)

### FIXED CODE ###

T1, T2 = map(int,input().split())
A1, A2 = map(int,input().split())
B1, B2 = map(int,input().split())

A1 *= T1
B1 *= T1
A2 *= T2
B2 *= T2

if A1+A2 > B1+B2: # Aを遅く
    A1,B1 ,A2,B2 = B1,A1 ,B2,A2

if A1+A2 == B1+B2:
    print("infinity")
    exit()

if A1 < B1:
    print(0)
    exit()

def nibu(l,r):
    if l >= r:
        return l
    c = (l+r+1)//2
    if (A1+A2)*(c-1)+A1 >= (B1+B2)*(c-1)+B1:
        return nibu(c,r)
    else:
        return(nibu(l,c-1))

ans = nibu(0,10**100)
if (A1+A2)*(ans-1)+A1 == (B1+B2)*(ans-1)+B1:
    print(ans*2-2)
else:
    print(ans*2-1)
a, b = map(int, input().split())
if b != 0:
    c = input()
    l = c.split()
    cc = [int(s) for s in l]
    ccc =list(cc)
    for i in range(a,101):
        if i in ccc:
            continue
        else:
            x = i
            break
    for i in reversed(range(0, a)):
        if i in ccc:
            continue
        else:
            y = i
            break
    if x-a<a-y:
        print(x)
    else:
        print(y)
else:
    d = input()
    print(a)

### FIXED CODE ###

a, b = map(int, input().split())
if b != 0:
    c = input()
    l = c.split()
    cc = [int(s) for s in l]
    ccc =list(cc)
    for i in range(a,102):
        if i in ccc:
            continue
        else:
            x = i
            break
    for i in reversed(range(0, a)):
        if i in ccc:
            continue
        else:
            y = i
            break
    if x-a<a-y:
        print(x)
    else:
        print(y)
else:
    d = input()
    print(a)