Harryxun/stf_run huggingface dataset:
import sys
import copy
from collections import deque
stdin = sys.stdin
 
mod = 10**9+7
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces
 
n = ni()
a = na()
a.sort()
b = copy.deepcopy(a)
 
maps = {}
 
for aa in a:
    if aa in maps:
        tmp = maps[aa]
        maps[aa] = tmp+1
    else:
        maps[aa] = 1
 
i = 0
while True:
    a_tmp = b[i]
    check = set()
    for j in range(len(b)-1, i, -1):
        if b[j]==a_tmp:
            check.add(i)
            check.add(j)
            continue
        if b[j]%a_tmp==0:
            check.add(j)
            continue
        if a_tmp*2 > b[j]:
            break
 
    check = list(check)
    check.sort(reverse=True)
    for c in check:
        del b[c]
    
    i += 1
    if i>=len(a):
        break
 
 
 
print(len(a))

### FIXED CODE ###

import sys
import copy
from collections import deque
stdin = sys.stdin
 
mod = 10**9+7
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces
 
n = ni()
a = na()
a.sort()
a_max = max(a)

c = [0 for _ in range(1000005)]
for aa in a:
    c[aa] += 1

dp = [False for _ in range(1000005)]
cnt = 0
for ai in set(a):
    if dp[ai]:
        continue
    if c[ai]==1:
        cnt += 1
    for j in range(ai+ai, a_max+1, ai):
        dp[j] = True

print(cnt)
def gcd(a,b):
    if b>a:
        a,b=b,a
    while b:
        a,b=b, a%b
    return a


def cul(n,x):
    l=len(x)
    b=[x[i] for i in range(l)]
    b.pop(n)
    tmp=b[0]
    for i in range(1,l-1):
        tmp=gcd(tmp,b[i])
    return tmp

import sys
import math
p=10
N=int(input())
a=list(map(int,input().split()))
if N<=p:
    ans=0
    
    for i in range(N):
        tmp=cul(i,a)        
        if tmp>ans: ans=tmp
    print(ans)
    sys.exit()
        
M=a[0]
for i in range(1,p):
    M=gcd(M,a[i])

ans=0
for i in range(1,math.ceil(M**0.5)+1 ):
    if M%i==0:
        cnt=0
        for j in range(p,N):
            if a[i]%i!=0:
                cnt+=1
                if cnt==2: break
            elif i==N-1 and i>ans: ans=i
        
        x=M//i
        cnt=0
        for j in range(p,N):
            if a[i]%x!=0:
                cnt+=1
                if cnt==2: break
            elif i==N-1 and x>ans: ans=x



print(ans)

### FIXED CODE ###

A,B,T=map(int,input().split())
ans=(T+0.5)//A
ans*=B
print(int(ans))
a=list(map(int,input()))
print(max(a)-min(a))

### FIXED CODE ###

a=list(map(int,input().split()))
print(max(a)-min(a))
import sys
def input():
	return sys.stdin.buffer.readline()[:-1]

s = input()
n = len(s)
q = int(input())
front = ""
back = ""
sgn = 0
for _ in range(q):
	query = input().split()
	if query[0] == "1":
		sgn ^= 1
	else:
		f, c = int(query[1])-1, query[2]
		if f ^ sgn == 0:
			front += c
		else:
			back += c
if not sgn:
	print(front[::-1] + s + back)
else:
	print(back[::-1] + s[::-1] + front)

### FIXED CODE ###

import sys
def input():
	return sys.stdin.readline()[:-1]

s = input()
#n = len(s)
q = int(input())
front = ""
back = ""
sgn = 0
for _ in range(q):
	query = input().split()
	if query[0] == "1":
		sgn ^= 1
	else:
		f, c = int(query[1])-1, query[2]
		if f ^ sgn == 0:
			front += c
		else:
			back += c
if not sgn:
	print(front[::-1] + s + back)
else:
	print(back[::-1] + s[::-1] + front)
x = int(input())
y = int(input())

  print(int(x+(y/2)))


### FIXED CODE ###

X,Y = map(int,input().split())
 
print( X + (Y // 2))
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math

N,M=map(int,input().split())
xyz=[list(map(int,input().split())) for m in range(N)]
dp=[[[0,0] for i in range(M)] for i in range(N)]
if M==0:
    print(0)
    exit()
num=0
for a in [-1,1]:
    for b in [-1,1]:
        for c in [-1,1]:
            dp=[[None for m in range(M)] for i in range(N)]
            for i in range(0,N):
                x,y,z=xyz[i]
                A=x*a+y*b+z*c
                #print(dp)
                if i==0:
                    dp[i][0]=A
                else:
                    for m in range(0,M):
                        if m==0:
                            dp[i][m]=max(dp[i-1][m],A)
                        else:
                            if dp[i-1][m]:
                                dp[i][m]=max(dp[i-1][m-1]+A,dp[i-1][m])
                            elif dp[i-1][m-1]:
                                dp[i][m]=dp[i-1][m-1]+A
                            else:
                                break

            num=max(dp[-1][-1],num)
print(num)


### FIXED CODE ###

# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math

N,M=map(int,input().split())
xyz=[list(map(int,input().split())) for m in range(N)]
dp=[[[0,0] for i in range(M)] for i in range(N)]
if M==0:
    print(0)
    exit()
num=0
for a in [-1,1]:
    for b in [-1,1]:
        for c in [-1,1]:
            dp=[[None for m in range(M)] for i in range(N)]
            for i in range(0,N):
                x,y,z=xyz[i]
                A=x*a+y*b+z*c
                #print(dp)
                if i==0:
                    dp[i][0]=A
                else:
                    for m in range(0,M):
                        if m==0:
                            dp[i][m]=max(dp[i-1][m],A)
                        else:
                            if dp[i-1][m]:
                                dp[i][m]=max(dp[i-1][m-1]+A,dp[i-1][m])
                            elif dp[i-1][m-1]:
                                dp[i][m]=dp[i-1][m-1]+A
                            else:
                                break
            if dp[-1][-1]:
                num=max(dp[-1][-1],num)
print(num)
N, M = map(int, input().split())
a_list = [int(input()) for _ in range(M)]

mod = 10 ** 9 + 7

dp = [0] * (N + 100)
dp[0] = 1
a_set = set(a_list)

for i in range(N):
    if i in a_set:
        continue
    else:
        dp[i + 1] += dp[i]
        dp[i + 1] %= mod
        dp[i + 2] += dp[i]
        dp[i + 2] %= mod

print(dp[N] % mod)


### FIXED CODE ###

P, Q, R = map(int, input().split())

print(P + Q + R - max(P, Q, R))
N, M, Q = map(int, input().split())
trains = {}
answers = {}
results = []
def make_range(L, R):
    return (pow(2, (R-L+1))-1)<<L-1

for i in range(M):
    a, b = map(int, input().split())
    train = make_range(a, b)
    if train in trains:
        trains[train] += 1
    else:
        trains[train] = 1
    
def combine_answer(answers, question, res):
    for other_question in answers:
        combine_question = other_question + question
        if other_question | question == combine_question:
            combine_res = answers[other_question] + res
            combine_answer(answers, combine_question, combine_res)
            answers[combine_question] = combine_res

for i in range(Q):
    a, b = map(int, input().split())
    question = make_range(a, b)
    if question in answers:
        results.append(answers[question])
    else:
        res = 0
        for train in trains:
            if question | train == question:
                res += trains[train]
        combine_answer(answers, question, res)
        answers[question] = res
        results.append(res)

for result in results:
    print(result)

### FIXED CODE ###

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

dp = [[0 for col in range(N)] for row in range(N)]

for i in range(M):
    l, r = map(int, input().split())
    dp[l-1][r-1]+=1

for i in range(N):
    for j in range(N)[:-1]:
        dp[i][j+1] += dp[i][j]
        
for i in range(N)[:0:-1]:
    for j in range(N):
        dp[i-1][j] += dp[i][j]

results = []

for i in range(Q):
    l, r = map(int, input().split())
    results.append(dp[l-1][r-1])

for result in results:
    print(result)
n, k, s = map(int, input().split())
if k == 0:
  print(' '.join([str(s + 1)]*n))
else:
  first = [str(s)|]*k
  second = [str(s + 1)]*(n - k)
  print(' '.join(first + second))

### FIXED CODE ###

n, k, s = map(int, input().split())
if k == 0:
    if s == 10**9:
        print(' '.join([str(s - 1)]*n))
    else:
        print(' '.join([str(s + 1)]*n))
else:
  first = [str(s)]*k
  if s == 1:
    second = [str(2)]*(n - k)
  else:
    second = [str(max(1, s - 1))]*(n - k)
  print(' '.join(first + second))
r = input()
s = 3 * r * r
print("s")

### FIXED CODE ###

r = int(input())
s = 3 * r * r
print(s)
move=((1,0),(0,1),(-1,0),(0,-1))

#深さ優先探索
def dfs(used,mat,node,nums):
    y,x=node
    color=mat[y][x]
    if used[y][x]==1 or color=='!':
        return
    
    used[y][x]=1
    nums[color]+=1
    for i,j in move:
        if mat[y+i][x+j]!=color and mat[y+i][x+j] != '!':
            dfs(used,mat,(y+i,x+j),nums)


H,W=list(map(int,input().split()))

grid=['!'*(W+2)]
used=[[0 for _ in range(W+2)] for _ in range(H+2)]

for i in range(H):
    grid.append('!'+input()+'!')
grid.append('!'*(W+2))

ans=0
for i in range(H+2):
    for j in range(W+2):
        nums={'#':0,'.':0}
        dfs(used,grid,(i,j),nums)
        ans+=nums['#']*nums['.']
print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

move=((1,0),(0,1),(-1,0),(0,-1))

#深さ優先探索
def dfs(used,mat,node,nums):
    y,x=node
    color=mat[y][x]
    if used[y][x]==1 or color=='!':
        return
    
    used[y][x]=1
    nums[color]+=1
    for i,j in move:
        if mat[y+i][x+j]!=color and mat[y+i][x+j] != '!':
            dfs(used,mat,(y+i,x+j),nums)


H,W=list(map(int,input().split()))

grid=['!'*(W+2)]
used=[[0 for _ in range(W+2)] for _ in range(H+2)]

for i in range(H):
    grid.append('!'+input()+'!')
grid.append('!'*(W+2))

ans=0
for i in range(H+2):
    for j in range(W+2):
        nums={'#':0,'.':0}
        dfs(used,grid,(i,j),nums)
        ans+=nums['#']*nums['.']
print(ans)
n=int(input())
s=input()
print("".jion(s.split()))

### FIXED CODE ###

'''
author : w2sc
  date : 2019/12/22
  time : 20:03:13
'''
n=int(input())
a,b=input().split()
i=0
s=""
while i<n:
    s+=a[i]+b[i]
    i+=1
print(s)
from collections import deque
n, m, k = map(int, input().split())
a = deque(list(map(int, input().split())))
b = deque(list(map(int, input().split())))

time = 0
count = 0
while len(a) > 0 or len(b) > 0:
    if len(a) ==  0:
        book_b = b.popleft()
        time += book_b
        count += 1
    elif len(b) == 0:
        book_a = a.popleft()
        time += book_a
        count+= 1
    elif a[0] > b[0]:
        book_b = b.popleft()
        time += book_b
        count += 1
    elif a[0] == b[0]:
        if a[1] > b[1]:
            book_b = b.popleft()
            time += book_b
            count += 1
        else:
            book_a = a.popleft()
            time += book_a
            count += 1            
    else:
        book_a = a.popleft()
        time += a.popleft()
        count += 1
    if time > k:
        count -= 1
        break

    
print(count)   

    


### FIXED CODE ###

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
book_a = [0] * (n + 1)
book_b = [0] * (m + 1)

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

for j in range(m):
    book_b[j + 1] = book_b[j] + b[j]

r = m
ans = 0

for i in range(n + 1):
    if book_a[i] > k:
        break
    while book_a[i] + book_b[r] > k:
        r -= 1
    ans = max(ans, i + r)

print(ans)
import math
import itertools
import statistics
#import numpy as np
import collections
#n = int(input())
k, s = list(map(int, input().split()))
#a = list(map(int, input().split()))
count = 0
for x in range(k+1):
    for y in range(s-x+1):
        z = s-x-y
        ans = x+y+z
        if ans==s and y <= k and z <= k:
            count += 1
print(count)


### FIXED CODE ###

k, s = list(map(int, input().split()))
count = 0
for x in range(k+1):
    for y in range(min(k+1, s-x+1)):
        z = s-x-y
        ans = x+y+z
        if y <= k and z <= k:
            count += 1
print(count)
two_dict = {}
for i in range(2001):
  two_dict[i] = min(i, 2000 - i) + 1 

while True:
  try:
    n = int(input())
    ans = 0
    for i in range(n + 1):
      ans += two_dict[i] * two_dict[n - i]
    print(ans)

  except EOFError:
    break



### FIXED CODE ###

from collections import Counter

pair_dict = Counter()
for i in range(2001):
  pair_dict[i] = min(i, 2000 - i) + 1 

while True:
  try:
    n = int(input())
    ans = 0
    for i in range(n + 1):
      ans += pair_dict[i] * pair_dict[n - i]
    print(ans)

  except EOFError:
    break
from math import sqrt
N = int(input())

max_v = int(sqrt(N))
for num in range(max_v,1,(-1)):
	if N % num == 0:
		div = num
		break

print(max(len(str(div)),len(str(N//max_v))))

### FIXED CODE ###

from math import sqrt
N = int(input())

div = 1
max_v = int(sqrt(N))
for num in range(max_v,1,(-1)):
	if N % num == 0:
		div = num
		break

#print(div)
print(max(len(str(div)),len(str(N//div))))
N=in(input())
conut=0

for i in range(1,N+1):
    a=[]
    if i%2==0:
        continue
     for j in range(1,i+1):
         if i%j==0:
             a.append(j)

    if len(a)==8:
        count+=1

print(count)

### FIXED CODE ###

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

N = int(input())
count = 0

for i in range(1, N + 1):
    a = []
    if i % 2 == 0:
        continue

    for j in range(1, i + 1):
        if i % j == 0:
            a.append(j)

    if len(a) == 8:
        count += 1

print(count)
n,m,k = map(int, raw_input().split(' '))
ais = map(int,raw_input().split(' '))
bis = map(int,raw_input().split(' '))

mem = {}
def f(i,j,k,ais,bis):
	if (i,j,k) in mem:
		return mem[(i,j,k)]
	m = 0
	if i < len(ais) and ais[i] <= k:
		m = max(m , 1+ f(i + 1,j, k - ais[i],ais,bis ))
	if j < len(bis) and bis[j] <= k:
		m = max(m , 1+ f(i,j+1, k - bis[i],ais,bis ))
	mem[(i,j,k)] = m
	return m

print f(0,0, k, ais, bis)


### FIXED CODE ###

import collections
n,m,k = map(int, raw_input().split(' '))
ais = map(int,raw_input().split(' '))
bis = map(int,raw_input().split(' '))
cumul = 0
pais = [0]
for ai in ais:
	cumul +=ai
	pais.append(cumul)

cumul = 0
pbis = [0]
for ai in bis:
	cumul +=ai
	pbis.append(cumul)
	


q = 0
for j,bi in enumerate(pbis):

	if k >= bi:
		j
		qq = k - bi
		lo,hi = 0, len(pais)-1
		while(lo < hi):
			med = (lo + hi + 1) >> 1
			if pais[med] <= qq:
				lo = med
			else:
				hi = med -1
		
		ans = j + lo
		q = max(ans, q)
print q
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

h, w = MAP()
a = [LIST() for _ in range(h)]
ans = []
for i in range(h):
    if i % 2 == 0:
        for j in range(w):
            if a[i][j] % 2 == 1:
                y = i
                x = j + 1
                if x >= w:
                    y += 1
                    x = 0
                a[y][x] += 1
                ans.append([str(i + 1), str(j + 1), str(y + 1), str(x + 1)])
    else:
        for j in reversed(range(w)):
            if a[i][j] % 2 == 1:
                y = i
                x = j - 1
                if x < 0:
                    y += 1
                    x = w - 1
                a[y][x] += 1
                ans.append([str(i + 1), str(j + 1), str(y + 1), str(x + 1)])
print(len(ans))
for i in range(len(ans)):
    print(' '.join(ans[i]))

### FIXED CODE ###

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

h, w = MAP()
a = [LIST() for _ in range(h)]
ans = []
for i in range(h):
    if i % 2 == 0:
        for j in range(w):
            if a[i][j] % 2 == 1:
                y = i
                x = j + 1
                if x >= w:
                    y += 1
                    x = w - 1
                if y < h:
                    a[y][x] += 1
                    ans.append([str(i + 1), str(j + 1), str(y + 1), str(x + 1)])
    else:
        for j in reversed(range(w)):
            if a[i][j] % 2 == 1:
                y = i
                x = j - 1
                if x < 0:
                    y += 1
                    x = 0
                if y < h:
                    a[y][x] += 1
                    ans.append([str(i + 1), str(j + 1), str(y + 1), str(x + 1)])
print(len(ans))
for i in range(len(ans)):
    print(' '.join(ans[i]))
import math
Q = int(input())

def prime(p):
    for i in range(2, int(math.sqrt(p))+1):
        if p % i == 0:
            return False
    return True

# エラトステネスの篩
data = [1]*(10**5+1)
data[0],data[1] = 0,0 #
for j in range(2, 10**5+1):
    if prime(j) == True:
        for k in range(j*2, 10**5+1, j):
            data[k] = 0
# 2017 like
for k in range(2,10**5)[::-1]: #
    if data[k] == 1 and k % 2 == 1:
        if data[int((k+1)/2)] == 0:
            data[k] = 0
    else: #
        data[k] = 0 #
# 累積和
t = [0]*10**5
for a in range(10**5-1):
    t[a+1] = t[a] + data[a]

for b in range(Q):
    l, r = map(int, input().split(" "))
    print(t[r+1] - t[l])

### FIXED CODE ###

import math 

def prime(n):
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return 0
    return 1

#エラトステネスのふるい
MAX =100000
is_prime = [1]*(MAX+1)
is_prime[0] = 0 
is_prime[1] = 0
for i in range(2,MAX+1):
    if prime(i) == 1:
        j = i*2
        while j <= MAX:
            is_prime[j] = 0
            j += i

#２０１７のような数かどうか
a = [0]*(MAX+1)
for i in range(0,MAX):
    if i % 2 == 1:
        if is_prime[i]==1 and is_prime[int((i+1)/2)]==1:
            a[i] = 1

#累積和
s = [0] * (MAX+1)
for i in range(0,MAX):
    s[i+1] = s[i] + a[i]

#クエリ処理
Q = int(input())
for q in range(Q):
    l,r = map(int,input().split())
    r += 1

    print(s[r]-s[l])
s = input()

list1 = [0]*len(s)


def r_search(start,index,count):
    if s[index] == "L":
        count -= 1 #RLで計算が始まる為
        if count == 0: #LRLの要な場合
            list1[index-1] += 1
            list1[index] += 1
            return index+1
        elif count %2 != 0: #奇数
            list1[index-1] += count//2 + 1 #このへんの+1は元々のRLの分
            list1[index] += count//2 +1 + 1
            return index+1
        else: #偶数
            list1[index-1] += count//2 + 1
            list1[index] += count//2 + 1
            return index+1
    else:
        return r_search(start,index+1,count+1)
        



def l_search(start,index,count): #start-1がL,-2がRで有ることが決まっている
    if index >= len(s) or s[index] == "R":
        if count %2 != 0: #奇数の場合逆側に１多く入る
            list1[start-2] += count//2+1
            list1[start-1] += count//2
            return index
        else:
            list1[start-2] += count//2
            list1[start-1] += count//2
            return index

    else:
        return l_search(start,index+1,count+1)
i = 0
while True:
    if i >= len(s):
        break
    elif s[i] == "R":
        i = r_search(i,i,0)
    else:
        i = l_search(i,i,0)
print(" ".join(map(str,list1)))

### FIXED CODE ###

s = input()

import sys
sys.setrecursionlimit(1000000)
list1 = [0]*len(s)


def r_search(start,index,count):
    if s[index] == "L":
        count -= 1 #RLで計算が始まる為
        if count == 0: #LRLの要な場合
            list1[index-1] += 1
            list1[index] += 1
            return index+1
        elif count %2 != 0: #奇数
            list1[index-1] += count//2 + 1 #このへんの+1は元々のRLの分
            list1[index] += count//2 +1 + 1
            return index+1
        else: #偶数
            list1[index-1] += count//2 + 1
            list1[index] += count//2 + 1
            return index+1
    else:
        return r_search(start,index+1,count+1)
        



def l_search(start,index,count): #start-1がL,-2がRで有ることが決まっている
    if index >= len(s) or s[index] == "R":
        if count %2 != 0: #奇数の場合逆側に１多く入る
            list1[start-2] += count//2+1
            list1[start-1] += count//2
            return index
        else:
            list1[start-2] += count//2
            list1[start-1] += count//2
            return index

    else:
        return l_search(start,index+1,count+1)
i = 0
while True:
    if i >= len(s):
        break
    elif s[i] == "R":
        i = r_search(i,i,0)
    else:
        i = l_search(i,i,0)
print(" ".join(map(str,list1)))
# -*- coding: utf-8 -*-

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

set_a = set(a)
a.sort()
k = 0
p = 0
ans = 0
for a_ in set_a:
    s = a[k]
    while True:
        if k<len(a) and a[k]==s:
            k+=1
            p+=1
        else:
            if p>=s:
                ans+=p-s
            else:
                ans+=p
            p=0
            break
print(ans)


### FIXED CODE ###

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

import math

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

print(math.ceil((a+b)/2))
#_*_ coding:utf-8 _*_
  2 import sys
  3 
  4 
  5 while True:
  6     vals = sys.stdin.readline()
  7     if(vals is  None or vals.strip() == '' ):
  8         break
  9     a,b,c,d,e,f=list( map(float,vals.strip().split()))
 10     temp = a * e - d * b
 11     print(temp)
 12     x = (c * e - b * f) / temp + 0.0
 13     y = (c * d - a * f) / -temp + 0.0
 14     print('%.3f %.3f' % (x,y))
 15     

### FIXED CODE ###

#_*_ coding:utf-8 _*_
import sys


while True:
    vals = sys.stdin.readline()
    if(vals is  None or vals.strip() == '' ):
        break
    a,b,c,d,e,f=list( map(float,vals.strip().split()))
    temp = a * e - d * b
    x = (c * e - b * f) / temp + 0.0
    y = (c * d - a * f) / -temp + 0.0
    print('%.3f %.3f' % (x,y))
A,B,C,D=int(input().split())
x=min(C,D)-max(A,B)
if x>0:
    print(x)
else:
    print("0")


### FIXED CODE ###

A,B,C,D=map(int,input().split())
x=min(B,D)-max(A,C)
if x>0:
    print(x)
else:
    print("0")
N = int(input())
S = []*N
AC = 0
WA = 0
TLE = 0
RE = 0

for n in range(N):
  S[n] = input()
  if S[n] == "AC":
    AC += AC
  elif S[n] == "WA":
    WA += WA
  elif S[n] == "TLE":
    TLE += TLE
  elif S[n] == "RE":
    RE += RE
    
print("AC x {}\nWA x {}\nTLE x {}\nRE x {}".format(AC,WA,TLE,RE))

### FIXED CODE ###

N = int(input())
S = [0]*N
AC = 0
WA = 0
TLE = 0
RE = 0

for n in range(N):
  S[n] = str(input())
  if S[n] == "AC":
    AC = AC + 1
  elif S[n] == "WA":
    WA = WA + 1
  elif S[n] == "TLE":
    TLE = TLE + 1
  elif S[n] == "RE":
    RE = RE + 1
    
print("AC x {}\nWA x {}\nTLE x {}\nRE x {}".format(AC,WA,TLE,RE))
x=input().split
y=map(int,x)
a=y[0]
b=y[1]
c=a*b
d=(a+b)*2
print c, d

### FIXED CODE ###

list=input().split()
x=int(list[0])
y=int(list[1])
print (x*y,(x*2)+(y*2))
N=int(input())
A=list(map(int,input().split()))
counter=1

while len(A)>1:
    res=(A[1]>=A[0])
    for i in range(len(A)):
        if (A[i+1]<A[i] and res) or (A[i+1]>A[i] and not res):
            A=A[i+1:]
            counter+=1
            break

print(counter)


### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
counter=1
res=0
for i in range(len(A)-1):
    if (A[i+1]<A[i] and res>0) or (A[i+1]>A[i] and res<0):
        counter+=1
        res=0
    elif A[i+1]!=A[i]:
        res=A[i+1]-A[i]


print(counter)
A, B, X = map(int, input().split())

n = int(X / A)
n = int(X / A) - B * len(str(n))

while X < A * n + B * len(str(n)):
    n -= 1

if n > 1000000000:
    n = 1000000000

if n < 0:
    n = 0

print(n)

### FIXED CODE ###


S = input()

day = ['SUN','MON','TUE','WED','THU','FRI','SAT']

n = day.index(S)

print(7 - n)