Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

from collections import Counter
s = input()
t_list = list()
for i in range(1, len(s) + 1):
    t_list.append(int(s[-i:]) % 2019)
t_list.append(0)
counter = Counter(t_list)
print(sum([m * (m - 1) // 2 for m in counter.values()]))

### FIXED CODE ###

s = input()[::-1]
mod_cnt = [0] * 2019
mod_cnt[0] = 1
t = 0
d = 1
for c in s:
    t += int(c) * d
    t %= 2019
    mod_cnt[t] += 1
    d *= 10
    d %= 2019
print(sum([m * (m - 1) // 2 for m in mod_cnt]))
### BUGGY CODE ###

n, m = map(int, input().split())
l, r = map(int, input().split())
c = set(range(l, r+1))
for _ in range(m-1):
    l, r = map(int, input().split())
    c = c & set(range(l, r+1))
print(len(c))


### FIXED CODE ###

n, m = map(int, input().split())
tl, tr = 1, n
for _ in range(m):
    l, r = map(int, input().split())
    if tr<l or tl>r:
        tl, tr = 1, 0; break
    else:
        tl = l if tl<l else tl
        tr = r if tr>r else tr
print(tr-tl+1)
### BUGGY CODE ###

K,S=map(int,input().split())
a=[];ans=0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):a.append((i,j,k))
for i in a: ans+=1 if sum(i)==S else 0
print(ans)

### FIXED CODE ###

K,S=map(int,input().split())
ans=0
for i in range(K+1):
    for j in range(K+1):
        if S-i-j<=K and 0<=S-i-j:ans+=1
print(ans)
### BUGGY CODE ###

#import 
#=input()
#int(input())
n,k=map(int,input().split())
a=list(map(int,input().split()))
#=[list(map(int,input().split())) for _ in range()]

for i in range(k,n):
    q = 1
    w = 1
    for j in range(k):
        q *= a[i-k+j]
        w *= a[i-j]
    if q < w:
        print('Yes')
    else:
        print('No')


### FIXED CODE ###

#import 
#=input()
#int(input())
n,k=map(int,input().split())
a=list(map(int,input().split()))
#=[list(map(int,input().split())) for _ in range()]

for i in range(k,n):
    if a[i-k] < a[i]:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

import math,bisect
n,d,a = map(int,input().split())
lst1 = [list(map(int,input().split())) for i in range(n)]
lst1.sort()

#解法3 - セグ木
"""
ダメージ量をセグ木の区間で管理する。
なお、72行目までセグ木のコードなのでそれ以降を読めば良い。

この解法では、
自分の座標より右側の巻き込める量を調べる
ではなく、
自分より右側なんてしったこっちゃ無いので自分より左側のダメージが足りてるかどうかを
逐一確認し、足りないなら自分の座標に必要なだけのダメージを記録する
という考え方をする。
故に、変数kは左側であるx - 2*dを参照する。

恐らくlst1を[[1,2]...]ではなく[1000000002,...]という感じで持てば間に合うが、
簡単の為そっちは実装しない。
"""
#####segfunc######
def segfunc(x,y):
    return x+y

def init(init_val): #渡されたリストでsegを初期化
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]    
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x): #segの要素kをxに変更(セグ木全体の更新)
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q): #区間[p,q)での、segfuncに準じた値を返す
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#####単位元######
"""
最小値のセグ木 → 10**9　(最小値の更新に影響しないため)
　　和のセグ木 → 0
　　積のセグ木 → 1
　　gcdのセグ木 → 0　(gcdを更新しない値は0)
"""
ide_ele = 0

#num:n以上の最小の2のべき乗
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num


#process
x = []
for i in lst1:
    x.append(i[0])


ans = 0

for i in range(n):
    k = bisect.bisect_left(x,lst1[i][0]-2*d) #手前側にあるダメージ量を確認

    r = query(k,i) #kからiまでの合計ダメージを取得

    if lst1[i][1] > r:
        need = math.ceil((lst1[i][1]-r)/a)
        ans += need
        update(i,need*a)

print(ans)

### FIXED CODE ###

import math,bisect
n,d,a = map(int,input().split())
lst1 = [list(map(int,input().split())) for i in range(n)]
lst1.sort()

#解法2 - imos法
"""
単純に座標に対してimos法を行うと、座標の制約は10**9なので間に合わない。
process1
そこで、各モンスターに対して、そのモンスターを左端で攻撃を行った際、右側の巻き込めるモンスターのインデックスを
保存するリストを作る。
process2
これにより、imosのテーブルはn+1個で答えを求めることができる。
また、imosの累積和は順次求めていく感じになる。
"""
x = []
for i in lst1:
    x.append(i[0])

#process1
index = 0
reach = []
for i in range(n):
    index = bisect.bisect_right(x,lst1[i][0]+2*d)
    reach.append(index)

#process2
ans = 0
imos = [0]*(n+1) #その座標に効いている魔法の回数(ダメージ量ではない)

for i in range(n):
    if imos[i]*a < lst1[i][1]: #ダメージが足りないなら
        need = math.ceil((lst1[i][1]-imos[i]*a)/a)
        imos[i] += need
        imos[reach[i]] -= need #届かなくなったとこでマイナス
        ans += need
    imos[i+1] += imos[i] #累積和を逐一とる

print(ans)
### BUGGY CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]

set_a = set(a)

cnt = 0
for i in list(set(a)):
    if a.count(i)%2 == 1:
        cnt += 1

print(cnt)

### FIXED CODE ###

from collections import Counter
n = int(input())
a = [int(input()) for _ in range(n)]

cnt = Counter(a).values()


flg = 0
for i in cnt:
    if i%2 == 1:
        flg += 1

print(flg)
### BUGGY CODE ###

K = int(input())
c = 1
nana = 7
if K%2 == 0:
  print("-1")
else:
  while True:
    if nana%K == 0:
      print(c)
      break
    else:
      nana = nana*10 + 7
      c += 1

### FIXED CODE ###

K = int(input())
c = 1
nana = 7
if K%2 == 0:
    print("-1")
else:
    n = 7%K
    while True:
        i = nana%K
        if i == 0:
            print(c)
            break
        elif c >= 10**6:
            print("-1")
            break
        else:
            nana = (10*i+n)%K
            c += 1
### BUGGY CODE ###

import numpy as np
from itertools import combinations

def gcd_memo(memo, a, b):
    if memo[a][b] > 0:
        return memo[a][b]
    res = np.gcd(a, b)
    memo[a][b] = res
    memo[b][a] = res
    return res

def main():
    k = int(input())
    res = 0
    memo = np.zeros((k+1, k+1), int)
    for i in range(1, k+1):
        memo[i][i] = i 
        res += i

    for c in combinations(range(1,k+1),2):
        ab = gcd_memo(memo, c[0], c[1])
        res += ab * 6

    for c in combinations(range(1,k+1), 3):
        ab = gcd_memo(memo, c[0], c[1])
        abc = gcd_memo(memo, ab, c[2])
        res += abc * 6
    print(res)


if __name__ == '__main__':
    main()



### FIXED CODE ###

import numpy as np
from itertools import combinations

def main():
    k = int(input())
    res = 0
    memo = np.zeros((k+1, k+1), int)
    for i in range(1, k+1):
        for j in range(i, k+1):
            tmp = np.gcd(i,j)
            memo[i][j] = tmp
            memo[j][i] = tmp

    for i in range(1, k+1):
        res += i 

    for c in combinations(range(1,k+1),2):
        ab = memo[c[0], c[1]]
        res += ab * 6

    for c in combinations(range(1,k+1), 3):
        ab = memo[c[0], c[1]]
        abc = memo[ab, c[2]]
        res += abc * 6
    print(res)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

n, ma, mb = map(int, input().split())
abc = [tuple(int(x) for x in input().split()) for _ in range(n)]

c = n * 100 + 1

dp = [[[] for _ in range(c)] for _ in range(n + 1)]

dp[0][0].append([0,0])

ans = 999999

for i in range(n):
    for j in range(c):
        for a, b in dp[i][j]:
            dp[i+1][j].append([a, b])
            if (abc[i][0] + a) * mb == (abc[i][1] + b) * ma:
                ans = min(ans, abc[i][2] + j)
            dp[i+1][j + abc[i][2]].append([abc[i][0] + a, abc[i][1] + b])

if ans == 999999:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

n, ma, mb = map(int, input().split())
abc = [tuple(int(x) for x in input().split()) for _ in range(n)]

c = n * 100 + 1

m = 401

dp = [[[99999 for _ in range(m)] for _ in range(m)] for _ in range(n + 1)]

ans = 99999
dp[0][0][0] = 0
for i in range(n):
    for j in range(m):
        for k in range(m):
            if dp[i][j][k] < 9999:
                dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k])
                dp[i+1][j+abc[i][0]][k+abc[i][1]] = min(dp[i+1][j+abc[i][0]][k+abc[i][1]], dp[i][j][k] + abc[i][2])
                if (j+abc[i][0]) * mb == (k+abc[i][1]) * ma:
                    ans = min(ans, dp[i+1][j+abc[i][0]][k+abc[i][1]])

if ans == 99999:
    print(-1)
else:
    print(ans)
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import deque

n,m = map(int,readline().split())
s = [set() for i in range(n)]
c = [set() for i in range(n)]
for i in range(m+n-1):
  a,b = map(int,readline().split())
  a -= 1
  b -= 1
  s[a].add(b)
  c[a].add(b)
  
class segment_():
    def __init__(self,n,ide_ele,segfunc):
        self.ide_ele = ide_ele
        self.num = 1 << n.bit_length()
        self.seg = [self.ide_ele] * 2 * self.num
        self.segfunc = segfunc
                
    def update(self, k, r):
        k += self.num
        self.seg[k] = r
        while k:
            k >>= 1
            self.seg[k] = self.segfunc(self.seg[k*2], self.seg[k*2+1])

S = segment_(n,set(),lambda a, b: a|b)
for i,ci in enumerate(c):
  S.update(i,ci)
  
p = set([int(i) for i in range(n)])
ans = [0]*n
root = deque()
root.append(-1)
cnt = 0

while root:
  if cnt == n:
    break
  now = root.popleft()
  if now >= 0:
    S.update(now,set())
  child = p-S.seg[1]
  for nex in child:
    cnt += 1
    ans[nex] = now+1
    root.append(nex)
    p.remove(nex)
print(*ans,sep='\n')

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import deque,defaultdict

n,m = map(int,readline().split())
c = [set() for i in range(n)]
d = defaultdict(int)
for i in range(m+n-1):
  a,b = map(int,readline().split())
  a -= 1
  b -= 1
  c[a].add(b)
  d[b] += 1
  
ans = [0]*n
root = deque()
for i in range(n):
  if d[i] == 0:
    root.append(i)
    break
cnt = 1

while True:
  now = root.popleft()
  for nex in c[now]:
    d[nex] -= 1
    if d[nex] == 0:
      cnt += 1
      ans[nex] = now+1
      root.append(nex)
  if cnt == n:
    break
print(*ans,sep='\n')
### BUGGY CODE ###

x,y,z,k = map(int,input().split())
li = [list(map(int,input().split())) for _ in range(3)]
li2 = []
li3 = []

for i in range(x):
    for j in range(y):
        li2.append(li[0][i]+li[1][j])
li2.sort(reverse = True)
li2[:min(k,len(li2))]

for i in range(z):
    for j in range(min(k,len(li2))):
        li3.append(li[2][i]+li2[j])
li3.sort(reverse = True)

for i in range(k):
    print(li3[i])


### FIXED CODE ###

def main():
    x,y,z,k = map(int,input().split())
    lia = sorted(list(map(int,input().split())))
    lib = sorted(list(map(int,input().split())))
    lic = sorted(list(map(int,input().split())))

    li2 = sorted(list(a+b for a in lia for b in lib),reverse = True)[:k]
    li3 = sorted(list(ab + c for ab in li2 for c in lic),reverse = True)[:k]

    print('\n'.join(map(str,li3)))

main()
### BUGGY CODE ###

N = int(input())
list = []

for i in range(N):
    tmp = int(input())
    list.append(tmp)

maxDiff = - 10 ** 9
for i in range(N):
    for j in range(i+1, N):
        tmpDiff = list[j] - list[i]
        if tmpDiff > maxDiff:
            maxDiff = tmpDiff
print(maxDiff)


### FIXED CODE ###

N = int(input())
list = []

for i in range(N):
    tmp = int(input())
    list.append(tmp)

maxDiff = - 10 ** 9
tmpMin = list[0]
for i in range(N-1):
    maxDiff = max([maxDiff, list[i+1] - tmpMin])
    tmpMin = min([tmpMin, list[i+1]])
print(maxDiff)
### BUGGY CODE ###

S=list(input())

while True:
  flag=True
  for i in range(len(S)-1):
    if S[i]=='S' and S[i+1]=='T':
      S.pop(i)
      S.pop(i)
      flag=False
      break
  if flag:
    break
print(len(S))

### FIXED CODE ###

S=input()

ans=len(S)
n=0
for s in S:
  if s=='S':
    n+=1
  elif s=='T' and n>0:
    n-=1
    ans-=2
print(ans)
### BUGGY CODE ###

N = int(input())
arr = []


for i in range(N):
  S = input()
  if S in arr:
    a = 0
  else:
    arr.append(S)
    
print(int(len(arr)))

### FIXED CODE ###

N = int(input())
arr = []

for i in range(N):
  S = input()
  arr.append(S)
    
arr.sort()
cnt = 1
for i in range(N-1):
  a = arr[i]
  b = arr[i+1]
  if a != b:
    cnt += 1

print(int(cnt))
### BUGGY CODE ###

import sys
from heapq import heapify, heappushpop
from operator import itemgetter

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	N, M = MAP()
	A = MAP()
	BC = [MAP() for _ in range(M)]
	
	BC.sort(key= itemgetter(1), reverse=True)
	
	heapify(A)
	
	fin = False
	for b, c in BC:
		#print(A, b, c)
		for _ in range(b):
			a = A[0]
			if a>c:
				fin = True
				break
			else:
				heappushpop(A, c)
		if fin:
			break
	
	print(sum(A))

if __name__ == '__main__':
	main()

### FIXED CODE ###

import sys
from heapq import heapify, heappop
from operator import itemgetter

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	N, M = MAP()
	A = MAP()
	BC = [MAP() for _ in range(M)]
	
	BC.sort(key= itemgetter(1), reverse=True)
	
	heapify(A)
	
	ans = 0
	
	fin = False
	for b, c in BC:
		#print(A, b, c)
		for _ in range(b):
			a = A[0]
			if a>c:
				fin = True
				break
			else:
				heappop(A)
				ans += c
				N -= 1
				if N == 0:
					fin = True
					break
		if fin:
			break
	
	print(ans+sum(A))

if __name__ == '__main__':
	main()
### BUGGY CODE ###

from math import *
N = int(input())
A = sorted(list(map(int,input().split())))
B = A[-1]
C = 0

for a in A:
  if C<comb(B,a):
    C = comb(B,a)
    ans = [A[-1],a]

print(*ans)

### FIXED CODE ###

N = int(input())
A = sorted(list(map(int,input().split())))
B = A[-1]
print(B,min(A,key=lambda x: abs(B-2*x)))
### BUGGY CODE ###

input_line = input()
abk = input_line.split(" ") 
ABK = [int(n) for n in abk]

while ABK[0] > 0 and ABK[2] >= 1:
    ABK[0] -= 1
    ABK[2] -= 1
else:
    pass
while ABK[1] > 0 and ABK[2] >= 1:
    ABK[1] -= 1
    ABK[2] -= 1
else:
    pass

print(ABK[0]," ",ABK[1])
    

### FIXED CODE ###


input_line = input()
abk = input_line.split(" ") 
ABK = [int(n) for n in abk]



if ABK[0] + ABK[1] <= ABK[2]:
    A = 0
    B = 0

elif ABK[0] <= ABK[2] and ABK[1] > ABK[2] - ABK[0]:
    A = 0
    B = ABK[1] -  (ABK[2] - ABK[0])

elif ABK[0] > ABK[2]:
    A = ABK[0] - ABK[2]
    B = ABK[1]

    
print(A," ",B)
### BUGGY CODE ###

import numpy as np
n = int(input())
s = np.array(list(input()))
RGB_select = {
    'RG': 'B', 'GR': 'B',
    'GB': 'R', 'BG': 'R',
    'RB': 'G', 'BR': 'G'}
RGB = {
    'R':np.cumsum(s == 'R'),
    'G':np.cumsum(s == 'G'),
    'B':np.cumsum(s == 'B')
}
ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        if s[i] == s[j]:
                continue
        color = RGB_select[s[i]+s[j]]
        ans += RGB[color][-1] - RGB[color][j]
        if j + (j - i) < n:
            ans -= s[j + (j-i)] == color
print(ans)

### FIXED CODE ###

n = int(input())
s = input()
ans = s.count('R') * s.count('G') * s.count('B')
for i in range(n-2):
    for j in range(i+1, n-1):
        k = j + (j - i)
        if k < n:
            if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                ans -= 1
print(ans)
### BUGGY CODE ###

n, k = map(int, input().split())
next = list(map(int, input().split()))
next = list(map(lambda x: x - 1, next))
c = list(map(int, input().split()))

ans = -(10 ** 17)

for i in range(n):
    now = i
    cycle_sum = 0
    cycle_len = 0

    while True:
        cycle_sum += c[now]
        cycle_len += 1
        now = next[now]
        if now == i:
            break

    sum = 0
    cnt = 0

    while cnt < k:
        sum += c[now]
        cnt += 1
        laps = (k - cnt) // cycle_len
        score = sum + max(0, cycle_sum) * laps
        ans = max(ans, score)

        now = next[now]
        if now == i:
            break

print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
next = list(map(int, input().split()))
next = list(map(lambda x: x - 1, next))
c = list(map(int, input().split()))

ans = -(10 ** 17)

for i in range(n):
    now = i
    cycle_sum = 0
    cycle_len = 0

    while True:
        cycle_sum += c[now]
        cycle_len += 1
        now = next[now]
        if now == i:
            break

    sum = 0
    cnt = 0

    while True:
        sum += c[now]
        cnt += 1

        if cnt > k:
            break

        laps = (k - cnt) // cycle_len
        score = sum + max(0, cycle_sum) * laps
        ans = max(ans, score)

        now = next[now]
        if now == i:
            break

print(ans)
### BUGGY CODE ###

import itertools

N=int(input())
A=[0]*N
for i in range(N):
    A[i]=int(input())

m=0
for i in range(N):
    n=N-i
    L=list(itertools.combinations(A,n))
    L=sorted(L)
    for j in range(len(L)):
        #print(L[-1-j])
        c=sum(L[-1-j])
        if(c%10!=0):
            m=max(c,m)
            break

print(m)

### FIXED CODE ###

import itertools

N=int(input())
A=[0]*N
for i in range(N):
    A[i]=int(input())

m=sum(A)

if(m%10==0):
    A=sorted(A)
    for a in A:
        if a%10!=0:
            print(m-a)
            exit()
    print(0)
else:
    print(m)
### BUGGY CODE ###

import heapq 
N=int(input())
A=list(map(int, input().split()))
A_rev = [-x for x in A[::-1]]#逆順にして各要素を-1倍する
ans=-float("inf")
for k in range(N, 2*N+1):
	left=A[:k]
	right=A_rev[:(3*N-k)]

	heapq.heapify(left)
	heapq.heapify(right)

	for _ in range(k-N):
		heapq.heappop(left)
	for _ in range(2*N-k):
		heapq.heappop(right)

	ans= max(sum(left)+sum(right), ans)
print(ans)

### FIXED CODE ###

#########################ABC解説実装#########################
import heapq
N=int(input())
A=list(map(int, input().split()))

left, right = A[:N], [-1 * i for i in A[2*N:]]
sum_left, sum_right = sum(left), sum(right)

results = [0] * (N+1)
results[0] = sum_left
results[N] = sum_right

heapq.heapify(left)
heapq.heapify(right)

for i in range(N, 2*N):
    v = A[i]
    p = heapq.heappushpop(left, v)
    sum_left += v - p
    results[i-N+1] += sum_left
    
for i in range(2*N-1, N-1, -1):
    v = -1 * A[i]
    p = heapq.heappushpop(right, v)
    sum_right += v - p
    results[i-N] += sum_right
print(max(results))
### BUGGY CODE ###

nk = input().split()
seisuuretu = input().split()

for i in range(len(seisuuretu)):
    seisuuretu[i] = int(seisuuretu[i])

list_max = []
beautiful_list = []
for start in range(len(seisuuretu) + 1):
    for end in range(len(seisuuretu) + 1):
        if start < end:
            temp_pattern = bin(sum(seisuuretu[start:end]))[2:]
            beautiful_list.append(temp_pattern)
            list_max.append(len(temp_pattern))

list_max = -max(list_max)

status = True
while status == True:
    temp = []
    count = 0
    len_all = 0
    for i in beautiful_list:
        try:
            if int(i[list_max]) == 1:
                count += 1
                temp.append(i)
        except:
            continue
    if count > int(nk[1]):
        list_max += 1
        beautiful_list = temp
    elif count == int(nk[1]):
        beautiful_list = temp
        num_count = True
        for num in beautiful_list:
            if num_count == True:
                ronriseki = int(num, 2)
            else:
                ronriseki = ronriseki & int(num, 2)
            num_count = False
        print(ronriseki)
        status = False
    elif list_max == -1:
        num_count = True
        for num in beautiful_list:
            if num_count == True:
                ronriseki = int(num, 2)
            else:
                ronriseki = ronriseki & int(num, 2)
            num_count = False
        print(ronriseki)
        status = False
    else:
        list_max += 1


### FIXED CODE ###

nk = input().split()
seisuuretu_2 = input().split()
nk1 = int(nk[1])

#seisuuretu = [int(i) for i in seisuuretu_2]
seisuuretu = list(map(int, seisuuretu_2))

list_max = set()
beautiful_list = []
for start in range(len(seisuuretu) + 1):
    for end in range(len(seisuuretu) + 1):
        if start < end:
            temp_pattern = bin(sum(seisuuretu[start:end]))[2:]
            beautiful_list.append(temp_pattern)
            list_max |= {len(temp_pattern),}

list_max = -max(list_max)

status = True
while status == True:
    temp = []
    count = 0
    for i in beautiful_list:
        try:
            if i[list_max] == "1":
                count += 1
                temp.append(i)
        except:
            continue
    if count > nk1:
        list_max += 1
        beautiful_list = temp
    elif count == nk1:
        num_count = True
        for num in temp:
            if num_count == True:
                ronriseki = int(num, 2)
            else:
                ronriseki = ronriseki & int(num, 2)
            num_count = False
        print(ronriseki)
        exit()
        status = False
    elif list_max == -1:
        num_count = True
        for num in beautiful_list:
            if num_count == True:
                ronriseki = int(num, 2)
            else:
                ronriseki = ronriseki & int(num, 2)
            num_count = False
        print(ronriseki)
        exit()
        status = False
    else:
        list_max += 1
### BUGGY CODE ###

def main():
    num = int(input())
    for i in range(num):
        X = " " + input()
        Y = " " + input()
        lx = len(X)
        ly = len(Y)
        T = [0] * ly
        for j in range(1,lx):
            C = T[:]
            for k in range(1,ly):
                k1 = k-1
                if X[j] == Y[k]:
                    T[k] = C[k1] + 1
                elif C[k] > T[k1]:
                    T[k] = C[k]
                else:
                    T[k] = T[k1]
        print(T[k])

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    num = int(input())
    A = []
    for i in range(num):
        X = input()
        Y = " " + input()
        lx = len(X)
        ly = len(Y)
        T = [0] * ly
        for j in range(lx):
            xj = X[j]
            C = T[:]
            for k in range(1,ly):
                k1 = k-1
                if xj == Y[k]:
                    T[k] = C[k1] + 1
                elif T[k] < T[k1]:
                    T[k] = T[k1]
        print(T[k])
if __name__ == '__main__':
    main()
### BUGGY CODE ###

import numpy as np
A = int(input())
a = [100,101,102,103,104,105]

N = A//100
dp = np.array([np.array([0 for i in range(A+1)]) for j in range(N+1)])
dp[0][0] = 1

for i in range(N):
    for j in range(A+1):
        if dp[i][j] == 1:
            dp[i+1][j+100:j+106] = 1

print(dp[N][A])

### FIXED CODE ###

import numpy as np
A = int(input())

if A >= 3000:
    print(1)
else:
    a = [100,101,102,103,104,105]
    N = A//100
    dp = np.array([np.array([0 for i in range(A+1)]) for j in range(N+1)])
    dp[0][0] = 1

    for i in range(N):
        for j in np.where(dp[i] == 1)[0]:
        #for j in range(A+1):
           # if dp[i][j] == 1:
            dp[i+1][j+100:j+106] = 1
    print(dp[N][A])
### BUGGY CODE ###

import copy
n = int(input())
x = list(map(int,input().split()))
m,k = map(int,input().split())
a = list(map(int,input().split()))
b = copy.deepcopy(x)
kako = [x]
while True:
  for i in range(m):
    to = a[i]-1
    if to == 0:
      b[0] = b[1]*2-b[0]
    elif to == n-1:
      b[n-1] = b[n-2]*2 - b[n-1]
    else:
      b[to] = (b[to+1]*2-b[to]+b[to-1]*2-b[to])/2
  if b ==x:
    break
  kako.append(copy.deepcopy(b))
k %= len(kako)
for i in kako[k]:
  print(i)

### FIXED CODE ###

n = int(input())
x = list(map(int,input().split()))
m,k = map(int,input().split())
a = list(map(int,input().split()))
b = []
x2 = []
c = []
for i in range(1,n):
  b.append(i-1)
  x2.append(x[i]-x[i-1])
for i in range(m):
  to = a[i]-1
  b[to],b[to-1] = b[to-1],b[to]
c = [-1] * (n-1)
for i in range(n-1):
  c[b[i]] = i
for i in range(60):
  x3 = [0]*(n-1)
  if k&(1<<i):
    for i in range(n-1):
      x3[c[i]] = x2[i]
    x2 = x3
  c2 = [-1] * (n-1)
  for i in range(n-1):
    c2[i] = c[c[i]] 
  c = c2
s = x[0]
print(s)
for i in x2:
  s += i
  print(s)