Harryxun/stf_run huggingface dataset:
def main():
    a, b, m = map(int, input().split())
    priceOfMicrowaves = list(map(int, input().split()))
    priceOfRefrigerators = list(map(int, input().split()))
    priceTable = [list(map(int,input().split())) for i in range(m)]
    cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
    for price in priceTable:
        if priceOfMicrowaves[price[0]-1] >= cheepest:
            continue
        elif priceOfMicrowaves[price[1]-1] >= cheepest:
            continue
        if priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
            cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
    for p in priceOfMicrowaves:
        if p >= cheepest:
            continue
        for q in priceOfRefrigerators:
            if q >= cheepest:
                continue
            if p + q < cheepest:
                cheepest = p + q
    print(cheepest)
    
main()

### FIXED CODE ###

a, b, m = map(int, input().split())
priceOfMicrowaves = list(map(int, input().split()))
priceOfRefrigerators = list(map(int, input().split()))
priceTable = [list(map(int,input().split())) for i in range(m)]
cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
for price in priceTable:
    if priceOfMicrowaves[price[0]-1]-price[2] >= cheepest:
        continue
    elif priceOfRefrigerators[price[1]-1]-price[2] >= cheepest:
        continue
    elif priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
        cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
if cheepest > min(priceOfMicrowaves) + min(priceOfRefrigerators):
    cheepest = min(priceOfMicrowaves) + min(priceOfRefrigerators)
print(cheepest)
date = list(map(int, input().split("/")))
if date[0] >= 2019:
	if date[1] >= 5:
		print("TBD")
    else:
      	print("Heisei")
else:
	print("Heisei")


### FIXED CODE ###

date = list(map(int, input().split("/")))
if date[0] >= 2019 and date[1] >= 5:
	print("TBD")
else:
  print("Heisei")
from collections import Counter

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

ans = 0
if p in {2, 5}:
    for i, num in enumerate(s):
        if num % p == 0:
            ans += i + 1
else:
    modp = [0]
    for num in s[::-1]:
        tmp = modp[-1] + pow(10, i, p) * num
        modp.append(tmp % p)
    cnt = [0] * p
    for i in modp:
        ans += cnt[i]
        cnt[i] += 1
print(ans)

if p == 3:
    print('hoge')

### FIXED CODE ###

from collections import Counter

n, p = map(int, input().split())
s = input()

ans = 0

if p in {2, 5}:
    lst = set(i for i in range(0, 10, p))
    for i, num in enumerate(s):
        if int(num) in lst:
            ans += i + 1
else:
    num = [int(s[-1]) % p]
    for i in range(1, len(s)):
        tmp = num[-1] + pow(10, i, p) * int(s[-i - 1])
        num.append(tmp % p)
    mod = [1] + [0] * (p - 1)
    for i in num:
        ans += mod[i]
        mod[i] += 1
print(ans)
import sys
s = input()
k = int(input())
ret = 0
t = 0

s = s*k

for j in range(1, len(s)):
    for i in range(len(s)-j):
        for u in range(j):
            if s[i + u] != s[i + u + 1]:
                break
            if u == j-1:
                if j % 2==1:
                    t += 1
                else:
                    t -= 1


print(t)

### FIXED CODE ###

import sys
s = input()
k = int(input())
ret = 0
t = 0
ss = []
ss.append(s[0])
for i in range(1, len(s)):
    if s[i-1] == s[i]:
        ss[-1]+=s[i]
    else:
        ss.append(s[i])

for ss_ in ss[1:-1]:
    ret += len(ss_) // 2 * k

if len(ss) >= 3:
    if ss[0][0] != ss[-1][0]:
        ret += len(ss[0]) // 2 * k
        ret += len(ss[-1]) // 2 * k
    else:
        ret += (len(ss[-1]) + len(ss[0]))  // 2 * (k-1)
        ret += len(ss[0]) // 2
        ret += len(ss[-1]) // 2

if len(ss) == 1:
    ret += len(ss[0]) * k // 2

if len(ss) == 2:
    ret += len(ss[0]) * k // 2
    ret += len(ss[1]) * k // 2

print(ret)
N = int(input())
DX = list(int(i) for i in input().split())
A = []
for i in range(N):
     A.append(input())
    
ai =[]
ans = N + DX[1]
for i in range(N):
    for n in range(DX[0]):
        if n*A[i]+1 <= DX[0]:
            ai.append(n)
    ans += max(ai)
    ai = []
print(ans)


### FIXED CODE ###

A = int(input())
B = int(input())
C = int(input())
D = int(input())
train = [A,  B]
bus = [C, D]
ans = min(train) + min(bus)
print(ans)
H, W, K = map(int, input().split())
S = list(input() for i in range(H))

sum = [[0] * (W+1) for i in range((H+1))]
for i in range(H):
    for j in range(W):
        sum[i+1][j+1] = sum[i][j+1] + sum[i+1][j] - sum[i][j] + (1 if s[i][j] == '1' else 0)

ans = H + W - 2

for ptn in range(1<<H-1): # 2^H - 1 通り
    cand = 0

    sep = [0] # 横方向の分割リスト、ここ天才
    for i in range(H-1):
        if((ptn >> i) & 1): # & を取ることで、上の桁を消せる
            sep.append(i+1)
            cand += 1
    sep.append(H)

    left = 0 # left は直前の分割
    for pos in range(W):
    	cur = [] # cur は今見てるホワイトチョコの個数のリスト

    	# 横方向に分割されている各部分について
    	for i in range(len(sep) - 1):
    		cur.append(sum[sep[i+1]][pos+1] - sum[sep[i+1]][left] - sum[sep[i]][pos+1] + sum[sep[i]][left])

    	if max(cur) > K:
    		if left == pos: # 縦に分割できない場合(一列しかない場合)
    			cand = H * W
    			break
    		else:
    			cand += 1
    			left = pos

    ans = min(ans, cand)

   print(ans)


### FIXED CODE ###

H, W, K = map(int, input().split())
S = list(input() for i in range(H))

sum = [[0] * (W+1) for i in range((H+1))]
for i in range(H):
    for j in range(W):
        sum[i+1][j+1] = sum[i][j+1] + sum[i+1][j] - sum[i][j] + (1 if S[i][j] == '1' else 0)

ans = H + W - 2

for ptn in range(1<<H-1): # 2^H - 1 通り
    cand = 0

    sep = [0] # 横方向の分割リスト、ここ天才
    for i in range(H-1):
        if((ptn >> i) & 1): # & を取ることで、上の桁を消せる
            sep.append(i+1)
            cand += 1
    sep.append(H)

    left = 0 # left は直前の分割
    for pos in range(W):
    	cur = [] # cur は今見てるホワイトチョコの個数のリスト

    	# 横方向に分割されている各部分について
    	for i in range(len(sep) - 1):
    		cur.append(sum[sep[i+1]][pos+1] - sum[sep[i+1]][left] - sum[sep[i]][pos+1] + sum[sep[i]][left])

    	if max(cur) > K:
    		if left == pos: # 縦に分割できない場合(一列しかない場合)
    			cand = H * W
    			break
    		else:
    			cand += 1
    			left = pos

    ans = min(ans, cand)

print(ans)
N,K=map(int,input().split())
P=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=-10**10
for st in range(N):
  now = st+1
  temp=[0]
  while(P[now-1] != st+1):
    temp.append(temp[-1]+C[P[now-1]-1])
    now = P[now-1]
    temp.append(temp[-1]+C[P[now-1]-1])
  if len(temp)>=K+1:
    ans=max(ans, max(temp[1:K+1]))
    continue
  if temp[-1]<=0:
    ans = max(ans, (max(temp[1:])))
  else:
    t=temp[-1]*(K//(len(temp)-1))-temp[-1]
    t+=max(temp+[temp[-1]+temp[i+1] for i in range(K%(len(temp)-1)+1)])
    ans=max(ans, t)
		
print(int(ans))


### FIXED CODE ###

S=input().strip("¥n")

if S=="RRR":
	print(3)
elif "RR" in S:
	print(2)
elif "R" in S:
	print(1)
else:
	print(0)
x = int(input())

if x=>30:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

x = int(input())

if x>=30:
  print("Yes")
else:
  print("No")
num = int(input())
if num % 2 == 0:	
     print(n/2)
else:
     print(n/2+1)

### FIXED CODE ###

num = int(input())
if num % 2 == 0:	
    print(int(num/2))
else:
    print(int(num/2+1))
import math

rawUsrInput = input()
usrInput = rawUsrInput.split()

a = int(usrInput[0])
b = int(usrInput[1])
x = int(usrInput[2])

print(((math.degrees(math.acos(((2*x)/a*b)/(math.sqrt(((4*x*x)/a*a*b*b)+b*b)))))))

### FIXED CODE ###

usrInput = input()
splitedInput = usrInput.split()
clearFlag = []

for i in range(2):
    if int(splitedInput[i]) < 10:
        clearFlag.append(True)
    else:
        clearFlag.append(False)

if bool(clearFlag[0]) == True and bool(clearFlag[1]) == True:
    print(int(splitedInput[0]) * int(splitedInput[1]))
else:
    print(-1)
n = input()
dishes = []
for i in range(int(n)):
    tmp = [int(each) for each in input().split()]
    dishes.append((tmp[0] - tmp[1], tmp[0], tmp[1]))

sorted(dishes, key=lambda v: v[0], reverse=True)

point = [0, 0]
player = 0
while len(dishes[0]) > 0:
    if player == 0:
        dish = dishes.pop(0)
    else:
        dish = dishes.pop(len(dishes) - 1)

    # remove dish
    dishes.remove(dish)

    point[player] += dish[player + 2]
    player = int(not player)
print(point[0] - point[1])


### FIXED CODE ###

n = input()
dishes = []
for i in range(int(n)):
    tmp = [int(each) for each in input().split()]
    dishes.append((abs(tmp[0] + tmp[1]), tmp[0], tmp[1]))

dishes = sorted(dishes, key=lambda x: x[0], reverse=True)

point = [0, 0]
player = 0
while len(dishes) > 0:
    dish = dishes.pop(0)
    point[player] += dish[player + 1]
    player = int(not player)
print(point[0] - point[1])
import collections
a = int(input())
l = []
for i in range(a):
    l.append(input())
counted = collections.Counter(l)

# 最頻値を求める
m = max(counted.values())

# 頻出数の文字を集める
chars = [key for key, value in counted.items()
             if value == m]

for i in chars:
    print(i)

### FIXED CODE ###

a,b,c = input().split()
d = 0
if a == b:
    if a != c:
        d +=1
if a == c:
    if b != c:
        d +=1
if c == b:
    if a != c:
        d +=1
if d>0:
    print("Yes")
else:
    print("No")
n = int(input())
dat =list(input().split())

for i in dat:
	i = int(i)

dat.sort(reverse=True)

asum = 0
bsum = 0

for i in range(n)
     if i % 2 == 0:
         asum = asum + dat[i]
     else:
         bsum = bsum + dat[i]
		
print(asum-bsum)

### FIXED CODE ###

n = int(input())
dat = list(input().split())

dat = list(map(int,dat))

dat.sort(reverse=True)

asum = 0
bsum = 0

for i in range(n):
	if i % 2 == 0:
		asum = asum + dat[i]
	else:
		bsum = bsum + dat[i]
		
print(asum-bsum)
# -*- coding: utf-8 -*-

X= int(raw_input().split())

a = 0
while X >0:
    a += 1
    X -= a
print a

### FIXED CODE ###

# -*- coding: utf-8 -*-

X= int(raw_input())

a = 0
while X >0:
    a += 1
    X -= a
print a
n,k=map(int,input().split())
l=list(map(int,input().split()))
list=[l[0]]
num=0
while True:
  if l[list[num]-1] in list:
    break
  list.append(l[list[num]-1])
  num+=1
y=list.index(l[list[num]-1])
x=len(list)-y
ans=list[y:]
print(ans[(k-y)%x-1])
n,k=map(int,input().split())
l=list(map(int,input().split()))
list=[l[0]]
num=0
while True:
  if l[list[num]-1] in set(list):
    break
  list.append(l[list[num]-1])
  num+=1
y=list.index(l[list[num]-1])
x=len(list)-y
ans=list[y:]
print(ans[(k-y)%x-1])
提出情報 


### FIXED CODE ###

import itertools
n,m,x=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
sum=[0]*m
for i in range(n):
  for j in range(1,m+1):
    sum[j-1]+=l[i][j]
for ss in sum:
  if ss<x:
    print(-1)
    exit()
list=[]
for p in itertools.product([1,0],repeat=n):
  cnt=[0]*m
  ans=0
  for i in range(n):
    if p[i]==1:
      ans+=l[i][0]
      for j in range(1,m+1):
        cnt[j-1]+=l[i][j]
  if all(cc>=x for cc in cnt):
    list.append(ans)
print(min(list))
n = int(input())
result = 1
for i in range(n):
  result *= int(input())

if result > 10 ^ 18:
  print(-1)
else:
  print(result)

### FIXED CODE ###

n =int(input())
ls =[]
ls =list(map(int,input().split()))
if 0 in ls:
	print(0)
else:
	ans = 1
	for a in ls:
		ans *= a
		if ans > 10 ** 18:
			ans = -1;
			break
		
	print(ans)
while 1:
   x, y = map(int, raw_input().split())
   if x == 0 and y == 0:
      break
   elif y < x:
      print '%s %s' %(y, x)
   else:
      print '%s %s' %(x, y)
    

### FIXED CODE ###

while 1:
   x, y = map(int, raw_input().split())
   if x == 0 and y == 0:
      break
   elif x > y:
      print '%s %s' % (y,x)
   else:
      print '%s %s' % (x,y)
from string import*;from itertools import*;b=ascii_lowercase;r=s=input();d=l=len(s);t=s[::-1];o=1
if l>25:d=-[p*len(list(k))for p,k in groupby([i<j for i,j in zip(s[::-1],s[-2::-1])])][0]-2;s,b,o=s[:d],s[d+1:],0
print(-(d<-26)or s+sorted(set(b)-set(s*o or b[:ord(s[d])-97]))[0])

### FIXED CODE ###

#!/usr/bin/env python3
from string import*
from itertools import*
b = ascii_lowercase
s = input()
l = len(s)
if l < 26:
    print(s + sorted(set(b) - set(s))[0])
else:
    t = s[::-1]
    a = [(p, len(list(k))) for p, k in groupby([i < j for i, j in zip(t, t[1:])])][0]
    d = - a[0]*a[1] - 2
    print(-(d < -26) or s[:d] + sorted(set(s[d+1:]) - set(b[:ord(s[d]) - 97]))[0])
a


### FIXED CODE ###

li=list(str(input()))
if '7' in li:
    print('Yes')
else:
    print('No')
import math
from itertools import accumulate
from typing import List, Set


class Job:

    def __repr__(self):
        return f'Job(reward={self.reward}, days={self.days})'

    def __init__(self, reward: int, days: int):
        self.reward = reward
        self.days = days


def dfs(jobs: Set[Job], remaing_days: int, selected_jobs: Set[Job]) -> int:
    reward = 0

    # print(jobs, remaing_days)

    if remaing_days == 0:
        return 0

    for job in jobs:
        if job.days <= remaing_days:
            # print(
            #     f'trying {job} sum: {reward} remaing_days:{remaing_days} selected:{selected_jobs}')

            next_selected_jobs = selected_jobs | set([job])
            remaining_jobs = jobs - set([job])
            new_reward = job.reward + \
                dfs(remaining_jobs, remaing_days - 1, next_selected_jobs)

            # if reward < new_reward:
            #     print(
            #          f'pickup {job} sum: {new_reward} remaing_days:{remaing_days} selected:{selected_jobs}')
            reward = max(reward, new_reward)
        # else:
        #     print(
        #         f'fail to pickup {job} sum: {reward} remaing_days:{remaing_days} selected:{selected_jobs}')

    return reward


N, M = list(map(int, input().split()))
jobs: Set[Job] = set()

for i in range(N):
    A, B = list(map(int, input().split()))
    jobs.add(Job(reward=B, days=A))

print(dfs(jobs, M, set()))


### FIXED CODE ###

import heapq


class Job:

    def __repr__(self):
        return "%d,%d".format(self.days, self.reward)

    def __lt__(self, other):
        return self.reward < other.reward

    def __init__(self, job_id, reward, days):
        self.id = job_id
        self.reward = reward
        self.days = days

N, M = list(map(int, input().split()))
h = []
jobs = []

for i in range(N):
    A, B = list(map(int, input().split()))
    jobs.append(Job(job_id=i, reward=B, days=A))


jobs = sorted(jobs, key=lambda j: j.days)
idx = 0
c = 0

for i in range(1, M+1):
    while idx < N and jobs[idx].days <= i:
        heapq.heappush(h, -jobs[idx].reward)
        idx += 1

    if len(h) != 0:
        c += -heapq.heappop(h)

print(c)
# coding: utf-8
N = int(input())
li = [True for _ in range(0, 2*10**5 + 1)]
A = list(map(int, input().split()))
A.sort()
ans = 0
for i in range(N):
    if li[A[i]]:
        ans += 1
    for j in range(A[i], 2*10**5 + 1, A[i]):
        li[j] = False
ans -= len(A) - len(set(A))
print(max(0, ans))

### FIXED CODE ###

# coding: utf-8
N = int(input())
li = [True for _ in range(0, 10**6 + 1)]
A = list(map(int, input().split()))
A.sort()
used = {}
for i in range(N):
    if A[i] not in used.keys():
        used[A[i]] = 1
    else:
        used[A[i]] += 1
ans = 0
for k in used.keys():
    if used[k] > 1:
        for j in range(k, 10**6 + 1, k):
            li[j] = False
for i in range(N):
    if li[A[i]] and used[A[i]] == 1:
        ans += 1
    else:
        continue
    for j in range(A[i], 10**6 + 1, A[i]):
        li[j] = False
print(ans)
N, Q = map(int, input().split())
S=list(input())
list=[]
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        list.append[i]
lis=[]
count=0
for j in range(Q):
    l, r = map(int, input().split())
    for h in range(l-1, r-2):
        lis.append(h)
        count+=len(set(list) & set(lis))
print(count)

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()

ans = [0]*N
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        ans[i+1] += (ans[i]+1)
    else:
        ans[i+1] = ans[i] 

for i in range(Q):
    l, r = map(int, input().split())
    print(ans[r-1] - ans[l-1])
#from collections import defaultdict
from copy import copy
n = int(input())
a = list(map(int, input().split()))

ok, ng = n, 0
while ok-ng > 1:
	x = (ok+ng)//2
	#d = defaultdict(int)
	d = dict()
	last = 0
	valid = True
	if x == 1:
		for i in range(n-1):
			if a[i] >= a[i+1]:
				valid = False
				break
		if valid:
			ok = x
		else:
			ng = x
		continue

	for i in range(n-1):
		if a[i] > a[i+1]:
			if a[i+1] > last:
				d[a[i+1]] = 1
			else:
				j = a[i+1]
				while j in d:
					if d[j] != x-1 and j <= 0:
						break
					else:
						del d[j]
						j -= 1
				if j in d:
					d[j] += 1
				else:
					d[j] = 1
			last = a[i+1]
		elif a[i] == a[i+1]:
			j = a[i+1]
			while j in d:
				if d[j] != x-1 and j <= 0:
					break
				else:
					del d[j]
					j -= 1
			if j in d:
				d[j] += 1
			else:
				d[j] = 1
			last = a[i+1]

		e = copy(d)
		for k in d.keys():
			if k > last:
				del e[k]
		d = copy(e)

        if 0 in d:
			valid = False
			break


	if valid:
		ok = x
	else:
		ng = x
print(ok)

### FIXED CODE ###

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

ok, ng = n, 0
while ok-ng > 1:
	x = (ok+ng)//2
	#d = defaultdict(int)
	d = dict()
	last = 0
	valid = True
	if x == 1:
		for i in range(n-1):
			if a[i] >= a[i+1]:
				valid = False
				break
		if valid:
			ok = x
		else:
			ng = x
		continue

	for i in range(n-1):
		dels = []
		if a[i] < a[i+1]:
			last = a[i+1]
			continue

		j = a[i+1]
		for k in d.keys():
			if j < k:
				dels.append(k)

		while j > 0:
			if j in d and d[j] == x-1:
				#d[j] = 0
				dels.append(j)
				j -= 1
			else:
				break

		if j in d:
			d[j] += 1
		else:
			d[j] = 1

		for k in dels:
			del d[k]

		if 0 in d:
			valid = False
			break
		last = j

	if valid:
		ok = x
	else:
		ng = x
print(ok)
a=int(input("a?"))
b=int(input("b?"))
c=int(input("c?"))
k=int(input("k?"))

ans="no"
for i in range(k+1):
  if a<b<c:
    ans="yes"
  else:
    if a>=b:
      b*=2
    elif b>=c:
      c*=2
    else:
      c*=2

print(ans)

### FIXED CODE ###

a,b,c=map(int, input().split())
k=int(input())

ans="No"
for i in range(k+1):
  if a<b<c:
    ans="Yes"
  else:
    if a>=b:
      b*=2
    elif b>=c:
      c*=2


print(ans)
A, B = map(float, input().split())

BB = int(B*100)

C = BB * A /100

C =math.floor(C)
print(C)

### FIXED CODE ###

a, b = input().split()
a = int(a)
b = round(100*float(b))
print(a*b//100)
N = input()

N = pow(N,3)

N = str(N)

print(N¥n)


### FIXED CODE ###

N = input()

N = pow(N,3)

print(N)
n=int(input())
v=[int(x) for x in input().split()]
c=[int(y) for y in input().split()]

new=[v[i]-c[i] for i in range(n)]
new.sort()
print(new[-2]+new[-1])


### FIXED CODE ###

n=int(input())
v=[int(x) for x in input().split()]
c=[int(y) for y in input().split()]

new=[v[i]-c[i] for i in range(n) if v[i]-c[i]>0]

print(sum(new))
l,r = map(int, input().split())
gap = r-l

vlist = []

    v = (l+x) % 2019
    vlist.append(v)

vlist.sort()
#print(vlist)

#res = i*j % 2019
print(vlist[0]*vlist[1])

### FIXED CODE ###

l,r = map(int, input().split())
gap = r-l
 
vlist = []
mini = 2019
 
for x in range(gap+1):
    v = (l+x) % 2019
    vlist.append(v)
    if v == 0:
        print(0)
        exit()
 
vlist.sort()

mini = 2019

for i in vlist:
    for j in vlist:
        if i==j:
            pass
        else:
            temp = (i*j) %2019
            mini = min(temp, mini)
            if mini == 0:
                print(0)
                exit()

print(mini)
    
#print((vlist[0]*vlist[1])%2019)
#print((vlist[0]*vlist[1])%2019)
s = input()
n = int(s)
sum =0
mir = n
for i in range(len(s)):
  sum += s[i]
if n%sum ==0:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

s = input()
n = int(s)
sum =0
mir = n
for i in range(len(s)):
  sum += int(s[i])
if n%sum ==0:
  print("Yes")
else:
  print("No")
from collections import defaultdict


def solve(pre_is_positive, a_list):
    total = 0
    ans = 0
    for a in a_list:
        total += a
        if pre_is_positive and total >= 0:
            ans += abs(total) + 1
            total = -1
        elif not pre_is_positive and total <= 0:
            ans += abs(total) + 1
            total = 1
        pre_is_positive = total > 0
    return ans


def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    print(min(solve(True, a_list), solve(False, a_list)))


if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    print(''.join([s[0].upper() for s in input().split()]))


if __name__ == "__main__":
    main()
def signal(a,e):
	s=""
	for i in range(7):
		s+="0" if a[i]==e[i] else "1"
	return s

ref=["0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"]
while 1:
	n=int(raw_input())
	if n==-1:break
	e="0000000"
	for i in range(n):
		a=ref[int(raw_input())]
		print signal(a,e)
		e=a

### FIXED CODE ###

# try-except is necessary for avoiding Runtime Error 
while 1:
	try:
		n,m=map(int,raw_input().split())
		if n==0:break
		v=sorted(map(int,raw_input().split()))[::-1]
		for i in range(m-1,n,m):
			v[i]=0
		print sum(v)
	except:
		pass
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = []
    b = []
    d = []
    for _ in range(n):
        ai, bi = ns()
        a.append(ai)
        b.append(bi)
        d.append((ai, bi))

    a.sort()
    b.sort()

    odd = n % 2 == 1
    even = n % 2 == 0
    min_choice = a[n // 2 - even]
    max_choice = b[n // 2]

    kouho = []
    for ai, bi in d:
        tmp = range(max(ai, min_choice), min(bi, max_choice))
        if len(tmp) > 0:
            kouho.append(tmp)

    dic_even = dict()
    dic_odd = dict()

    for k in kouho:
        for t in k:
            dic_even[t] = 0

    for i in range(len(kouho)):
        for t in kouho[i]:
            for j in range(i + 1, len(kouho)):
                for l in kouho[j]:
                    dic_odd[(t + l) / 2] = 0
    
    e = set(dic_even.keys())
    o = set(dic_odd.keys())
    
    ans = e+o
    print(len(ans))


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = []
    b = []
    for _ in range(n):
        ai, bi = ns()
        a.append(ai)
        b.append(bi)

    a.sort()
    b.sort()

    if n % 2:
        ans = b[n // 2] - a[n // 2] + 1
    else:
        ans = b[n // 2] + b[n // 2 - 1] - (a[n // 2] + a[n // 2 - 1]) + 1
    print(ans)


if __name__ == '__main__':
    main()
import math
A,B,C,D = map(int, input().split())
x = abs(A-B)//C + 1
y = abs(A-B)//D + 1
if abs(A-B)//((C*D)//math.gcd(C,D)) == 0:
    z = 0
else:
    z = abs(A-B)//((C*D)//math.gcd(C,D)) + 1
print(B-A+1-x-y+z)

### FIXED CODE ###

import fractions
A,B,C,D = map(int, input().split())
BC = B//C
if A%C == 0:
    AC = A//C-1
else:    
    AC = A//C
BD = B//D
if A%D == 0:
    AD = A//D - 1
else:
    AD = A//D
GCD = C*D//fractions.gcd(C,D)
BB = B//GCD
if A%GCD == 0:
    AA = A//GCD - 1
else:
    AA = A//GCD
print((B-A+1)-(BC-AC)-(BD-AD)+(BB-AA))
n = int(input())
m = [int(i) for i in input().split()]
mi = 2*10**5+1
h = 0
if n!=1:
  for i in range (n):
    if mi>m[i]:
      mi=m[i]
      h+=1
    g+=1
  print(h)
else:
  print(n)

### FIXED CODE ###

n = int(input())
m = [int(i) for i in input().split()]
mi = 2*10**5+1
h = 0

for i in range (n):
  if mi>m[i]:
    mi=m[i]
    h+=1

    
print(h)
S = input()
n = 0

for s in S:
  if s == "+"
    n += 1
  else:
    n -= 1

print(n)

### FIXED CODE ###

S = input()
n = 0

for s in S:
  if s == "+":
    n += 1
  else:
    n -= 1

print(n)