akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#define int long long
using namespace std;
const int NM = 100000+1;
const int MOD = 1e9+7;
int n;
bool visited[NM];
vector<int> graph[NM];
pair<int,int> colors[NM];

pair<int,int> getColor(int i,int p=0) {
    colors[i].first = colors[i].second = 1;
    visited[i] = true;
    for(int j = 0;j<graph[i].size();j++) {
        if(graph[i][j] != p) {
            auto c = getColor(graph[i][j],i);
            colors[i].first = (colors[i].first * c.second)%MOD;
            colors[i].second = (colors[i].second * ((c.first + c.second)%MOD))%MOD;
        }
    }
    return colors[i];
}
void solve() {
    auto ans = getColor(1);
    cout << (ans.first+ans.second)%MOD<<'\n';
}
signed main() {
    cin>>n;
    for(int i=0;i<NM;i++) visited[i] = false;
    for(int i=0;i<NM;i++) colors[i].first = colors[i].second = 0;

    for(int i = 0;i<n-1;i++) {
        int x,y;
        cin>>x>>y;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    solve();
//    for(int i =0;i<5;i++)
//        cout << colors[i].first << ' ' << colors[i].second << '\n';
}



Measured memory_bytes: 14336
stdin.ReadLine()
|> ignore
|> fun () -> stdin.ReadLine()
|> fun s ->
  [0..(s.Length - 1)]
  |> Seq.fold (fun m i ->
    match Map.tryFind s.[i] m with
    | Some _ -> m
    | _ ->
      m.Add (
        s.[i],
        s.[(i + 1)..] |> (
          fun s ->
            [0..(s.Length - 1)]
            |> Seq.fold (fun m i ->
              match Map.tryFind s.[i] m with
              | Some _ -> m
              | _ ->
                m.Add (
                  s.[i],
                  s.[(i + 1)..]
                  |> Seq.distinct
                  |> Seq.length
                )
            ) Map.empty
            |> Seq.sumBy (fun x -> x.Value)
        )
      )
  ) Map.empty
  |> Seq.sumBy (fun x -> x.Value)
|> printfn "%d"


Measured memory_bytes: 34124
/*
g++ -ggdb -fsanitize=address -std=c++14 A.cpp && ./a.out <<< "3 3
.##
.#.
##."
*/

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (int i = a; i < (b); i++)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename A>
string to_string(A v) { int cnt = 0; string res; for (const auto &x : v) { if (cnt++) res += " "; res += to_string(x); } return "[" + res + "]"; }
string to_string(const string& s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);

    int H, W; cin >> H >> W;
    vector<string> Grid(H); rep(i, 0, H) cin >> Grid[i];

    int INF = 1e9;
    vector<vi> DA(H, vi(W, INF));
    vector<vi> DB(H, vi(W, INF));

    DA[0][0] = Grid[0][0] == '.' ? 0 : INF;
    DB[0][0] = Grid[0][0] == '.' ? INF : 1;

    rep(r, 0, H) {
        rep(c, 0, W) {

            for (int di = 0; di < 2; di++) {
                int dr = di == 0 ? -1 : 0;
                int dc = di == 0 ? 0 : -1;
                if (r + dr >= 0 && c + dc >= 0) {
                    if (Grid[r][c] == Grid[r + dr][c + dc]) {
                        DA[r][c] = min(DA[r][c], DA[r + dr][c + dc]);
                        DB[r][c] = min(DB[r][c], DB[r + dr][c + dc]);
                    }
                    else {
                        DA[r][c] = min(DA[r][c], DB[r + dr][c + dc]);
                        DB[r][c] = min(DB[r][c], DA[r + dr][c + dc] + 1);
                    }
                }
            }
        }
    }

// rep(r, 0, H) debug(r, DA[r]);
// rep(r, 0, H) debug(r, DB[r]);

    cout << min(DA[H - 1][W - 1], DB[H - 1][W - 1]) << endl;
}

Measured memory_bytes: 384
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

class UnionFind:
    def __init__(self, N):
        """
        N:要素数
        root:各要素の親要素の番号を格納するリスト.
             ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数.
        rank:ランク
        """
        self.N = N
        self.root = [-1] * N
        self.rank = [0] * N

    def __repr__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    def find(self, x):
        """頂点xの根を見つける"""
        if self.root[x] < 0:
            return x
        else:
            while self.root[x] >= 0:
                x = self.root[x]
            return x

    def union(self, x, y):
        """x,yが属する木をunion"""
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.rank[x] > self.rank[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def same(self, x, y):
        """xとyが同じグループに属するかどうか"""
        return self.find(x) == self.find(y)

    def count(self, x):
        """頂点xが属する木のサイズを返す"""
        return - self.root[self.find(x)]

    def members(self, x):
        """xが属する木の要素を列挙"""
        _root = self.find(x)
        return [i for i in range(self.N) if self.find == _root]

    def roots(self):
        """森の根を列挙"""
        return [i for i, x in enumerate(self.root) if x < 0]

    def group_count(self):
        """連結成分の数"""
        return len(self.roots())

    def all_group_members(self):
        """{ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す"""
        return {r: self.members(r) for r in self.roots()}

N, M = getNM()
que = [getList() for i in range(M)]

# 最小全域木
# 島の数 - 1
U = UnionFind(N)
for a, b in que:
    U.union(a - 1, b - 1)

print(U.group_count() - 1)

Measured memory_bytes: 96380
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int inf = 1000000000;

int main(){
  int N,M;
  cin >> N >> M;
  int d[N][N];
  fill(d[0],d[N],inf);
  for(int i=0;i<N;i++) d[i][i] = 0;
  int a[M],b[M],c[M];
  for(int i=0;i<M;i++){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--; b[i]--;
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }

  //ワーシャルフロイド
  for(int k=0;k<N;k++){
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        d[i][j] = min(d[i][j] , d[i][k] + d[k][j]);
      }
    }
  }

  int cnt = 0;
  for(int i=0;i<M;i++){
    if(d[a[i]][b[i]] == c[i]) cnt++;
  }

  cout << M - cnt << endl;
  return 0;
}

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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 100007;

int n;
int x[MAXN];
int a[MAXN];
int p[MAXN];
int m;
LL K;
int op[MAXN];
int ans[MAXN];
LL ax[MAXN];
bool vis[MAXN];

void init ();
void input ();
void work ();

AR(int) getcyc ( int beg );



int main()
{
	init();
	input();
	work();
}



void init ()
{
	// Init Everything Here
	
	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method
	
	scanf ( "%d", &n );
	lpi ( i, 1, n ) scanf ( "%d", &x[i] );
	scanf ( "%d%lld", &m, &K );
	lpi ( i, 1, m ) scanf ( "%d", &op[i] );
}

void work ()
{
	// main work
	
	lp ( i, 1, n ) a[i] = x[i+1] - x[i];
	
	lp ( i, 1, n ) p[i] = i;
	lpi ( i, 1, m ) swap ( p[op[i]], p[op[i]-1] );
	
	lpi ( i, 1, n ){
		if ( !vis[i] ){
			AR(int) ret = getcyc ( i );
			int len = ret.size ();
			int tms = K % len;
			lp ( i, 0, len ) ans[ret[i]] = ret[(i+tms)%len];
		}
	}
	
	ax[1] = x[1];
	lpi ( i, 2, n ) ax[i] = ax[i-1] + a[ans[i-1]];
	
	lpi ( i, 1, n ) printf ( "%lld\n", ax[i] );
}



AR(int) getcyc ( int beg )
{
	AR(int) ans;
	int now = beg;
	while ( !vis[now] ){
		vis[now] = true;
		ans.PB ( now );
		now = p[now];
	}
	return ans;
}

Measured memory_bytes: 4208
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
#include <stack>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef map<int, int> Mii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;
typedef pair<ll, ll> Pll; 

int g[10001][1300];

int main()
{
	int N, M;
	while (cin>>N>>M && (N || M)) {
		memset(g,0,sizeof(g));
		int r; cin >> r;
		rep(i,0,r) {
			int t,n,m,s;
			cin>>t>>n>>m>>s;
			if (s == 1)
				g[m][t] += 1;
			else
				g[m][t] -= 1;
		}
		rep(i,1,M+1) rep(j,540, 1260) g[i][j+1] += g[i][j];  

		int q; cin >> q;
		rep(i,0,q) {
			int s,e,m;
			cin>>s>>e>>m;
			int cnt = 0;
			rep(j,s,e) if (g[m][j]) cnt++;
			cout << cnt << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 53860
n=int(input())
t=input()
ans=0
tmp=""
for i in t:
  if i=="A":
    tmp="A"
  elif i=="B":
    if tmp=="A":
      tmp+="B"
    else:
      tmp=""
  elif i=="C":
    if tmp=="AB":
      ans+=1
    tmp=""
  else:
    tmp=""
print(ans)

Measured memory_bytes: 3060
#include <cstddef>
#include <cstdint>
#include <type_traits>
#include <vector>

namespace null_null {

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using usize = std::size_t;

template <typename T>
std::vector<T> make_v(usize a) { return std::vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(usize a, Ts... ts) {
  return std::vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename V>
typename std::enable_if<std::is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename std ::enable_if<std::is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
  for (auto &e : t) fill_v(e, v);
}

template <typename T, typename V>
inline void chmin(T &a, V b) {
  if (a > b) a = b;
}
template <typename T, typename V>
inline void chmax(T &a, V b) {
  if (a < b) a = b;
}

} // namespace null_null

#include <algorithm>
#include <iostream>
#include <map>
#include <utility>

class UnionFind {
private:
  std::vector<int> data;

  bool isSame(int x, int y) {
    return find(x) == find(y);
  }

  bool doUnite(int x, int y) {
    x = find(x), y = find(y);
    if (x == y) return (false);
    if (data[x] > data[y]) std::swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int getFind(int k) {
    if (data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int getSize(int k) {
    return (-data[find(k)]);
  }

public:
  UnionFind(int N) {
    data.resize(N, -1);
  }

  int same(int x, int y) { return isSame(x, y); }
  bool unite(int x, int y) { return doUnite(x, y); }
  int find(int k) { return getFind(k); }
  int size(int k) { return getSize(k); }
};

namespace null_null {

void main_() {
  constexpr u32 MAX = 101010;
  UnionFind uf(2 * MAX);

  usize N;
  std::cin >> N;

  for (usize i = 0; i < N; i++) {
    int x, y;
    std::cin >> x >> y;
    uf.unite(x, y + MAX);
  }

  std::map<i32, i64> mpx, mpy;
  for (usize i = 0; i < MAX; i++) mpx[uf.find(i)]++;
  for (usize i = MAX; i < 2 * MAX; i++) mpy[uf.find(i)]++;

  i64 ans = 0;
  for (usize i = 0; i < 2 * MAX; i++) ans += mpx[i] * mpy[i];
  ans -= N;

  std::cout << ans << std::endl;
}

} // namespace null_null

int main() {
  null_null::main_();
  return 0;
}


Measured memory_bytes: 26240
#include <iostream>
using namespace std;
int main() {
    string S;
    cin >> S;
    for(int i = 0; i < S.size() - 1; i++)
        if(S[i] == 'A' && S[i + 1] == 'C') {
            cout << "Yes";
            return 0;
        }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
using ll = long long;

int main() {
  ll x, y;
  cin >> x >> y;

  ll ans = -1;
  ll i = 2;
  ll n = x * i;
  ll m = max(x, y);
  while (n <= m * m) {
    if (x == y || x % y == 0) {
      break;
    }
    if (n % y != 0) {
      ans = n;
      break;
    }
    n = x * ++i;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int m = 0;
  int a, b;
  scanf("%d %d", &a, &b);

  switch (a)
  {
  case 1:
    m += 300000;
    break;
  case 2:
    m += 200000;
    break;
  case 3:
    m += 100000;
    break;
  }
  switch (b)
  {
  case 1:
    m += 300000;
    break;
  case 2:
    m += 200000;
    break;
  case 3:
    m += 100000;
    break;
  }

  if (m == 600000)
  {
    m += 400000;
  }
  printf("%d\n", m);

  return 0;
}

Measured memory_bytes: 128
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String S = scan.next();
		String T = scan.next();
		scan.close();
		if(S.equals(T)) {
			System.out.println("Yes");
			System.exit(0);
		}

		String []t = new String[S.length()];
		Deque<String> q1 = new ArrayDeque<String>();

		for(int i = 0; i < S.length(); i++) {
			t[i] = T.substring(i, i + 1);
			q1.addLast(S.substring(i, i + 1));
		}

		int flag = 1;
		for(int i = 0; i < S.length(); i++) {
			flag = 1;
			String te = q1.pollLast();
			q1.addFirst(te);
			//disp(q1);
			int index = 0;
			for(String s1 : q1) {
				if(!s1.equals(t[index])) {
					flag = 0;
					break;
				}
				index ++;
			}
			if(flag == 1) {
				System.out.println("Yes");
				System.exit(0);
			}

		}

		System.out.println("No");
	}
	static void disp(Deque<String> q1) {
		for(String s : q1) {
			System.out.print(s);
		}
		System.out.println();
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int a[51],b[51],c[110];
int main(){
	int n,m,i,j;
	cin>>n>>m;
	for(i=1;i<=m;i++){
		cin>>a[i];
		cin>>b[i];
	}
	for(i=1;i<=m;i++){
		for(j=1;j<=n;j++){
			if(a[i]==j||b[i]==j) c[j]++;
		}
	}
	for(i=1;i<=n;i++){
		cout<<c[i]<<endl;
	}
	return 0;
}

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

int main(){
    ll n;
    cin>>n;
    string s,t;
    cin>>s>>t;

    ll ans=2*n;
    for(ll i=0;i<n;++i){
        string a=s.substr(i, n-i);
        string b=t.substr(0, n-i);
        if(a==b){
            ans -= n-i;
            break;
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    string ss,si;
    cout << 0 << endl;
    cin >> ss;
    if(ss == "Vacant") return 0;
    cout << n-1 << endl;
    cin >> si;
    if(si == "Vacant") return 0;
    ll sup = 0, inf = n-1;
    while(true){
        ll tmp = (sup+inf)/2;
        cout << tmp << endl;
        string s;
        cin >> s;
        if(s == "Vacant") return 0;
        ll m = tmp - sup + 1;
        if(m%2){
            if(s == ss){
                sup = tmp;
                ss = s;
            }else{
                inf = tmp;
                si = s;
            }
        }else{
            if(s == ss){
                inf = tmp;
                si = s;
            }else{
                sup = tmp;
                ss = s;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3836
N, M = map(int, input().split())
lightList = []
for _ in range(M):
    lightList.append(list(map(int, input().split())))
P = list(map(int, input().split()))

ans = 0
for i in range(2**N):
    flag = True
    for a in range(M):
        cnt = 0
        for b in lightList[a][1:]:
            if not (i & (1<<b-1)):
                cnt += 1
        if cnt % 2 != P[a]:
            flag = False
    if flag:
        ans += 1
print(ans)


Measured memory_bytes: 3064
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		string s = Console.ReadLine();
    int markOneCountL = 0;//左の.の個数
    int markTwoCountL = 0;//左の#の個数
    int markOneCountR = 0;
    int markTwoCountR = 0;
    long memo = 0;
		long answer = 0;

    for(int i = 0; i < n; i++)
    {
      if(s[i] == '.') markOneCountR++;
      else markTwoCountR++;
    }

    answer = markOneCountR;

    for(int i = 0; i < n; i++)
    {
      if(s[i] == '.')
      {
        markOneCountL++;
        markOneCountR--;
      }else
      {
        markTwoCountL++;
        markTwoCountR--;
      }
      
      answer = Math.Min(answer, markTwoCountL + markOneCountR);
    }

		Console.WriteLine(answer);
	}
}


Measured memory_bytes: 11616
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int z;
		for (int i = 3; i <= n; i++) {
			z = i;
			if (z % 3 == 0) {
				System.out.print(" " + i);
				continue;
			}
			while (z != 0) {
				if (z % 10 == 3) {
					System.out.print(" " + i);
					break;
				}
				z /= 10;
			}
		}
		System.out.println("");
	}
}


Measured memory_bytes: 28840
import sys
from heapq import heappop, heappush

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    X, Y, Z, K = map(int, readline().split())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))
    C = list(map(int, readline().split()))

    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)

    hq = [(-(A[0] + B[0] + C[0]), 0, 0, 0)]

    ans = [0] * K
    added = {(0, 0, 0)}

    for idx in range(K):
        taste, i, j, k = heappop(hq)
        ans[idx] = -taste
        if i < X - 1 and (i + 1, j, k) not in added:
            heappush(hq, (-(A[i + 1] + B[j] + C[k]), i + 1, j, k))
            added.add((i + 1, j, k))
        if j < Y - 1 and (i, j + 1, k) not in added:
            heappush(hq, (-(A[i] + B[j + 1] + C[k]), i, j + 1, k))
            added.add((i, j + 1, k))
        if k < Z - 1 and (i, j, k + 1) not in added:
            heappush(hq, (-(A[i] + B[j] + C[k + 1]), i, j, k + 1))
            added.add((i, j, k + 1))

    print(*ans, sep='\n')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 78460
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>
#define vi vector<ll>
#define pi pair<ll,ll>
#define TC int t;cin>>t;while(t--)
#define in(n) ll n;cin>>n;
#define inarr(n) ll n;cin>>n;ll arr[n];
int main(void){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    in(x);in(y);
    string ans ="No";
    for(int i=0;i<=x;i++){
        for(int j=0;j<=x;j++){
            if(2*i+4*j==y && i+j==x)
                ans="Yes";
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3656
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

main :-
    get_number(A, B, C),
    (100 * A + 10 * B + C) mod 4 =:= 0 -> writeln("YES") ; writeln("NO").


Measured memory_bytes: 8040
using System;

class Plogram
{
    static void Main()
    {
        var line = Console.ReadLine();
        string i = "1", j = "1", k = "1";

        if(line.Substring(0,1) == "1")
        {
            i = "9";
        }
        if(line.Substring(1,1) == "1")
        {
            j = "9";
        }
        if(line.Substring(2,1) == "1")
        {
            k = "9";
        }
        Console.WriteLine(i + j + k);
    }
}

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

#define ll long long

void solve(){
	int x, n; cin>>x>>n;
	vector< int > v(n);
	map< int, int > m;
	for(int &i : v){
		cin>>i;
		m[i]++;
	}
	for(int i = 0; ; i++){
		if(!m[x - i]){
			cout<<x - i<<endl;
			return;
		}
		if(!m[x + i]){
			cout<<x + i<<endl;
			return;
		}
	}
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1; //cin>>t;
	while(t--){
		solve();
	}
	return 0;
}



Measured memory_bytes: 3668
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(b>=a&&b>=c){
		int f=a;
		a=b;
		b=f;
	}
	else if(c>=a&&c>=b){
		int f=a;
		a=c;
		c=f;	
	}
	cout<<a*10+b+c<<endl; 
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int N, A;
int x[51];
int dp[51][51][2501];

void _main() {
    cin >> N >> A;
    REP (i, N) cin >> x[i];
    dp[0][0][0] = 1;
    REP (i, N) REP (j, N) REP (k, 2501) if (dp[i][j][k]) {
        dp[i + 1][j][k] += dp[i][j][k];
        dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
    }
    int ans = 0;
    FOR (i, 1, N + 1) ans += dp[N][i][i * A];
    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

int main() {
  int sx, sy, tx, ty;
  int w, h;
  string ans;
  cin >> sx >> sy >> tx >> ty;
  w = tx - sx;
  h = ty - sy;
  for(int i=0; i<w; i++) {
    ans.push_back('R');
  }
  for(int i=0; i<h; i++) {
    ans.push_back('U');
  }
  for(int i=0; i<w; i++) {
    ans.push_back('L');
  }
  for(int i=0; i<h; i++) {
    ans.push_back('D');
  }
  ans.push_back('L');
  for(int i=0; i<h+1; i++) {
    ans.push_back('U');
  }
  for(int i=0; i<w+1; i++) {
    ans.push_back('R');
  }
  ans.push_back('D');
  ans.push_back('R');
  for(int i=0; i<h+1; i++) {
    ans.push_back('D');
  }
  for(int i=0; i<w+1; i++) {
    ans.push_back('L');
  }
  ans.push_back('U');
  cout << ans;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n, x;
    cin >> n >> x;
    int ans = 0;
    int minv = 1e6;
    rep(i, n)
    {
        int m;
        cin >> m;
        minv = min(m, minv);
        x -= m;
    }
    OP(x / minv + n);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); i++)
double kov(vector<double> q, double n){
    double inner = 0;
    rep(i, q.size()){
        inner += pow(q[i], n);
    }
    double ans = pow(inner, 1/n);
    return ans;
}
int main(){
    int n;
    cin >> n;
    vector<double> x(n);
    vector<double> y(n);
    vector<double> z(n);
    rep(i, n){
        cin >> x[i];
    }
    rep(i, n){
        cin >> y[i];
    }
  	double maxi = DBL_MIN;
    rep(i, n){
        z[i] = abs(x[i] - y[i]);
      	maxi = max(z[i], maxi);
    }
  	double sum = 0;
  	rep(i, n){
      sum += z[i];
    }
    double ans1 = kov(z, 1.0);
    double ans2 = kov(z, 2.0);
    double ans3 = kov(z, 3.0);
    printf("%.6f\n%.6f\n%.6f\n%.6f", ans1, ans2, ans3, maxi);
}


Measured memory_bytes: 3468
#include<stdio.h>
#include<string.h>

#define N 1000000
#define L 12

char H[N][L];

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum=0,p=1,i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % N; }
int h2(int key){ return 1 + (key % (N-1)); }

int find(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i=0;;i++){
    h = (h1(key)+i*h2(key))%N;
    if(strcmp(H[h],str) == 0)return 1;
    else if(strlen(H[h]) == 0)return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i=0;;i++){
    h = (h1(key)+i*h2(key))%N;
    if(strcmp(H[h],str) == 0)return 1;
    else if(strlen(H[h]) == 0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < N; i++ ) H[i][0] = '\0';

    scanf("%d", &n);

    for ( i = 0; i < n; i++ ){
        scanf("%s %s", com, str);

        if ( com[0] == 'i' ){
          if(insert(str)){
          }
        } else {
            if (find(str)){
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 13444
program CODE_FESTIVAL2016qBB
    implicit none
    integer(8)::N,A,B,count_B,i,flg,pass
    character(100000)::S
    read*,N,A,B,S
    count_B=0
    pass=0
    do i=1,N
        flg=0
        if(S(i:i)=="a")then
            if(pass<A+B)then
                flg=1
                pass=pass+1
            end if
        end if
        if(S(i:i)=="b")then
            count_B=count_B+1
            if(pass<A+B.and.count_B<=B)then
                flg=1
                pass=pass+1
            end if
        end if

        if(flg==0)print'(A)',"No"
        if(flg==1)print'(A)',"Yes"
    end do
end program CODE_FESTIVAL2016qBB

Measured memory_bytes: 932
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;

ll a[5], k, flag = true;

int main() {
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4]>>k;

	FOR(i, 0, 5) {
		FOR(j, 0, 5) {
			if (i == j)continue;
			if (abs(a[i] - a[j]) > k) {
				flag = false;
				break;
			}

		}
	}
	if (flag)cout << "Yay!" << endl;
	else cout << ":(" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,t; cin>>n;
  int dp[n],h[n];
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  dp[0]=0;
  dp[1]=max(h[0],h[1])-min(h[0],h[1]);
  for(int i=2;i<n;i++){
    dp[i]=dp[i-1]+max(h[i-1],h[i])-min(h[i-1],h[i]);
    t=dp[i-2]+max(h[i-2],h[i])-min(h[i-2],h[i]);
    dp[i]=min(dp[i],t);
  }
  cout<<dp[n-1]<<endl;
}

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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[],int n){
    for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
    }
    cout<<endl;
}
int no=1,n1;
int recu(int n,int k,int val){


	if(n==n1){
		return min(val*2,val+k);
	}
	return min( recu(n+1,k,2*val),recu(n+1,k,val+k)              );


}

int main() {
    int i,m,k,sum=0;
    c_p_c();
    // cout<<"Sd"<<endl;>
    cin>>n1>>k;
    cout<<recu(1,k,1);
 	return 0;

   }

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

using namespace std;

template <class T> inline T updmax(T& a, T b) { return a = max(a, b); }
template <class T> inline T updmin(T& a, T b) { return a = min(a, b); }

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int a;
	string s;
	cin >> a >> s;
	if (a >= 3200)
		cout << s << endl;
	else
		cout << "red" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <regex>
#include <string>
#include <cstdlib>
#include <math.h>
using namespace std;
int main() {
  int N;
  cin >> N;

  int P[N], Q[N];
  for (int i = 0; i < N; i++) {
    cin >> P[i];
  }

  for (int i = 0; i < N; i++) {
    cin >> Q[i];
  }

  int A[N];
  for (int i = 0; i < N; i++) {
    A[i] = i + 1;
  }

  int a = 0;
  int b = 0;
  int cnt = 0;
  do {
    cnt++;
    bool fa = true;
    bool fb = true;
    for (int i = 0; i < N; i++) {
      if (A[i] != P[i]) {
        fa = false;
      }
      if (A[i] != Q[i]) {
        fb = false;
      }
    }

    if (fa) {
      a = cnt;
    }
    if (fb) {
      b = cnt;
    }
  }while(next_permutation(A,A+N));

  cout << abs(a - b) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

Int power(Int a, Int n) {
    Int res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

int main(){
    Int N, N2;
    cin >> N;
    N2 = N;
    int pow = 0;
    rep(i,20) {
        Int pownow = power(26,i);
        if ((N2 + (pownow - 1)) / pownow <= 26) {
            pow = i;
            break;
        }
        else {
            N2 -= pownow * 26;
        }
    }

    string T = "";
    for (int i = pow; i>=0; i--) {
        T += 'a' - 1 + ((N2 + (power(26,i) - 1)) / power(26,i));
        N2 -= power(26,i) * ((N2 - 1) / power(26,i));
    }

    cout << T << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;

ll gcd(ll a, ll b){
  if(b == 0) return a;
  return gcd(b,a%b);
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }
    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

//階乗関数　ATCODER_AMARIに注意
ll factorial(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    //sum = sum % ATCODER_AMARI;
  }
  return sum;
}

int main() {
  ll a,b;
  cin >> a >> b;

  ll greatest_c_d = gcd(a,b);

  vector<pair<ll,ll>> ans = prime_factorize(greatest_c_d);

  ll true_ans = ans.size() + 1;

  cout << true_ans << endl;

  
  
}


Measured memory_bytes: 3628
#include <algorithm>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  string S;
  while (cin >> S) {
    int N = S.size();
    bool ok = true;
    ok &= S[0] == '1';
    ok &= S[N - 1] == '0';
    for (int i = 0; i < N - 1; i++) {
      ok &= S[i] == S[N - 2 - i];
    }
    if (!ok) {
      cout << -1 << endl;
      continue;
    }
    vec<int, 2> G(N);
    int r = 0, v = 1, pre = 1;
    for (int i = 1; i < N - 1; i++) {
      if (S[i] == '0') continue;
      G[v].push_back(r);
      r = v;
      ++v;
      int need = (i + 1) - pre - 1;
      for (int j = 0; j < need; j++) {
        G[r].push_back(v);
        ++v;
      }
      pre = i + 1;
    }
    G[v].push_back(r);
    for (int i = 0; i < N; i++) {
      for (int j : G[i]) {
        cout << (i + 1) << " " << (j + 1) << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 6912
#F
def divisor(n):
  ass = []
  for i in range(1,int(n**0.5)+1):
    if n%i == 0:
      ass.append(i)
      if i**2 == n:
        continue
      ass.append(n//i)
  return ass

n=int(input())
ans1=divisor(n-1)
ans1.remove(1)
as0=divisor(n)
ans0=[]
for x in as0:
  if x!=1:
    m=n
    while m>=x and m%x==0:
      m=m//x
    if m%x==1:
      ans0.append(x)

ans=set(ans0)|set(ans1)
ans=list(ans)




print(len(ans))
"""
ans.sort()
print(ans)
for x in ans:
  m=n
  while m%x==0:
    m=m//x
  print(x,m%x)
"""

Measured memory_bytes: 3188
#include <algorithm>
#include <map>
#include <iostream>
#include <string>
#include <set>
#include <queue>
#include <cmath>
#include <iterator>
#include <array>
typedef long long int ll;
using namespace std;
#define maxN 6.28318530718

int n;

void solve() {

}

int main() {
//	ios::sync_with_stdio(0);
//	cin.tie(0);
	int in1;
	cin>>in1;
	printf("%.2lf\n",maxN*in1);
}

Measured memory_bytes: 3764
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int result = 0;
        ArrayList<Integer> p = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            p.add(scanner.nextInt());
        }
        Collections.sort(p);
        for (int i = 0; i < k; i++) {
            result = p.get(i) + result;
        }
        System.out.println(result);
    }
}

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

int main() {
	int n=0;
	cin>>n;
	int x=0;
	string s="";
	while(n)
	{
	    x=n%10;
	    if(x==9)
	    {
	        s+='1';
	    }
	    else
	    {
	        s+='9';
	        //a=(a*10)+9;
	    }
	    n=n/10;
	}
	reverse(s.begin(),s.end());
	cout<<s<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

int a;

void init() {

}

void input() {
  cin >> a;
}

void solve() {
  set<int> s;
  for (int i = 1; ; i++) {
    if (s.count(a) > 0) {
      cout << i << endl;
      return;
    }
    s.insert(a);
    if (!(a&1)) a /= 2;
    else a = a*3+1;
  }
}

int main() {
	init();
	input();
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <deque>
#include <vector>
#include <tuple>
using namespace std;
using ll = long long;

int n, d = 1;
vector<int> e[200010];
int dfs(int x, int p) {
	int max_d = 0;
	for (int c : e[x]) {
		if (c == p)
			continue;
		int depth = dfs(c, x);
		d = max(d, max_d + depth + 1);
		max_d = max(max_d, depth);
	}
	return max_d + 1;
}
int nim[200010];
int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		e[a].emplace_back(b);
		e[b].emplace_back(a);
	}
	dfs(1, 0);
	nim[1] = 1, nim[2] = 0;
	for (int i = 3; i <= d; i++)
		nim[i] = nim[i - 1] ^ nim[i - 2];
	printf(nim[d] ? "First\n" : "Second\n");
}

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

#include <bits/stdc++.h>
using namespace std;

int64_t modpow(int64_t a,int64_t n,int64_t m){
  int64_t res=1;
  while(n>0){
    if(n&1) res=res*a%m;
    a=a*a%m;
    n>>=1;
  }
  return res;
}

int64_t modinv(int64_t a,int64_t p){
  int64_t res=modpow(a,p-2,p);
  return res;
}

int64_t combi(int64_t n,int64_t r,int64_t p){
  int64_t res;
  int64_t a=1,b=1;
  for(int i=n-r+1;i<=n;i++){
    a=a*i%p;
  }
  for(int i=1;i<=r;i++){
    b=b*i%p;
  }
  res=a*modinv(b,p)%p;
  return res;
}

int main() {
  int n,a,b;
  int big=1000000007;
  cin >> n >> a >> b;
  int64_t ans=modpow(2,n,big);
  ans--;
  ans=(ans-combi(n,a,big)+big-combi(n,b,big)+big)%big;
  cout << ans;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

bool dp[100300];

int main() {
    vector<li> p;
    repp(i, 100, 106) {
        p.pb(i);
    }
    li x;
    cin >> x;
    rep(i, x + 1) {
        dp[i] = false;
    }
    dp[0] = true;
    rep(i, x + 1) {
        if (!dp[i]) {
            continue;
        }
        for (auto v : p) {
            dp[i + v] = true;
        }
    }
    cout << (dp[x] ? 1 : 0) << endl;


    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll a,b;
	cin >> a >> b;
	cout << a/b << " " << a%b << " " << DOUBLE << double(a)/double(b) << endl;
	return 0;
}


Measured memory_bytes: 3244
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int h, w;
string a[1010];

ll dp[1010][1010];

ll solve() {
    dp[0][0] = 1;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (a[i][j] == '.') {
                dp[i+1][j] += dp[i][j]; dp[i+1][j] %= mod;
                dp[i][j+1] += dp[i][j]; dp[i][j+1] %= mod;
            }
        }
    }
    return dp[h-1][w-1];
}

void input() {
    cin >> h >> w;
    for (int i = 0; i < h; i++) cin >> a[i];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 9216
#include<stdio.h>

int main()
{
	int i;
	int w1=0,w2=0,w3=0,k1=0,k2=0,k3=0;
	int w[10];
	int k[10];
	for(i=0;i<10;i++){
		scanf("%d",&w[i]);
		if(w[i]>=w1){w3=w2;w2=w1;w1=w[i];}
		else if(w[i]>=w2){w3=w2;w2=w[i];}
		else if(w[i]>w3){w3=w[i];}
		}
	for(i=0;i<10;i++){
		scanf("%d",&k[i]);
		if(k[i]>=k1){k3=k2;k2=k1;k1=k[i];}
		else if(k[i]>=k2){k3=k2;k2=k[i];}
		else if(k[i]>k3){k3=k[i];}
	}
	printf("%d %d\n",w1+w2+w3,k1+k2+k3);
	return 0;
}


Measured memory_bytes: 2080