Harryxun/stf_run huggingface dataset:
import math
n = int(input())
A, B = 0, 0
for i in range(n):
    x, y = int(input.split())
    dx, dy = 1, 1
    if A > x:
        dx = A // x
        if A % x != 0:
            dx += 1
    
    if B > y:
        dy = B // y
        if B % y != 0:
            dy += 1

    a = max(dx, dy)
    A, B = a * x, a * y
print(A + B)

### FIXED CODE ###

n = int(input())
A, B = 0, 0
for i in range(n):
    x, y = map(int,input().split())
    dx, dy = 1, 1
    if A > x:
        dx = A // x
        if A % x != 0:
            dx += 1
    
    if B > y:
        dy = B // y
        if B % y != 0:
            dy += 1

    a = max(dx, dy)
    A, B = a * x, a * y
print(A + B)
import math

def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
      
def factorize(x):
    ans=1
    div=2
    while div**2<=x:
        while x%div==0:
            x=x//div
            flag=1
        if flag==1:
            ans+=1
        div+=1
        flag=0
    if x>1:
        ans+=1
    return ans

a,b=map(int,input().split())
g=gcd(a,b)
f=factorize(g)
print(f)


### FIXED CODE ###

import math
#最大公約数
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
#因数分解
def factorize(x):
    f=[]
    div=2
    while div**2<=x:
        while x%div==0:
            f.append(div)
            x=x//div
        div+=1
    if x>1:
        f.append(x)
    return f

"""def factorize(x):
    ans=1#約数１
    div=2
    while div**2<=x:
        while x%div==0:
            x=x//div
            flag=1
        if flag==1:
            ans+=1
        div+=1
        flag=0
    if x>1:
        ans+=1
    return ans"""

a,b=map(int,input().split())
g=gcd(a,b)
f=factorize(g)
print(len(set(f))+1)
# coding: utf-8

N = int(input().strip())

input_tuples = []
selected_tuple = None

for _ in range(N):
    x, y, h = [int(s) for s in input().strip().split()]
    if selected_tuple is None and h > 0:
        selected_tuple = ((x, y, h))
    else:
        input_tuples.append((x, y, h))

for cx in range(0, 101):
    for cy in range(0, 101):
        H = selected_tuple[2] + \
            abs(selected_tuple[0] - cx) + abs(selected_tuple[1] - cy)

        for x, y, h in input_tuples:
            if h != max(H - abs(x - cx) - abs(y - cy), 0):
                break
        else:
            break
        continue
    else:
        continue
    break

print("{} {} {}".format(cx, cy, H))


### FIXED CODE ###

# coding: utf-8

def main():
    N = int(input().strip())

    if N == 1:
        print("Hello World")
    else:
        A = int(input().strip())
        B = int(input().strip())
        print(A+B)


if __name__ == "__main__":
    main()
n = int(input())
x = list(range(n))
y = list(range(n))
h = list(range(n))

for i in range(n):
  x[i], y[i], h[i] = map(int, input().split())

flag=0
i = 0
while(flag==0 and i < 101):
  j = 0
  while(flag==0 and j < 101):
    ans_h = 0
    for k in range(n):
      if h[k] == 0:
        continue
      elif ans_h == 0:
        ans_h = abs(i-x[k])+abs(j-y[k])+h[k]
      elif abs(i-x[k])+abs(j-y[k])+h[k] != ans_h:
        break
      if k == n-1:
        ans_x = i
        ans_y = j
        flag=1
        break
    j+=1
  i+=1

print(ans_x, ans_y, ans_h)

### FIXED CODE ###

n = int(input())
x = list(range(n))
y = list(range(n))
h = list(range(n))

for i in range(n):
  x[i], y[i], h[i] = map(int, input().split())
  if h[i] != 0:
    X = x[i]
    Y = y[i]
    H = h[i]

flag=0
i = 0
while(flag==0 and i < 101):
  j = 0
  while(flag==0 and j < 101):
    ans_h = abs(i-X)+abs(j-Y)+H
    for k in range(n):
      h_ = max(ans_h-abs(i-x[k])-abs(j-y[k]), 0)
      if h_ != h[k]:
        break
      if k == n-1:
        ans_x = i
        ans_y = j
        flag=1
        break
    j+=1
  i+=1

print(ans_x, ans_y, ans_h)
import sys


def main():
    N = int(input())
    S = input()
    if N % 2 == 1:
        print("No")
        sys.exit()
    n = N / 2
    yesno = "Yes" if S[:n] == S[n:] else "No"
    print(yesno)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    N = int(input())
    S = input()
    if N % 2 == 1:
        print("No")
        quit()
    n = N // 2
    yesno = "Yes" if S[:n] == S[n:] else "No"
    print(yesno)


if __name__ == "__main__":
    main()
N, K = map(int, input().split())
S = input()

arr = []
cnt = 0
comp = S[0]
for s in S:
    if s==comp:
        cnt += 1
    else:
        if comp=='0':
            arr.append(-cnt)
        else:
            arr.append(cnt)
        cnt = 1
        comp = s
if comp=='0':
    arr.append(-cnt)
else:
    arr.append(cnt)

def iter(A, cnt):
    if cnt>=K or len(A)<2:
        return max(A)
    elif len(A)==2:
        return abs(A[0]) + abs(A[1])
    m = -A[0]+A[1]
    args = [-1]
    for i in range(len(A)-2):
        s3 = A[i] - A[i+1] + A[i+2]
        if m<s3:
            m = s3
            args = [i]
        elif m==s3:
            args.append(i)
    s3 = A[-2]-A[-1]
    if m<s3:
        m = s3
        args = [len(A)-1]
    elif m==s3:
        args.append(len(A)-1)
    cands = []
    for arg in args:
        if arg==-1:
            B = [-A[0]+A[1]] + A[2:]
        elif arg==len(A)-1:
            B = A[:-2] + [A[-2]-A[-1]]
        else:
            B = A[:arg] + [A[arg] - A[arg+1] + A[arg+2]] + A[arg+3:]
        cands.append(iter(B, cnt+1))
    return max(cands)


print(iter(arr, 0))

### FIXED CODE ###

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

arr = []
cnt = 0
comp = S[0]
for s in S:
    if s==comp:
        cnt += 1
    else:
        arr.append(cnt)
        cnt = 1
        comp = s
arr.append(cnt)

if len(arr)<3:
    print(sum(arr))
else:
    if S[0]=='1':
        L = (len(arr)+1)//2 - K +1
        l = 0
        tmp = sum(arr[2*l:2*(l+K)+1])
        ans = tmp
        for l in range(1, L):
            tmp = tmp - (arr[2*(l-1)]+arr[2*l-1]) + sum(arr[2*(l-1+K)+1 : min(2*(l+K)+1, len(arr))])
            ans = max(tmp, ans)
    else:
        L = (len(arr)+1)//2 - K + 1
        l = 0
        tmp = sum(arr[2*l:2*(l+K)])
        ans = tmp
        for l in range(1, L):
            tmp = tmp - sum(arr[max(0,2*l-3) : 2*l-1]) + sum(arr[2*(l+K-1): min(2*(l+K), len(arr))])
            ans = max(tmp, ans)
            
    print(ans)
N, M = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for i in range(N - 1 + M)]

from collections import defaultdict

vs = defaultdict(set)
ws = defaultdict(set)

for a, b in AB:
    vs[a].add(b)
    ws[b].add(a)

#print(vs)
#print(ws)

L = []

cs = [0] * (1 + N)

def visit(n):
    if cs[n] == 1:
        return
    elif cs[n] == 0:
        cs[n] = 1
        for m in vs[n]:
            visit(m)
        cs[n] = 2
        L.append(n)

for n in range(1, N + 1):
    if cs[n] == 0:
        visit(n)

#print(L)

nrank = {}

for r, n in enumerate(L):
    nrank[n] = r

#print(nrank)

for n in range(1, N + 1):
    r = 0
    if ws[n]:
        r = sorted(ws[n], key=lambda x:nrank[x])[0]
    print(r)


### FIXED CODE ###

N, M = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for i in range(N - 1 + M)]

import sys
sys.setrecursionlimit(200000)

from collections import defaultdict

vs = defaultdict(set)
ws = defaultdict(set)

for a, b in AB:
    vs[a].add(b)
    ws[b].add(a)

#print(vs)
#print(ws)

L = []

cs = [0] * (1 + N)

def visit(n):
    if cs[n] == 1:
        return
    elif cs[n] == 0:
        cs[n] = 1
        for m in vs[n]:
            visit(m)
        cs[n] = 2
        L.append(n)

for n in range(1, N + 1):
    if cs[n] == 0:
        visit(n)

#print(L)

nrank = {}

for r, n in enumerate(L):
    nrank[n] = r

#print(nrank)

for n in range(1, N + 1):
    r = 0
    if ws[n]:
        r = sorted(ws[n], key=lambda x:nrank[x])[0]
    print(r)
import sys
from itertools import combinations
from math import sqrt
import numpy as np

read = sys.stdin.read
readline = sys.stdin.readline


def main():
    N, K, *xyc = map(int, read().split())
    x = xyc[::3]
    y = xyc[1::3]
    xy = list(zip(x, y))
    c = xyc[2::3]
    left = 0
    right = 10 ** 6
    delta = 0.1 ** 7
    while right - left > delta:
        mid = (left + right) / 2
        intersections = []
        r = [(mid / i) ** 2 for i in c]
        for i, j in combinations(range(N), 2):
            x1, y1 = xy[i]
            x2, y2 = xy[j]
            X = x2 - x1
            Y = y2 - y1
            XY = X ** 2 + Y ** 2
            r1 = r[i]
            r2 = r[j]

            a = (XY + r1 - r2) / 2
            b = XY * r1 - a ** 2
            if b < delta:
                continue
            b = sqrt(b)
            xi1 = (a * X + Y * b) / XY + x1
            yi1 = (a * Y - X * b) / XY + y1
            xi2 = (a * X - Y * b) / XY + x1
            yi2 = (a * Y + X * b) / XY + y1
            intersections.append((xi1, yi1))
            intersections.append((xi2, yi2))

        intersections.extend(xy)
        intersections = np.array(intersections, np.float)
        cnt = np.zeros(len(intersections), np.int64)

        for (i, j), k in zip(xy, r):
            XY = (intersections[:, 0] - i) ** 2 + (intersections[:, 1] - j) ** 2
            cnt[XY < k + delta] += 1

        if np.any(cnt >= K):
            right = mid
        else:
            left = mid

    print(right)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from itertools import combinations
from math import sqrt

read = sys.stdin.read
readline = sys.stdin.readline


def main():
    N, K, *xyc = map(int, read().split())
    x = xyc[::3]
    y = xyc[1::3]
    xy = list(zip(x, y))
    c = xyc[2::3]
    left = 0
    right = 10 ** 6
    delta = 0.1 ** 7
    while right - left > delta:
        mid = (left + right) / 2
        intersections = []
        r = [(mid / i) ** 2 for i in c]
        for i, j in combinations(range(N), 2):
            x1, y1 = xy[i]
            x2, y2 = xy[j]
            X = x2 - x1
            Y = y2 - y1
            XY = X ** 2 + Y ** 2
            r1 = r[i]
            r2 = r[j]

            a = (XY + r1 - r2) / 2
            b = XY * r1 - a ** 2
            if b < delta:
                continue
            b = sqrt(b)
            xi1 = (a * X + Y * b) / XY + x1
            yi1 = (a * Y - X * b) / XY + y1
            xi2 = (a * X - Y * b) / XY + x1
            yi2 = (a * Y + X * b) / XY + y1
            intersections.append((xi1, yi1))
            intersections.append((xi2, yi2))

        intersections.extend(xy)
        cnt = 0
        for X, Y in intersections:
            tmp = 0
            for (i, j), k in zip(xy, r):
                XY = (X - i) ** 2 + (Y - j) ** 2
                if XY < k + delta:
                    tmp += 1
            cnt = max(tmp, cnt)
            if cnt >= K:
                break
        if cnt >= K:
            right = mid
        else:
            left = mid

    print(right)


if __name__ == '__main__':
    main()
hoge=input()
hoge=hoge.split()
a=int(hoge[0])
b=int(hoge[1])
if a % 2 == 0 or b % 2 == 0:
  print("Even")
else:
  print("Odd"

### FIXED CODE ###

hoge=input()
hoge=hoge.split()
a=int(hoge[0])
b=int(hoge[1])
if a % 2 == 0 or b % 2 == 0:
  print("Even")
else:
  print("Odd")
from itertools import combinations
n = int(input())
l = list(map(int,input().split()))
c = combinations(l,3)
ans=0
for (a,b,c) in c:
	if a+b>c and b+c>a and c+a>b and a!=b and b!=c and a!=c:
		+=1
print(ans)


### FIXED CODE ###

from itertools import combinations
n = int(input())
l = list(map(int,input().split()))
c = combinations(l,3)
ans=0
for (a,b,c) in c:
  if a+b>c and b+c>a and c+a>b and a!=b and b!=c and a!=c:
    ans+=1
print(ans)
N = int(input())
a = [int(i) for i in input().split()]

a.sort()
for i in range(N-1):
    if a[i-1] ^ a[i+1] == a[i]:
        continue
    else:
        print("No")
        exit()

if a[N-2] ^ a[0] != a[N-1]:
    print("No")
        exit()

print("Yes" if flag else "No")


### FIXED CODE ###

from collections import Counter
N = int(input())
a = [int(i) for i in input().split()]

c = Counter(a)

if c[0] == N:
    print("Yes")
    exit()

if N % 3 == 0 and c[0] == N // 3 and len(c.values()) == 2:
    print("Yes")
    exit()

n =  N // 3
k = list(c.keys())
v = list(c.values())

if N % 3 == 0 and v == [n, n, n] and k[0]^k[1]^k[2] == 0:
    print("Yes")
    exit()

print("No")
A = input()
B = input()
C = input()

xa = 0
xb = 0
xc = 0

#配列の次のカードの文字を返す
def next(X, i):
    if X[i] == 'a':
        return A[xa]
    elif X[i] == 'b':
        return B[xb]
    else:
        return C[xc]

h = 'A'
xa += 1
k = next(A, xa - 1) #最初

while True:
    if k == 'a':
        h = 'A'
        xa += 1
        if xa <= len(A):
            k = next(A, xa - 1)
    elif k == 'b':
        h = 'B'
        xb += 1
        if xb <= len(B):
            k = next(B, xb - 1)
    else:
        h = 'C'
        xc += 1
        if xc <= len(C):
            k = next(C, xc - 1)

print(h)


### FIXED CODE ###

A = input()
B = input()
C = input()

xa = 0
xb = 0
xc = 0

h = 'A'
k = A[0] #最初の１枚を抜く
xa += 1

while True:

    if k == 'a':
        h = 'A'
        if xa < len(A):
            k = A[xa]
            xa += 1
        else:
            break
    elif k == 'b':
        h = 'B'
        xb += 1
        if xb < len(B):
            k = B[xb]
            xb += 1
        else:
            break
    elif k == 'c':
        h = 'C'
        xc += 1
        if xc < len(C):
            k = C[xc]
            xc += 1
        else:
            break

print(h)
a=int(input('>>'))
    b=int(input('>>'))
    
    if b%a==0:
        print(a+b)
    else:
        print(b-a)

### FIXED CODE ###

a,b=map(int,input().split())
if b%a==0:
	print(a+b)
else:
	print(b-a)
import math
N, K = input().split(" ")
N, K = int(N), int(K)
P = 0
if (N < K):
  for n in N:
    P += 1/(N*math.ceil(math.log2(K)-math.log2(n)))
else:
  for n in K:
    P += 1/(N*math.ceil(math.log2(K)-math.log2(n)))
  P += (K-N)/N
print(P)

### FIXED CODE ###

import math
N, K = input().split(" ")
N, K = int(N), int(K)
P = 0
if (N < K):
  for n in range(1,N+1):
    P += 1/(N*pow(2,math.ceil(math.log2(K)-math.log2(n))))
else:
  for n in range(1, K+1):
    P += 1/(N*pow(2,math.ceil(math.log2(K)-math.log2(n))))
  P += (N-K)/N
print(P)
n,m,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort(key=lambda x: x[0])
money = 0
ans = 0
for i in range(n):  
  c = A[i][0]
  a = A[i][1:]
  aa = min(a)
  money += c
  ans += aa
  if ans >= x:
    print(money())
    exit()
print(-1)


### FIXED CODE ###

n, m, X = map(int, input().split())

A = [[] for _ in range(n)]
c = [0] * n

for i in range(n):
    c_as = list(map(int, input().split()))
    c[i], A[i] = c_as[0], c_as[1:]

INF = 10**9
ans = INF
    
for s in range(0, 1 << n):
    smart = [0] * m
    cost_sum = 0
    for i in range(n):
        if (s >> i) % 2 == 0:continue
        cost_sum += c[i]
        for j in range(m):
            smart[j] += A[i][j]
    ok = True
    for j in range(m):
        if smart[j] < X:
            ok = False
    if ok:
        ans = min(ans, cost_sum)

if ans == INF:
    ans = -1

print(ans)
s = list(input())
k = int(input())

for i, si in enumerate(s):
    if si != '1':
        ind = i
        res = si
        break
    if i == len(s):
        res = 'one'

if res == 'one':
    print(1)
elif ind >= k:
    print(1)
else:
    print(res)

### FIXED CODE ###

s = list(input())
k = int(input())

for i, si in enumerate(s):
    if si != '1':
        ind = i
        res = si
        break
    if i == len(s) - 1:
        res = 'one'

if res == 'one':
    print(1)
elif ind >= k:
    print(1)
else:
    print(res)
list[]
for i range(0,10):
    n = int(raw_input())
    list.append(n)
list.sort(reverse=True)
for i in range(0,3):
    print list[i]

### FIXED CODE ###

list=[]
for i in range(0,10):
    n = int(raw_input())
    list.append(n)
#print'---------------------'
list.sort(reverse=True)
for i in range(0,3):
    print list[i]
S = input()
while S:
    print(S)
    for x in ['dreamer', 'eraser', 'dream', 'erase']:
        if S.endswith(x):
            S = S[:-len(x)]
            break
    else:
        print('NO')
        exit()
print('YES')
        

### FIXED CODE ###

S = input()
while S:
    for x in ['dreamer', 'eraser', 'dream', 'erase']:
        if S.endswith(x):
            S = S[:-len(x)]
            break
    else:
        print('NO')
        exit()
print('YES')
a, b, c = map(int, input().splitr())

print(a*b//2)

### FIXED CODE ###

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

print(a*b//2)
r, c = map(int, input().split())
for i in range(r):
    a = list(map(int, input(),split()))
    print(a,sum(a))
    


### FIXED CODE ###

n,m=map(int,input().split())
a = []
for i in range(n):
    a.append(list(map(int, input().split())))
    a[i]+=[sum(a[i])]
    print(*a[i])
a=list(zip(*a[::-1]))
for i in range(m):print(sum(a[i]),end=' ')
print(sum(a[m]))
a,b=input().split()
d=0
n=0
l=input().split( )
while True:
  if d>int(b):
    break
  if d==int(b):
    n+=1
    break
  else:
    w=l[n]
    d+=int(w)
    n+=1

print(n)

### FIXED CODE ###

a,b=input().split()
d=0
n=1
l=input().split( )
for p in range(int(a)):
  d+=int(l[p])
  if d<=int(b):
    n+=1
print(n)
import bisect


n, k = map(int, input().split())
xs = list(map(int, input().split()))
index = bisect.bisect_right(xs, -1)

a = xs[:index][::-1]
cost = 0
if xs[index] == 0:
    cost += 1
    b = xs[index + 1:]
else:
    b = xs[index:]

cost_a = [0]
cost_b = [0]
for c in a:
    cost_a.append(abs(c))
for c in b:
    cost_b.append(c)

ret = float('inf')
if len(a) >= k - cost:
    ret = min(ret, cost_a[k - cost])
if len(b) >= k - cost:
    ret = min(ret, cost_b[k - cost])

for i in range(len(cost_a)):
    if 0 <= k - i < len(cost_b):
        try:
            ret = min(ret, 2 * cost_a[i] + cost_b[k - i])
        except Exception:
            pass

for i in range(len(cost_b)):
    if 0 <= k - i < len(cost_a):
        try:
            ret = min(ret, 2 * cost_b[i] + cost_a[k - i])
        except Exception:
            pass
print(ret)



### FIXED CODE ###

import bisect


n, k = map(int, input().split())
xs = list(map(int, input().split()))
index = bisect.bisect_right(xs, -1)

a = xs[:index][::-1]
cost = 0
if index < len(xs) and xs[index] == 0:
    cost += 1
    b = xs[index + 1:]
else:
    b = xs[index:]

cost_a = [0]
cost_b = [0]
for c in a:
    cost_a.append(abs(c))
for c in b:
    cost_b.append(c)

ret = float('inf')
if len(a) >= k - cost:
    ret = min(ret, cost_a[k - cost])
if len(b) >= k - cost:
    ret = min(ret, cost_b[k - cost])

for i in range(len(cost_a)):
    if 0 <= k - i < len(cost_b):
        ret = min(ret, 2 * cost_a[i] + cost_b[k - i])

for i in range(len(cost_b)):
    if 0 <= k - i < len(cost_a):
        ret = min(ret, 2 * cost_b[i] + cost_a[k - i])
print(ret)
import fractions

n = int(input())
ai = [int(i) for i in input().split()]


mod = 10**9+7

if n == 1:
    print(1)
    exit()

b_li = []

seki = 1

for i in range(n):
    seki *= ai[i]

for i in range(n):
    b_li.append(seki/ai[i])

t_gcd = fractions.gcd(b_li[0],b_li[1])

for i in range(n-2):
    t_gcd = int(fractions.gcd(t_gcd,b_li[i+2]))
    
ans = 0

for i in range(n):
    ans += int(seki/t_gcd/ai[i])
    
print(ans%mod)

### FIXED CODE ###

import collections
import math
n = int(input())
ai = [int(i) for i in input().split()]

mod = 10**9+7

if n == 1:
    print(1)
    exit()
    
    
# 素因数分解、辞書で返すやつ
# mathをimportする
def prime(n):
    factor = {}
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            if not num in factor.keys():
                factor[num] = 1
            else:
                factor[num] += 1
        if num > n:
            break
    if n != 1:
        if not n in factor.keys():
            factor[n] = 1
        else:
            factor[n] += 1
    return factor


dic = {}
for a in ai:
    pr = prime(a)
    for num, count in pr.items():
        if not num in dic.keys():
            dic[num] = count
        else:
            if dic[num] < count:
                dic[num] = count

kari = 1
for num,count in dic.items():
    kari *= pow(num,count,mod)
    kari %= mod

kari_old = kari
ans = 0

for i in range(n):
    kari = kari_old
    #com_ab_new = copy.deepcopy(com_ab)
    #print(com_ab,com_ab_new)
    #kari = 1
    #for j in range(kosu):
    #kari *= pow(sosu_li[j][0],com_ab[sosu_li[j][0]],mod)
    kari *= pow(ai[i],mod-2,mod)
    ans += kari
    ans %= mod
    #print(ans)
    #print(ans)
        
print(ans)
a=input().split("¥n")
S_len=len(a[0])
K=int(a[1])
for i in range(S_len):
  if(int(a[0][i])==1):
    K-=1
    if(K<=1):
      print("1")
      break
  else:
    print(a[0][i])
    break


### FIXED CODE ###

S=input()
S_len=len(S)
K=int(input())
for i in range(S_len):
  if(int(S[i])==1):
    K-=1
    if(K<=0):
      print("1")
      break
  else:
    print(S[i])
    break
import math
a,b,c,d=map(int,input().split())
s=b-a
bc=b//c
if a%c==0:
    ac=a//c-1
else:
    ac=a//c
bd=b//d
if a%d==0:
    ad=a//d-1
else:
    ad=a//d
gcd=math.gcd(c,d)
l=c*d/gcd
bl=b//l
if a%l==0:
    al=a//l-1
else:
    al=a//l
print(int(b-a+1-(bc-ac+bd-ad-bl+al)))

### FIXED CODE ###

a,b,c,d=map(int,input().split())
bc=int(b//c)
if a%c==0:
    ac=int(a//c)-1
else:
    ac=int(a//c)
bd=b//d
if a%d==0:
    ad=int(a//d)-1
else:
    ad=int(a//d)
e=c
f=d
while f:
    e, f = f, int(e % f)
gcd=int(e)
l=int(c*d/gcd)
bl=int(b//l)
if a%l==0:
    al=int(a//l)-1
else:
    al=int(a//l)
s=int(b-a+1)
s2=int(bc-ac+bd-ad-bl+al)
print(s-s2)
N=int(input())
edge = [[] for _ in range(N+1)]

for _ in range(N-1):
    u,v,w=[int(x) for x in input().split()]
    if w&1:
        edge[u].append((v,-1))
        edge[v].append((u,-1))
    else:
        edge[u].append((v,1))
        edge[v].append((u,1))
    
color = [None]*(N+1)

def set_color(v,c):
    color[v]=c
    for x,sgn in edge[v]:
        if color[x] is None:
            set_color(x,sgn*c)
set_color(1,1)

for x in color[1:]:
    print((x+1)//2)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

N=int(input())
edge = [[] for _ in range(N+1)]

for _ in range(N-1):
    u,v,w=[int(x) for x in input().split()]
    if w&1:
        edge[u].append((v,-1))
        edge[v].append((u,-1))
    else:
        edge[u].append((v,1))
        edge[v].append((u,1))
    
color = [None]*(N+1)

def set_color(v,c):
    color[v]=c
    for x,sgn in edge[v]:
        if color[x] is None:
            set_color(x,sgn*c)
set_color(1,1)

for x in color[1:]:
    print((x+1)//2)
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools

N,K,*A = map(int,read().split())

A = [0] + [x-1 for x in A]

# 和が0となる場所を答えればよい

Acum = list(itertools.accumulate(A))
Acum = [x % K for x in Acum]

counter = [0] * (K+10)
answer = 0
for i,x in enumerate(Acum):
    answer += counter[x]
    counter[x] += 1
    if i >= K-1:
        counter[Acum[i-K+1]] -= 1

print(answer)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools
from collections import defaultdict

N,K,*A = map(int,read().split())

A = [0] + [x-1 for x in A]

# 和が0となる場所を答えればよい

Acum = list(itertools.accumulate(A))
Acum = [x % K for x in Acum]

counter = defaultdict(int)
answer = 0
for i,x in enumerate(Acum):
    answer += counter[x]
    counter[x] += 1
    if i >= K-1:
        counter[Acum[i-K+1]] -= 1

print(answer)
S = raw_input()

print('2018/01' + S[-2]

### FIXED CODE ###

S = raw_input()
print('2018/01/' + S[-2] + S[-1])