Harryxun/stf_run huggingface dataset:
#!/usr/bin/env pypy3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys,collections

N = int(sys.stdin.readline())
a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param

from math import gcd
import math
acc = a[0]
LIMIT=10**6
minPrime = [0]*(LIMIT+1)
#minPrime[1] = 1
count = 0
for i in range(2,LIMIT):
    if minPrime[i] == 0:
        count += 1
        j = i
        while j <= LIMIT:
            if minPrime[j] == 0:
                minPrime[j] = i
            j += i
#print(minPrime)
def factrial(N):
    ret = []
    while minPrime[N] != N:
        ret.append(minPrime[N])
        N = N//minPrime[N]
    if N != 1:
        ret.append(N)
    return ret

pairwise = True
# facts = [set(factrial(e)) for e in a]
p = set() #all prime
s = set(factrial(a[0])) # pair prime
for e in a:
    f = set(factrial(e))
    s = s & f
    if p & f:
        pairwise = False
    p = p | f
#print(p,s,pairwise)

if s:
    print("not coprime")
elif pairwise:
    print("pairwise coprime")
else:
    print("setwise coprime")
# for s:
#     acc = math.gcd(acc,a[i])
# if acc != 1:
#     print("not coprime")
#     exit()
# print("pairwise coprime")
# for i in range(N):
#     for j in range(i+1,N):
#         b = gcd(a[i],a[j])
#         if b != 1:
#             print("setwise coprime")
#             exit()
# if pairwise == True:
#     print("pairwise coprime")
# else:
#     print("not coprime")


### FIXED CODE ###

import math
from collections import defaultdict
pc = True
n = int(input())
a = list(map(int,input().split()))
g = math.gcd(a[0],a[1])
for i in range(2,n):
    g = math.gcd(g,a[i])
M = max(a)
class Sieve_of_Eratosthenes:
    def __init__(self, N):
        self.sieve = [-1] * (N+1)
 
        for i in range(2,N+1):
            if self.sieve[i] == -1:
                for j in range(1,1+N//i):
                    self.sieve[i*j] = i
 
    def isprime(self, num):
        if num <= 1:
            return False
        else:
            return self.sieve[num] == num
 
    def factorization(self, num):
        ret = set([])
        while num != 1:
            div = self.sieve[num]
            ret.add(div)
            num //= div
        return ret
 
sofe = Sieve_of_Eratosthenes(M)
ddic = defaultdict()
judge = set([])
 
for i in a:
    if not pc:
        break
    asf = sofe.factorization(i)
    
    if judge & asf != set():
        pc = False
    judge |= asf
if pc:
    print("pairwise coprime")
elif g == 1:
    print("setwise coprime")
else:
    print("not coprime")
s　=　input()

print(s[:3])

### FIXED CODE ###

s = input()

print(s[:3])
A = list(map(int,input().split()))
AA = sum([i%2 for i in A])
if N == 1:
    print('YES')
    exit()
if AA % 2 == 1:
    print('NO')
    exit()
print('YES') 


### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
AA = sum([i%2 for i in A])
if N == 1:
    print('YES')
    exit()
if AA % 2 == 1:
    print('NO')
    exit()
print('YES')
S=input()
print(S)
while(len(S)>=5):
    if(S[len(S)-7:len(S)]=='dreamer'):
        S=S[:len(S)-7]
    elif(S[len(S)-6:len(S)]=='eraser'):
        S=S[:len(S)-6]
    elif(S[len(S)-5:len(S)]=='dream' or S[len(S)-5:len(S)]=='erase'):
        S=S[:len(S)-5]
    else:
        print("NO")
        exit()
    print(S)
if(len(S)!=0):
    print("NO")
else:
    print("YES")

### FIXED CODE ###

S=input()
while(len(S)>=5):
    if(len(S)>=7 and S[len(S)-7:len(S)]=='dreamer'):
        S=S[:len(S)-7]
    elif(len(S)>=6 and S[len(S)-6:len(S)]=='eraser'):
        S=S[:len(S)-6]
    elif(S[len(S)-5:len(S)]=='dream' or S[len(S)-5:len(S)]=='erase'):
        S=S[:len(S)-5]
    else:
        print("NO")
        exit()
if(len(S)!=0):
    print("NO")
else:
    print("YES")
import sys
 
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
mod = pow(10, 9)+7
zero = 0
plus = []
minus = []
for i in range(n):
  if a[i] == 0:
    zero += 1
  elif a[i] > 0:
    plus.append(a[i])
  else:
    minus.append(a[i])
 
P, M = len(plus), len(minus)
plus.sort(reverse=True)
minus.sort()
ans = 1
if n == k:
  for i in range(n):
    ans *= a[i]
    ans %= mod
elif P+M < k:
  ans = 0
elif P == 0 and k%2 ==1 :
  if zero >= 1:
    ans = 0
  else:
    minus.sort(reverse=True)
    for i in range(k):
      ans *= minus[i]
      ans %= mod
else:
  if k%2 == 1:
    ans *= plus[0]
    ans %= mod
    q = 1
  judge = []
  for i in range((P-q)//2):
    judge.append(plus[2*i+q]*plus[2*i+q+1])
  for i in range(M//2):
    judge.append(minus[2*i]*minus[2*i+1])
  judge.sort(reverse=True)
  for i in range(k//2):
    ans *= (judge[i]%mod)
    ans %= mod
 
print(ans)

### FIXED CODE ###

import sys
 
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
mod = pow(10, 9)+7
zero = 0
plus = []
minus = []
for i in range(n):
  if a[i] == 0:
    zero += 1
  elif a[i] > 0:
    plus.append(a[i])
  else:
    minus.append(a[i])
 
P, M = len(plus), len(minus)
plus.sort(reverse=True)
minus.sort()
ans = 1
if n == k:
  for i in range(n):
    ans *= a[i]
    ans %= mod
elif P+M < k:
  ans = 0
elif P == 0:
  if zero and k%2:
    ans = 0
  else:
    if k%2:
      minus.reverse()
    for i in range(k):
      ans *= minus[i]
      ans %= mod
else:
  q = 0
  if k%2:
    ans *= plus[0]
    ans %= mod
    q = 1
  judge = []
  for i in range((len(plus)-q)//2):
    judge.append(plus[2*i+q]*plus[2*i+q+1])
  for i in range(len(minus)//2):
    judge.append(minus[2*i]*minus[2*i+1])
  judge.sort(reverse=True)
  for i in range(k//2):
    ans *= (judge[i]%mod)
    ans %= mod
 
print(ans)
n = int(input())
l = []
for i in range(n):
    tmp = list(map(int,input().split()))
    l.append(tmp)

from collections import defaultdict
d = defaultdict(int)

for i in range(len(l)):
    for j in range(len(l)):
        difx = l[i][0] - l[j][0]
        dify = l[i][1] - l[j][1]
        if difx!=0 or dify!=0:
            dif = str(difx) + "_" + str(dify)
            d[dif] += 1

p_q = max((v,k) for (k,v) in d.items())[1]
p,q = p_q.split("_")

ans=0
for i in range(len(l)):
    found=False
    for j in range(len(l)):
        difx = l[i][0] - l[j][0]
        dify = l[i][1] - l[j][1]
        if difx==int(p) and dify==int(q):
            found=True
            break
    if not found:
        ans+=1
print(ans)

### FIXED CODE ###

n = int(input())
l = []
for i in range(n):
    tmp = list(map(int,input().split()))
    l.append(tmp)

if len(l) == 1:
    print(1)
    exit()


from collections import defaultdict
d = defaultdict(int)

for i in range(len(l)):
    for j in range(len(l)):
        difx = l[i][0] - l[j][0]
        dify = l[i][1] - l[j][1]
        if difx!=0 or dify!=0:
            dif = str(difx) + "_" + str(dify)
            d[dif] += 1

p_q = max((v,k) for (k,v) in d.items())[1]
p,q = p_q.split("_")

ans=0
for i in range(len(l)):
    found=False
    for j in range(len(l)):
        difx = l[i][0] - l[j][0]
        dify = l[i][1] - l[j][1]
        if difx==int(p) and dify==int(q):
            found=True
            break
    if not found:
        ans+=1
print(ans)
a,b,c,d=map(int,input().split())
x=int(a+b)
y=int(c+d)
if 0<=x<=12 and 0<=b<=12:
  if x==y==0:
    print('NA')
  else:
    print('AMBIGUOUS')
elif 0<=x<=99 and 1<=y<=12:
  print('YYMM')
elif 1<=x<=12 and 0<=y<=99:
  print('MMYY')
else:
  print('NA')

### FIXED CODE ###

a,b,c,d=input()
x=int(a+b)
y=int(c+d)
if 1<=x<=12 and 1<=y<=12:
  print('AMBIGUOUS')
elif 1<=x<=12 and 1<=y<=12:
  print('AMBIGUOUS')
elif 0<=x<=99 and 1<=y<=12:
  print('YYMM')
elif 1<=x<=12 and 0<=y<=99:
  print('MMYY')
else:
  print('NA')
import bisect
N,Q=map(int,input().split())
STX=[list(map(int,input().split())) for i in range(N)]
STX.sort(key=lambda x:x[2])
ans=[-1]*Q
jump=[-1]*Q
D=[int(input()) for i in range(Q)]
for s,t,x in STX:
    l=bisect.bisect_left(D,s-x)
    r=bisect.bisect_left(D,t-x)
    while(l<r):
        k=jump[l]
        if k==-1:
            ans[l]=x
            jump[l]=r
            l+=1
        else:
            l=jump[k]
for i in range(Q):
    print(ans[i])


### FIXED CODE ###

import bisect
import sys
input=sys.stdin.readline
N,Q=map(int,input().split())
STX=[tuple(map(int,input().split())) for i in range(N)]
STX.sort(key=lambda x:x[2])
ans=[-1]*Q
jump=[-1]*Q
D=[int(input()) for i in range(Q)]
for s,t,x in STX:
    l=bisect.bisect_left(D,s-x)
    r=bisect.bisect_left(D,t-x)
    while(l<r):
        k=jump[l]
        if k==-1:
            ans[l]=x
            jump[l]=r
            l+=1
        else:
            l=k
for i in range(Q):
    print(ans[i])
x, y = input()
print(x * y + " " + 2*x + 2*y)

### FIXED CODE ###

a, b = list(map(int, input().split()))
print(a * b, 2*(a + b))
str = input()
count5 = str.count(5)
count7 = str.count(7)
if count5 == 2 and count7 == 1:
  print('Yes')
else:
  print('NO')


### FIXED CODE ###

num= input().split()
count5 = 0
count7 = 0
 
for i in range(len(num)):
    if num[i] == '5':
        count5 += 1
    elif num[i] == '7':
        count7 += 1
    else:
        continue
if count5 == 2 and count7 == 1:
    print('YES')
else:
    print('NO')
import sys
sys.setrecursionlimit(100000)

N = int(input())
D = []
dp = []
for _ in range(N):
    a,b,c = map(int, input().split())
    D.append([a,b,c])
    dp.append([-1]*3)

def dfs(n, activity):#n日目にactivityを選んだ場合の最大幸福
    if dp[n][activity]!=-1:
        return dp[n][activity]
    if n==1:
        ans = 0
        for i in range(3):
            if i!=activity:
                ans = max(ans, D[1][activity]+D[0][i])
        return ans
    ans = 0
    for i in range(3):
        if i!=activity:
            ans =max(ans, D[n][activity]+dfs(n-1, i))
    dp[n][activity] = ans
    return ans
ans = 0
for i in range(3):
    ans = max(ans, dfs(N-1, i))
print(ans)




### FIXED CODE ###

N = int(input())

vacation = []

for i in range(N):
    a,b,c = map(int, input().split())

    vacation.append([a,b,c])

dp = []*N

for i in range(N):
    dp.append([0, 0, 0])

dp[0][0]=vacation[0][0]
dp[0][1]=vacation[0][1]
dp[0][2]=vacation[0][2]

for i in range(0, N-1, 1):

    for j in range(3):
        for k in range(3):
            if j==k:
                continue
            dp[i+1][j] = max(dp[i+1][j], dp[i][k]+vacation[i+1][j])

print(max(dp[N-1]))
n,m = map(int,input().split())

A = [[input()] for i in range(n)]
B = [[input()] for i in range(m)]
ans = 0
for i in range(n-m+1):
    for j in range(n-m+1):
        temp=0
        for k in range(m):
            for l in range(m):
                if B[k][l]==A[i+k][j+l]:
                    temp+=1
                    ans = max(ans,temp)
                                    
print('Yes' if ans==m*m else 'No')

### FIXED CODE ###

import sys

n,m = map(int,input().split())
A = [list(input()) for i in range(n)]
B = [list(input()) for i in range(m)]
for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            if k == 0:
                C = [A[i][j:m+j]]
            else:
                C += [A[i+k][j:m+j]]
        if B == C:
            print('Yes')
            sys.exit()
print('No')
n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=-10**18
flag=dict()
for i in range(n):
    if i in flag:
        continue
    cur=i
    accum=[]
    flag[cur]=0
    s=0
    while flag[cur]<2:
        cur=p[cur]-1
        s+=c[cur]
        accum.append(s)
        if cur not in flag:
            flag[cur]=0
        else:
            flag[cur]+=1
    l=len(accum)//2
    accum=[0]+accum
    for x in range(1,l+1):
        if accum[x+l-1]-accum[x-1]<=0:
            ans=max(ans,max(accum[x:x+min(k,l)])-accum[x-1])
        else:
            a=max(accum[x:x+l])-accum[x-1]
            b=max(accum[x:x+k%l])-accum[x-1]
            d=accum[x+l-1]-accum[x-1]
            ans=max(ans,max(k//l*d+b,max(k//l-1,0)*d+a))
print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=-10**18
flag=dict()
for i in range(n):
    if i in flag:
        continue
    cur=i
    accum=[]
    flag[cur]=0
    s=0
    while flag[cur]<2:
        cur=p[cur]-1
        s+=c[cur]
        accum.append(s)
        if cur not in flag:
            flag[cur]=0
        else:
            flag[cur]+=1
    l=len(accum)//2
    accum=[0]+accum
    #print(accum)
    for x in range(1,l+1):
        if accum[x+l-1]-accum[x-1]<=0 or k//l<1:
            ans=max(ans,max(accum[x:x+min(k,l)])-accum[x-1])
        else:
            a=max(accum[x:x+l-1])-accum[x-1]
            d=accum[x+l-1]-accum[x-1]
            if k%l!=0:
                b=max(accum[x:x+k%l])-accum[x-1]
                ans=max(ans,max(k//l*d,k//l*d+b,(k//l-1)*d+a))
            else:
                b=max(accum[x:x+l-1])-accum[x-1]
                ans=max(ans,max(k//l*d,(k//l-1)*d+a))
print(ans)
n,k = map(int, input().split())
p = [[0,0]]
for i in range(n):
    a,b = map(int, input().split())
    p.append([a,b])
p.sort()
ans = 0
i = 0
while ans<=k:
    ans+=p[i][1]
    i+=1
print(p[i-1][0])

### FIXED CODE ###

n,k = map(int, input().split())
p = [[0,0]]
for i in range(n):
    a,b = map(int, input().split())
    p.append([a,b])
p.sort()
ans = 0
p.pop(0)
for i in range(n):
    ans+=p[i][1]
    if ans>=k:
        print(p[i][0])
        exit()
    else:
        continue
import numpy as np
from numba import njit

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

@njit
def light(a_list):
    outcome= np.array([0]*(n+1))
    for i in range(n):
        outcome[max(0,i-a_list[i])] += 1
        outcome[min(n,i+a_list[i]+1)] -= 1
    outcome = np.cumsum(outcome)[:-1]
    return outcome

for _ in range(k):
    if sum(a) >= n*n:
        break
    a = light(a)

[print(aa,end=' ') for aa in a]

### FIXED CODE ###

import numpy as np
from numba import njit

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

@njit(cache=True)
def light(n,a_list):
    outcome= np.zeros(n+1, dtype=np.int64)
    for i in range(n):
        outcome[max(0,i-a_list[i])] += 1
        outcome[min(n,i+a_list[i]+1)] -= 1
    outcome = np.cumsum(outcome)[:-1]
    return outcome

for _ in range(k):
    if min(a) == n:
        break
    a = light(n,a)

[print(aa,end=' ') for aa in a]
def main():
    H = int(input())
    div = {2**i for i in range(40)}
    ans = 0
    from math import log2, ceil
    if not(H in div):
        for h in range(int(log2(H)) + 1):
            ans += 2**h
        print(ans)
    else:
        for h in range(int(log2(H)) + 1):
            ans += 2**h
        print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    H = int(input())
    div = {2**i for i in range(40)}
    ans = 0
    from math import log2, ceil
    if not(H in div):
        for h in range(int(log2(H)) + 1):
            ans += 2**h
        print(ans)
    else:
        for h in range(int(log2(H)) + 1):
            ans += 2**h
        print(ans)


if __name__ == '__main__':
    main()
import sys
sys.setrecursionlimit(10**6)

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

from collections import deque

a = deque(a)
b = deque(b)

ans = 0
time = k

while time >= 0:
    if a and b:
        tmp_a = time-a[0]
        tmp_b = time-b[0]
        if tmp_a >= 0 and tmp_b >= 0 and a[0] <= b[0]:
            time -= a[0]
            a.popleft()
            ans += 1
        elif tmp_a >= 0 and tmp_b >= 0 and b[0] < a[0]:
            time -= b[0]
            b.popleft()
            ans += 1
        elif tmp_a >= 0:
            time -= a[0]
            a.popleft()
            ans += 1
        elif tmp_b >= 0:
            time -= b[0]
            b.popleft()
            ans += 1
        else:
            break
    elif a:
        tmp_a = time-a[0]
        if tmp_a >= 0:
            time -= a[0]
            a.popleft()
            ans += 1
        else:
            break
    elif b:
        tmp_b = time-b[0]
        if tmp_b >= 0:
            time -= b[0]
            b.popleft()
            ans += 1
        else:
            break
    else:
        break
    print(a,b,ans)

print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

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

a, b = [0], [0]

for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M

for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]: # 前のループで求めたjから走査すれば良い（毎回Mから始める必要はない）
        j -= 1
    ans = max(ans, i + j)

print(ans)
from collections import defaultdict
import itertools
 

def analyze(string):
  s_count = defaultdict(int)
  for s in string:
    s_count[s] += 1
  return s_count
 
def count_up(s_count):
  strings = list(s_count.keys())
  ans = 0
  for num in range(1, len(strings) + 1):
    for s_list in itertools.product(strings, num):
      a = 1
      for s in s_list:
        a *= s_count[s]
      ans += a
  print(ans)
  
N, string = input().split('\n')
N = int(N)
 
s_count = analyze(string)
count_up(s_count)

### FIXED CODE ###

from collections import defaultdict
import itertools
from functools import reduce


def analyze(string):
  s_count = defaultdict(int)
  for s in string:
    s_count[s] += 1
  counts = tuple(s_count.values())
  return counts

N = int(input())
string = input()

def search(N, string):
    memo = {}
    def count(counts, num_set):
        if (counts, num_set) in memo:
            return memo[(counts, num_set)]

        if num_set == 1:
            ans = sum(counts)
        elif num_set == 2:
            num_sum = sum(counts)
            ans = 0
            for i in range(len(counts)):
                num_sum -= counts[i]
                ans += counts[i] * num_sum
        else:
            ans = 0
            for i in range(len(counts) - 1):
                ans += counts[i] * count(counts[i + 1:], num_set - 1)

        memo[(counts, num_set)] = ans
        return ans

    counts = analyze(string)
    ans = 0
    for i in range(1, len(counts) + 1):
        ans += count(counts, i)
    print(ans % (10**9 + 7))

search(N, string)
N,M,K=map(int,input().split())
P=998244353
class FactInv:
    def __init__(self,N,P):
        fact=[];ifact=[];fact=[1]*(N+1);ifact=[0]*(N+1)
        for i in range(1,N):
            fact[i+1]=(fact[i]*(i+1))%P
        ifact[-1]=pow(fact[-1],P-2,P)
        for i in range(N,0,-1):
            ifact[i-1]=(ifact[i]*i)%P
        self.fact=fact;self.ifact=ifact;self.P=P
    def comb(self,n,k):
        return (self.fact[n]*self.ifact[k]*self.ifact[n-k])%self.P
FI=FactInv(N+10,P)
ans=0
for i in range(0,K+1):
    ans+=(M*FI.comb(N-1,i)*pow(M0,N-1-i,P))%P
    ans%=P
print(ans)

### FIXED CODE ###

N,M,K=map(int,input().split())
P=998244353
class FactInv:
    def __init__(self,N,P):
        fact=[];ifact=[];fact=[1]*(N+1);ifact=[0]*(N+1)
        for i in range(1,N):
            fact[i+1]=(fact[i]*(i+1))%P
        ifact[-1]=pow(fact[-1],P-2,P)
        for i in range(N,0,-1):
            ifact[i-1]=(ifact[i]*i)%P
        self.fact=fact;self.ifact=ifact;self.P=P
    def comb(self,n,k):
        return (self.fact[n]*self.ifact[k]*self.ifact[n-k])%self.P
FI=FactInv(N+10,P)
ans=0
for k in range(0,K+1):
    ans+=(M*FI.comb(N-1,k)*pow(M-1,N-1-k,P))%P
    ans%=P
print(ans)
A, B = input().split()
1 <= A <= 100
1 <= B <= 100
sum = A*B
print(sum)

### FIXED CODE ###

a, b =map(int,input().split())
print(a*b)
def iroha():
    n, k, price, special = map(int, input().split())
    result = 0
    for i in range(n):
        if i < k:
            result += price
        else:
            result += special
    
    print(result)
            

if __name__ == "__main__":
    iroha()

### FIXED CODE ###

def iroha():
    n, k, price, special = [int(input()) for i in range(4)]
    result = 0
    for i in range(n):
        if i < k:
            result += price
        else:
            result += special
    print(result)

if __name__ == "__main__":
    iroha()
N, K = map(int, input().split())
*T, = map(int, input().split())

INF = float("inf")  # pythonでの無限大の作り方
DP = [INF for i in range(N)]

def chmin(a, b):
     if a > b:
          return b
     return a

DP[0] = 0
for i in range(1, N):
    for j in range(1, K+1):
        DP[i] = chmin(DP[i], DP[i-j] + abs(T[i-j] - T[i]))

print(int(DP[-1]))

### FIXED CODE ###

import sys
import numpy as np

input = sys.stdin.readline

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

INF = float("inf")  # pythonでの無限大の作り方
DP = [INF for i in range(N)]

def chmin(a, b):
     if a > b:
          return b
     return a

DP[0] = 0
"""
# 2重for文ではTLE
for i in range(1, N):
    for j in range(1, K+1):
        if i-j >= 0:
            DP[i] = chmin(DP[i], DP[i-j] + abs(T[i-j] - T[i]))
"""
"""
# list内包表記でもTLE (2重for文よりはマシ)
for i in range(1, N):
    DP[i] = min([chmin(DP[i], DP[i-j] + abs(T[i-j] - T[i])) for j in range(1, K+1) if i-j >= 0])
"""

DP = np.zeros(N, dtype=int)
T = np.array(T)

for i in range(1, N):
    start = max(0, i-K)
    DP[i] = min(DP[start:i] + np.abs(T[i] - T[start:i]))

print(int(DP[-1]))
s = list(map(str, input().split()))
ans = 0
for i in range(4):
    if s[i] == '+':
        ans += 1
    else:
        ans -= 1
print(ans)

### FIXED CODE ###

s = input()
print(s.count('+') - s.count('-'))
s=input()
k=int(input())
ans=0
chg=0
for i in range(1,len(s)):
  if chg==0 and s[i-1]==s[i]:
    ans+=1
    chg=1
  else:
    chg=0
ans2=1
chg2=1
for i in range(1,len(s)):
  if chg==0 and s[i-1]==s[i]:
    ans2+=1
    chg2=1
  else:
    chg2=0
if s[0]!=s[1]:
  print(k*ans)
else:
  print(k*min(ans,ans2))



### FIXED CODE ###

s=input()
k=int(input())
if len(s)==1:
  print(k//2)
else:
  ans=0
  chg=0
  for i in range(1,len(s)):
    if chg==0 and s[i-1]==s[i]:
      ans+=1
      chg=1
    else:
      chg=0
  ans2=1
  chg2=1
  for i in range(1,len(s)):
    if chg2==0 and s[i-1]==s[i]:
      ans2+=1
      chg2=1
    else:
      chg2=0
  if s[0]!=s[-1] or chg==1:
    print(k*ans)
  elif chg2==0:
    print((k-1)*ans2+ans)
  else:
    print(ans*((k+1)//2)+ans2*(k//2))
for i in N:
  x += 1
print(x)

### FIXED CODE ###

N = int(input())
s = 0
i = 1
while i <= N:
  s = s + i
  i += 1
print(s)
def main():
    n, k = map(int, input().split())
    l_list = sorted([int(i) for i in input().split()], reverse=True)
    print(sum(l_list[:k]))
    

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    a, b = map(int, input().split())

    if a%3 == 0 or b%3 == 0 or (a+b)%3 == 0: print("Possible")
    else: print("Impossible")


if __name__ == "__main__":
    main()
S = input()
T = input()

mS = []
d = len(S) - len(T)


for j in range(d):
    m = 0
    for i in range(len(T)):
        if S[i] != T[i] :
            m += 1

    mS.append(m)
    S = S[1:]
print(min(mS))


### FIXED CODE ###

S = input()
T = input()

mS = []
d = len(S) - len(T)
m = 0

if len(S) == len(T) :
    for i in range(len(T)):
        if S[i] != T[i] :
            m += 1
    print(m)

else :

    for j in range(d):
        m = 0
        for i in range(len(T)):
            if S[i] != T[i] :
                m += 1

        mS.append(m)
        S = S[1:]
    print(min(mS))
n, k = map(int, input().split())
count == 0
while n >= k:
  n = n // k
  count += 1
print(count)

### FIXED CODE ###

n, k = map(int, input().split())
count = 0
while n >= k:
  n = n // k
  count += 1
print(count+1)
def calc_gcd(a, b):
    from math import gcd
    return gcd(a, b)


if __name__ == '__main__':
    data = [int(x) for x in input().split(' ')]
    result = calc_gcd(data[0], data[1])
    print('{0}'.format(result))

### FIXED CODE ###

def calc_gcd(x, y):
    """
    math.gcd()????????¨??§????????????python3.5??\??????AOJ???python?????????????????????3.4????????§?????¨??§?????????
    """
    if y == 0:
        return x
    else:
        return calc_gcd(y, x % y)


if __name__ == '__main__':
    data = [int(x) for x in input().split(' ')]
    result = calc_gcd(data[0], data[1])
    print('{0}'.format(result))