Harryxun/stf_run huggingface dataset:
def hoge(t, i):
	global data
	if lists[i][1] > t:
		t = lists[i][1]
	C, S, F = lists[i][0], lists[i][1], lists[i][2]

	return (t // F + 1) * F + C

if __name__ == '__main__':
	N = int(input())
	data = list()

	for i in range(N - 1):
		l = input().split()
		list.append(l)

	for i in range(N):
		t = 0
		for j in range(N-i):
			t = hoge(t,j)
		print(t)



### FIXED CODE ###

def hoge(t, i):
	global data
	C, S, F = int(data[i][0]), int(data[i][1]), int(data[i][2])
	if S > t:
		t = S
	if t % F != 0:
		t += F - t % F
	return t + C

if __name__ == '__main__':
	N = int(input())
	data = list()

	for i in range(N - 1):
		l = input().split()
		data.append(l)

	for i in range(N - 1):
		t = 0
		for j in range(i, N - 1):
			t = hoge(t,j)
		print(t)
	print(0)
from collections import deque
s = deque(input())
cnt = 0
while s:
  if s[0] == s[-1] == "x":
    s.pop()
    s.popleft()
  elif s[0] == "x":
    s.popleft()
    cnt += 1
  elif s[-1] == "x":
    s.pop()
    cnt += 1
  else:
    print(-1)
    break
else:
  print(cnt)

### FIXED CODE ###

from collections import deque
s = deque(input())
le = len(s)
cnt = 0
while le>1:
  if s[0] == s[-1]:
    s.pop()
    s.popleft()
    le -= 2
  elif s[0] == "x":
    s.popleft()
    cnt += 1
    le -= 1
  elif s[-1] == "x":
    s.pop()
    cnt += 1
    le -= 1
  else:
    print(-1)
    break
else:
  print(cnt)
def conv(x, n):
    nchar = '0123456789ABCDEF'
    digit = 0
 
    result = ''
 
    while x > 0:
        result = nchar[x % n] + result
        x = x / n
 
    return result
n, k = map(int, input().split())
print(conv(n, k))

### FIXED CODE ###

from math import log
n, k = map(int, input().split())
print(int(log(n, k)) + 1)
import copy

n, k = map(int, input().split())
v = list(map(int, input().split()))

mx = 0
for num_out in range(k+1):
	if num_out > n:
		num_out = n
		num_ret = min(k-n, n)
		out = copy.deepcopy(v).sort()
		for ret_v in out[:num_ret]:
			if ret_v < 0:
				ret_value += ret_v
			else:
				break
		val = sum(out) - ret_value
		if val > mx:
			mx = val
		continue
	
	num_ret = k-num_out
	for num_out_l in range(num_out+1):
		num_out_r = num_out - num_out_l
		out = v[:num_out_l] + v[n-num_out_r:]
		out.sort()
		ret_value = 0
		for ret_v in out[:num_ret]:
			if ret_v < 0:
				ret_value += ret_v
			else:
				break
		val = sum(out) - ret_value
		if val > mx:
			mx = val
			# mx_out = out

print(mx)
# print(mx_out)


### FIXED CODE ###

import copy

n, k = map(int, input().split())
v = list(map(int, input().split()))

mx = 0
for num_out in range(k+1):
	if num_out > n:
		num_out = n
		num_ret = min(k-n, n)
		out = copy.copy(v)
		out.sort()
		ret_value = 0
		for ret_v in out[:num_ret]:
			if ret_v < 0:
				ret_value += ret_v
			else:
				break
		val = sum(out) - ret_value
		if val > mx:
			mx = val
		continue
	
	num_ret = k-num_out
	for num_out_l in range(num_out+1):
		num_out_r = num_out - num_out_l
		out = v[:num_out_l] + v[n-num_out_r:]
		out.sort()
		ret_value = 0
		for ret_v in out[:num_ret]:
			if ret_v < 0:
				ret_value += ret_v
			else:
				break
		val = sum(out) - ret_value
		if val > mx:
			mx = val
			# mx_out = out

print(mx)
# print(mx_out)
from itertools import permutations

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

Matrix = [[False for i in range(N)] for j in range(N)] #隣接行列

#for i in range(N) :
#    Matrix[i][i] = True

for i in range(N) :
    row,column = map(int,input().split())
    Matrix[row-1][column-1] = True
    Matrix[column-1][row-1] = True
    
arange = list(range(2,N+1))
ans = 0
for pm in permutations(arange) :
    P = [1] + list(pm)
    for row,column in zip(P,P[1:]) :
        if not Matrix[row-1][column-1] :
            break
    else :
        ans += 1
print(ans)


### FIXED CODE ###

from itertools import permutations

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

L = [[False for i in range(N)] for j in range(N)]

for i in range(N) :
    L[i][i] = True
for i in range(M) :
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    L[a][b] = True
    L[b][a] = True

arange = range(2,N+1)

res = 0
for P in permutations(arange) :
    P = [1] + list(P)
    for S,G in zip(P,P[1:]) :
        if not L[S-1][G-1] :
            break
    else :
        res += 1
print(res)
N,M = map(int,input().split())
A = list(map(int,input().split()))
B = [list(map(int,input().split())) for _ in range(M)]
B.sort(key = lambda x:x[1])
B = list(reversed(B))
A.sort()

num = 0
for i in range(M):
    for j in range(B[i][0]):
        if A[num] < B[i][1]:
            A[num] = B[i][1]
            num += 1
        else:
            break
        
print(sum(A))

### FIXED CODE ###

N,M = map(int,input().split())
A = list(map(int,input().split()))
B = [list(map(int,input().split())) for _ in range(M)]
B.sort(key = lambda x:x[1])
B = list(reversed(B))
A.sort()

num = 0
for i in range(M):
    for j in range(B[i][0]):
        if num > N-1:
            break
        if A[num] < B[i][1]:
            A[num] = B[i][1]
            num += 1
        else:
            break

print(sum(A))
A, B, M = map(int, input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
X = [input() for i in range(M)]

min_price = min(a) + min(b)

for i in X:
    min_price = min(min_price, a[int(i[0])-1] + b[int(i[2])-1] - int(i[4:]))

print(min_price)

### FIXED CODE ###

A, B, M = map(int, input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
X = [list(map(int,input().split())) for i in range(M)]

min_price = min(a) + min(b)

for i in X:
    min_price = min(min_price, a[i[0]-1] + b[i[1]-1] - i[2])

print(min_price)
import math
from functools import reduce

N = int(input())

A = list(map(int, input().split()))
max_A = max(A)
gcd_list = []
for i in range(N):
    tmp = A[i]
    A[i] = max_A
    gcd = reduce(math.gcd, A)
    gcd_list.append(gcd)
    A[i] = tmp

print(max(gcd_list))
# 最大の値と変えてもいい


### FIXED CODE ###

def gcd(m, n):
    while n:
        m, n = n, m % n
    return m


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

left = [0]
right = [0]

for i in range(N):
    left.append(gcd(left[-1], A[i]))
    right.append(gcd(right[-1], A[(N-1)-i]))  # こっちのAは後ろからみる, iがN-1になった時はA[0]


right.reverse()  # indexが小さいほうが多くの数字を考慮した最大公約数になっている


gcd_list = [gcd(left[i], right[i+1]) for i in range(N)]

print(max(gcd_list))
X = int(input())
Y = int(input())
Z = int(input())

print(Z, X, Y)






### FIXED CODE ###

X,Y,Z=list(map(int,input().split()))

print(Z, X, Y)
s=input()
k=int(input())
t=set(s)
t.append(s)
for i in range(len(s)-1):
  t.append(s[i]+s[i+1])
  if i == len(s)-1:
    break
  t.append(s[i]+s[i+1]+s[i+2])
  if i == len(s)-2:
    continue
  t.append(s[i]+s[i+1]+s[i+2]+s[i+3])
t.sort()
print(t[k])


### FIXED CODE ###

s = input()
K = int(input())
N = len(s)

ans = []

for i in range(min(K, N)):
  for j in range(N-i):
    ans.append(s[j:j+i+1])
  
ans.sort()
count = 0
now = '0'
for i in range(len(ans)):
  if ans[i] != now:
    count += 1
    now = ans[i]
    if count == K:
      print(now)
      exit()
#!/usr/bin/env python3
import math
import sys
from functools import lru_cache

sys.setrecursionlimit(10 ** 7)

MOD = 1000000007  # type: int


@lru_cache(10000)
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def solve(N: int, K: int):
    choices = N - K + 1
    for i in range(K):
        print(int(combinations_count(choices, i + 1) * combinations_count(K - 1, i)) % MOD)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import math
import sys
from functools import lru_cache

sys.setrecursionlimit(10 ** 7)

MOD = 1000000007  # type: int


@lru_cache(10000)
def combinations_count(n, r):
    if n - r < 0:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def solve(N: int, K: int):
    choices = N - K + 1
    for i in range(K):
        print(int(combinations_count(choices, i + 1) * combinations_count(K - 1, i)) % MOD)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()
import math

x, y, X, Y = [int(i) for i in input().split()]
print(math.sqrt((x-X)**2 + abs(y-Y)**2),end='')

### FIXED CODE ###

import math

x, y, X, Y = [float(i) for i in input().split()]
print(math.sqrt((x-X)**2 + (y-Y)**2))
N = int(input())
ans = 1
A = list(map(int, input().split()))

for i in range(N):
  ans = ans * A[i]
  if ans = 0:
    break

if ans > 10 ** 18:
  print('-1')
else:
  print(ans)

### FIXED CODE ###

N = int(input())
ans = 1
A = list(map(int, input().split()))
flag = 0

for j in range(len(A)):
  if A[j] == 0:
    flag = 1
    ans = 0

if flag == 0:
  for i in range(N):
    ans = ans * A[i]
    if ans > 10 ** 18:
      break


if ans > 10 ** 18:
  print('-1')
else:
  print(ans)
print(x ** 3)

### FIXED CODE ###

x = int(input())

print (x ** 3)
N   =   int(input())
L   =   int(input())

s_list = [input() for _ in range(N)]

for ele in sorted(s_list): 
    print(ele, end = '')

### FIXED CODE ###

n, l = map(int, input().strip().split())
s_list = [input() for _ in range(n)]
s_list.sort()
 
for s in s_list:
    print(s, end='')
print()
s=input()
s+="Z"
S=""
F=0
for i in range(len(s)):
    if F==0:
        if s[i]=="B":
            F=1
        else:
            S+=s[i]
    else:
        if s[i]=="C":
            S+="D"
            F=0
        elif s[i]=="B":
            S+="B"
        else:
            S+=s[i]
            F=0
S=S[:len(S)-1]
#print(S)
S=S[::-1]
L=[]
if S[0]=="D":
    L.append(1)
else:
    L.append(0)
for i in range(1,len(S)):
    if S[i]=="D":
        L.append(L[i-1]+1)
    elif S[i]=="A":
        L.append(L[i-1])
    else:
        L.append(0)
L=L[::-1]
S=S[::-1]
#print(S)
#print(L)
ANS=0
for i in range(len(S)):
    if S[i]=="A":
        ANS+=L[i]
print(ANS)
        

### FIXED CODE ###

s=input()

S=[s[0]]

for i in range(1,len(s)):
    if S[len(S)-1]=="B" and s[i]=="C":
        S[len(S)-1]="D"
    else:
        S.append(s[i])
#print(S)

L=[]
if S[len(S)-1]=="D":
    L.append(1)
else:
    L.append(0)
    
for i in range(1,len(S)):
    if S[len(S)-1-i]=="D":
        L.append(L[len(L)-1]+1)
    elif S[len(S)-1-i]=="A":
        L.append(L[len(L)-1])
    else:
        L.append(0)
L=L[::-1]
#print(L)
ANS=0
for i in range(len(S)):
    if S[i]=="A":
        ANS+=L[i]
print(ANS)
n=int(input())
xu=[list(map(str,input().split())) for _ in range(n)]
ans=0
for i in range(n):
    if xu[i][1]=="JPY":
        ans+=int(xu[i][0])
    else:
        ans+=int(xu[i][0]*380000.0)
print(ans)


### FIXED CODE ###

n=int(input())
xu=[list(map(str,input().split())) for _ in range(n)]
ans=0
for i in range(n):
    if xu[i][1]=="JPY":
        ans+=float(xu[i][0])
    else:
        ans+=float(xu[i][0])*380000.0
print(ans)
# 最短でゴールして残った黒をぜんぶ白に変えれば最大のポイントをもらえそう
# ってなふうに雑に考えてたけど、探索・最短経路復元・解答それぞれで1度ずつBFSをしなきゃならんのか？？？？

h, w = map(int, input().split())
table = [[] for _ in range(h)]
for y in range(h):
    table[y] = list(input())
# ステップ更新用
my_table = [[-1 for _ in range(w)] for _ in range(h)]
my_table[0][0] = 0
yo = [(0, 0)]
steps = [0, -1, 0, 1, 0]
while len(yo) > 0:
    p = yo[0]
    yo = yo[1:]
    for i in range(4):
        next_x, next_y = steps[i + 1] + p[1], steps[i] + p[0]
        if next_x < 0 or w <= next_x or next_y < 0 or h <= next_y:
            continue
        if table[next_y][next_x] == "#":
            continue
        if my_table[next_y][next_x] >= 0:
            continue
        my_table[next_y][next_x] = my_table[p[0]][p[1]] + 1
        yo.append((next_y, next_x))

# 経路を逆からたどって最短経路復元
restore_table = [["o" for _ in range(w)] for _ in range(h)]
restore_table[h - 1][w - 1] = "x"
now = my_table[h - 1][w - 1]
cur = (h - 1, w - 1)
while now != 0:
    for i in range(4):
        next_y, next_x = steps[i] + cur[0], steps[i + 1] + cur[1]
        if next_x < 0 or w <= next_x or next_y < 0 or h < next_y:
            continue
        if my_table[next_y][next_x] == now - 1:
            restore_table[next_y][next_x] = "x"
            cur = (next_y, next_x)
            now -= 1
            break

# やっと答え
ans = 0
for y in range(h):
    for x in range(w):
        if restore_table[y][x] == "o" and table[y][x] == ".":
            ans += 1
print(ans)


### FIXED CODE ###

# #の数を数えておいて、最初の.の数-最短距離
# 最短経路なので幅優先でやる
from collections import deque

h, w = map(int, input().split())
table =[]
default_dot = 0
for _ in range(h):
  line = list(input())
  default_dot+=line.count(".")
  table.append(line)

default_dot-=2  # スタートとゴール
table[0][0] = 0

cur = [0, 0]   # x, y
queue = deque()
queue.append(cur)
steps = [0, 1, 0, -1, 0]

minimum_step = 0

while True:
  if len(queue)==0:
    print(-1)
    exit()
  now = queue.popleft()
  if now[0] == w-1 and now[1] == h-1:
    minimum_step = table[now[1]][now[0]]-1
    break
  for i in range(4):
    next_y, next_x = now[1]+steps[i], now[0]+steps[i+1]
    if 0<=next_y<h and 0<=next_x<w and table[next_y][next_x] == ".":
      table[next_y][next_x] = table[now[1]][now[0]]+1
      queue.append([next_x, next_y])


print(default_dot-minimum_step)
while True:
    a = input()
    if a == "0":
        break
    print(sum([int(b) for b in list(a)])

### FIXED CODE ###

while True:
    number = input()
    if(number == "0"): 
        break
    print(sum([int(a) for a in list(number)]))
s=raw_input()
t=raw_input()
sa=''.join(sorted(s))
tz=''.join(sorted(t,reverse=True))
if sa < tz:
  print 'Yes'
else:
  pritn 'No'

### FIXED CODE ###

s=raw_input()
t=raw_input()
sa=''.join(sorted(s))
tz=''.join(sorted(t,reverse=True))
if sa < tz:
  print 'Yes'
else:
  print 'No'
'''input
7
1 1 1 1 2 3 4
'''
n = input()
arr = map(int,raw_input().split())
for i in range(n):
	arr[i] = (arr[i]-(i+1))
arr.sort()
median = float(arr[n//2]+arr[n//2+1])/n
ans = 10**30
for i in range(int(mean)-30,int(mean)+30):
	q = 0
	for j in range(n):
		q += abs(arr[j]-i)
	ans = min(q,ans)
print ans

### FIXED CODE ###

'''input
7
1 1 1 1 2 3 4
'''
n = input()
arr = map(int,raw_input().split())
for i in range(n):
	arr[i] = (arr[i]-(i+1))
arr.sort()
mean = float(arr[n//2])
ans = 10**30
for i in range(int(mean)-30,int(mean)+30):
	q = 0
	for j in range(n):
		q += abs(arr[j]-i)
	ans = min(q,ans)
print ans
S=input()
print(["Heisei,""TBD"][int(S[5:7]+S[8:10])>430])

### FIXED CODE ###

S=input()
print(["Heisei","TBD"][int(S[5:7]+S[8:10])>430])
N, K = map(int, input().split())
# print(N, K)

def print_simple(N, K, simple_max_edges):
    remain = simple_max_edges - K
    print(4 + remain)
    for i in range(1, N):
        print(i, i + 1)

    for i in range(1, N - 1):
        if remain == 0:
            break
        print(i, i + 2)
        remain -= 1

simple_max_edges = N - 2
if K <= simple_max_edges:
    print_simple(N, K, simple_max_edges)
    exit()

max_edges = (N - 2) * (N - 1) // 2
if max_edges < K:
    print(-1)
    exit()

print(4 + remain)
for i in range(2, N + 1):
    print(1, i)

remain = max_edges - K
for i in range(2, N + 1):
    if remain == 0:
        break
    print(i, i + 1)
    remain -= 1


### FIXED CODE ###

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

max_edges = (N - 2) * (N - 1) // 2
if max_edges < K:
    print(-1)
    exit()

remain = max_edges - K
print(N - 1 + remain)
for i in range(2, N + 1):
    print(1, i)

for i in range(2, N + 1):
    if remain <= 0:
        break
    for j in range(i + 1, N + 1):
        if remain <= 0:
            break
        print(i, j)
        remain -= 1
import math


def lcm(x, y):
    return (x*y) // math.gcd(x, y)


N = int(input())
ans = 0
for i in range(N):
    T = int(input())

    if i == 0:
        ans = T

    else:
        ans = lcm(ans, T)

print(ans)


### FIXED CODE ###

N = input()

print("Yes" if N[0] == N[2] else "No")
a, b = (int(i) for i in input().split())

#if a == "H" and b == "H" or a == "D" and b = "D":
if a ==  b
	return "H"
else:
	return "D"

### FIXED CODE ###

import sys

a, b = (i for i in input().split(" "))

#if a == "H" and b == "H" or a == "D" and b = "D":
if a ==  b:
	print("H")
else:
	print("D")
N,M = 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())

d = [[0]*N for i 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 s in range(M):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][s]+d[s][j])

count = 0
for i in range(M):
    d[i][i] = float("inf")
    if c[i] > d[a[i]-1][b[i]-1]:
            count += 1
print(count)

### FIXED CODE ###

N,M = 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())
    a[i] -= 1
    b[i] -= 1
    

d = [[float("inf")]*N for i in range(N)]

for i in range(M):
    d[a[i]][b[i]] = c[i]
    d[b[i]][a[i]] = c[i]
    
for i in range(N):
    d[i][i] = 0

for s in range(N):
    for j in range(N):
        for i in range(N):
            d[i][j] = min(d[i][j], d[i][s]+d[s][j])

count = 0
for i in range(M):
    if d[a[i]][b[i]] < c[i]:
        count += 1
print(count)
a=int(input())
b=int(input())
c=a*b
print(c)


### FIXED CODE ###

a,b = map(int,input().split())
c = a*b
print(int(c))
import numpy

n = int(input())

num = [0] * n
num = list(map(int, input().split()))

if 0 in num:
    print(0)
else:
    mult = numpy.prod(num)
    if mult > 10**18:
        print(-1)
    else:
        print(mult)

### FIXED CODE ###

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

limit = 10 ** 18
A.sort()
result = A[0]
for a in A[1:]:
    result *= a
    if result > limit:
        print(-1)
        exit()
print(result)
import math
from functools import reduce

n,x = map(int,input().split())
A = list(map(int,input().split()))
for i in range(n):
    A[i] -= x
print(reduce(math.gcd, A))

### FIXED CODE ###

def gcd(A,B):
    while B != 0:
        A,B = B,A%B
    return A
n,x = map(int,input().split())
li = [abs(int(i)-x) for i in input().split()]
ans = li[0]
for i in range(n):
    ans = gcd(ans,li[i])

print(ans)
a, b, c, d = map(int, input().split())
c_flag = 0
d_flag = 0
cd_flag = 0

def gcd_strategy():
    import math
    import fractions
    return math.gcd if hasattr(math, "gcd") else fractions.gcd


gcd = gcd_strategy()


def lcm(x, y):
    return (x * y) // gcd(x, y)


c_multiple_last = b // c
d_multiple_last = b // d
cd_multiple_last = b // lcm(c, d)

for i in range(a, b+1):
    if i % c == 0 and c_flag == 0:
        c_multiple_first = i // c
        c_flag = 1
    if i % d == 0 and d_flag == 0:
        d_multiple_first = i // d
        d_flag = 1
    if i % lcm(c, d) == 0 and cd_flag == 0:
        cd_multiple_first = i // lcm(c, d)
        cd_flag = 1
    if c_flag == 1 and d_flag == 1 and cd_flag == 1:
        break

c_count = c_multiple_last - c_multiple_first + 1
d_count = d_multiple_last - d_multiple_first + 1
cd_count = cd_multiple_last - cd_multiple_first + 1

a_to_b_count = b - a + 1
ans = a_to_b_count - (c_count + d_count - cd_count)
print(ans)

### FIXED CODE ###

import fractions


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


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

c_multiple_last = b // c
d_multiple_last = b // d
cd_multiple_last = b // lcm(c, d)

c_multiple_first = (a-1) // c
d_multiple_first = (a-1) // d
cd_multiple_first = (a-1) // lcm(c, d)

c_count = c_multiple_last - c_multiple_first
d_count = d_multiple_last - d_multiple_first
cd_count = cd_multiple_last - cd_multiple_first

a_to_b_count = b - a + 1
ans = a_to_b_count - (c_count + d_count - cd_count)
print(ans)
N, Q = [int(nq) for nq in input().split(" ")]
S = input()
s = S.replace("AC", "NM")
for i in range(Q):
    li, ri = [int(lr) for lr in input().split(" ")]
    print(li, ri, S[li-1:ri])
    print(s[li-1:ri].count("NM"))


### FIXED CODE ###

N, Q = [int(nq) for nq in input().split(" ")]
S = input()
t = [0] * (N)
for i in range(1, N):
  t[i] = t[i-1] + (1 if (S[i-1] == "A" and S[i] == "C") else 0)
for _ in " " * Q:
  l, r = [int(lr) for lr in input().split(" ")]
  print(t[r-1]-t[l-1])
n = int(input())
a = list(map(int,input().split()));
q = int(input())
aa = 0;
for i in range(n):
    aa += a[i];

b = [input().split() for l in range(q)]

bu = [0]*(100000);

for i in range(100000):
    bu[i] = a.count(i);
    
for x in range(q):
    c = int(b[x][0])
    d = int(b[x][1])
    aa += (d-c)*(bu[c]);
    bu[d] += bu[c];
    bu[c] = 0;
    print(aa);

### FIXED CODE ###


n = int(input())
a = list(map(int,input().split()));
q = int(input())
aa = 0;
for i in range(n):
    aa += a[i];

b = [input().split() for l in range(q)]

bu = [0]*(100000);

for i in range(n):
    bu[a[i]-1] += 1;
    
for x in range(q):
    c = int(b[x][0])
    d = int(b[x][1])
    aa += (d-c)*(bu[c-1]);
    bu[d-1] += bu[c-1];
    bu[c-1] = 0;
    print(aa);
a = input()
print(a + a*a + a*a*a)

### FIXED CODE ###

a = int(input())
print(a+a*a+a*a*a)
a,b,k=(long(i)for i in input().split())
while 0<k:
    if 0<a:a=a-1
    elif 0<b:b=b-1
    k=k-1
print(a,b)


### FIXED CODE ###

s=input().split()
print(s[1]+s[0])
n = int(input())

if n == 1:
    print(1/a)
elif n % 2 == 0:
    print(1/2)
else:
    print(((n+1)/2)/n)

### FIXED CODE ###

a = int(input())

if a == 1:
    print(1/a)
elif a % 2 == 0:
    print(1/2)
else:
    print(((a+1)/2)/a)
L = ['SAT','FRI','THU','WED','TUE','MON','SUN']

for i,l in enumerate(L):
  if S == l:
    print(i+1)
    break

### FIXED CODE ###

S = input()
L = ['SAT','FRI','THU','WED','TUE','MON','SUN']
for i,l in enumerate(L):
  if S == l:
    print(i+1)
    break
import sys
import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
import math
start=time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n=ri()
a=rl()
t=0
for i in a:
    t^=i
t=bin(t)[2:]
max_len=max(len(bin(max(a)))-2,len(t))

if len(t)<max_len:t="0"+t
try:
    a=list(map(lambda x : bin(x)[2:],a))
except:
    sys.exit()
    
    

for i in range(n):
    if len(a[i])<max_len:
        a[i]="0"+a[i]
#print(a)
ans=[[] for i in range(n)]
for i in range(max_len):
    for j in range(n):
        if a[j][i]==t[i]:
            ans[j].append("0")
        else:
            ans[j].append("1")
#print(ans)
for i in ans:
    print(int("".join(i), 2))


### FIXED CODE ###

import sys
import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
import math
start=time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n=ri()
a=rl()
t=0
for i in a:
    t^=i
t=bin(t)[2:]
max_len=max(len(bin(max(a)))-2,len(t))

if len(t)<max_len:t="0"*(max_len-len(t))+t
try:
    a=list(map(lambda x : bin(x)[2:],a))
except:
    sys.exit()
    
try:
    for i in range(n):
        if len(a[i])<max_len:
            a[i]="0"*(max_len-len(a[i]))+a[i]
except:
    sys.exit()


ans=[[] for i in range(n)]
for i in range(max_len):
    for j in range(n):  
            if a[j][i]==t[i]:
                ans[j].append("0")
            else:
                ans[j].append("1")

for i in ans:
    print(int("".join(i), 2))
N = int(input('N:'))
R = int(input('R:'))
while int(N) == N and int(R) == R:
    if 1 <= N <= 100 and 0 <= R <= 4111:
        if N > 10:
            print(R)
        else:
            K = 100 * (10 - N)
            print(R + K)
    break

### FIXED CODE ###

NR= input().split()
N= int (NR[0])
R= int (NR[1])
if (N >= 10):
    print(R)
else:
    print (R+100*(10-N))