Harryxun/stf_run huggingface dataset:
import bisect
n=int(input())
A=list(map(int,input().split()))
S=[A[0]]
for i in range(n-1):
  S.append(S[-1]+A[i+1])
ans=10**15
for i in range(2,n-1):
  A1=A[0:i]
  A2=A[i:n]
  if len(A1)==2:
    M1=max(A1)
    m1=min(A1)
  else:
    x=bisect.bisect_left(S,S[i-1]//2,lo=0,hi=i+1)
    M11=max(S[x-1],S[i-1]-S[x-1])
    m11=min(S[x-1],S[i-1]-S[x-1])
    M12=max(S[x],S[i-1]-S[x])
    m12=min(S[x],S[i-1]-S[x])
    M1=min(M11,M12)
    m1=max(m11,m12)
  S2=[A[i]]
  for i in range(i+1,n):
    S2.append(S2[-1]+A[i])
  if len(A2)==2:
    M2=max(A2)
    m2=min(A2)
  else:
    x=bisect.bisect_left(S2,S2[-1]//2,lo=0,hi=len(S2))
    M21=max(S2[x-1],S2[-1]-S2[x-1])
    m21=min(S2[x-1],S2[-1]-S2[x-1])
    M22=max(S2[x],S2[-1]-S2[x])
    m22=min(S2[x],S2[-1]-S2[x])
    M2=min(M21,M22)
    m2=max(m21,m22)
  a=max(M1,M2)-min(m1,m2)
  if a<ans:
    ans=a
print(ans)

### FIXED CODE ###

n=int(input())
if n%2==0:
  print(n)
else:
  print(2*n)
import math
n, x = map(int, input().split())
cities = list(map(int, input().split()))
cities.append(x)
cities.sort()

def get_res(cities):
    if len(cities) == 2:
        return cities[1] - cities[0]

    gcds = []
    for i in range(len(cities) - 2):
        c1 = cities[i]
        c2 = cities[i + 1]
        c3 = cities[i + 2]
        gcds.append(math.gcd(c2 - c1, c3 - c2))

    return min(gcds)

print(get_res(cities))

### FIXED CODE ###

n, x = map(int, input().split())
cities = list(map(int, input().split()))
cities.append(x)
cities.sort()

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def get_res(cities):
    if len(cities) == 2:
        return cities[1] - cities[0]
    else:
        gcds = []
        for i in range(len(cities) - 2):
            c1 = cities[i]
            c2 = cities[i + 1]
            c3 = cities[i + 2]
            gcds.append(gcd(c2 - c1, c3 - c2))
        return min(gcds)

print(get_res(cities))
MOD=10**9+7
import bisect
N,K=[int(s) for s in input().split()]
ls=[int(s) for s in input().split()]
ls=sorted(ls)
s=bisect.bisect_left(ls,0)
t=bisect.bisect_right(ls,0)
mls=ls[:s]
pls=ls[t:]
M=s
P=N-t
ans=set()
#プラスの値にすること不可能か？
if (P==0 and K%2==1) or (N==K and M%2==1):
  #ゼロにできるか？
  if N-P-M>0:
    print(0)
  else:
    mls.reverse()
    mul=1
    if P==0:
      for i in range(K):
        mul*=mls[i]
    else:
      for i in range(N):
        mul*=ls[i]
    ans.add(mul)
    print(max(ans)%MOD)
else:
  als=sorted(ls, key=lambda x: -abs(x))
  mul=1
  for i in range(K):
    mul*=als[i]
  if mul>0:
    print(mul%MOD)
  else:
    ls2=als[:K]
    ls3=als[K:]
    ls2.sort()
    ls3.sort()
    ans=set()
    ans.add(mul*ls3[0]//ls2[-1])
    ans.add(mul*ls3[-1]//ls2[0])
    print(max(ans)%MOD)


### FIXED CODE ###

MOD=10**9+7
N,K=[int(s) for s in input().split()]
ls=[int(s) for s in input().split()]
ans=set()
ls=sorted(ls, key=lambda x: -abs(x))
mul=1
sign=0
zeroflag=0
flag=[0 for _ in range(N)]
for i in range(K):
  flag[i]=1
  if ls[i]<0:
    sign=(sign+1)%2
if sign==1:
  if 0 in ls:
    zeroflag=1
  a=[0,0,0,0]
  b=[0,0,0,0]
  for j in range(K,N):
    if ls[j]>0:
      for k in range(K):
        if ls[K-1-k]<0:
          a[0]=ls[j]
          b[0]=j
          a[1]=ls[K-1-k]
          b[1]=K-1-k
          break
      break
  for j in range(K,N):
    if ls[j]<0:
      for k in range(K):
        if ls[K-1-k]>0:
          a[2]=ls[j]
          b[2]=j
          a[3]=ls[K-1-k]
          b[3]=K-1-k
          break
      break
  if a==[0,0,0,0]:
    flag.reverse()
  elif b[0]==0 and b[1]==0:
    flag[b[2]]=1
    flag[b[3]]=0
  elif b[2]==0 and b[3]==0:
    flag[b[0]]=1
    flag[b[1]]=0
  elif abs(a[0]*a[3])>abs(a[1]*a[2]):
    flag[b[0]]=1
    flag[b[1]]=0
  else:
    flag[b[2]]=1
    flag[b[3]]=0
if sign==1 and a==[0,0,0,0] and zeroflag==1:
  print(0)
else:
  mul=1
  for i in range(N):
    if flag[i]==1:
      mul=mul*ls[i]%MOD
  print(mul)
N = int(input())
max_num = 1
cnt = 0
list_num = [int(x) for x in input().split()]
for i in range(len(list_num)):
	if max_num <= a:
		cnt += 1
		max_num = list_num[i]
print(cnt)

### FIXED CODE ###

N = int(input())
max_num = 1
cnt = 0
list_num = [int(x) for x in input().split()]
for i in range(len(list_num)):
	if max_num <= list_num[i]:
		cnt += 1
		max_num = list_num[i]
print(cnt)
M = map(int,input().split()) #N:スイッチ　＃M：電球
#print(N)

light=[]
for i in range(M):
    light.append(list(map(int,input().split())))
#print(light)


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

ans = 0
for i in range(2**N):
    #print("num {}" .format(i), end="")
    sw = [0]*N
    for j in range(N):
        if ((i >>j) & True):
            sw[j]=1

    else:
        pass
        #print(sw)

    #Ans =[]
    On_Light_nmb = 0
    for m in range(M): #電球ごとに判定
        sum = 0
        for k in range(light[m][0]):
            s_nmb = int(light[m][k+1])
            #print(s_nmb)
            #print(sw[s_nmb-1])
            sum += sw[s_nmb-1]

        if sum%2 == p[m]: #電球mのOnスイッチの合計が
            #Ans.append(1)
            On_Light_nmb +=1
            #print('light '+str(m)+' on')
        else:
            pass
            #Ans.append(0)
            #print('light '+str(m)+' off')

    #print('ans:'+str(ans))

    #もしすべてのライトがついていたら
    if On_Light_nmb == m+1:
        ans +=1

print(ans)

### FIXED CODE ###

N,M = map(int,input().split()) #N:スイッチ　＃M：電球
light=[]
for i in range(M):
    light.append(list(map(int,input().split())))



p = list(map(int,input().split()))
ans = 0
for i in range(2**N):
    #print("num {}" .format(i), end="")
    sw = [0]*N
    for j in range(N):
        if ((i >>j) & True):
            sw[j]=1
    On_Light_nmb = 0
    for m in range(M): #電球ごとに判定
        sum = 0
        for k in range(light[m][0]):
            s_nmb = int(light[m][k+1])
            sum += sw[s_nmb-1]

        if sum%2 == p[m]: #電球mのOnスイッチの合計が
            #Ans.append(1)
            On_Light_nmb +=1


    #もしすべてのライトがついていたら
    if On_Light_nmb == m+1:
        ans +=1

print(ans)
n = int(input())
w = list(map(int, input().split()))
s2 = ans = sum(w)
s1 = 0
for i in range(n-1):
  s2 -= w[i]
  s1 += w[i]
  if ans < abs(s2-s1):
    break:
  else:
	ans = abs(s2-s1)

print(ans)

### FIXED CODE ###

n = int(input())
w = list(map(int, input().split()))
s2 = ans = sum(w)
s1 = 0
for i in range(n-1):
  s2 -= w[i]
  s1 += w[i]
  if ans < abs(s2-s1):
    break
  else:
    ans = abs(s2-s1)

print(ans)
from math import gcd
n, k = map(int, input().split())
a = list(map(int, input().split()))
g = 0
for x in a:
    g = gcd(g, x)
print(("IMPOSSIBLE", "POSSIBLE")[k <= max(a) and k % g == 0])

### FIXED CODE ###

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

n, k = map(int, input().split())
a = list(map(int, input().split()))
g = a[0]
for x in a:
    g = gcd(g, x)
print(("IMPOSSIBLE", "POSSIBLE")[k <= max(a) and k % g == 0])
import sys
sys.setrecursionlimit(10000)

n = int(input())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))

rates = []
for i in range(3):
	if aa[i] > bb[i]:
		rates.append([bb[i], aa[i]])
	else:
		rates.append([aa[i], bb[i]])

memo = [-1 for _ in range(n + 1)]

#print(rates)

def dp(rest, obtained):
	#print(rest, obtained)
	if rest < 0:
		return -10000

	if memo[rest] != -1:
		return memo[rest]

	ans = max([dp(rest - rates[i][0],  obtained + rates[i][1]) for i in range(3)] + [rest + obtained])
	memo[rest] = ans
	return ans

print(dp(n, 0))
#print(memo)

### FIXED CODE ###

n = int(input())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))

rates_list = [[],[]]
for i in range(3):
	if aa[i] > bb[i]:
		rates_list[1].append([bb[i], aa[i]])
	else:
		rates_list[0].append([aa[i], bb[i]])

max_d = n
for j in range(2):
	rates = rates_list[j]
	if len(rates) == 1:
		max_d = (max_d // rates[0][0]) * rates[0][1] + max_d % rates[0][0]
	elif len(rates) == 2:
		val = [rates[0][1] * i for i in range(max_d // rates[0][0] + 1)]
		rest = [max_d - rates[0][0] * i for i in range(max_d // rates[0][0] + 1)]
		val = [val[i] + rates[1][1] * (rest[i] // rates[1][0]) + (rest[i] % rates[1][0]) if rest[i] > 0 else val[i] for i in range(len(val))]
		max_d = max(val)
	elif len(rates) == 3:
		dp = [(d // rates[0][0]) * rates[0][1] + d % rates[0][0] for d in range(max_d + 1)]
		for d in range(1, max_d + 1):
			dp[d] = max([dp[d]] + [dp[d - rates[i][0]] + rates[i][1] if d - rates[i][0] >= 0 else d for i in range(1, len(rates))])
		max_d = dp[-1]
print (max_d)
import math
K=int(input())
c = 0
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      c += math.gcd(i, j, k)
print(c)

### FIXED CODE ###

import math
K=int(input())
c = 0
for i in range(1,K+1):
  for j in range(1,K+1):
    if math.gcd(i,j) == 1:
      c += K
    else:
      for k in range(1,K+1):
        if i == j == k:
          c += i
        elif i == j:
          c += math.gcd(i,k)
        elif i == k:
          c += math.gcd(i,j)
        elif j == k:
          c += math.gcd(i,k)
        else:
          c += math.gcd(math.gcd(i, j), k)
print(c)
from sys import stdin
for line in stdin:
	if line == '0 ? 0':
		break
	tmp = line.strip('\n').split(' ')
	a, b = int(tmp[0]), int(tmp[-1])
	if tmp[1] == '+':
		print(a + b)
	elif tmp[1] == '-':
		print(a - b)
	elif tmp[1] == '*':
		print(a * b)
	elif tmp[1] == '/':
		print(a // b)



### FIXED CODE ###

from sys import stdin
for line in stdin:
	tmp = line.strip('\n').split(' ')
	a, b = int(tmp[0]), int(tmp[-1])
	if tmp[1] == '+':
		print(a + b)
	elif tmp[1] == '-':
		print(a - b)
	elif tmp[1] == '*':
		print(a * b)
	elif tmp[1] == '/':
		print(a // b)
	else:
		break
#D
N, K = map(int,input().split())
A = list(map(int,input().split()))

now = 0
visited = [0]
visited_set = set([0])

for i in range(K):
    now = A[now] - 1
    if now in visited_set:
        roop_start = now
        break
    visited.append(now)
    visited_set.add(now)
    
ind = visited.index(roop_start)
roop = visited[ind:]

if len(roop) != 0:
    print(roop[(K-ind)%len(roop)]+1)
else:
    print(visited[K-1]+1)

### FIXED CODE ###

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

now = 0
visited = [0]
visited_set = set([0])

for i in range(K):
    now = A[now] - 1
    if now in visited_set:
        break
    visited.append(now)
    visited_set.add(now)
if len(visited) == N:
    print(visited[K-1]+1)
else:    
    ind = visited.index(now)
    roop = visited[ind:]
    print(roop[(K-ind)%len(roop)]+1)
# -*- coding:utf-8 -*-
n, m = map(int, input().strip().split())
digit = {}
for i in range(m):
    tmp_d, tmp = map(int, input().strip().split())
      
    if ((tmp_d == 1) and (tmp == 0)):
        print(-1)
        exit()
    elif (tmp_d in digit.keys()) and (digit[tmp_d] != tmp):
        print(-1)
        exit()
    else:
        digit[tmp_d] = tmp
 
 
    
ans = 0
for key in digit.keys():
    ans += digit[key]*(10**(n-key))
 
if (ans // n == 0) and n >= 2:
  ans += 1*(10**(n-1))
print(ans)
# -*- coding:utf-8 -*-
n, m = map(int, input().strip().split())
digit = {}
for i in range(m):
    tmp_d, tmp = map(int, input().strip().split())
      
    if ((tmp_d == 1) and (tmp == 0)):
        print(-1)
        exit()
    elif (tmp_d in digit.keys()) and (digit[tmp_d] != tmp):
        print(-1)
        exit()
    else:
        digit[tmp_d] = tmp
 
 
    
ans = 0
for key in digit.keys():
    ans += digit[key]*(10**(n-key))
 
if (ans // (10*(n-1)) == 0) and n >= 2:
  ans += 1*(10**(n-1))
print(ans)

### FIXED CODE ###

# -*- coding:utf-8 -*-
n, m = map(int, input().strip().split())
ans = 0

digit ={}
for i in range(m):
    tmp_d, tmp = map(int, input().strip().split())
       	
    if (tmp_d in digit.keys()) and (digit[tmp_d] != tmp):
        print(-1)
        exit()
    else:
        digit[tmp_d] = tmp
      
      
if not (1 in digit.keys()) and n>=2:
	digit[1] = 1
    
ans = 0
for key in digit.keys():
  ans += digit[key]*(10**(n-key))

if len(str(ans)) == n: 
  print(ans)
else:
  print(-1)
import sys
from collections import Counter
from math import gcd

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
C = Counter()
for i in range(N):
    a, b = MAP()
    g = gcd(a, b)
    ga, gb = a // g, b // g
    C[((a < 0) ^ (b < 0), abs(ga), abs(gb))] += 1

ans = 1
for k, v in C.items():
    if v == 0:
        continue
    op, a, b = k
    ans *= pow(2, C[(op, a, b)], MOD) + pow(2, C[(1-op, b, a)], MOD) - 1
    if (1-op, b, a) in C:
        C[(1-op, b, a)] = 0
print(ans)


### FIXED CODE ###

import sys
from collections import Counter
from math import gcd

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
C = Counter()
zero = 0
for i in range(N):
    a, b = MAP()
    if a == b == 0:
        zero += 1
    elif a == 0:
        C[(0, 1, 0)] += 1
    elif b == 0:
        C[(1, 0, 1)] += 1
    else:
        g = gcd(a, b)
        ga, gb = a // g, b // g
        C[((a < 0) ^ (b < 0), abs(ga), abs(gb))] += 1

ans = 1
for k, v in C.items():
    if v == 0:
        continue
    op, a, b = k
    ans *= pow(2, C[(op, a, b)], MOD) + pow(2, C[(1-op, b, a)], MOD) - 1
    ans %= MOD
    if (1-op, b, a) in C:
        C[(1-op, b, a)] = 0
print((zero+ans-1)%MOD)
n = input()
a = list(map(int, input().split()))
max_a_list = [0]*n
max_a_list[0] = a[0]

for i in range(1,n):
  max_a_list[i] = max(max_a_list[i - 1],a[i])
sum_ = 0
for i in range(n):
  sum_ += max(max_a_list[i] - a[i], 0)
print(sum_)



### FIXED CODE ###

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

for i in range(1,n):
  max_a_list[i] = max(max_a_list[i - 1],a[i])
sum_ = 0
for i in range(n):
  if max_a_list[i] > a[i]:
    sum_ += max_a_list[i] - a[i]
print(sum_)
n = input().split()
vs = list(map(int, input().split()))

eve = {}
odd = {}

for i in range(len(vs)):
    if i % 2 == 0:
        if vs[i] in eve:
            eve[vs[i]] += 1
        else:
            eve[vs[i]] = 1
    else:
        if vs[i] in odd:
            odd[vs[i]] += 1
        else:
            odd[vs[i]] = 1

es = sorted(eve.items(), key=lambda x: -x[1])
os = sorted(odd.items(), key=lambda x: -x[1])

if es[0][0] == os[0][0]:
    if es[0][1] > os[0][1]:
        del es[0]
        if len(os) > 1 :
            del os[1]
    elif es[0][1] < os[0][1]:
        del os[0]
        if len(es) > 1 :
            del es[1]
    else:
        if len(es) == 1:
            del es[0]
            del os[1]
        elif len(os) == 1:
            del es[1]
            del os[0]
        else:
            if es[1][1] < os[1][1]:
                del es[0]
                del os[1]
            else:
                del es[0]
                del os[1]



else:
    del os[0]
    del es[0]

trans = 0

for i in range(len(es)):
    trans += es[i][1]
for i in range(len(os)):
    trans += os[i][1]

print(trans)

### FIXED CODE ###

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

eve = {}
odd = {}

for i in range(len(vs)):
    if i % 2 == 0:
        if vs[i] in eve:
            eve[vs[i]] += 1
        else:
            eve[vs[i]] = 1
    else:
        if vs[i] in odd:
            odd[vs[i]] += 1
        else:
            odd[vs[i]] = 1

es = sorted(eve.items(), key=lambda x: -x[1])
os = sorted(odd.items(), key=lambda x: -x[1])

if es[0][0] == os[0][0]:
    if es[0][1] > os[0][1]:
        del es[0]
        if len(os) > 1 :
            del os[1]
    elif es[0][1] < os[0][1]:
        del os[0]
        if len(es) > 1 :
            del es[1]
    else:
        if len(es) == 1 and len(os) == 1:
            del os[0]
        elif len(es) == 1 and len(os) != 1:
            del es[0]
            del os[1]
        elif len(es) != 1 and len(os) == 1:
            del es[1]
            del os[0]
        else:
            if es[1][1] < os[1][1]:
                del es[0]
                del os[1]
            else:
                del es[1]
                del os[0]
else:
    del os[0]
    del es[0]

trans = 0

for i in range(len(es)):
    trans += es[i][1]
for i in range(len(os)):
    trans += os[i][1]

print(trans)
if S[2]==S[3] and S[4]==S[5]:
    print("Yes")
else : 
    print("No")


### FIXED CODE ###

S=input()
if S[2]==S[3] and S[4]==S[5]:
    print("Yes")
else : 
    print("No")
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    a.sort()
    yn = [0]*(10**6+1)
    for i in a:
        yn[i] += 1

    def yakusu(n):
        if n == 1:
            return []
        ys = [1]
        ni = 2
        while ni**2 <= n:
            if n%ni == 0:
                ys.append(ni)
                ys.append(n//ni)
            ni += 1
        return ys

    if a[0] == 1:
        if a[1] == 1:
            print(0)
            exit()
        print(1)
        exit()

    ans = 0
    for i in a:
        f = True
        if yn[i] != 1:
            continue
        ni = 2
        while ni**2 <= i:
            if i%ni == 0:
                if yn[ni]:
                    f = False
                    break
                if yn[i//ni]:
                    f = False
                    break
            ni += 1
        if f:
            ans += 1

    print(ans)

    return

if __name__ == '__main__':
    main()


### FIXED CODE ###

import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    a.sort()
    ma = max(a)+1
    al = [True]*ma
    ans = 0
    pi = 0
    for i in a:
        if al[i]:
            ans += 1
            for j in range(i,ma,i):
                al[j] = False
            pi = i
        else:
            if i == pi:
                ans -= 1
                pi = 0

    print(ans)

    return

if __name__ == '__main__':
    main()
def LCS(str1,str2):
    A = [0 for _ in range(len(str2)+1)]
    for i in range(len(str1)):
        A_copy = A[:]
        for j in range(len(str2)):
            if(str1[i]==str2[j]):
                (int)A[j+1] = (int)A_copy[j]+1
            elif((int)A[j] > (int)A[j+1]):
                (int)A[j+1] = (int)A[j]
    print(A[-1])


m = int(input())
for i in range(m):
    str1 = input()
    str2 = input()
    LCS(str1,str2)


### FIXED CODE ###

def LCS(str1,str2):
    A = [0 for _ in range(len(str2)+1)]
    for i in range(len(str1)):
        A_copy = A[:]
        for j in range(len(str2)):
            if(str1[i]==str2[j]):
                A[j+1] = A_copy[j]+1
            elif(A[j] > A[j+1]):
                A[j+1] = A[j]
    print(A[-1])


m = int(input())
for i in range(m):
    str1 = input()
    str2 = input()
    LCS(str1,str2)
N, K = map(int, input().split())
li = []
for i in range(N):
  li.append(int(input())

member = [ x for j in li if x >= K]
print(len(member))


### FIXED CODE ###

N, K, *H = map(int, open(0).read().split())
li = [i for i in H if i >= K]
print(len(li))
# find-union

import sys
input = sys.stdin.readline

#木の根を求める
def find(x):
    if par[x] == x:
        return x
    else:
        return find(par[x])

#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)

    if x != y:
        #xとyの属している集合が異なるとき
        if rank[x] < rank[y]:
            par[x] = y
            size[y] += size[x]
        else:
            par[y] = x
            size[x] += size[y]
            if rank[x] == rank[y]:
                rank[x] += 1

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#################################

#初期化
n,m = map(int,input().split())

par = [0]*n     #親
for i in range(n):
    par[i] = i
rank = [1]*n    #深さ
size = [1]*n    #size[i]:iを根とするグループのサイズ

edge = [tuple(map(int,input().split())) for i in range(m)]
edge = edge[::-1]

res = []
for i in range(m):
    fi = find(edge[i][0])
    se = find(edge[i][1])
    if fi == se:
        res.append(0)
    else:
        res.append(size[fi]*size[se])
        unite(fi,se)
ass  = 0
for i in range(m):
    ass += res[m-1-i]
    print(ass)

### FIXED CODE ###

# find-union

import sys
input = sys.stdin.readline

#木の根を求める
def find(x):
    if par[x] == x:
        return x
    else:
        return find(par[x])

#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)

    if x != y:
        #xとyの属している集合が異なるとき
        if rank[x] < rank[y]:
            par[x] = y
            size[y] += size[x]
        else:
            par[y] = x
            size[x] += size[y]
            if rank[x] == rank[y]:
                rank[x] += 1

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#################################

#初期化
n,m = map(int,input().split())

par = [0]*(n+1)     #親
for i in range(n):
    par[i] = i
rank = [1]*(n+1)    #深さ
size = [1]*(n+1)    #size[i]:iを根とするグループのサイズ

edge = [tuple(map(int,input().split())) for i in range(m)]
edge = edge[::-1]

res = []
for i in range(m):
    fi = find(edge[i][0])
    se = find(edge[i][1])
    if fi == se:
        res.append(0)
    else:
        res.append(size[fi]*size[se])
        unite(fi,se)
ass  = 0
for i in range(m):
    ass += res[m-1-i]
    print(ass)
import bisect
a,b,q=map(int,input().split())
ls=[-10**11]
lg=[-10**11]
for i in range(a):
  ls.append(int(input()))
for i in range(b):
  lg.append(int(input()))
ls.append(10**11)
lg.append(10**11)
ls=sorted(ls)
lg=sorted(lg)
for i in range(q):
  x=int(input())
  i1=bisect.bisect_left(ls,x)
  i2=bisect.bisect_left(lg,x)#xはi-1~iにある
  l1=[i1,i1+1]
  l2=[i2,i2+1]
  ans1=10**10
  ans2=10**10
  for i in l1:
    for j in l2:
      ans3=abs(x-ls[i])+abs(ls[i]-lg[j])
      if ans3<ans1:
        ans1=ans3
      ans4=abs(x-lg[j])+abs(ls[i]-lg[j])
      if ans4<ans2:
        ans2=ans4
  print(min(ans1,ans2))

### FIXED CODE ###

import bisect
a,b,q=map(int,input().split())
ls=[-10**11]
lg=[-10**11]
for i in range(a):
  ls.append(int(input()))
for i in range(b):
  lg.append(int(input()))
ls.append(10**11)
lg.append(10**11)
ls=sorted(ls)
lg=sorted(lg)
for i in range(q):
  x=int(input())
  i1=bisect.bisect_left(ls,x)
  i2=bisect.bisect_left(lg,x)#xはi-1~iにある
  d1=x-ls[i1-1]
  d2=ls[i1]-x
  d3=x-lg[i2-1]
  d4=lg[i2]-x
  d5=abs(ls[i1-1]-lg[i2-1])
  d6=abs(ls[i1]-lg[i2-1])
  d7=abs(ls[i1-1]-lg[i2])
  d8=abs(ls[i1]-lg[i2])
  ans1=d1+d5
  ans2=d1+d7
  ans3=d2+d6
  ans4=d2+d8
  ans5=d3+d5
  ans6=d3+d6
  ans7=d4+d7
  ans8=d4+d8
  print(min(ans1,ans2,ans3,ans4,ans5,ans6,ans7,ans8))
import sys
for i in sys.stdin:
  inl=map(int, raw_input().split())
  num=inl[0]+inl[1]
  a=list(str(num))

  time=0
  for i in a:
    time+=1

  print time

### FIXED CODE ###

import sys

a = []
for line in sys.stdin:
    a.append(line)

for n in a:
    inl=n.split()
    num=int(inl[0])+int(inl[1])
    l=list(str(num))
    time=0
    for i in l:
        time+=1
    print time