## The time I accidentally wrote the official solution

(Copied from Facebook. Remembered this fun story while taking a break from the past paper madness…)

In IMO final training last year we worked on this geometry problem, which seemed strangely familiar. After I found the solution I remembered that I’d solved it before on AoPS – Turkey’s problem 6 from 2012.

We then read the official solution from the booklet – hey, I used the same method! They even used Brokard’s theorem like I did. Wait…

Turns out, they printed the exact solution I posted on AoPS two years ago. :P

http://artofproblemsolving.com/community/c6h508906

I like this problem – the idea is similar to the geometry problem I wrote for the Junior Olympiad in 2013. Here it is, Turkey NMO 2012, Problem 6:

Let $B$ and $D$ be points on segments $[AE]$ and $[AF]$ respectively. Excircles of triangles $ABF$ and $ADE$ touching sides $BF$ and$DE$ is the same, and its center is $I$. $BF$ and $DE$ intersects at $C$. Let $P_1, P_2, P_3, P_4, Q_1, Q_2, Q_3, Q_4$ be the circumcenters of triangles $IAB, IBC, ICD, IDA, IAE, IEC, ICF, IFA$ respectively.

a) Show that points $P_1, P_2, P_3, P_4$ concylic and points $Q_1, Q_2, Q_3, Q_4$ concylic.
b) Denote centers of these circles as $O_1$ and $O_2$. Prove that $O_1, O_2$ and $I$ are collinear.

## Into the (slow-burning) fire

The next month promises to be an electrifying one. We’re on the brink of the most important exams of the year, and the atmosphere here in college is somewhat strung – gone are the days where people could (or wanted to) hide behind a veneer of nonchalance, it’s the A levels, darn it!

Exams have already begun, with our pioneers taking the first of the papers today (7 brave students daring the waters of Marine Science). For the rest of us, we’re waiting for the papers with the sort of anticipation one gets while waiting for trains in KL during rush hour – we know it’s going to be uncomfortable, but let’s just get it over with, shall we? My calendar is littered with scribbles about exam papers, most of them uncomfortably squeezed into the first few weeks of this hectic time of the year. Life for most of us nowadays revolves around (boring) past year papers, (re-)reading textbooks and notes, and at least for me, surprise existential crises (wait, what am I even doing in class?).

```while (1) {
c++;
}
```

I recently thought of stuff related to stress and sanity while writing code, and the phrase ‘code sanity’ floated across my imagination (metaphorically). I can see it on a motivational poster on some hacker’s dingy basement wall as the green-lit background on his text editor illuminates the freckles (probably acne) on his face. Code with sanity, perhaps – don’t go around getting the poor executable stuck on some infinite while loop or access memory out of bounds (shame).

Alternatively, it could be a way of saying that you’re so burnt out that you can only think logically in code, for instance, oh I don’t know, after staying up for 3 hours past midnight doing a programming competition on a school night. Yep, that happened this week. I wonder why I’m still on the laptop now typing this instead of clawing my skin out with shame and repent for the time I spent not studying.

Still, this particular round was quite a good one. It was Codeforces’ special round #300, because we like trailing zeroes in numbers. I ranked 336, made it to Master, and went to bed.

Considering that I’m not participating in many math competitions this year, I’ve been doing lots more coding instead. It’s replacing the void left in my mind whenever I stop thinking about math and realize how boring the real world is. (I’m just kidding.) Code is much more petty and messy than math, because one bug, one misplaced letter can kill a program. When I started off coding in Form 4, I was put off when I searched 3 hours for this bug between about a hundred lines of C++:

```for (int i = 0; i < n; i++) {
for (int j = 0; j < n; i++) {
//magic
}
}
```

But as you go along, you realize how important it truly is. You can’t tell a computer to do something if you enter the wrong keys. You can’t tell a compiler what to compile if you don’t declare <algorithm> before using min. You can’t tell me what to do if you don’t feed me good food. Then you join competitions and look at people like Petr blazing through 6 questions in this exact same round (#300) within half an hour – he did it without making a single bug, accepted on first attempt.

Coding is an art. You’re a mastermind controlling bits on a machine that is astoundingly dumb, and your job is to transfer your eternal wisdom onto it. No, the machine won’t know that you intended to type j instead of i in the code above. It won’t know that the segment tree you actually wanted to implement had size 4n instead of n (seriously, declare your trees with 4n nodes). It can catch little errors though, like when you stupidly declare a priority_queue and call .front() on it. Not much else.

```error: 'cout' was not declared in this scope
error: 'class std::priority_queue' has no member named 'front'
```

Then I learned more about coding. I learned graph algorithms like DFS and BFS, and learned how to implement them quickly and free of bugs. After that, I learned about Dijkstra, Bellman-Ford, and various ways to walk on a graph. You also get to learn that strings can be turned into trees and you can fill tables from the bottom up or from top down. You start associating the name Graham with the convex hull algorithm instead of the crackers.

And then you start doing competitions, and you feel good when you write something like this in just a few minutes and know exactly how it’s going to work. It feels really good when you code without pausing, though perhaps only because I’m picturing how cool it must look on the outside.

```if (tp) {
if (h[u]%2) {
if (adj[u].size() == 0) ans = 1;
else {
ans = MX;
for (int i = 0; i < adj[u].size(); i++) {
ans = min(ans, sz[v]-go(1, v));
}
ans = sz[u] - ans;
}
}
else {
for (int i = 0; i < adj[u].size(); i++) {
ans += go(1, v)-1;
}
ans++;
}
}
```

(This is an excerpt from the DP portion of the code I submitted for E in the Codeforces round above, full code here. I liked this problem.)

After a few years of coding, I’m pretty used to bugs and consider it part of the experience. Once you accept that yes, you might spend hours looking for silly bugs, you can start appreciating the hard problems. I recently spent a few hours implementing a (sadly doomed) $O(N^2)$ solution for a problem before I decided to read the editorial – and found out that there was a pretty simple solution in $O(n\log n)$ (using line sweeps, if anyone’s interested). This line sweep idea (but actually with some additional data structures) seems so simple, but it makes the difference between linear and logarithmic time. The difference is huge, just in case you’re not familiar.

I’m actually surprised that the little counter under the text box here is showing that I’m approaching 1000 words. I’m not sure why I started writing this in the first place. Next Saturday, I’m heading down to KL to participate in the 2015 APIO, and then return to this jungle of a college to continue my trudge through AS levels.

I guess if there was a point to this post, it would be this: writing code is keeping me challenged now, and I think I wouldn’t be able to function properly if I wasn’t. And now it feels appropriate and edgy to end this post with the quintessential example of basic programming:

```int main() {
cout << "Hello World!" << endl;
return 0;
}
```

## Halfway through, April

It’s halfway through April, I have 13 papers impending in the AS examinations next month and a couple of other exams to prepare for – it would seem that I should be, at least, slightly stressed out at the thought of the next two months. But strangely I’m feeling pretty good! Some interesting things this month:

1. UKM MEDebate 2015

We went to another debate tournament! Because it was the weekend right after our trial exams ended, the three of us headed to UKM to debate, unprepared, nervous and more than a little worried that we’d crash and burn miserably. It was a varsity tournament, for god’s sake, and we were the only A level team there. The tournament was themed ‘Medical Ethics’, something that unfortunately none of us knew much about, so we researched as much as we could the day before – reading up on the Hippocratic Oath, the vaccination controversy, issues about genetics and GMOs, etc – and hoped that our wit and whatever knowledge we had would pull us through.

We did our best anyway! We debated three preliminary rounds and won just one of them. We did, however, lose very narrowly to the eventual champions, so we felt slightly better about the result. Despite being the youngest team there (and probably the most inexperienced), we still ranked 5th on total speaks, and I finished at 12th on the speaker ranks!

KYUEM at UKM MEDebate 2015

Something I’ve noticed through debate is how persuasive speech can be – seven minutes of speech about an issue can be incredibly powerful. So whenever I go into a debate, I speak, keeping in mind that my opponents wield a huge amount of power when I hand over the floor. Conversely, I also recognize the fact that by speaking, I am also in a powerful position to repair and strengthen our case, to rebut every valid point the opposition has raised and turn the tides back in our favor.

It’s a far cry from math and code, where logic is definitive and words exact – logic here is infallible and binary. In language, it’s very hard to make general statements that are correct. It’s not true to say that “personal autonomy is the most important right”, because when your civil liberties trespass on other citizen’s rights, one might argue that one loses his/her autonomy there and then. But even here it’s subject to interpretation – why then do we allow people to smoke? Then we have to back up and fix the hole there.

This realm of debate is a much messier world, where words can be twisted, meaning warped, and logic bent. Still, I’m proud that I’m progressing and becoming more eloquent with speech. Words come more freely to my tongue now, and I’m looking forward to more next semester!

2. Code, code and more code

Despite trials taking up the bulk of last month, I found myself doing more and more coding as trials grew nearer. I did the Croatian Open the weekend before trials, and did two rounds of US Open the weekend between trials. These took up 13 hours in total, and I spent more time figuring out the problems I didn’t manage to solve during the contests. I got a perfect score on US Open silver:

Full results here

The Silver problems this year frankly weren’t that hard. I still made a few mistakes – for P1 I initially thought that I could count the permutations for each word separately and multiply, and foolishly started to code it out before realizing the obvious flaw halfway through. P2 was pretty nice in my opinion, but quite easily solved once you saw that you could iterate over each bale and find the extreme at the other end in $O(n)$ in one sweep. For P3, once you figure out that you could run BFS on each vertex to find the minimum distances, then a further $O(n^2)$ DP finishes it off.  Promoted to Gold!

I also did SRM 655 and finished 3rd on Division 2. I then proceeded to do quite badly on SRM 656 and a CF round two days ago. While I’m looking forward to more rounds, I’m also reading algorithms and data structures – balanced binary trees, maximum flow, and a seemingly infinite number of other paradigms. I’m just excited that there’s still a lot more for me to discover.

//////

Classes were suspended (temporarily, sadly) during the two weeks of trials, and all of a sudden I remembered why I loved having time to myself in high school. I spent so much time doing things that were simply interesting to me, and I loved having the liberty and free time to pursue whatever I wanted. During trials, I became that self again – I coded a little, read algorithms, read math, listened to music, and then I studied. I was happy again! And this is how the rest of the year is going to be – let’s do some great things.

## I joined a debate championship

Last weekend, I represented my college, KYUEM, at the Malaysian National Debating Championship at KDU Glenmarie. It was my first debating competition of any kind, and I dove into the competition feeling simultaneously terrified and excited.

I can’t really describe the feeling I had throughout the whole weekend, but it was just so, so amazing. Debating with my teammates felt amazing: the intense pressure of building a solid case in 30 minutes, seeing my teammates nod vigorously in agreement and say ‘hear, hear!’ while I delivered my speeches, the apprehension leading up to the announcement of results. Bracing ourselves for the disappointment of losing while having hope for the joy of winning.

It was just an incredible experience, and I’m looking forward to more of it later in the year. I might feel terrified all over again, but with this group of people, I’d be down for anything.

<3

## Focus refocus

ephemeral / transient / fleeting / transitory / fugacious

It’s 45 minutes away from the end of January, and I’m here in my college dorm room, thinking about this past month. My fluorescent lamp is broken and my room is dark, but for the most part, it’s been a good month.

Of course, there was some turbulence along the way. I spent the first three weeks of January preparing for the SAT, and with it came a plethora of vulnerabilities: dealing with College Board customer service, the lingering moodiness after a bad practice test, and the nascent worry that would float sporadically to the front of my mind – am I ready for this?

Part of this strange uneasiness is the recognition of the fact that in half a year, I’ll be sending off postmarked applications to universities across the world, detailing my thoughts and dreams, my achievements and some of my failures. It seems very much like an exercise in efficient marketing: explain and describe your being in 4000 characters and a few pages of paper. Thus I think the most important aspect of this process is to understand who I truly am and what I want to become. It’s rather nerve-wracking. A year ago in January, I enthusiastically set off to live alone in Kuala Lumpur on a three-month internship as a software programmer, an experience that convinced me that computer science was not for me and left me again without direction. Fast forward a year and I find myself with a clearer head and compass. I think I now understand better who I am.

On the 24th I traveled down to Subang Jaya to take the SAT. I had arranged meetings with some of my friends studying in KL, and frankly I couldn’t wait for the test to end so that I could talk to them again. I met up with Chun Horng, Michelle, Anzo and Yi Kye, and it felt amazing to see them and talk about the past and portend about the future. Now that I’m in college in an isolated jungle, these are the people I find myself thinking about when it’s past 12am and I can’t sleep. I send messages to them and hope they reply. Occasionally I boot up my laptop and look through the photos from the past – pictures from the IMO, family trips, birthday celebrations. Some nights I miss them so much my body seems to ache!

As January draws to a close, I want to remind myself to put things in perspective. Living in a small boarding school has this tunneling effect, and I often find myself worrying and moping about tiny little issues that seem so gargantuan under the microscope of this college. As of this moment, many things are OK with the world and my life. In a few minutes I will flip my desk calendar to ‘February’ knowing that it will perhaps bring even more (unwarranted) tumult and worry than this month has brought. But I know that at the end of it all I’ll be here again, reflecting about what’s happened and what’s not happened, and realize that things are indeed…fine.

Have a happy February!

## The power of voice

KYUEM delegation at TAYMUN 2014!

I used to have horrible stage fright: I would be so deathly terrified of walking up to a stage and opening my mouth that I would go to great lengths to avoid it. I turned down all my teachers’ suggestions that I participate in story-telling competitions and poem recitals in primary school, and singing and dancing on stage was just out of the question.

It wasn’t until late in secondary school that I realized sometimes, I would get this sudden urge to say things – that I actually had things that I wanted to express. The written word was my weapon, so I delved into this world of literature and writing, and I discovered the pen can sometimes be mightier than the mouth. I used to think by writing my thoughts down (or more frequently, clickety-clack on the keyboard), I was being forced to consider and reconsider them properly and thus engage in a more coherent and correct form of expression.

Sure, I could have all the clarity and accuracy I wanted in black and white on a piece of paper, but these 4 months at KYUEM has shown me how much I enjoy the chaotic world of speech. There’s a certain beauty in the spontaneity of speaking, the wit and humor in retorts and responses, the occasional slip of the tongue, and most importantly, the fast-paced two-dimensional exchange of ideas. In writing, we spend days writing 800-word essays and publish them, and by the time a reply gets back to us, the urgency of debate is lost. Speaking puts you on the spot and forces you to listen, interpret, analyze and articulate your response all in the frame of a few seconds, which is what I experienced and strangely…got into it.

Last month, I joined the first (of many more) debating workshops. where some of my debating friends had invited a seasoned debater to come and coach us after classes on Thursday and Friday. On my first day I apologetically told him that I was completely new to debating and that I had no prior experience, and for the rest of the night I tried to listen and understand what he was saying. I didn’t get much, really, and I felt quite out of place in the entire setting. I returned reluctantly for the second session on Friday. “OK, we’re gonna do what I call ‘speech therapy': you come out, give a speech, and I’ll tell you what you should work on.” Well, shit.

I worked on my topic for ten minutes and came up with a short speech about voting rights. I started to speak, and because it was so short, I ran out of words a minute later. “…and that’s all I have,” I said apologetically. Then he told me that it was actually pretty good. Encouraged, I returned for the subsequent workshops and found myself actually debating about strange topics like self-immolation. It was a whole new experience, and despite the discomfort, I grew to like it more and more.

This weekend I traveled up to Kuala Lumpur for the annual Taylor’s Model United Nations Conference (TAYMUN 2014). I represented China in the Disarmament and International Security Council (DISEC), where the topic of discussion was about foreign military intervention and the leakage of classified information. I’m pretty sure that this is the first time China has ever been so quiet about such topics, but I was again, nervous about speaking out even though I had done quite a bit of research into the debate. I gave a short speech and raised a few points of information, but I wish I had spoke out more and ignored this silly apprehension of mine.

If I could say one thing about my first semester, I’d say I’m grateful to have opportunities like these to push me out of my comfort zone, and good friends to share the experience with. Here’s to more debates and more diplomacy at model UN!

## Biology

Biology class picture!

December leaves me standing at the end of my first semester in college. Back in May I wrote a post trying to articulate my ambivalence about choosing a subject to further my studies in, and I think it’s time to ask myself – have I come far since then? Over the past few months and many unpublished drafts, I’ve tried to string this web of tangled thoughts into coherent pieces of language to no avail. But one thing I can be sure of is this: I like Biology.

Over the past few months in college, I’ve found myself gradually falling in love with the subject. I’m lucky enough to have an incredible, incredible Biology teacher who makes me look forward to class every day. He makes us venture beyond the confines of the syllabus to explain facts and figures presented in the coursebook, making sure we understand the motivation and reasons they must be true. He uses stories and scenarios coupled with wit and humor to drive points across, and I often find myself so immersed in these tales that they stay with me long after class ends.

I still can’t fully explain it, but I find Biology so, so amazing. It excites me to learn about the DNA replication mechanism – how it unwinds (catalyzed by topoisomerase), unzips (catalyzed by DNA helicase), how nucleotides are activated, how the base pairs bond to each other (hydrogen bonding), how the sugar-phosphate backbones are bonded (DNA polymerase III). My teacher even went beyond that – we learned about the leading and lagging strands, Okazaki fragments, the 10-base RNA primer. I truly felt that I was learning Biology and discovering more about the natural world, and I experience this over and over again, through the chapters about mitosis, molecular biology, even basic cell structure.

Among my conversations with my father this year, a large amount of them were about medicine and whether I should become a doctor. I also remember there was once I told him how I was, at once, fascinated and horrified by cancer, and how I thought I would be happy doing research in it. Sometime in September, we started on our first day of molecular biology. The introductory page on the coursebook mentioned the ‘relatively large number of Nobel prizes awarded in this field’, and I read, with interest, about the Nobel awarded for the discovery of DNA, as my teacher ran a background narration of the Meselson-Stahl experiment on the DNA replication mechanism in 1958.

I couldn’t help, then, but wonder if I could one day be able to contribute to the human race just as these scientists have. For all my thoughts about ‘doing something extraordinary’, perhaps the most extraordinary thing I can do, the one with the most seismic impact, would be to help save lives – not only during my lifetime but for centuries after. I can’t remember what my father said in response to my comment, but I do remember him saying how much he liked this line in my scholarship application essay: “I want to make an impact that is measurable and lasting, and I will be able to do that by becoming a…”