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

import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

# field[H][W]
def create_grid(H, W, value = 0):
    return [[ value for _ in range(W)] for _ in range(H)]

########

S = input()
N = len(S)

# dp[i][k]: i桁目までのkで割った余りの数
dp = create_grid(N+1, 13)

dp[0][0] = 1 # 0桁目

for i in range(N):
    c = S[N-i-1]
    if c == "?":
        v = range(10)
    else:
        v = [int(c)]
    for vi in v:
        for j in range(13):
            amari = (vi*(10**i) + j) % 13
            dp[i+1][amari] = (dp[i][j] + dp[i+1][amari]) % MOD

print(dp[N][5])



### FIXED CODE ###

import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

# field[H][W]
def create_grid(H, W, value = 0):
    return [[ value for _ in range(W)] for _ in range(H)]

########

S = input()
N = len(S)

# dp[i][k]: i桁目までのkで割った余りの数
dp = create_grid(N+1, 13)

dp[0][0] = 1 # 0桁目

s = [1]
for i in range(N):
  s.append((s[-1]*10)%13)

for i in range(N):
    c = S[N-i-1]
    if c == "?":
        v = range(10)
    else:
        v = [int(c)]
    for vi in v:
        for j in range(13):
            amari = (vi*s[i] + j) % 13
            dp[i+1][amari] = (dp[i][j] + dp[i+1][amari]) % MOD

print(dp[N][5])
### BUGGY CODE ###

N=int(input())
A=input().split()

j=1
result=[]
while j<=N:
    for i in range(len(A)):
        if int(A[i])==j:
            result.append(i+1)
            j+=1

print(*result)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
result = [0]*N
for i in range(N):
    result[A[i]-1] = i+1
print(*result)
### BUGGY CODE ###

H, W = map(int, input().split()) # 横に2個
state = [[0 if a == '.' else 1 for a in list(input())] for _ in range(H)]

checked = [[False for _ in range(W)] for _ in range(H)]
qs = []
for h in range(H):
    for w in range(W):
        if state[h][w] == 1:
            qs.append([h, w])
            checked[h][w] = True

c = -1
while qs:
    qqs = []
    for h,w in qs:
        checked[h][w] = True
        next = [[h+1, w], [h-1, w], [h, w+1], [h, w-1]]
        for hn, wn in next:
            if 0<=hn<=H-1 and 0<=wn<=W-1:
                if not checked[hn][wn]:
                    qqs.append([hn, wn])
    c += 1
    qs = qqs

print(c)





### FIXED CODE ###

import sys
input = sys.stdin.readline

B = int(1E8)

def main():

    H, W = map(int, input().split())
    
    l = 0
    q = []
    checked = []
    for h in range(H):
        S = input()
        L = []
        for w in range(W):
            if S[w] == '#':
                l += 1
                L.append(True)
                q.append(B*h+w)
            else:
                L.append(False)
        checked.append(L)

    Next = [[[] for _ in range(W)] for _ in range(H)]
    for h in range(H):
        for w in range(W):
            if h != 0:
                Next[h][w].append(B*(h-1) + w)
            if h != H-1:
                Next[h][w].append(B*(h+1) + w)
            if w != 0:
                Next[h][w].append(B*h + w-1)
            if w != W-1:
                Next[h][w].append(B*h + w+1)

    c = -1
    for _ in range(H+W+2):
        qq = []
        if len(q) == 0:
            break
        for hw in q:
            h, w = hw//B, hw%B
            for nhw in Next[h][w]:
                nh, nw = nhw//B, nhw%B
                if not checked[nh][nw]:
                    qq.append(B*nh + nw)
                    checked[nh][nw] = True
        q = qq
        c += 1

    print(c)


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

n,m = map(int,input().split())
a = []
for _ in range(m):
    b = int(input())
    a.append(b)
inf = 1000000007

dp = [0] * (n+1)
dp[0] = 1

if 1 not in a:
    dp[1] = 1
else:
    dp[1] = 0

for i in range(2,n+1):
    if i in a:
        continue
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= inf

print(dp[n])

### FIXED CODE ###

n,m = map(int,input().split())
a = set([int(input()) for i in range(m)])
inf = 1000000007

dp = [0] * (n+1)
dp[0] = 1

if 1 not in a:
    dp[1] = 1
else:
    dp[1] = 0

for i in range(2,n+1):
    if i in a:
        continue
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= inf

print(dp[n])
### BUGGY CODE ###

def main():
    n=int(input())
    if n==1:
        print("Yes")
        print(2)
        print(1,1)
        print(1,1)
        exit()
    a=1
    while True:
        t=a*(a-1)//2
        if t>n:
            print("No")
            exit()
        if t==n:
            print("Yes")
            break
        a+=1
    print(a)
    s=set(range(1,1+n))
    l=[0]*(n+1)
    ans=[set()]

    for i in range(a):
        ll=set()
        for j in ans[:i+1]:
            for p in s&j:
                if p not in ll:
                    ll.add(p)
                    if l[p]==1:
                        s.remove(p)
                    else:
                        l[p]+=1
                    break

        for p in s:
            if len(ll)>=n*2//a:
                break
            else:
                if l[p]==0:
                    ll.add(p)
                    l[p]+=1

        ans.append(ll)
    for i in ans[1:]:
        print(n*2//a,*i)


if __name__ == '__main__':
    main()








### FIXED CODE ###

def main():
    n=int(input())
    m=int((2*n)**0.5)
    if m*(m+1)==n*2:
        print("Yes")
        m+=1
        print(m)
    else:
        print("No")
        exit()
    
    ans=[[m-1] for i in range(m)]
    c=1
    for i in range(m):
        for j in range(i+1,m):
            ans[i].append(c)
            ans[j].append(c)
            c+=1
    for i in ans:
        print(*i)


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

n = int(input())
t = 10**9+7
z = list(map(int,input().split() ))
_sum = 0
y = len(z)
for i in range(y-1):
    _sum += (z[i]*sum(z[i+1:y]))
        #print("_sum:"+str(_sum))
print(_sum%t)
    

### FIXED CODE ###

n = int(input())
t = 10**9+7
z = list(map(int,input().split() ))
_sum = 0
x = sum(z)
y = len(z)
for i in range(y-1):
    x = x-z[i]
    _sum += (z[i]*x)
        #print("_sum:"+str(_sum))
print(_sum%t)
### BUGGY CODE ###

import numpy as np
n, k = map(int, input().split())
s = input()
s = s.replace('LR', 'L,R')
s = s.replace('RL', 'R,L')
s = s.split(',')
s = list(map(len, s))
l = 2*k+1
ans = -1

s_ = list(np.array(s) - 1)
if l >= len(s):
    ans = sum(s)-1
else:
    
    for i in range(len(s)-l+1):
        cnt = 0
        cnt += sum(s_[:i])
        cnt += sum(s[i:l+i])-1
        cnt += sum(s_[l+i:])
        ans = max(ans, cnt)   
print(ans)

### FIXED CODE ###

n, k = map(int,input().split())
s = input()
ans=0
for i in range(n-1):
    if s[i] == s[i+1]:
        ans += 1

ans += k*2
if ans > n-1:
    ans = n-1
    
print(ans)
### BUGGY CODE ###

N=int(input())
for n in range(1,N+1):
    s=0
    for x in range(1,41):  
        for y in range(x,41):
            for z in range(y,41):
                fn=x*x+y*y+z*z+x*y+y*z+z*x
                if fn==n:
                    if x==y:
                        if x==z:
                            s=s+1
                        else:
                            s=s+3
                    else:
                        if y==z:
                            s=s+3
                        else:
                            s=s+6    
    print(s)  

### FIXED CODE ###

N=int(input())
ans=[0]*(N+1)
for x in range(1,101):  
    for y in range(1,101):
        for z in range(1,101):
            fn=x**2+y**2+z**2+x*y+y*z+z*x
            if fn>N:
                break
            else:
                ans[fn]=ans[fn]+1
for n in range(1,N+1):
    print(ans[n])
### BUGGY CODE ###

import numpy as np
import sys
def input():
    return sys.stdin.readline()[:-1]
# input
N, K, Q = map(int, input().split())
As = [int(input()) for i in range(Q)]

points = np.array([K for i in range(N)])

for a in As:
    # points = [0 if point == 0 for point in points else point - 1]
    points -= 1
    points[a - 1] += 1

survive = ['Yes' if point >= 1 else 'No' for point in points]

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

### FIXED CODE ###

# import math
# import numpy as np
import sys
def input():
    return sys.stdin.readline()[:-1]
# input
N, K, Q = map(int, input().split())
As = [int(input()) for i in range(Q)]

points = [K - Q] * N

for a in As:
    # points = [0 if point == 0 for point in points else point - 1]
    # points -= 1
    # points[a - 1] += 1
    points[a-1] += 1
survive = ['Yes' if point >= 1 else 'No' for point in points]

print(*survive, sep="\n")
### BUGGY CODE ###

import sys
input=sys.stdin.readline
n,q=map(int,input().split())
c=list(map(int,input().split()))
l=[]
for i in range(q):
  L,R=map(int,input().split())
  l.append([R,L,i])
l.sort()

L=[-1]*(5*10**5+1)

class Bit:
  def __init__(self,n):
    self.size=n
    self.tree=[0]*(n + 1)
    self.depth=n.bit_length()

  def sum(self,i):
    s=0
    while i>0:
      s+=self.tree[i]
      i-=i&-i
    return s

  def add(self,i,x):
    while i<=self.size:
      self.tree[i]+=x
      i+=i&-i

BIT=Bit(n+1)

ans=[0]*q
ct=0
for i in range(q):
  while ct<=l[i][0]:
    if L[c[ct-1]-1]!=-1:
      BIT.add(L[c[ct-1]-1],-1)
    L[c[ct-1]-1]=ct+1
    BIT.add(ct+1,1)
    ct+=1
  ans[l[i][2]]=BIT.sum(l[i][0]+1)-BIT.sum(l[i][1])

for i in range(q):
  print(ans[i])

### FIXED CODE ###

n,q=map(int,input().split())
c=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(q)]
for i in range(q):
  l[i].append(i)
l2=sorted(l,key=lambda x:x[1])

L=[-1]*(5*10**5+1)

class Bit:
  def __init__(self,n):
    self.size=n
    self.tree=[0]*(n + 1)
    self.depth=n.bit_length()

  def sum(self,i):
    s=0
    while i>0:
      s+=self.tree[i]
      i-=i&-i
    return s

  def add(self,i,x):
    while i<=self.size:
      self.tree[i]+=x
      i+=i&-i

BIT=Bit(n+1)

ans=[0]*q
ct=0
for i in range(q):
  while ct<=l2[i][1]:
    if L[c[ct-1]-1]!=-1:
      BIT.add(L[c[ct-1]-1],-1)
    L[c[ct-1]-1]=ct+1
    BIT.add(ct+1,1)
    ct+=1
  ans[l2[i][2]]=BIT.sum(l2[i][1]+1)-BIT.sum(l2[i][0])

for i in range(q):
  print(ans[i])
### BUGGY CODE ###

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

def kitai(l):
  return (l+1)/2

max_ = 0
for i in range(n-k+1):
  max_ = max(max_, sum(kitai(j) for j in  a[i:i + k]))
  

print(max_)

### FIXED CODE ###

n , k = map(int, input().split())
a = list(int(i) for i in input().split())
 
temp = sum(a[0:k])
max_  = temp
for i in range(n-k):
  f = a[i]
  s = a[i+k]
  temp -= f
  temp += s
  max_ = max(max_, temp)
    
print((max_+k)/2)
### BUGGY CODE ###

from collections import deque

reflag = 0
s = deque(input())
q = int(input())

for _ in range(q):
    x = input().split()
    
    if(x[0]=='1'):
        reflag = reflag + 1
        #s.reverse()
    else:
        if(reflag % 2 == 0):
            reflag = 0
        else:
            s.reverse()
            reflag = 0
        
        s.appendleft(x[2]) if(x[1]=='1') else s.append(x[2])

if(reflag % 2 == 0):
    pass
else:
    s.reverse()

print(''.join(s))


### FIXED CODE ###

from collections import deque

revFlag = False

s = deque(input())
q = int(input())

for i in range(q):
    a,b,c, *_ = input().split() + [None, None]
    
    if(a == '1'):
        revFlag = not revFlag
        
    else:
        b = int(b)
        if(revFlag):
            b = (int(b)%2)+1
        
        if(b == 1):
            s.appendleft(c)
        else:
            s.append(c)
            
    #print(_,*s, sep="")

if(revFlag):
    s.reverse()
    
print(*s, sep='')
### BUGGY CODE ###

import sys

n = int(input())

def calc(a, b):
  return a**5 - b**5
  
for i in range(-10000, 10001):
  for j in range(-10000, 10001):
    if calc(i, j) == n:
      print(i, j)
      sys.exit()
    

### FIXED CODE ###

import sys

n = int(input())

def calc(a, b):
  return a**5 - b**5
  
for i in range(-1000, 1001):
  for j in range(-1000, 1001):
    if calc(i, j) == n:
      print(i, j)
      sys.exit()
### BUGGY CODE ###

# -*- coding: utf-8 -*-
# AtCoder Beginner Contest


if __name__ == '__main__':
    from statistics import median

    n = int(input())
    a = list(map(int, input().split()))
    total = 0

    # See:
    # https://www.youtube.com/watch?v=UX4AuiCVtN4
    # https://beta.atcoder.jp/contests/abc102/submissions/2768315
    mod_a = sorted([ai - i for i, ai in enumerate(a, 1)])

    for i in range(n):
        total += abs(mod_a[i] - median(mod_a))

    print(int(total))


### FIXED CODE ###

# -*- coding: utf-8 -*-
# AtCoder Beginner Contest


if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    total = 0

    for i in range(n):
        a[i] -= i + 1

    sorted_a = sorted(a)
    b = sorted_a[n // 2]

    for i in range(n):
        total += abs(a[i] - b)

    print(int(total))
### BUGGY CODE ###

s = input()
n = len(s)

dp = [0] * (n + 1)

for i in range(3, n):
	cnt = 0
	j = 0
	while i - j >= 3:
		sub = s[j:i+1]
		if int(sub) % 2019 == 0:
			cnt += 1
		j += 1
	dp[i] = dp[i - 1] + cnt

print(dp[n-1])

### FIXED CODE ###

s = input()
n = len(s)

MOD = 2019
T = [1] + [0] * 2018
d, p = 0, 1
for c in reversed(s):
	d = (d + p * int(c)) % MOD
	p = p * 10 % 2019
	T[d] += 1

print(sum(x * (x - 1) // 2 for x in T))
### BUGGY CODE ###


N = int(input())
strN = str(N)
order = len(strN)
Ns = int(strN[0])
Ne = int(strN[-1])
count = 0
for e in range(1, 10):
  e = str(e)
  for s in range(1, 10):
    s = str(s)
    ces = 0
    cse = 0
    for n in range(1, N + 1):
      sn = str(n)
      if sn[0] == s and sn[-1] == e:
        ces += 1
      if sn[0] == e and sn[-1] == s:
        cse += 1
    count += ces * cse
    
print(count)

### FIXED CODE ###

N = int(input())
strN = str(N)
order = len(strN)
Ns = int(strN[0])
Ne = int(strN[-1])

ces = [[0  for i in range(10) ] for j in range(10)]
cse = [[0  for i in range(10) ] for j in range(10)]
for n in range(1, N + 1):
  n_last = n % 10
  n_first = n
  while n_first >= 10:
    n_first = n_first // 10
  ces[n_last][n_first] += 1
  cse[n_first][n_last] += 1

count = 0
for e in range(1, 10):
  for s in range(1, 10):
    count += ces[e][s] * cse[e][s]
    
print(count)
### BUGGY CODE ###

s = str(input())
loop = int(input())

for i in range(loop):
    queries = input().split()
    if len(queries) == 1:
        s = s[::-1]
    else:
        type = int(queries[1])
        c = str(queries[2])
        if type == 1:
            s = c + s
        else:
            s = s + c
print(s)



### FIXED CODE ###

from collections import deque

s = deque((str(input())))
loop = int(input())

rev = 0
for i in range(loop):
    queries = input().split()
    if len(queries) == 1:
        rev = (rev+1) % 2
    else:
        type = int(queries[1])
        c = str(queries[2])
        if (type + rev) % 2 == 1:
            s.appendleft(c)
        else:
            s.append(c)
if rev == 1:
    print("".join(reversed(list(s))))
else:
    print("".join(list(s)))
### BUGGY CODE ###

# coding: utf-8

n = int(input())
a = list(map(int, input().split()))

appear_D = {}


def sosuu(n):
    output = []
    for i in range(1, int(pow(n, 0.5))+1):
        if n % i == 0:
            output.append(i)
            if i != n // i:
                output.append(n // i)

    return output


ans_cantdidate = []
sosuus = sosuu(a[0]) + sosuu(a[1])
for num in sosuus:
    n_appear = 0
    for i in range(n):
        if a[i] % num == 0:
            n_appear += 1
    if n_appear >= n-1:
        ans_cantdidate.append(num)

print(max(ans_cantdidate))

### FIXED CODE ###

# coding: utf-8

n = int(input())
a = list(map(int, input().split()))

appear_D = {}


def sosuu(n):
    output = []
    for i in range(1, int(pow(n, 0.5))+1):
        if n % i == 0:
            output.append(i)
            if i != n // i:
                output.append(n // i)

    return output


ans_cantdidate = []

min_fst = a[0]
for i in range(n):
    if a[i] < min_fst:
        min_fst = a[i]

min_snd = a[0] if a[0] != min_fst else a[1]
for i in range(n):
    if min_fst < a[i] < min_snd:
        min_snd = a[i]

sosuus = set(sosuu(min_fst)) | set(sosuu(min_snd))
for num in sosuus:
    not_common = 0
    for i in range(n):
        if a[i] % num > 0:
            not_common += 1
        if not_common > 1:
            break
    if not_common < 2:
        ans_cantdidate.append(num)

print(max(ans_cantdidate))
### BUGGY CODE ###

N = int(input())
S = input()

cnt = N
for i in range(1, N + 1):
    tmp = S[:i-1].count('W') + S[i:].count('E')#changeDirection(S, i, N)
    if tmp < cnt:
        cnt = tmp
        
print(cnt)

### FIXED CODE ###

def EW(x, char):
    re = 0
    if x == char:
        re = 1
    return re
        
def main(num, string):
    e = list(map(lambda x:EW(x, 'E'), string))
    w = list(map(lambda x:EW(x, 'W'), string))
    
    for i in range(1, num):
        w[i] = w[i-1] + w[i]
        e[num - i -1] = e[num - i  - 1] + e[num - i]
    
    w.insert(0, 0)
    w.insert(num+1,0)
    e.insert(0, 0)
    e.insert(num+1, 0)
    cnt = num
    for i in range(1, num + 1):
        tmp = w[i-1] + e[ i + 1]
        if tmp < cnt:
            cnt = tmp
    return cnt

num = int(input())
string = input()
 
print(main(num, string))
### BUGGY CODE ###

N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(1<<N):
    val = 0
    for j in range(N):
        if i >> j & 1:
            val+=V[j]
            val-=C[j]
    ans = max(ans, val)
print(ans)


### FIXED CODE ###

N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(2**N):
    val = 0
    for j in range(N):
        if (i >> j) & 1:
            val+=V[j]
            val-=C[j]
    ans = max(ans, val)
print(ans)
### BUGGY CODE ###

N=int(input())
S=[list(sorted(str(input())))]
r=0
for i in range(1,N):
  s=list(sorted(str(input())))
  r+=S.count(s)
  S.append(s)
print(r)

### FIXED CODE ###

N=int(input())
M={}
ans=0
for i in range(N):
    s=''.join(sorted(list(str(input()))))
    if s in M:
        ans+=M[s]
        M[s]+=1
    else:
        M[s]=1
print(ans)
### BUGGY CODE ###

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

count = 0
for i in range(N):
    new_arr = arr[0:i+1]
    if min(new_arr) >= arr[i]:
        count += 1

print(count)

### FIXED CODE ###

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

count = 0
mn = float('inf')
for i in range(N):
    if mn >= arr[i]:
        count += 1
        mn =min(mn,arr[i])

print(count)
### BUGGY CODE ###

a,b,c,d = map(int,input().split())
count = 0
for i in range(a,b+1):
    if i % c != 0 and i % d != 0:
        count += 1
print(count)

### FIXED CODE ###

a,b,c,d = map(int,input().split())
u = b - a + 1
from fractions import gcd
cd = c*d//gcd(c,d)
n_c = b//c - (a-1)//c
n_d = b//d - (a-1)//d
n_cd =b//cd - (a-1)//cd
print(int(u - n_c - n_d + n_cd))
### BUGGY CODE ###

N = int(input())
s = input()
i = 1
li = []
charas = 'abcdefghijklmnopqrstuvwxyz'
while i < N:
  m = 0
  s1 = s[0:i]
  s2 = s[i:]
  for chara in charas:
    if chara in s1 and chara in s2:
      m += 1
  li.append(m)
print(max(li))

### FIXED CODE ###

N = int(input())
s = input()
i = 1
li = []
charas = 'abcdefghijklmnopqrstuvwxyz'
while i < N:
  m = 0
  s1 = s[0:i]
  s2 = s[i:]
  for chara in charas:
    if chara in s1 and chara in s2:
      m += 1
  li.append(m)
  i += 1
print(max(li))
### BUGGY CODE ###

x,y=map(int,input().split())
if x<y:
    x,y=y,x

z = x % y
if x==y:
    print(x)
else:
    gcd=0
    for i in range(1,z+1):
        if z % i ==0 and y % i ==0:
            gcd=i
    print(gcd)



### FIXED CODE ###

def calc_gcd(a,b):
    if a < b:
        a,b=b,a
    if b == 0:
        return a
    return calc_gcd(b,a%b)

x,y=map(int,input().split())
print("%d"%(calc_gcd(x,y)))
### BUGGY CODE ###

from collections import deque

N,M,K = map(int,input().split())
friend = [list(map(int,input().split())) for _ in range(M)]
block = [list(map(int,input().split())) for _ in range(K)]

f = [[False]*(N+1) for _ in range(N+1)]
for i in friend:
    f[i[0]][i[1]] = True
    f[i[1]][i[0]] = True

b = [[False]*(N+1) for _ in range(N+1)]
for i in block:
    b[i[0]][i[1]] = True
    b[i[1]][i[0]] = True
    
stack=deque()
linkList = []
ans = []
nonViseted = list(range(1,N+1))

for i in range(1,N+1):
    if not i in nonViseted:
        continue
    link = [i]
    nonViseted.remove(i)
    stack.append(i)
    while stack:
        n = stack.pop()
        for j in nonViseted:
            if f[n][j]:
                stack.append(j)
                nonViseted.remove(j)
                link.append(j)
    linkList.append(link)

for i in range(1,N+1):
    #連結成分のサイズ
    linkSize = 0
    #「友達関係」または「ブロック関係」はマイナスする
    minus = 0
    for link in linkList:
        if not i in link:
            continue
        for j in link:
            linkSize = len(link)
            if f[i][j] or b[i][j]:
                minus += 1
    ans.append(linkSize-minus-1)

print(*ans)
    

### FIXED CODE ###

from collections import deque

N,M,K = map(int,input().split())
friend = [list(map(int,input().split())) for _ in range(M)]
block = [list(map(int,input().split())) for _ in range(K)]

f = [set() for _ in range(N+1)]
b = [set() for _ in range(N+1)]

for i,j in friend:
    f[i].add(j)
    f[j].add(i)
for i,j in block:
    b[i].add(j)
    b[j].add(i)

stack=deque()
linkList = []
ans = [0] *(N+1)
visited = [0] * (N+1)

for i in range(1,N+1):
    if visited[i]:
        continue
    link = {i}
    visited[i] = 1 
    stack.append(i)
    while stack:
        n = stack.pop()
        for j in f[n]:
            if j in f[n] and visited[j]==0:
                stack.append(j)
                visited[j] = 1
                link.add(j)
    linkList.append(link)
    for i in link:
        ans[i] = len(link) - len(link & f[i]) - len(link & b[i]) - 1
print(*ans[1:])
### BUGGY CODE ###

s=input()
s= s[::-1]

S=[0,]
cnt=[0]*2019
cnt[0]=1
for n,i in enumerate(s):
    # print(s[n], i, n)
    S.append((int(S[n]) + int(i) * 10**n) % 2019)
    cnt[S[n+1]]+=1

# print(S)
ans=0
for i in cnt:
    ans += i*(i-1) //2

print(ans)

### FIXED CODE ###

s=input()
s= s[::-1]

S=[0,]
cnt=[0]*2019
cnt[0]=1
d=1
num=0
for i in range(len(s)):
    num += int(s[i])*d
    num %= 2019
    d *= 10
    d%= 2019
    # S.append((int(S[i]) + int(s[i]) * 10**i) % 2019)
    cnt[num]+=1

ans=0
for i in cnt:
    ans += i*(i-1) //2

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

a = input()
l = len(a)
blk = a
i = 0
rem = 0
while i < (l - 1):
    if(blk[i] != blk[i+1]):
        blk = blk[:i] + blk[i+2:]
        l -= 2
        rem += 2
        i = 0
    else:
        i += 1
    
print(rem)

### FIXED CODE ###

a = input()
l = len(a)
blk = a
i = 0
rem = 0
num0 = 0
num1 = 0
while i < l:
    if blk[i] == "0":
        num0 += 1
    else:
        num1 += 1
    i += 1
rem = min(num0, num1)
print(rem * 2)