Harryxun/stf_run huggingface dataset:
import math
N = int(input())
A = list(map(int, input().split()))
x = [0] * N
y = [0] * N
tmp = A[0]
for i in range(1, N):
    t = math.gcd(tmp, A[i])
    x[i] = int(tmp / t)
    tmp = t
tmp = A[N - 1]
for i in range(N - 2, -1, -1):
    t = math.gcd(tmp, A[i])
    y[i] =  int(tmp / t)
    tmp = t
m = 0
for i in range(1, N - 1):
    a = math.gcd(x[i], y[i])
    if m < a:
        m = a
print(tmp * max(m, y[0], x[N - 1]))




### FIXED CODE ###


import fractions
N = int(input())
A = list(map(int, input().split()))
x = [0] * N
y = [0] * N
tmp = A[0]
for i in range(1, N):
    t = fractions.gcd(tmp, A[i])
    x[i] = int(tmp / t)
    tmp = t
tmp = A[N - 1]
for i in range(N - 2, -1, -1):
    t = fractions.gcd(tmp, A[i])
    y[i] =  int(tmp / t)
    tmp = t
m = 0
for i in range(1, N - 1):
    a = fractions.gcd(x[i], y[i])
    if m < a:
        m = a
print(tmp * max(m, y[0], x[N - 1]))
#import itertools
from scipy.special import comb

def cmb_1(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def main():
    x, y = map(int, input().split())

    if x < y:
        x_ = y
        y_ = x

        x = y_
        y = x_
    
    if (x+y) % 3 != 0:
        print(0)

    else:
        n = (x+y)//3
        r = x//2

        #a = len(list(itertools.combinations(range(n), r)))
        #a = comb(n, r, exact=True)
        #a = comb_1(n, r)
        def cmb(n, r, mod):
            if ( r<0 or r>n ):
                return 0
            r = min(r, n-r)
            return g1[n] * g2[r] * g2[n-r] % mod

        mod = 10**9+7 #出力の制限
        N = 10**4
        g1 = [1, 1] # 元テーブル
        g2 = [1, 1] #逆元テーブル
        inverse = [0, 1] #逆元テーブル計算用テーブル

        for i in range( 2, N + 1 ):
            g1.append( ( g1[-1] * i ) % mod )
            inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
            g2.append( (g2[-1] * inverse[-1]) % mod )

        a = cmb(n,r,mod)

        print(a)

        #print(int(a) % ((1e9) + 7))

if __name__ == '__main__':
    main()



### FIXED CODE ###

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )



x, y = map(int, input().split())

if (2*y-x)%3 == 0 and (2*x-y)%3 == 0:
    m = (2*y-x)//3
    n = (2*x-y)//3

    if n >= 0 or m >= 0:
        print( str(int(cmb(n+m,n, mod) % (10e9+7)) ))
    else:
        print(0)
else:
    print(0)
import datetime

a  = (datetime.datetime.strptime('2019/04/30', '%Y/%m/%d') - datetime.datetime.strptime(input(), '%Y/%m/%d')).days

print('Heisei'a >= 0 else 'TBD')


### FIXED CODE ###

import datetime

# if not (datetime.datetime.strptime('2019/04/30', '%Y/%m/%d') - datetime.datetime.strptime(input(), '%Y/%m/%d')):
#     print('Heisei')
# else:
#     print('TBD')
a  = (datetime.datetime.strptime('2019/04/30', '%Y/%m/%d') - datetime.datetime.strptime(input(), '%Y/%m/%d')).days
if a >= 0:
    print('Heisei')
else:
    print('TBD')
# -*- Coding: utf-8 -*-

n = int(input())
A = [list(map(int,input().split())) for i in range(n-1)]
C = list(map(int,input().split()))

C2 = []
for i in range(n):
    C2.append([C[i],i])

C2.sort()

ans = sum(C)-C2[-1][0]

T = [[] for i in range(n)]
for i in range(len(A)):
    T[A[i][0]-1].append(A[i][1]-1)
    T[A[i][1]-1].append(A[i][0]-1)
#print(T)


E = [[0,i] for i in range(n)]
E[0][0]=1
# co = 0
# while co < n-1:
#     #print(co)
#     t = 0
#     while t < n+1 :
#         if len(T[t]) == 1:
#             E.append(t)
#             if co == n-2 :
#                 E.append(T[t][0])
#             T[T[t][0]].remove(t)
#             T[t] = []
#             co += 1
#         t += 1

def ho(u):
    p = E[u][0]
    for j in range(len(T[u])):
        if E[T[u][j]][0] == 0:
            E[T[u][j]][0] = p+1
            ho(T[u][j])
ho(0)
#print(E)
E.sort(reverse=1)


#print(E)

D = [0 for i in range(n)]
for i in range(n):
    D[E[i][1]] = C2[i][0]

print(ans)
s = ""
for i in range(n):
    s += str(D[i])
    s += " "

print(s)


### FIXED CODE ###

# -*- Coding: utf-8 -*-

n = int(input())
A = []
A = [list(map(int,input().split())) for i in range(n-1)]
C = list(map(int,input().split()))

C2 = []
for i in range(n):
    C2.append([C[i],i])

C2.sort()

ans = sum(C)-C2[-1][0]

T = [[] for i in range(n)]
for i in range(len(A)):
    T[A[i][0]-1].append(A[i][1]-1)
    T[A[i][1]-1].append(A[i][0]-1)
#print(T)


E = [[0,i] for i in range(n)]
E[0][0]=1
# co = 0
# while co < n-1:
#     #print(co)
#     t = 0
#     while t < n+1 :
#         if len(T[t]) == 1:
#             E.append(t)
#             if co == n-2 :
#                 E.append(T[t][0])
#             T[T[t][0]].remove(t)
#             T[t] = []
#             co += 1
#         t += 1

holist=[0]
hot = 0

def ho(u):
    p = E[u][0]
    for j in range(len(T[u])):
        if E[T[u][j]][0] == 0:
            E[T[u][j]][0] = p+1
            holist.append(T[u][j])

while hot < len(holist):
    ho(holist[hot])
    hot += 1
#print(E)
E.sort(reverse=1)


#print(E)

D = [0 for i in range(n)]
for i in range(n):
    D[E[i][1]] = C2[i][0]

print(ans)
s = ""
for i in range(n):
    s += str(D[i])
    s += " "

print(s)
from sys import stdin
r, g, b = stdin.readline().rstrip().split()
a = 100*r+10*g+b
if a%4 == 0:
    print("YES")
else:
    print("NO")


### FIXED CODE ###

from sys import stdin
r,g,b = [int(x) for x in stdin.readline().rstrip().split()]
a = 100*r+10*g+b
if a%4 == 0:
    print("YES")
else:
    print("NO")
a,b,c,d,e=int(input())

### FIXED CODE ###

import math
a=int(input());b=int(input());c=int(input());d=int(input());e=int(input())

N=math.ceil(a/10)*10+math.ceil(b/10)*10+math.ceil(c/10)*10+math.ceil(d/10)*10+math.ceil(e/10)*10
X=[a%10,b%10,c%10,d%10,e%10]
n=0
while(n!=5):
  if X[n]==0:
    X[n]=10
  n+=1

else:
  print(N-(10-min(X)))
S = [["0" for i in range(10)] for j in range(10)]

while True:
    check = [[False for i in range(10)] for j in range(10)]
    x = 0
    y = 0
    LOOP = False
    
    H, W = map(int, raw_input().split())
    
    if (H == 0 and W == 0):
        break
    
    for i in range(H):
        S[i] = raw_input()
    
    while (S[y][x] != "."):
        if (check[y][x] == True):
            LOOP = True
            print "LOOP"
            break
        
        check[y][x] = True
        
        if (S[y][x] == "^"):
            y -= 1
        elif (S[y][x] == ">"):
            x += 1
        elif (S[y][x] == "v"):
            y += 1
        else:
            x -= 1

    if (LOOP == False):
        print x, y

### FIXED CODE ###

S = [["0" for i in range(101)] for j in range(101)]

while True:
    check = [[False for i in range(101)] for j in range(101)]
    x = 0
    y = 0
    LOOP = False
    
    H, W = map(int, raw_input().split())
    
    if (H == 0 and W == 0):
        break
    
    for i in range(H):
        S[i] = raw_input()
    
    while (S[y][x] != "."):
        if (check[y][x] == True):
            LOOP = True
            print "LOOP"
            break
        
        check[y][x] = True
        
        if (S[y][x] == "^"):
            y -= 1
        elif (S[y][x] == ">"):
            x += 1
        elif (S[y][x] == "v"):
            y += 1
        else:
            x -= 1

    if (LOOP == False):
        print x, y
for i in range(N):
  line = input().split()
  sheet+=[(int(line[0]), int(line[1]))]
dic = {}
for i in range(N):
  start = sheet[i]
  for j in range(i+1, N):
    vec = [(sheet[j][0]-start[0]), (sheet[j][1]-start[1])]
    size = fractions.gcd(vec[0],vec[1])
    vec[0] = vec[0]//size
    vec[1] = vec[1]//size
    if vec[0]<0 and vec[1]<0:
      vec[0] = -vec[0]
      vec[1] = -vec[1]
    vec = tuple(vec)
    if vec not in dic.keys():
      dic[vec] = set([j])
    else:
      dic[vec].add(j)
m = 0
for s in dic.values():
  if len(s)>m:
    m = len(s)
print(N-m)

### FIXED CODE ###

N,*L = map(int, open(0).read().split())
ls = [0]*N
for i,c in enumerate(zip(*[iter(L)]*2)):
  ls[i] = c
ls.sort()
pls = []
for i in range(N):
  for j in range(i+1,N):
    a,b = ls[i]
    x,y = ls[j]
    pls += [(x-a,y-b)]
ans = 10**10
for X,Y in pls:
  s = set()
  m = 0
  for x,y in ls:
    if (x-X, y-Y) not in s:
      m += 1
    s.add((x,y))
  ans = min(m,ans)
if N==1:
  ans = 1
print(ans)
n, l = map(int, input().split())
sList = []
for i in range(n):
    sList.append()
sList.sort()
print(''.join(sList))

### FIXED CODE ###

n, l = map(int, input().split())
sList = []
for i in range(n):
    sList.append(input())
sList.sort()
print(''.join(sList))
import sys

input = sys.stdin.readline


def main():
    n, m = map(int, input().split())
    if m == 0:
        print(10 ** (n - 1))
        return

    numbers = [-1 for _ in range(n)]
    ret = ''
    for _ in range(m):
        s, c = map(int, input().split())
        if s == 1 and c == 0:
            ret = -1

        if numbers[s - 1] == -1:
            numbers[s - 1] = c
        elif numbers[s - 1] != c:
            ret = -1

    if ret == -1:
        print(ret)
        return

    for i in range(len(numbers)):
        if numbers[i] == -1:
            if i == 0:
                numbers[i] = 1
            else:
                numbers[i] = 0
        if numbers[i] < 0 or numbers[i] > 9:
            ret = -1
            break
        ret += str(numbers[i])

    print(int(ret))


if __name__ == '__main__':
    main()


### FIXED CODE ###

import math
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    print(math.ceil(n / 2))


if __name__ == '__main__':
    main()
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

n = int(input())
cnt=0
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):

            cnt += gcd(i,j,k)

print(cnt)

### FIXED CODE ###

import math

n = int(input())
cnt=0
for i in range(1,n+1):
    for j in range(1,n+1):
        t = math.gcd(i,j)
        for k in range(1,n+1):
            cnt +=  math.gcd(k,t)

print(cnt)
#-------------------------------------------------------------------------------
#関数定義
def f(a,d,T):
    try:
        return T[d+1:].index(a)+(d+1)
    except ValueError:
        return len(T)

def g(a,d,T):
    try:
        return (d-1)-T[d-1::-1].index(a)
    except ValueError:
        return 0
#-------------------------------------------------------------------------------
#インポート
from math import inf,exp
from random import random,randint
import time
from copy import copy
#-------------------------------------------------------------------------------
#定数
TIME_LIMIT=1.862 #ループの時間制限  
A=26 #アルファベットの数
START=time.time()

TEMP=10 #アニーリング法の初期温度
ICE=0.000001 #アニーリング法で更新毎に減少する温度
#-------------------------------------------------------------------------------
#読み込み部
D=int(input())

C=[True]+list(map(int,input().split())) #減る満足度のベース
S=[True]*(D+1) #S[d][i] :(d+1)日目にコンテストiを開催した時の満足度

for i in range(1,D+1):
    S[i]=[0]+list(map(int,input().split()))           
#-------------------------------------------------------------------------------
#貪欲部
L=[0]*(A+1)
T=[0]
for d in range(1,D+1):
    Y=-inf
    E=0
    for a in range(1,A+1):
        X=S[d][a]
        for s in range(1,A+1):
            if a!=s:
                X-=C[s]*(d-L[s])

        if X>Y:
            Y=X
            E=a
    L[E]=d
    T.append(E)
#-------------------------------------------------------------------------------
#調節部
while time.time()-START<TIME_LIMIT:
    t=time.time()-START
    d=randint(1,D)
    p=T[d]
    q=randint(1,A)
    Y=(d-g(p,d,T))*(f(p,d,T)-d)
    Z=(d-g(q,d,T))*(f(q,d,T)-d)
        
    Delta=(S[d][q]-S[d][p])+Z*C[q]-Y*C[p]
    if (Delta>=0) or (Delta<0 and random()<exp(Delta/(TIME_LIMIT-t))):
        T[d]=q
    
for i in range(1,D+1):
    print(T[i])


### FIXED CODE ###

from random import randint
A=26

D=int(input())

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

S=[0]*D
for i in range(D):
    S[i]=list(map(int,input().split()))

for j in range(D):
    print(randint(1,A))
A, B, K = map(int, input().split())

list=[]
list= [i for i in range(10000) if A%i==0 and B%i==0]
list[K-1]

### FIXED CODE ###

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

list=[]
for i in range(1,10000):
    if (A%i==0 and B%i==0):
        list.append(i)
    else:
        continue

print(list[-K])
while True:
    n = int(raw_input())
    if n == 0:
        break
    m = int(raw_input())-1
    x = int(raw_input())-1
    d = int(raw_input())
    amida = []
    for i in range(d):
        amida.append(map(int, raw_input()))
    rroot = []
    for i in range(d-1,-1,-1):
        if x > 0:
            if amida[i][x-1] == 1:
                x -= 1
        if x < n-1:
            if amida[i][x] == 1:
                x += 1
        rroot.append(x)
    if m == x:
        print 0
    else:
        root = []
        for i in range(d):
            if m > 0:
                if amida[i][m-1] == 1:
                    m -= 1
            if m < n-1:
                if amida[i][m] == 1:
                    m += 1
            root.append(m)
        rroot.reverse()
        for i in range(d):
            if abs(root[i]-rroot[i]) == 1:
                p = min(root[i],rroot[i])
                if p == 0:
                    if amida[i][p+1] == 0:
                        print i+1, p+1
                        break
                elif p == n-2:
                    if amida[i][p-1] == 0:
                        print i+1, p+1
                        break
                else:
                    if amida[i][p-1] + amida[i][p+1] == 0:
                        print i+1, p+1
                        break
            if i == d-1:
                print 1

### FIXED CODE ###

while True:
    n = int(raw_input())
    if n == 0:
        break
    m,x,d = int(raw_input()),int(raw_input()),int(raw_input())
    amida = ["" for i in range(d)]
    for i in range(d):
        amida[i] = "0" + raw_input() + "0"
    rroot = []
    for i in range(d-1,-1,-1):
        if amida[i][x-1] == "1": x -= 1
        elif amida[i][x] == "1" : x += 1
        rroot.append(x)

    if m == x: print 0
    else:
        root = []
        for i in range(d):
            if amida[i][m-1] == "1": m -= 1
            elif amida[i][m] == "1" : m += 1
            root.append(m)
        rroot.reverse()
        for i in range(d):
            if abs(root[i]-rroot[i]) == 1:
                p = min(root[i],rroot[i])
                if int(amida[i][p-1]) + int(amida[i][p+1]) == 0:
                    print i+1, p
                    break
            if i == d-1: print 1
# 所持している鍵の集合をbitで表現する
#　鍵の集合を表す2進数が少なくなる方向に遷移することはないから，for文for文でかける

N, M = map(int, input().split())
status_money = [float('inf')] * (1 << N)
key_money = []

# 初期状態からの遷移を記録
for _ in range(M) :
    a, b = map(int, input().split())
    key_money.append(a)
    C = 0
    for c in input().split() :
        C |= (1 << int(c) - 1)
    status_money[C] = min(status_money[C], a)
    
# ある状態とある状態の組合せを全部取る
for c in range(1 << N):
    # どんな鍵の組合せでも到達できない宝箱の組合せがあるかもしれない
    if status_money[c] == float('inf'):
        continue
    for d in range(1 << N):
        # c と d の論理和をとって新しく生成される状態 e を考える
        e = c | d
        # eにあらかじめ格納されている最小コストと，今生成したコストとのminをとる
        status_money[e] = min(status_money[c] + status_money[d], status_money[e])

# そもそも到達できない場合の処理を記述       
if status_money[-1] == float('inf'):
    print(-1)
else:
    print(status_money[-1])

### FIXED CODE ###

import math
A, B = map(int, input().split())

def gcd(a, b):
	if b == 0: return(a)
	else : return gcd(b, a % b)
		
G = gcd(A, B)
ctr = 1
for i in range(2, int(math.sqrt(G)) + 1):
    if G == 1: 
        break
    if G % i == 0: 
        ctr += 1
    while G % i == 0:
        G /= i
        
if G == 1:        
    print(ctr)
else:
    print(ctr + 1)
import math
data = list(map(int,input().split()))
a = data[0]
b = data[1]
x = data[2]

c = a*a*b/2
d = a*a*b-x
if x>c:
  e = ((d/a)*2)/a
  t = a/e
  print(math.degrees(math.atan(t)))
else:
  f = ((x/a)*2)/b
  t = f/b
  print(90-math.degrees(math.atan(t)))

### FIXED CODE ###

import math
data = list(map(int,input().split()))
a = data[0]
b = data[1]
x = data[2]

c = a*a*b/2
d = a*a*b-x
if d==0:
  print(0)
else:
  if x>c:
    e = ((d/a)*2)/a
    t = a/e
    print(90-math.degrees(math.atan(t)))
  else:
    f = ((x/a)*2)/b
    t = f/b
    print(90-math.degrees(math.atan(t)))
N, M = map(int, input().split())
A = list(set((map(int, input().split()))))
vote = []
for Ai in A:
    if Ai >= (1 / (4 * M) * sum(A)):
        vote.append(Ai)
if len(vote) >= M:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a = input()
b = a.split()
print(b[2] + " " + b[0] + " " + b[1])
N, M = map(int, input().split())
S = []
for _ in range(M):
    ks = list(map(int, input().split()))
    S.append(ks[1:])
P = list(map(int, input().split()))

ans = 0
for i in range(2**M):
    bi = str(bin(i))[2:]
    bi = bi.zfill(M)
    isAddable = True
    for j in range(M):
        s_sum = 0
        for s in S[j]:
            if bi[s-1] == '1':
                s_sum += 1
        if s_sum % 2 != P[j]:
            isAddable = False
            break
    if isAddable:
        ans += 1
print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
s = []
for i in range(m):
    inputs = list(map(int, input().split()))
    k = inputs[0]
    s.append(inputs[1:])

p = list(map(int, input().split()))

res = 0
for i in range(2 ** n):
    flag = True
    bit_i = bin(i)[2:].zfill(n)
    for j in range(m):
        sum_s = 0
        for idx in s[j]:
            sum_s += int(bit_i[idx-1])
        if sum_s % 2 != p[j]:
            flag = False
            break
    if flag:
        res += 1

print(res)
a = readline()
b = readline()
c = readline()
print((a-b)%c)

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
print((a-b)%c)
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int n, k;
    scanf("%d %d", &n, &k);
    if (k == 1){
        printf("0\n");
    }else{
        while ((double)n >= (double)k / 2){
            n = abs(k - n);
        }
        printf("%d\n", n);
    }
    return 0;
}


### FIXED CODE ###

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

if k > n:
    tmp = n
else:
    tmp = n % k

if tmp > k / 2:
    tmp = k - tmp

print(tmp)
import math
from collections import Counter

mod = 10**9+7
n = int(input())
c = Counter()
cc = Counter()

for _ in range(n):
    a, b = map(int, input().split())
    a, b = a//math.gcd(a, b), b//math.gcd(a, b)
    if b < 0:
        a = -a
        b = -b
    if a == 0 and b == 0:
        c[-1] += 1
        continue

    key = a*(10**19)+b
    c[key] += 1
    cc[key] += 1

l = []

for r in cc.keys():
    if r == -1:
        continue
    ra = c[r]
    
    a, b = r//(10**19), r % (10**19)
    if a >= 0:
        r_inv = (-b)*10**19 + a
    else:
        r_inv = b*(10**19) - a
    rb = c[r_inv]

    if ra >= 0 and rb >= 0:
        l.append([ra, rb])
        c[r] -= 10**9
        c[r_inv] -= 10**9

ans = 1
for a, b in l:
    ans *= pow(2, a, mod)-1 + pow(2, b, mod)-1 + 1
    ans %= mod

ans = (ans-1) + c[-1]
ans %= mod

print(ans)


### FIXED CODE ###

import math
from collections import Counter

mod = 10**9+7
n = int(input())
c = Counter()
cc = Counter()

for _ in range(n):
    a, b = map(int, input().split())
    if b < 0:
        a = -a
        b = -b
    if a == 0 and b == 0:
        c[-1] += 1
        continue
    elif a != 0 and b == 0:
        a, b = 1, 0
    elif a == 0 and b != 0:
        a, b = 0, 1
    else:
        a, b = a//math.gcd(a, b), b//math.gcd(a, b)

    c[(a, b)] += 1
    cc[(a, b)] += 1

l = []

for r in cc.keys():
    if r == -1:
        continue
    ra = c[r]

    a, b = r
    if a == 0:
        r_inv = (1, 0)
    elif b == 0:
        r_inv = (0, 1)
    elif a > 0:
        r_inv = (-b, a)
    else:
        r_inv = (b, -a)
    rb = c[r_inv]

    if ra >= 0 and rb >= 0:
        l.append([ra, rb])
        c[r] -= 10**9
        c[r_inv] -= 10**9

ans = 1
for a, b in l:
    ans *= pow(2, a, mod)-1 + pow(2, b, mod)-1 + 1
    ans %= mod

ans = (ans-1) + c[-1]
ans %= mod

print(ans)
def solve(h, w):
    if h % 3 == 0 or w % 3 == 0:
        return 0
    if h == 1 or w == 1:
        return 1
    min_diff = h * w
    vals = [0, 0, 0]
    def f(a, b):
        for i in range(1, a // 2 + 1):
            vals[0] = i * b
            vals[1] = (a - i) * (b // 2 + b % 2)
            vals[2] = (a - i) * (b // 2)
            diff = max(vals) - min(vals)
            if diff < min_diff:
                min_diff = diff
            vals[1] = b * ((a - i) // 2 + (a - i) % 2)
            vals[2] = b * ((a - i) // 2)
            diff = max(vals) - min(vals)
            if diff < min_diff:
                min_diff = diff
    f(h, w)
    f(w, h)
    return min_diff

_h, _w = map(int, input().split())
print(solve(_h, _w))


### FIXED CODE ###

def solve(h, w):
    if h % 3 == 0 or w % 3 == 0:
        return 0
    if w < h:
        h, w = w, h
    if h == 1:
        return 1
    min_diff = h * w
    vals = [0, 0, 0]
    for i in range(1, w // 2 + 1):
        vals[0] = i * h
        if h % 2 == 0:
            vals[1] = (w - i) * (h // 2)
            vals[2] = vals[1]
        else:
            vals[1] = (w - i) * (h // 2 + 1)
            vals[2] = (w - i) * (h // 2)
        diff = max(vals) - min(vals)
        if diff < min_diff:
            min_diff = diff
        if (w - i) % 2 == 0:
            vals[1] = h * ((w - i) // 2)
            vals[2] = vals[1]
        else:
            vals[1] = h * ((w - i) // 2 + 1)
            vals[2] = h * ((w - i) // 2)
        diff = max(vals) - min(vals)
        if diff < min_diff:
            min_diff = diff
    h, w = w, h
    for i in range(1, w // 2 + 1):
        vals[0] = i * h
        if h % 2 == 0:
            vals[1] = (w - i) * (h // 2)
            vals[2] = vals[1]
        else:
            vals[1] = (w - i) * (h // 2 + 1)
            vals[2] = (w - i) * (h // 2)
        diff = max(vals) - min(vals)
        if diff < min_diff:
            min_diff = diff
        if (w - i) % 2 == 0:
            vals[1] = h * ((w - i) // 2)
            vals[2] = vals[1]
        else:
            vals[1] = h * ((w - i) // 2 + 1)
            vals[2] = h * ((w - i) // 2)
        diff = max(vals) - min(vals)
        if diff < min_diff:
            min_diff = diff
    return min_diff

_h, _w = map(int, input().split())
print(solve(_h, _w))
s=input();n=len(s);print(min(n*(s[i-1]==s[i])or max(i,n-i)for i in range(1,n)))

### FIXED CODE ###

s=input();n=len(s);print(min([max(i,n-i)for i in range(1,n)if s[i-1]!=s[i]]or[n]))
import math

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

R = 1 # 最小公倍数
# 最小公倍数を求める
for A in A_list:
    R = R * A // math.gcd(R, A)

# Bの合計を求める
ans = 0
for A in A_list:
    ans = ans + (R / A)

print("%d"%(ans%(pow(10,9)+7)))


### FIXED CODE ###

import fractions

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

mod = 10**9+7

R = 1 # 最小公倍数
# 最小公倍数を求める
for A in A_list:
    R *= A // fractions.gcd(R, A)

# Bの合計を求める
ans = 0
for A in A_list:
    ans = ans + R // A # 計算は小数として出してはダメだから//を使う

ans %= mod

print(ans)
import sys
line=[int(c) for c in sys.stdin.rstrip()]
length=len(line)
while True:
  line2=[]
  for i in range(len(line)-1):
    if line[i]!=2 and line[i]!=line[i+1]:
      line[i]=2
      line[i+1]=2
    elif line[i]!=2:
      line2.append(line[i])
  if len(line)!=0 and line[len(line)-1]!=2:
      line2.append(line[len(line)-1])
  if 2 in line:
    line=[i for i in line2]
  else:
    break
print(length-len(line))

### FIXED CODE ###

s=str(input())
if s.count('1')>s.count('0'):
    print(s.count('0')*2)
else:
    print(s.count('1')*2)