akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){

    int m, f, r;
    int sum=0;

    while(true){
    cin >> m >> f >> r;

    if((m==-1)&&(f==-1)&&(r==-1)) break;

    sum = (m+f+r);

    if((m==-1)||(f==-1)) cout << 'F' << endl;
    else if((m+f)>=80) cout << 'A' << endl;
    else if(((m+f)>=65)&&((m+f)<80)) cout << 'B' << endl;
    else if(((m+f)>=50)&&((m+f)<65)) cout << 'C' << endl;
    else if((((m+f)>=30))&&((m+f)<50)){
        if(r>=50) cout << 'C' << endl;
        else cout << 'D' << endl;
    }
    else if((m+f)<30) cout << 'F' << endl;
    }

    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m;
vector<int>edge[100005];
int dp[100005];
int rec(int x){
	if(dp[x] >= 0) return dp[x];
	if(edge[x].size() == 0) return dp[x] = 0;
	for(int i=0;i<edge[x].size();i++){
		int to = edge[x][i];
		dp[x] = max(dp[x],rec(to)+1);
	}
return dp[x];}
int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b; cin>>a>>b;
		edge[a].pb(b);
	}
	for(int i=1;i<=n;i++) dp[i] = -1;
	for(int i=1;i<=n;i++){
		rec(i);
	}
	int ans = 0;
	repn(i,n)ans=max(ans,dp[i]);cout<<ans<<endl;}

Measured memory_bytes: 8192
from functools import lru_cache
MOD = 10**9+7
x,y = map(int, input().split())
summ = x+y

@lru_cache(maxsize=None)
def inv(n):
    return pow(n,-1,MOD)

if summ%3 == 0 and summ//3 <= x and summ//3 <= y:
    mn = min(x,y)
    n = mn - summ//3
    a = summ//3
    b = 1
    ans = 1
    for i in range(n):
        ans *= a
        ans *= inv(b)
        ans %= MOD
        a -= 1
        b += 1
    print(ans)
else:
    print(0)

Measured memory_bytes: 40860
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<long long, long long> pl;
 
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define form(i, n) for (size_t i = 0; i < size_t(n); ++i)
#define forn(i, n) for (size_t i = 1; i <= size_t(n); ++i)
template<class T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll mod(ll a, ll b) { return (a%b+b)%b; }
ll gcd(ll x, ll y) { return __gcd(x, y); }
ll lcm(ll x, ll y) { return x * 1ll * y / gcd(x, y); }
 
 
const ll MAXN = 1e18;
const ll SIZE = 1e5 + 5;
const ll MOD  = 1e9 + 7;

ll a, b;
double c;


int main() { speedhack()

	cin >> a >> c;
	b = (c * 100) + 0.0001;

	a = a * b;
	a = a / 100;

	cout << a << endl;


	return 0;
}


Measured memory_bytes: 3740
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        String t = sc.next();

        for(int i = 0; i < n; i++) {
        	if(s.charAt(i) == t.charAt(0)) {
        		String subS = s.substring(i+1, n);
        		String subT = t.substring(1, n - i);
        		if(subS.equals(subT)) {
        			System.out.println(n + i);
        			return;
        		}
        	}
        }
        System.out.println(n + n);
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
int main(){
    int n,q;
    cin >> n >> q;
    string s;
    cin >>s;
    vector<int> l(q);
    vector<int> r(q);
    for(int i=0;i<q;i++){
        cin >> l[i] >> r[i];
        l[i] -=1;
        r[i] -=1;
    }
    vector<int> ac(n,0);
    if(s[0]=='A'&&s[1]=='C'){
        ac[1]=1;
    }
    for(int i=1;i<n;i++){
        if(s[i-1]=='A'&& s[i]=='C'){
            ac[i]=ac[i-1]+1;
        }
        else{
            ac[i]=ac[i-1];
        }
    }
    rep(i,q){
        cout << ac[r[i]]-ac[l[i]]<<endl;
        //cout << ac[i] << " ";
    }
    cout <<endl;
}

Measured memory_bytes: 2176
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) throws IOException{ 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		int[] abc = new int[26];
		while((line = br.readLine()) != null){
			for (int i = 0; i<line.length() ; i++ ) {
				char c = line.charAt(i);
				c = Character.toLowerCase(c);
				char cc ='a';
				for (int j = 0; j<abc.length ; j++ ) {
					if (cc == c) {
						abc[j]++;
					}
						cc++;
				}
			}
		}

		char c ='a';
		for (int i = 0 ; i<abc.length ; i++ ) {
			System.out.println(c+" : "+abc[i]);
			c++;
		}
	}
}

Measured memory_bytes: 24344
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
    
    
    int a,b,c,d,e,f,x,y,z;
    
    cin>>a>>b>>c>>d>>e>>f;
    
    x=min(min(min(a,b),c),d);
    z=a+b+c+d;
    z=z-x;
    y=max(e,f);
    cout<<z+y<<endl;
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main(){
    int n,m;
    cin >> n >> m;
    vector<bool> ac_bool(n,false);
    vector<int> wa_cnt(n);
    for(int i=0;i<m;i++){
        int p;
        string s;
        cin >> p >> s;
        if(ac_bool[p-1]) continue;
        else{
            if(s=="AC"){
                ac_bool[p-1]=true;
            }else{
                ++wa_cnt[p-1];
            }
        }
    }
    int ac_num=0,wa_num=0;
    for(int i=0;i<n;i++){
        if(ac_bool[i]){
            ++ac_num;
            wa_num+=wa_cnt[i];
        }
    }
    printf("%d %d\n",ac_num,wa_num);
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

int main() {
    int a,b,c,x,y,t1,t2,t3;
    
    std::cin >> a >> b >> c >> x >> y;

    t3 = a * x + b * y;
    if(x>y){
        t1 = c * 2 * y + a * (x - y);
        t2 = c * 2 * x;
    } else {
        t1 = c * 2 * x + b * (y - x);
        t2 = c * 2 * y;
    }

    std::cout << std::min(std::min(t1, t2), t3) << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

int main() {
  int X,Y,Z,K;
  cin >> X >> Y >> Z >> K;
  vector<long long> A(X), B(Y), C(Z);
  REP(i, X) cin >> A[i];
  REP(i, Y) cin >> B[i];
  REP(i, Z) cin >> C[i];
  vector<long long> dp;
  REP(i, X) REP(j, Y) dp.push_back(A[i] + B[j]);
  sort(dp.rbegin(), dp.rend());
  dp.resize(K+1);
  vector<long long> dp2;
  REP(i, dp.size()) REP(j, Z) dp2.push_back(dp[i] + C[j]);
  sort(dp2.rbegin(), dp2.rend());
  REP(i, K) cout << dp2[i] << '\n';
}


Measured memory_bytes: 43112
#include <cstdlib>
#include <iostream>
#include <typeinfo>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int count = 0;
  for (int i = 0; i <= a;i++){
    for (int j = 0; j <= b;j++){
      for (int k = 0; k <= c;k++){
        if(500*i+100*j+50*k==x){
          count++;
        }
      }
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if(a > b) swap(a,b);
	if(b > c) swap(b,c);
	if(a > b) swap(a,b);
	if((b-a)%2==0)cout << (c-b)+(b-a)/2;
	else {
		a+= 1;
		c+= 1;
		cout << c-b+(b-a)/2+1;
	}
	return 0;
}

Measured memory_bytes: 256
#define dbg(...) "amit_dwivedi"
#define db(...)  "Too OP"
#include "bits/stdc++.h"        
using namespace std;using ll=long long;
ll power(ll a, ll b)    //a is base, b is exponent
{
    return a*a*a*a*a;
}
ll x;
void sol(){
    cin>>x;
    for(int i=-200; i< 200; i++) {
        for(int j=-200; j< 200; j++) {
            ll cur = power(j,5) - power(i,5);
            if(x == cur){
                cout<<j<<" "<<i<< endl;
                return;
            }
        }
    }
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);
    // int t;cin>>t;while(t--)
    sol();
}
 

Measured memory_bytes: 3612
//#include <tourist>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD =
    998244353;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//g++ yarudake.cpp -std=c++17 -I .
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    vector<ll> ans = convolution<MOD>(a, b);
    rep(i, ans.size()) cout << ans[i] << "\n";
}

Measured memory_bytes: 27252
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum[2000000], ans, dp[100000], a[500][500];
Pll b[2000000];
string str;
bool f;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } };
struct Edge { LL from, cost; };
vector<Edge>vec[1000000];
vector<Pll>v;
map<string, LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> h >> w >> n;
	rep(i,h)
		rep(j, w) {
		cin >> a[i][j];
		b[a[i][j]-1] = Pll(i,j);
	}
	cin >> q;
	rep(i, h*w) {
			dp[i] = -1;
	}
	Mfor(i, h*w) {
		if (dp[i] == -1) {
			dp[i] = 0;
			cnt = 1;
			while (i - cnt * n >= 0) {
				dp[i - cnt * n] = dp[i - (cnt - 1)*n]
					+ abs(b[i - (cnt - 1)*n].fir - b[i - cnt * n].fir)
					+ abs(b[i - (cnt - 1)*n].sec - b[i - cnt * n].sec);
				cnt++;
			}
		}
	}
	rep(i, q) {
		LL x, y;
		cin >> x >> y;
		cout << dp[x-1] - dp[y-1] << endl;
	}
	return 0;
}


Measured memory_bytes: 33920
slime_num = int(input())
color_str = input()
ans = 0
pre_color = "aa"
same_color_check = 0
for i in color_str:
    if not same_color_check:
        if i == pre_color:
            same_color_check = 1
        else:
            ans += 1
            pre_color = i
    else:
        if i != pre_color:
            same_color_check = 0
            pre_color = i
            ans += 1
print(ans)


Measured memory_bytes: 3316
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	list := make([]int, m)
	broken := make([]bool, n+1)
	for i := 0; i < m; i++ {
		fmt.Scan(&list[i])
		broken[list[i]] = true
	}

	dp := make([]int, n+1)
	dp[0] = 1
	if !broken[1] {
		dp[1] = 1
	}
	for i := 2; i <= n; i++ {
		if !broken[i-1] {
			dp[i] += dp[i-1]
		}
		if !broken[i-2] {
			dp[i] += dp[i-2]
		}
		dp[i] %= 1000000007
	}
	fmt.Println(dp[n])
}


Measured memory_bytes: 5504
#include<iostream>
#include<set>
using namespace std;

int N, K;
int P[200000];
int uft[200000];

int root(int x){
  if(uft[x] == x){
    return x;
  }
  return uft[x] = root(uft[x]);
}

void unite(int x, int y){
  uft[root(x)] = root(y);
}



int main(){
  cin >> N >> K;
  for(int i = 0; i < N; i++){
    cin >> P[i];
  }
  for(int i = 0; i < N; i++){
    uft[i] = i;
  }

  bool sorted[200000] = {};
  int prev_sorted_idx = 0;
  for(int i = 1; i < N; i++){
    if(P[i] < P[i - 1]){
      prev_sorted_idx = i;
    }
    if(i - prev_sorted_idx + 1 >= K){
      sorted[i - K + 1] = true;
      unite(N - K + 1, i - K + 1);
    }
  }

  set<int> values;
  for(int i = 0; i < K; i++){
    values.insert(P[i]);
  }

  for(int i = K; i < N; i++){
    if(P[i] > *values.rbegin() && P[i - K] == *values.begin()){
      unite(i - K, i - K + 1);
    }
    values.erase(P[i - K]);
    values.insert(P[i]);
  }

  for(int i = 0; i <= N; i++){
    root(i);
  }
  int ans = 0;
  for(int i = 0; i + K <= N; i++){
    if(root(i) == i){
      // cout << i << endl;
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 11136
#include <iostream>
#include <map>

int main()
{
	int n;
	std::cin >> n;
	std::map<int, int> a;
	int key;
	for (int i = 1; i <= n; i++) {
		std::cin >> key;
		a[key] = i;
	}
	
	for (auto [key, value] : a) {
		std::cout << value << ' ';
	}
	std::cout << std::endl;
	
	return 0;
}


Measured memory_bytes: 7868
#include<cstdio>
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a<=b&&b<=c){
	    printf("%d %d %d\n",a,b,c);
    }
	else if(a<=c&&c<=b){
		printf("%d %d %d\n",a,c,b);
	}
	else if(b<=a&&a<=c){
		printf("%d %d %d\n",b,a,c);
	}
	else if(b<=c&&c<=a){
		printf("%d %d %d\n",b,c,a);
	}
	else if(c<=a&&a<=b){
		printf("%d %d %d\n",c,a,b);
	}
	else if(c<=b&&b<=a){
		printf("%d %d %d\n",c,b,a);
	}
}

Measured memory_bytes: 2728
# coding: utf-8
H = int(raw_input())
A = map(int,raw_input().split())

for i in range(H):
    parent_key = ""; left_key = ""; right_key = ""; ans = ""
    if i > 0:
        parent_key = "parent key = " + str(A[(i+1)/2-1]) + ", "
    if 2*(i+1) - 1 < H:
        left_key = "left key = " + str(A[2*(i+1)-1])  +", "
    if 2*(i+1) < H:
        right_key= "right key = " + str(A[2*(i+1)]) + ", "
    ans = "node " +str(i + 1) + ": key = "+ str(A[i]) + ", " +\
        parent_key + left_key + right_key
    print ans

Measured memory_bytes: 4228
#include <bits/stdc++.h>
 
#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second
#define sf scanf
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
 
const int N = (int) 1e6;
const int INF = (int) 1e9 + 7;
 
int main(int argc, char *argv[])
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);
 
	int n;
	sf("%d", &n);
	char s[N + 7];
	vector<ii> a;
	vector<ii> b;
	for (int j = 0; j < n; ++j) {
		sf("%s", s);
		int x = 0;
		int y = 0;
		for (int i = 0; i < strlen(s); ++i) {
			if (s[i] == '(') {
				++x;
			}
			else {
				if (x < 1) {
					++y;
				}
				else {
					--x;
				}
			}
		}
 
		if (x > y) {
			a.pp(mp(y, x));
		}
		else if (x < y) {
			b.pp(mp(x, y));
		}
		else {
			a.pp(mp(y, x));
			b.pp(mp(x, y));
		}
	}
 
	sort(a.begin(), a.end());

	int cur = 0;
	for (int i = 0; i < a.size(); ++i) {
		if (cur < a[i].fs) {
			puts("No");
			return 0;
		}
 
		cur += a[i].sc - a[i].fs;
	}

	sort(b.begin(), b.end(), greater<ii>());

	for (int i = 0; i < b.size(); ++i) {
		if (cur < b[i].sc) {
			puts("No");
			return 0;
		}
		cur += b[i].fs - b[i].sc;
	}
 
	puts(cur == 0 ? "Yes" : "No");
 
	return 0;
}


Measured memory_bytes: 11272
import java.io.*;
public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
		String str=input.readLine();
		String[] str2=str.split(" ");
		int a=Integer.parseInt(str2[0]);
		int b=Integer.parseInt(str2[1]);
		if(a<b){
		System.out.println("a < b");
		}
		if(a>b){
		System.out.println("a > b");
		}
		if(a==b){
		System.out.println("a == b");
		}
		
		
	}
}

Measured memory_bytes: 24292
// Code for D - Chat in a Circle
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define FOR(i,x,y) for(ll i=x;i<(ll)(y);i++)

#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

int main() {
  ll N;
  cin >> N;

  vector<ll> A(N);
  REP(i, N) {
    cin >> A[i];
  }

  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());

  if (N == 2) {
    cout << A[0] << endl;
    return 0;
  }

  // N = 3 のとき
  ll total = A[0];
  FOR(i, 2, N) {
    total += A[i / 2];
  }

  cout << total << endl;
  return 0;
}


Measured memory_bytes: 4824
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    sort(all(v));
    double price = (double) v[0];
    for (int i = 1; i < n; i++) {
        price = (price + v[i]) / 2.0;
    }
    cout << price << "\n";
}

Measured memory_bytes: 3688
S = gets.chop

s0 = S[0,2].to_i
s1 = S[2,2].to_i

def is_month(v)
  return (v <= 12 and v >= 1)
end

if is_month(s0)
  if is_month(s1)
    puts "AMBIGUOUS"
  else
    puts "MMYY"
  end
else
  if is_month(s1)
    puts "YYMM"
  else
    puts "NA"
  end
end
                

Measured memory_bytes: 1788
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;

int main() {
  int n; cin>>n;
  int p[100];

  for(int i=0;i<n;i++)
    cin >> p[i] ;

  int count=0;

  for(int i=1; i<=n ;i++)
  if(i != p[i-1]) count++;

  if(count <=2) cout << "YES"<<endl;
  else cout<<"NO"<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;

int n;
int _left[25];
int _right[25];
int root_id;
vector<int> pre, in, post;

void input() {
	cin >> n;
	
	bool is_root[25];
	int i;
	for (i = 0; i < n; i++) is_root[i] = true;
	for (i = 0; i < n; i++) {
		int id;
		cin >> id;
		cin >> _left[id] >> _right[id];
		if (_left[id] >= 0) {  is_root[_left[id]] = false; }
		if (_right[id] >= 0) { is_root[_right[id]] = false; }
	}
	for (i = 0; i < n; i++) {
		if (is_root[i]) {
			root_id = i;
			break;
		}
	}
}

void dfs(int v) {
	pre.push_back(v);
	if (_left[v] != -1) dfs(_left[v]);
	in.push_back(v);
	if (_right[v] != -1) dfs(_right[v]);
	post.push_back(v);
}

int main() {
	input();
	dfs(root_id);
	
	cout << "Preorder" << endl << " ";
	for (int i = 0; i < pre.size(); i++) {
		cout << pre[i];
		if (i + 1 < pre.size()) cout << " ";
	}
	cout << endl;
	
	cout << "Inorder" << endl << " ";
	for (int i = 0; i < in.size(); i++) {
		cout << in[i];
		if (i + 1 < in.size()) cout << " ";
	}
	cout << endl;
	
	cout << "Postorder" << endl << " ";
	for (int i = 0; i < post.size(); i++) {
		cout << post[i];
		if (i + 1 < post.size()) cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define ld double
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pob pop_back
#define pll pair<ll,ll>
using namespace std;

int main() 
{
	int n,i,j,prod=0;
	cin>>n;
	vector<int>a(n);
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=0;i<n-1;i++)
	{
		int temp1=a[i];
		for(j=i+1;j<n;j++)
		{
			prod=prod+temp1*a[j];
		}
	}
	cout<<prod;
	return 0;
}


Measured memory_bytes: 256
from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

T = input()
t=list(T)
cnt=0
for i in range(len(t)):
    if t[i] == "?":
        if i == len(t)-1:
            t[i] ="D"
        elif t[i+1] != "P" and t[i-1] !="P":
            t[i] ="P"
        else:
            t[i] ="D"


for i in range(len(t)):
    print(t[i] ,end="")
print("")

Measured memory_bytes: 10864
#include "iostream"
#include "string"


int main()
{
	short int room[4][3][10] = {0};
	short int b, f, r, v, n;
	std::cin >> n;

	for (int i = 0; i < n; i++) {
		std::cin >> b >> f >> r >> v;
		room[b - 1][f - 1][r - 1] += v;
	}

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				std::cout << " " << room[i][j][k];
			}
			std::cout << std::endl;
		}
		if (i < 3)
			std::cout << "####################" << std::endl;
		
	}
    return 0;
}

Measured memory_bytes: 3080
/*================================================================
Love China, Love YALI, Love OI!
*   
*   File Name：B.cpp
*   Author：YaliKiWi
*   Date：2019年08月18日
*   Discribe：
*
================================================================*/


#include<bits/stdc++.h>
using namespace std;
#define fo(i,s,e) for(register int i=s;i<=e;i++)
#define max_(x,y) ((x)>(y)?(x):(y))
#define min_(x,y) ((x)<(y)?(x):(y))
#define dd double
#define ull unsigned long long
#define ll long long
#define maxn 110
dd a[maxn],ans;
int n;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	fo(i,1,n){
		cin>>a[i];
		dd b=1/a[i];
		ans+=b;
	}
	printf("%.6f",1/ans);
	return 0;
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define ushi int
#define tapu main
#define nichia (
#define kunn void
#define wara )

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/

int main(){

	int a[3];
	scanf("%d%d%d", &a[0], &a[1], &a[2]);
	sort(a , a + 3);
	printf("%d\n", abs(a[1] - a[0]) + abs(a[2] - a[1]));

	Please AC;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

typedef long long int_type;
const int MAX_N = 5005;
int_type base = 1007;
int_type mod = 1000000007;

vector<int_type> pow1(MAX_N,1);
void pow_init() {
    for(int i=1;i<MAX_N;++i) {
        pow1[i] = pow1[i-1] * base % mod;
    }
}

struct RollingHash {

    vector<int_type> hash;

    RollingHash(){}

    void init(const string &s) {
        int n=s.size();
        hash.assign(n+1,0);
        for (int i=0;i<n;++i) {
            hash[i+1] = (hash[i]+s[i]) * base % mod;
        }
    }

    int_type get(int l, int r) {
        int_type t = (hash[r] - hash[l] * pow1[r-l] % mod + mod) % mod;
        return t; 
    }

    int lcp(RollingHash &b, int l1, int r1, int l2, int r2) {
        int len = min(r1-l1, r2-l2);
        int low = -1;
        int high = len+1;
        int mid;
        while(high-low>1) {
            mid = (high+low) / 2;
            if(get(l1,l1+mid) == b.get(l2,l2+mid)) low = mid;
            else high = mid;
        }
        return low;
    }

    int_type concat(int_type h1, int_type h2, int h2_len) {
        int_type res = h1 * pow1[h2_len] % mod + h2;
        if(res >= mod) res -= mod;
        return res;   
    }

};

int main() {
    pow_init();
    int N; cin >> N;
    string S; cin >> S;
    RollingHash RH; RH.init(S);
    int high = N;
    int low = 0;
    int mid;
    while(high-low>1) {
        mid = (high+low) / 2;
        map<int_type,int> hash_set;
        bool flag = false;
        REP(i,N-mid+1) {
            if(hash_set.find(RH.get(i,i+mid))==hash_set.end()) {
                hash_set[RH.get(i,i+mid)] = i;
            }
            else if(i-hash_set[RH.get(i,i+mid)]<mid){
				continue;
            }
			else {
            	flag = true;
				break;
            }
        }
        if(flag) low = mid;
        else high = mid;
    }
    cout << low << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;

llint m, n;
llint lb[105][105], ub[105][105];
vector<llint> G[105];
vector<llint> topo;
bool used[105];

void tpsort(int v)
{
	used[v] = true;
	for(int i = 0; i < G[v].size(); i++){
		if(!used[G[v][i]]) tpsort(G[v][i]);
	}
	topo.push_back(v);
}

int main(void)
{
	cin >> m >> n;
	llint x, s, t; string c;
	for(int i = 1; i <= m; i++){
		for(int j = 1; j <= n; j++) ub[i][j] = inf, lb[i][j] = -inf;
		cin >> x;
		for(int j = 0; j < x; j++){
			cin >> s >> c >> t;
			if(c == "<=") ub[i][s] = min(ub[i][s], t);
			else lb[i][s] = max(lb[i][s], t);
		}
	}
	
	for(int i = 1; i <= m; i++){
		for(int j = 1; j <= n; j++){
			if(ub[i][j] < lb[i][j]){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	for(int i = 1; i <= m; i++){
		for(int j = 1; j <= m; j++){
			for(int k = 1; k <= n; k++){
				if(ub[i][k] < lb[j][k]){
					G[i].push_back(j);
					break;
				}
			}
		}
	}
	
	
	for(int i = 1; i <= m; i++) if(!used[i]) tpsort(i);
	reverse(topo.begin(), topo.end());
	
	for(int i = 1; i <= m; i++) used[i] = false;
	for(int i = 0; i < topo.size(); i++){
		int v = topo[i];
		used[v] = true;
		for(int j = 0; j < G[v].size(); j++){
			if(used[G[v][j]]){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	
	return 0;
}


Measured memory_bytes: 3460
def input_from_console():
    s = input().rstrip()
    k = input().rstrip()
    return s, k


def solve(s, k):
    if s.isalpha() and k.isalpha() and s == k[0:len(s)] and len(s) == len(k) - 1:
        return "Yes"
    return "No"


def main():
    s, k = input_from_console()

    print(solve(s, k))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()

Measured memory_bytes: 9152
import java.util.*;
public class Main {
	public static void main(String[] args){
	    Scanner sc=new Scanner(System.in);
	    int n=sc.nextInt();
	    while(n!=0){
	        int[] num=new int[n];
	        for(int i=0;i<n;i++)num[i]=sc.nextInt();
	        int max=Integer.MIN_VALUE,min=0,sum=0;
	        for(int i=0;i<n;i++){
	        	sum += num[i];
	        	if(sum-min>max)max=sum-min;
	        	if(sum<min)min=sum;
	        }
	        System.out.println(max);
	        n=sc.nextInt();
	    }
	}
}
//by Tuvshee 12.05.2012
//Maximum sum sequence

Measured memory_bytes: 12000
#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

using ll = long long;

const int Inf = 100100100;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	int p, q, r;
	cin >> p >> q >> r;
	cout << min(p + q, min(q + r, r + p)) << endl;
	
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef tree<signed, null_type, less_equal<signed>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//find_by_order();
//order_of_key();
 
#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair
 
#define debug(_x)		cerr << #_x << '=' << (_x) << endl;
#define debug2(_x, _y)	cerr << #_x << '=' << (_x) << ' ' << #_y << '=' << (_y) << endl;
#define debugn(_a)		cerr << #_a << ": "; for (const auto _x: _a) cerr << (_x) << ' '; cerr << endl;

#define HERE debug(__LINE__);

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX>>1;
const int NINF = LONG_LONG_MIN/2;

const double PI = 3.141592653589793238;

int32_t main() {
	FAST_IO;
	
	int a, b, h, m;
	cin >> a >> b >> h >> m;
	
	double theta_h = h*(2*PI/(double)12);
	double theta_m = m*(2*PI/(double)60);
	theta_h += (theta_m/(2*PI))*(2*PI/(double)12);

	double delta_theta = abs(theta_h-theta_m);
	
	cout << fixed << setprecision(10) << sqrt(a*a + b*b - 2*a*b*cos(delta_theta)) << endl;
}

// g++ -Wall -Wextra -Wshadow -fsanitize=undefined


Measured memory_bytes: 4240
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b; cin >> a >> b;
    if(a == 1) a = 14;
    if(b == 1) b = 14;
    cout << (a == b ? "Draw" : a > b ? "Alice" : "Bob") << endl;
    return 0;
}


Measured memory_bytes: 256
list_w = []
list_k = []

for i in range(10) :
    list_w.append(int(input()))
for i in range(10) :
    list_k.append(int(input()))

list_w.sort(reverse = True)
list_k.sort(reverse = True)

sumw = sum(list_w[0:3])
sumk = sum(list_k[0:3])

print(sumw, sumk)


Measured memory_bytes: 5600
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int i;
  int n;
  while(cin>>n,n){
    deque<int> a,b;
    for(i=0;i<n;i++){
      int p,q;
      cin>>p>>q;
      a.push_back(p);
      b.push_back(q);
    }
    int x=0,y=0;
    double z=M_PI/2;
    double sm=0;
    while(a.size()){
      int mn=0;
      for(i=1;i<(int)a.size();i++){
	if(0){
	}else if((atan2(b[mn]-y,a[mn]-x)>z?atan2(b[mn]-y,a[mn]-x)-M_PI*2:atan2(b[mn]-y,a[mn]-x))<(atan2(b[i]-y,a[i]-x)>z?atan2(b[i]-y,a[i]-x)-M_PI*2:atan2(b[i]-y,a[i]-x))){
	  mn=i;
	}else if((atan2(b[mn]-y,a[mn]-x)>z?atan2(b[mn]-y,a[mn]-x)-M_PI*2:atan2(b[mn]-y,a[mn]-x))==(atan2(b[i]-y,a[i]-x)>z?atan2(b[i]-y,a[i]-x)-M_PI*2:atan2(b[i]-y,a[i]-x))){
	  if((a[mn]-x)*(a[mn]-x)+(b[mn]-y)*(b[mn]-y)>(a[i]-x)*(a[i]-x)+(b[i]-y)*(b[i]-y))
	    mn=i;
	}
      }
      sm+=sqrt((a[mn]-x)*(a[mn]-x)+(b[mn]-y)*(b[mn]-y));
      z=atan2(b[mn]-y,a[mn]-x);
      x=a[mn];
      y=b[mn];
      a.erase(a.begin()+mn);
      b.erase(b.begin()+mn);
    }
    printf("%.1lf\n",sm);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

const int N = 1e5;

int pos[N], ans[N];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);


    string s;
    cin >> s;
    int n = (int)s.size();

    int last;
    for (int i = 0; i < n; ++i)
    {
        if (s[i] == 'R')
            last = i;
        else
            pos[i] = last;
    }
    for (int i = n - 1; i >= 0; --i)
    {
        if (s[i] == 'L')
            last = i;
        else
            pos[i] = last;
    }


    for (int i = 0; i < n; ++i)
        ans[i] = 0;

    for (int i = 0; i < n; ++i)
    {
        if (i < pos[i])
        {
            if ((pos[i] - i) & 1)
                ++ans[pos[i] - 1];
            else
                ++ans[pos[i]];
        }
        else
        {
            if ((i - pos[i]) & 1)
                ++ans[pos[i] + 1];
            else
                ++ans[pos[i]];
        }
    }

    for (int i = 0; i < n; ++i)
        cout << ans[i] << ' ';
}


Measured memory_bytes: 1488
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using vb = vector<bool> ;
using pll = pair<ll, ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;


void pre(){

    

}

ll go(ll n){
    if(n==0)    
        return 0;
    ll bits = __builtin_popcount(n);
    return 1 + go(n%bits);
}


void solve(){

    ll n;
    cin >> n;
    string s;
    cin >> s;
    reverse(all(s));
    ll c=0;
    for(auto ch : s)if(ch=='1')c++;

    vll mod = {c-1,c,c+1};
    vll A[3];
    for(ll i=0;i<3;i++){
        A[i].resize(n+1);
        fill(all(A[i]),1);
        for(ll j=0;j<n;j++){
            if(mod[i]){
                A[i][j+1] = A[i][j]*2%mod[i];
            }
        }
    } 

    vll tot(3,0);
    for(ll i=0;i<n;i++){
        if(s[i] == '1'){
            for(ll j=0;j<3;j++){
                tot[j] += A[j][i]; 
            }
        }
    }

    vll ans(n,0);
    for(ll i=0;i<n;i++){
        if(s[i] == '1'){
            if(c==1){
                ans[i] = 0;
            }else{
                ans[i] = 1 + go((tot[0] - A[0][i] + mod[0])%mod[0]);
            }
        }else{
            ans[i] = 1 + go((tot[2] + A[2][i])%mod[2]);
        }
    }
    reverse(all(ans));
    for(ll i=0;i<n;i++){
        cout << ans[i] << endl;
    }

}


int main(){
    #ifndef ONLINE_JUDGE
    freopen("input00.txt","r",stdin);
    #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 9576
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;

int scores[10001];

int main() {
    int n;
    cin >> n;
    long s;
    REP(i,n) {
        cin >> s;
        for (int j = 10000; j >= 0; j--) {
            if (scores[j]) {
                scores[j + s] = 1;
            }
        }
        scores[s] = 1;
    }
    
    long ans = 0;
    REP(i,10001) {
        if (scores[i] && i % 10) {
            ans = i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import math
A, B, H, M  = map(int, input().split())

Hx = A*math.sin(math.radians(360*((H*60+M)/(12*60)))) 
Hy = A*math.cos(math.radians(360*((H*60+M)/(12*60)))) 
Mx = B*math.sin(math.radians(360*(M/60))) 
My = B*math.cos(math.radians(360*(M/60)))

print(((Hx-Mx)**2 + (Hy-My)**2)**(1/2))

Measured memory_bytes: 9548
#include <iostream>
#include <vector>
#include <string>

//using namespace std;


int main(void) {

	int n,i;
	std::cin >> n;
	std::vector<int> a(n);
	std::vector<int> b(n);
	std::vector<int> c(n);
	for (i = 0; i < n; i++) {
		std::cin >> a.at(i);
	}
	for (i = 0; i < n; i++) {
		std::cin >> b.at(i);
	}
	for (i = 0; i < n-1; i++) {
		std::cin >> c.at(i);
	}
	int s = 0;
	for (i = 0; i < n; i++) {
		s += b.at(i);
	}

	//std::cout << s << std::endl;


	
	for (i = 0; i < n-1; i++) {
		if (a.at(i + 1) - a.at(i) == 1) {
			s += c.at(a.at(i)-1);
			
		}

	}
	std::cout << s << std::endl;
	return 0;
}


Measured memory_bytes: 256
// khodaya khodet komak kon
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;

const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll N = 2e5 + 10;
const ll INF = 1e18;
const ll LOG = 20;
ll n, v ,u, dp[N];
vl g[N];
ll longest_path;
ll Max, who;
ll DFS(ll v, ll p = 0, ll h = 0){
	if (h > Max){
		who = v;
		Max = h;
	}
	for (auto u:g[v]){
		if (u == p) continue;
		DFS(u, v, h + 1);
	}
}


int main(){
	IOS;
	cin >> n;
	for (int i = 1; i < n; i++){
		cin >> v >> u;
		g[v].pb(u), g[u].pb(v);
	}
	dp[1] = 1;
	dp[2] = 2;
	for (int i = 3; i < N; i++){
		if (dp[i - 1] == 2 || dp[i - 2] == 2) dp[i] = 1;
		else dp[i] = 2;
	}
	DFS(1);
	Max = 0;
	DFS(who);
	if (dp[Max + 1] == 1) cout << "First";
	else cout << "Second";
	
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




Measured memory_bytes: 21760
#include <bits/stdc++.h>
using namespace std;
// int facctorialMethod(int k){
//     int sum = 1;
//     for (int i = 1; i <= k; ++i)
//     {
//         sum *= i;
//     }
//     return sum;
// }
int main(){
    int N;
    int M;
    cin >> N >> M;
    vector<int> A(M);
    int sum = 0;
    for(int i=0;i<M;i++){
        cin >> A.at(i);
        sum += A.at(i);
    }
    if(sum > N){
        cout << -1 << endl;
    }
    else{
        cout << N-sum << endl;
    } 
    // vector<int> c(N);
    // sort(vec.begin(),vec.end());
    // string tmp = vec.at(0);
    // for(int i=1;i<N;i++){
    //     if(vec.at(i)==tmp){
    //         tmp = vec.at(i)
    //         c(i)
    //     }
    // }
    // cout << 2.00000*N*M_PI << endl;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;

int main(){
  string s;
  cin >> s;
  int ans = 0;
  for(int i=0;i<4;i++){
    if(s.at(i) == '+'){
      ans++;
    }else{
      ans--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1e9+7) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

// ------------------------------------------------------------------------------------------

signed main() {
  int K, A, B;
  cin >> K >> A >> B;

  if (A >= B) {
    cout << K + 1 << endl;
    return 0;
  }

  int ans = 1;
  while (K > 0) {
    if (ans >= A && K >= 2 && (B - A) > 1) {
      ans += B - A;
      K -= 2;
    } else {
      ans++;
      K--;
    }
    // dbg(ans)
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;

}

signed main() {
	ll n;

	cin >> n;

	vector<vector<ll>> a(n, vector<ll>(n, 0));
	vector<vector<ll>> dp(n + 1, vector<ll>(1 << n, 0));

	REP(i, n) {
		REP(j, n) {
			cin >> a[i][j];
		}
	}

	dp[0][0] = 1;

	FOR(i, 1, n + 1) {
		REP(j, 1 << n) {
			bitset<22> bs(j);
			if (bs.count() == i - 1) {
				REP(k, n) {
					if (!bs[k] && a[i - 1][k]) {
						dp[i][j | (1 << k)] += dp[i - 1][j];
						dp[i][j | (1 << k)] %= MOD;
					}
				}
			}
		}
	}

	cout << dp[n][(1 << n) - 1] % MOD << endl;
}

Measured memory_bytes: 377216
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  vector<char> kigo(4);
  for (int i=0; i<4; i++) cin >> kigo[i];
  int ans = 0;
  for (int i=0; i<4; i++) {
    if (kigo[i] == '+') ans++;
    else ans--;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        long[] A = cin.ArrayLong(N);
        long[] sum = new long[N];
        long now = 0;
        Dictionary<long, long> dic = new Dictionary<long, long>();
        dic[now] = 1;

        long ans = 0;
        for (int i = 0; i < N; i++)
        {
            now += A[i];
            if (!dic.ContainsKey(now)) dic[now] = 0;
            ans += dic[now];
            dic[now]++;
        }

        Console.WriteLine(ans);
    }

}




class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}



Measured memory_bytes: 42096
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  string s[]={"Sunny","Cloudy","Rainy"};
  string t;
  cin >> t;
  for(int i=0;i<3;i++){
    if(t==s[i]){
      cout << s[(i+1)%3]<<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
ans = 0
while(1):
  tmp = len(list(filter(lambda x: x%2 == 0,A)))
  if tmp == N:
    ans += 1
    A = list(map(lambda x: x//2,A))
  else:
    break
print(ans)

Measured memory_bytes: 3060