import java.io.BufferedWriter; import java.io.FileInputStream; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.BitSet; import java.util.HashMap; import java.util.List; import java.util.Queue; import java.util.Stack; public class Main { public static void main(String[] args) throws NumberFormatException, IOException {Solve solve = new Solve();solve.solve();} } class Solve{ void dump(int[]a){for(int i=0;i node = new ArrayList<>(); final int[] dx = {1, 1, 1, 0, 0, -1, -1, -1}; final int[] dy = {1, 0, -1, 1, -1, 1, -1, 0}; final int[] dx4 = {1,0,-1,0}; final int[] dy4 = {0,1,0,-1}; BitSet used = new BitSet(); Stack oq = new Stack<>(); Stack qu = new Stack<>(); oq.add(0L); int mask = (1<<30)-1; int id = 0; node.add(new Node(0, 0)); while(!oq.isEmpty()){ long ot = oq.pop(); final int p = (int)ot&mask; ot >>= 30; if(used.get(p)) continue; used.set(p); final int y = p/m; final int x = p%m; if(y==2 && x==13){ System.out.println(); } if(!map.get(p)){ for(int i=0; i<4; i++){ final int ny = y+dy4[i]; final int nx = x+dx4[i]; final int np = ny*m+nx; if(out(ny, nx) || used.get(np)) continue; oq.add(np|ot<<30); } }else{ id++; int left = m; int ly = 0; int size = 0; qu.clear(); qu.add(p); while(!qu.isEmpty()){ final int ip = qu.pop(); size++; final int iy = ip/m; final int ix = ip%m; if(ix3) oq.add(ly*m+left+1 | (long)id<<30); Node newnode = new Node(id, size); Node parent = node.get((int)ot); node.add(newnode); newnode.append(parent); parent.append(newnode); } } int x1 = dfs(node.get(0), -1, true); System.out.println(Math.max(x1, allx-x1)); } int dfs(Node v, int par, boolean f){ int sum = 0; for(Node nv: v.edge){ if(nv.id == par) continue; sum += dfs(nv, v.id, !f); } return sum + (f?v.size:0); } boolean out(int y, int x){ return y<0||y>=n||x<0||x>=m; } } class Node{ int id; int size; List edge = new ArrayList<>(); Node(int id, int s){ this.id = id; size = s; } void append(Node v){ edge.add(v); } } class MultiSet extends HashMap{ @Override public Integer get(Object key){return containsKey(key)?super.get(key):0;} public void add(T key,int v){put(key,get(key)+v);} public void add(T key){put(key,get(key)+1);} public void sub(T key) {final int v=get(key);if(v==1)remove(key);else put(key,v-1);} } class Timer{ long time; public void set(){time=System.currentTimeMillis();} public long stop(){return time=System.currentTimeMillis()-time;} public void print() {System.out.println("Time: "+(System.currentTimeMillis()-time)+"ms");} @Override public String toString(){return"Time: "+time+"ms";} } class Writer extends PrintWriter{ public Writer(String filename)throws IOException {super(new BufferedWriter(new FileWriter(filename)));} public Writer()throws IOException{super(System.out);} } class ContestScanner { private InputStreamReader in;private int c=-2; public ContestScanner()throws IOException {in=new InputStreamReader(System.in);} public ContestScanner(String filename)throws IOException {in=new InputStreamReader(new FileInputStream(filename));} public String nextToken()throws IOException { StringBuilder sb=new StringBuilder(); while((c=in.read())!=-1&&Character.isWhitespace(c)); while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();} return sb.toString(); } public String readLine()throws IOException{ StringBuilder sb=new StringBuilder();if(c==-2)c=in.read(); while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();} return sb.toString(); } public long nextLong()throws IOException,NumberFormatException {return Long.parseLong(nextToken());} public int nextInt()throws NumberFormatException,IOException {return(int)nextLong();} public double nextDouble()throws NumberFormatException,IOException {return Double.parseDouble(nextToken());} }