akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
import time
import re
import math

def main():
    N=int(input())
    XY=[]
    for a in range(N):
        XY.append(list(map(int,input().split())))
    DL=[]
    for a in range(N):
        xa=XY[a][0]
        ya=XY[a][1]
        for b in range(N):
            if(b==a):continue
            xb=XY[b][0]
            yb=XY[b][1]
            d=D(xa,ya,xb,yb)
            DL.append(d)
    mx=0
    for a in range(len(DL)):
        mx=max([mx,DL.count(DL[a])])
    #print(DL)
    print(N-mx)
def D(x1,y1,x2,y2):
    x=x2-x1
    y=y2-y1
    return [x,y]
start=time.time()
main()
#print("処理速度 {}sec".format(time.time()-start))
#"YNeos"[True::2]
#A=list(map(int,input().split()))
#n=int(input())
# global n,A,s,memo,mx,mn,L,B


Measured memory_bytes: 3568
#include <iostream>
#include <string>

using namespace std;

int main() {
	int number ,sum;
	string s;
	while (cin >> s) {
		if (s == "0") {
			break;
		}
		sum = 0;
		for (int i = 0; i < s.size(); i++) {
			number = s[i] - '0';
			sum += number;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1188
#include<stdio.h>
#include<stdlib.h>

int main(){
	int A[200000];
	char line[15];
	int index = 0;
	int q ;
	int i ;
	
	scanf("%d", &q);
	getchar();
	//printf("a");
	for(i = 0 ; i < q ; i++){
		fgets(line,15,stdin);
		//printf("b");
		
			if(line[0] == '0'){
				A[index] = atoi(line + 2);
				index++;
			}	
			else if(line[0] == '1'){
				printf("%d\n", A[atoi(line + 2)]);
			}
			else{
				index--;
			}
		
		
	}
	return 0 ;
}




Measured memory_bytes: 2508
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

void solve() {
    cini(h1);
    cini(m1);
    cini(h2);
    cini(m2);
    cini(k);

    int toth=(h2-h1)*60;
    int totm=(m2-m1);
    if(toth<0)
        toth+=24*60;

    int tot=toth+totm;
    cout<<tot-k<<endl;
    
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


Measured memory_bytes: 3648
from operator import itemgetter

def multisort(xs, specs):
    for key, reverse in reversed(specs):
        xs.sort(key=itemgetter(key), reverse=reverse)
    return xs

def solve():
    N = int(input())
    l = []
    c = 1
    for _ in range(N):
        a, b = list(input().split())
        l.append((a,int(b), c))
        c += 1
    l = multisort(l, [(0, False), (1, True)])
    for (_,_,c) in l:
        print(c)
    
# print(solve())/

# def solve()が@return voidのとき
solve()

Measured memory_bytes: 3064
import heapq
import sys


def dijkstra(n, paths, root):
	total_cost = [10 ** 9] * (n + 1)
	total_cost[root] = 0

	not_checked = set(range(1, n + 1))
	checked = set()
	cur_node = root
	h = []

	while not_checked:
		checked.add(cur_node)
		not_checked -= {cur_node}

		for next_node, cost in paths[cur_node]:
			if next_node in not_checked:
				heapq.heappush(h, (total_cost[cur_node] + cost, next_node))

		if not_checked:
			cost, next_node = heapq.heappop(h)

			while next_node in checked:
				cost, next_node = heapq.heappop(h)

			cur_node = next_node
			total_cost[cur_node] = cost

	return total_cost
		

def main():
	readline = sys.stdin.readline

	n = int(readline().rstrip())

	path = []
	for _ in range(n + 1):
		path.append([])

	for _ in range(n - 1):
		a, b, c = map(int, readline().rstrip().split())
		path[a].append((b, c))
		path[b].append((a, c))

	

	q, k = map(int, readline().rstrip().split())

	cost_from_k = dijkstra(n, path, k)

	for _ in range(q):
		x, y = map(int, readline().rstrip().split())
		print(cost_from_k[x] + cost_from_k[y])


if __name__ == '__main__':
	main()


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

long inv(int a, int m) {
    long i = 1, j = 0;
    for(int b = m; a > 1; swap(i, j), swap(a, b)) {
        j = (j + b / a * (m - i)) % m;
        b %= a;
    }
    return i;
}
long f[2222222] = {1};
int main() {
    int x, y, p = 1e9 + 7;
    cin >> x >> y;
    int a = (x + y) / 3;
    if((x + y) % 3 || a > x || a > y) {
        cout << 0 << endl;
        return 0;
    }
    x -= a, y -= a;
    for(int i = 0; i < x + y; i++)
        f[i + 1] = f[i] * (i + 1) % p;
    cout << f[x + y] * inv(f[x] * f[y] % p, p) % p << endl;
    return 0;
}


Measured memory_bytes: 5504
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <map>
using namespace std;
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; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
#define min(a, b) ((a) < (b) ? (a) : (b))

struct request {
	long long start;
	long long end;
};

int main() {
	long long N, M;
	cin >> N;
	long long tmpX, tmpLength;
	vector<request> requests;
	for (long long i = 0; i < N; i++) {
		cin >> tmpX >> tmpLength;
		requests.push_back({ tmpX - tmpLength, tmpX + tmpLength });
	}
	sort(requests.begin(), requests.end(), [](const request& x, const request& y) {return x.end < y.end; });
	long long firstStart = requests.at(0).start;
	long long firstEnd = requests.at(0).end;
	long long res = 0;
	long long cur = - INF;
	requests.at(0);
	for (auto x : requests) {
		if (cur > x.start) continue;
		++res;
		cur = x.end;
	}

	cout << res  << endl;
}

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

using Vertex = size_t;
using Graph = unordered_multimap<Vertex, Vertex>;
template<typename T> using PropMap = vector<T>;

inline void addEdge(Graph& g, Vertex u, Vertex v) {
    g.emplace(u, v);
    g.emplace(v, u);
}

template<typename Action>
inline void forEachOutVertices(const Graph& g, Vertex u, const Action& action) {
    auto p = g.equal_range(u);
    for (auto it = p.first; it != p.second; ++it) {
        action(it->second);
    }
}

int main() {
    size_t n, m, k;
    cin >> n >> m >> k;
    Graph frends;
    for (size_t i = 0; i < m; i++) {
        Vertex a, b;
        cin >> a >> b;
        addEdge(frends, a - 1, b - 1);
    }
    Graph blocks;
    for (size_t i = 0; i < k; i++) {
        Vertex a, b;
        cin >> a >> b;
        addEdge(blocks, a - 1, b - 1);
    }
    PropMap<int> vertexProp(n);
    for (Vertex u = 0; u < n; u++) {
        if (vertexProp[u] == 0) {
            unordered_set<Vertex> visitedVertices;
            stack<Vertex> q;
            q.push(u);
            while(!q.empty()) {
                Vertex v = q.top();
                q.pop();
                if (visitedVertices.count(v) == 0) {
                    visitedVertices.emplace(v);
                    forEachOutVertices(frends, v, [&](auto w) {
                        q.push(w);
                    });
                }
            }
            for (Vertex v : visitedVertices) {
                int count = visitedVertices.size() - 1;
                forEachOutVertices(frends, v, [&](auto w) {
                    if (visitedVertices.count(w) != 0) {
                        count--;
                    }
                });
                forEachOutVertices(blocks, v, [&](auto w) {
                    if (visitedVertices.count(w) != 0) {
                        count--;
                    }
                });
                vertexProp[v] = count;
            }
        }
        if (u != 0) {
            cout << " ";
        }
        cout << vertexProp[u];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 21520
import heapq

def main():
    N, M = map(int, input().split())
    a_to_b = {}
    for i in range(N):
        a, b = map(int, input().split())
        if a <= M:
            if a not in a_to_b:
                a_to_b[a] = []
            a_to_b[a].append(b)

    res = 0
    h = []
    for i in range(1,M+1):
        if i in a_to_b:
            b_list = a_to_b[i]
            for bi in b_list:
                heapq.heappush(h, (-1)*bi)
        if len(h) > 0:
            res -= heapq.heappop(h)

    print(res)


if __name__ == "__main__":
    main()

Measured memory_bytes: 95672
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){

  int N; cin >> N;
  ll L[N], R[N];
  for (int i = 0; i < N; i++){
    cin >> L[i] >> R[i];
  }
  
  ll L_max = L[0], R_min = R[0];
  int L_index = 0, R_index = 0;
  for (int i = 0; i < N; i++){
    if (L_max < L[i]){
      L_max = L[i];
      L_index = i;
    }
    if (R[i] < R_min){
      R_min = R[i];
      R_index = i;
    }
  }

  ll ans = max(0ll, R_min - L_max + 1);
  ll Deg_max = 0;
  for (int i = 0; i < N; i++){
    Deg_max = max(Deg_max, R[i] - L[i] + 1);
  }
  ans += Deg_max;

  Pll AB[N];
  for (int i = 0; i < N; i++){
    ll A = max(0ll, R[i] - L_max + 1);
    ll B = -1 * max(0ll, R_min - L[i] + 1);
    AB[i] = make_pair(A, B);
  }
  sort(AB, AB + N);

  ll B = -1 * AB[0].second;
  for (int i = 0; i + 1 < N; i++){
    B = min(B, -1 * AB[i].second);
    ans = max(ans, AB[i + 1].first + B);
  }
  cout << ans << endl;
  
  
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

ll mp[2019];
ll tmp[2019];

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

	string str;cin >> str;
	ll ans = 0;
	ll now = 0;
	mp[0]++;

	REP(i, str.size()){
		now *= 10;
		now += str[i] - '0';
		now %= 2019;

		ans += mp[now];
		mp[now]++;
		REP(j, 2019)tmp[j*10%2019] = mp[j];
		REP(j, 2019)mp[j] = tmp[j];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3360
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
void main()
{
    auto n = lread();
    auto a = aryread();
    long cnt;
    while (func(a))
    {
        foreach (i; 0 .. n)
        {
            a[i] = a[i] / 2;
        }
        cnt += 1;
    }
    writeln(cnt);

}

auto func(long[] x)
{
    long cnt;
    foreach (i; 0 .. x.length)
    {
        if (x[i] % 2 == 0)
        {
            cnt += 1;
        }
    }
    if (cnt == x.length)
    {
        return true;
    }
    else
    {
        return false;
    }
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


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

int main() {
  int n, q;
  cin >> n >> q;

  vector<priority_queue<int>> qs(n);
  for (int i = 0; i < q; ++i) {
    int q, t;
    cin >> q >> t;

    if (q == 0) {
      int x;
      cin >> x;
      qs[t].push(x);
    }
    if (q == 1) {
      if (!qs[t].empty())
        cout << qs[t].top() << endl;
    }
    if (q == 2) {
      if (!qs[t].empty())
        qs[t].pop();
    }
  }
}


Measured memory_bytes: 4048
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yay!")
    else:print(":(")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
#n = ip()                                     #入力整数1つ
#a,b= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
n = len(a)
c = 0
add = 0
for i in range(len(a)-1):
    if a[i] == a[i+1]:
        add+=1
        add%=2
    if add:c+=1
print(min(n-c,c))

Measured memory_bytes: 13576
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <queue>
#include <numeric>
#include <functional>

template <class ForwardIt, class Compare>
auto f(ForwardIt first, ForwardIt mid1, ForwardIt mid2, ForwardIt last, Compare comp) {
  using Tp = typename ForwardIt::value_type;

  std::vector<Tp> res;
  Tp sum = 0;
  std::priority_queue<Tp, std::vector<Tp>, Compare> q(comp);
  for (auto it = first; it != mid1; ++it) {
    sum += *it;
    q.push(*it);
  }

  res.push_back(sum);
  for (auto it = mid1; it != mid2; ++it) {
    sum += *it;
    q.push(*it);
    sum -= q.top();
    q.pop();
    res.push_back(sum);
  }

  return res;
}

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<intmax_t> a(3*N);
  for (auto& ai: a) scanf("%jd", &ai);

  auto sa = f(a.begin(), a.begin()+N, a.end()-N, a.end(), std::greater<intmax_t>());
  auto sb = f(a.rbegin(), a.rbegin()+N, a.rend()-N, a.rend(), std::less<intmax_t>());

  // for (size_t i = 0; i < sa.size(); ++i)
  //   fprintf(stderr, "%jd%c", sa[i], i+1<sa.size()? ' ':'\n');

  // for (size_t i = 0; i < sb.size(); ++i)
  //   fprintf(stderr, "%jd%c", sb[i], i+1<sb.size()? ' ':'\n');

  intmax_t res = -1e14;
  for (size_t i = 0; i <= N; ++i)
    res = std::max(res, sa[i]-sb[N-i]);

  printf("%jd\n", res);
}


Measured memory_bytes: 5996
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int nmax = 8;

bool graph[nmax][nmax];  //グラフの隣接行列

int dfs(int v, int N, bool visited[nmax]) {  // vはdfsを開始する頂点、Nはグラフの頂点数
    
    bool all_visited = true;  //全ての頂点を訪れたかどうか

    //未訪問の頂点があればall_visitedはfalse
    rep(i, N) {
        if(!visited[i]) {
            all_visited = false;
        }
    }

    //すべての頂点を訪れている場合はdfsで返す値を1増やす
    if(all_visited) {
        return 1;
    }

    int ret = 0;
    //頂点vに隣接する未訪問の頂点を全探索
    rep(i, N) {
        //vと隣接していなかったらダメ
        if(!graph[v][i]) {
            continue;
        }
        //訪問済みだったらダメ
        if(visited[i]) {
            continue;
        }

        //頂点iを訪問済みにする
        visited[i] = true;

        //頂点iから新たにdfsを始めて求めるパスの数をretに加える
        ret += dfs(i, N, visited);

        //探索が終了した頂点はもう訪れないのでfalseにする
        visited[i] = false;
    }

    return ret;
}

int main() {
    int n;  //頂点数
    int m;  //辺数
    cin >> n >> m;

    //無向グラフの入力
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        graph[a-1][b-1] = graph[b-1][a-1] = true;
    }

    bool visited[nmax];  // visited[i] : 頂点iを訪問したかどうか

    //全頂点を未訪問にする
    rep(i, n) {
        visited[i] = false;
    }

    //スタート位置の頂点0を訪問済みにする
    visited[0] = true;

    cout << dfs(0, n, visited) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
const int MaxN = 2e3;
typedef long long LL;
const LL INF = 1LL << 50;

int n, m;
struct PP
{
	int u, v;
	LL cost;
}edge[MaxN + 5];
LL dis[MaxN + 5];
bool neg[MaxN + 5];
int main()
{
	while(scanf("%d %d", &n, &m) != EOF)
	{
		for(int i = 1; i <= m; i++)
		{
			scanf("%d %d %lld", &edge[i].u, &edge[i].v, &edge[i].cost);
			edge[i].cost = (-1) * edge[i].cost;
		}
		for(int i = 1; i <= n; i++)
		{
			if(i == 1) dis[i] = 0;
			else dis[i] = INF;
		}
		for(int i = 1; i <= n - 1; i++)
		{
			for(int j = 1; j <= m; j++)
			{
				if(dis[edge[j].u] == INF) continue;
				if(dis[edge[j].u] + edge[j].cost < dis[edge[j].v])
					dis[edge[j].v] = dis[edge[j].u] + edge[j].cost;
			}
		}
		for(int i = 1; i <= n - 1; i++)
		{
			for(int j = 1; j <= m; j++)
			{
				if(dis[edge[j].u] == INF) continue;
				if(dis[edge[j].u] + edge[j].cost < dis[edge[j].v])
				{
					dis[edge[j].v] = dis[edge[j].u] + edge[j].cost;
					neg[edge[j].v] = 1;
				}
				if(neg[edge[j].u])
					neg[edge[j].v] = 1;
			}
		}
		if(neg[n]) printf("inf\n");
		else printf("%lld\n", -dis[n]);
		memset(edge, 0, sizeof(edge));
		memset(dis, 0, sizeof(dis));
		memset(neg, 0, sizeof(neg));
	}
	return 0;
}

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

using namespace std;

typedef long long ll; 
typedef pair<int, int> pii;

#define REP(i,n) for(int(i)=0;(i)<(int)(n);(i)++)

long long f(long long b, long long n) {
    if (n == 0) return 0;
    return n%b + f(b,n/b);
}

long long n, s;
int main() {
    scanf("%lld %lld", &n, &s);

    if (s == n) {
        printf("%lld\n", n+1);
        return 0;
    }
    
    for (int i = 2; i <= 400000; i++) {
        if (f(i,n) == s) {
            printf("%lld\n", i);
            return 0;
        }
    }

    if (s > n || n <= 400000) {
        printf("-1\n");
        return 0;
    }

    long long k = n-s;
    long long ans = -1;
    for (long long x = 1; x <= 400000; x++) {
        if (k%x == 0) {
            long long b = k/x + 1;
            if (x < b && s>=x && s-x < b) {
                //printf("found x! %lld %lld\n", x, s-x);
                ans = b; 
            }
        }
    }

    printf("%lld\n", ans);
}

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

int main() {
  string S;
  cin >> S;
  
  bool ans = true;
  
  if(S.at(0) == S.at(1)) ans = false;
  if(S.at(1) == S.at(2)) ans = false;
  if(S.at(2) == S.at(3)) ans = false;

  
  if(ans){
    cout << "Good" << endl;     
  }else{
    cout << "Bad" << endl;    
  }

  return 0;
}



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

// macros
#define overload_rep(va_0, va_1, va_2, va_3, name, ...) name
#define rep_0_(i, n) for(int i = 0; i < (n); ++i)
#define rep_1_(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep_2_(i, x, y, z) for(int i = (x); i >= (y); --i)
#define rep(...) overload_rep(__VA_ARGS__, rep_2_, rep_1_, rep_0_)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// libraries

// declarations
typedef long long lint;
constexpr lint inf = 1ll << 60;
int N, K;
int H[301];
lint dp[301][301][301];

// solve
int main(){

    cin >> N >> K;
    rep(i, 1, N)cin >> H[i];

    rep(i, 301)rep(j, 301)rep(k, 301)dp[i][j][k] = inf;
    dp[0][0][0] = 0;
    rep(i, N){
        rep(j, 0, K){
            rep(k, 0, i){
                if(H[k] < H[i + 1]){
                    chmin(dp[i + 1][j][i + 1], dp[i][j][k] + H[i + 1] - H[k]);
                } else {
                    chmin(dp[i + 1][j][i + 1], dp[i][j][k]);
                }
                if(j < K){
                    chmin(dp[i + 1][j + 1][k], dp[i][j][k]);
                }
            }
        }
    }

    lint ans = inf;
    rep(i, 0, K)rep(j, 0, N)chmin(ans, dp[N][i][j]);
    cout << ans << '\n';
    return 0;

}


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

typedef long long ll;

int main() {
	int n, w;
	cin>>n>>w;
	
	vector<ll> dp(w+1, -1);
	dp[0] = 0;
	for(int i=0; i<n; i++) {
		ll weight, value;
		cin>>weight>>value;
		
		for(int wa=w-weight; wa >= 0; wa--) {
			if(dp[wa]!=-1) dp[wa+weight] = max(dp[wa+weight], dp[wa]+value);
		}
	}
	//for(int i=0; i<=w; i++) cout<<dp[i]<<" \n"[i==w];
	cout<<*max_element(dp.begin(), dp.end())<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef long long ll;

int main() {
  string s;
  cin >> s;
  int g = 0;
  rep(i,(int)s.size()) {
    if( s[i] == 'g' ) ++g;
    else              --g;
  }
  cout << (int)(g/2) << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n, m, to[100010], par[100010];
vector <int> v[100010];
int a, b;
void topsort()
{
	queue <int> q;
	for (int i = 1; i <= n; ++i){
		if (!to[i]){
			par[i] = 0;
			q.push(i);
		}
	}
	while (!q.empty()){
		int a = q.front();
		q.pop();
		for (int i = 0; i < v[a].size(); ++i){
			to[v[a][i]]--;
			if (!to[v[a][i]]){
				q.push(v[a][i]);
				par[v[a][i]] = a;
			}
		}
	}
}
int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n - 1 + m; ++i){
		scanf("%d%d", &a, &b);
		v[a].push_back(b);
		to[b]++;
	}
	topsort();
	for (int i = 1; i <= n; ++i)cout << par[i] << endl;
	return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N, P, Q;
ll C[500000];
ll inv[500000];
vector<l_l> v;
ll now = 0;
ll ans = -1e18;

void chmax(ll &a, ll b) {
    a = max(a, b);
}
struct SegmentTree {
private:
    int n;
    vector<int> node;
 
public:
    SegmentTree() {
        int sz = 500010;
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, 0);
        for(int i=0; i<sz; i++) node[i+n-1] = 0;
        for(int i=n-2; i>=0; i--) node[i] = min(node[2*i+1], node[2*i+2]);
    }
 
    void update(int x, int val) {
        x += (n - 1);
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = (node[2*x+1] + node[2*x+2]);
        }
    }
    // hannkaikukann 
    int getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return node[k];
 
        int vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        int vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return (vl + vr);
    }
};


int main() {
    //cout.precision(10);
    cin >> N >> P >> Q;
    for(ll i = 0; i < N; i++) {
        cin >> C[i];
        v.push_back({P * i + C[i], i});
        now += C[i];
    }
    ans = now;
    sort(v.begin(), v.end());
    SegmentTree seg;
    for(auto tmp : v) {
        int idx = tmp.second;
        now -= C[idx];
        ll num = seg.getsum(0, idx);
        num = num - (idx - num);
        //cerr << num;
        now += (Q + num) * P;
        now += (2 * seg.getsum(idx, N)) * P;
        chmax(ans, now);
        seg.update(idx, 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 18720
from math import atan2
n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]
l.sort(key=lambda x: atan2(x[1], x[0]))
ans = 0
for lp in range(n):
    for rg in range(n):
        lf = lp
        x, y = l[lf]
        lf += 1
        if lf == n:
            lf = 0
        while lf != rg:
            x += l[lf][0]
            y += l[lf][1]
            lf += 1
            if lf == n:
                lf = 0
        ans = max(ans, (x ** 2 + y ** 2) ** .5)
print(ans)


Measured memory_bytes: 3316
n=int(input())
f=[]
for i in range(n):
    f.append(list(map(int,input().split())))
p=[]
for i in range(n):
    p.append(list(map(int,input().split())))
op=[[0],[1]]
for i in range(9):
    tmp=[]
    for j in op:
        tmp.append(j+[0])
        tmp.append(j+[1])
    op=tmp
ans=-10000000000000
for i in tmp:
    if sum(i)==0:
        continue
    t=0
    for k in range(n):
        c=0
        for j in range(10):
            c+=f[k][j]*i[j]
        t+=p[k][c]
    ans=max(t,ans)
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long a,b,i,j=0,k,m=1,n=1;
cin>>i;
while(i--)
{
	cin>>a>>b;
	j=max((m+a-1)/a,(n+b-1)/b);
	m=a*j, n=b*j;
}
cout<<m+n<<endl;
return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>

int n,m,a[200001],b[200001],ta,tb;

int main(void){
	register int i;
	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++)
		scanf("%d%d",&ta,&tb),
		a[tb]|=(ta==1),
		b[ta]|=(tb==n);
	for(i=1;i<n;i++)
		if(a[i]&&b[i])
			return puts("POSSIBLE"),0;
	puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 1664
#!/usr/bin/env python3
import sys
import math
import bisect

def solve(n: int, a: "List[int]"):
    if n == 2:
        print(*sorted(a,reverse=True))
        return 

    a.sort()
    max_a = a[-1]


    if max_a%2 ==1:
        searchValue = max_a//2+1
    else:
        searchValue = max_a//2

    index = bisect.bisect_left(a,searchValue)
    if abs(max_a/2-a[index]) > abs(max_a/2-a[index-1]):
        print(max_a,a[index-1])
    else:
        print(max_a,a[index])

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(n)]  # type: "List[int]"
    solve(n, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 15556
#include <stdio.h>

int main(){
	unsigned long long a;

	// b の整数部分と小数部分
	unsigned long long b_integer, b_decimal;

	// %*c で小数点の 1 文字分をよける
	scanf("%llu%llu%*c%llu", &a, &b_integer, &b_decimal);

	// 小数点以下は 2 桁までしかないので， 100 倍すると整数になる
	unsigned long long b_times_100 = b_integer * 100 + b_decimal;

	printf("%llu\n", a * b_times_100 / 100);

}


Measured memory_bytes: 1736
import Control.Applicative

getInt :: IO Integer
getInt = (\a -> read a :: Integer) <$> getLine
getIntArray :: IO [Integer]
getIntArray = ((map (\a -> read a :: Integer)) . words) <$> getLine

conSqrt :: Integer -> Integer -> Integer -> Integer
conSqrt x n p
    | x < p * n = p
    | otherwise = conSqrt x n $ n * p
loop :: Integer -> Integer -> Integer
loop x n
    | x < n * n = 0
    | otherwise = maximum [(loop x $ n + 1), (conSqrt x n n)]

main = do
    x <- getInt
    print $ if x < 4 then 1 else loop x 2


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

const int INF = 1 << 28;
int X[1000];
int wsum[1000];
vector<int> G[1000];
ll dp2[1010][5010];

bool f(int v){
	if(G[v].size() == 0){
		wsum[v] = X[v];
		return true;
	}

	for(auto c : G[v]){
		if(!f(c)) return false;
		wsum[v] += wsum[c];
	}

	for(int i = 0; i <= G[v].size(); i++){
		for(int j = 0; j < 5010; j++){
			dp2[i][j] = INF;
		}
	}

	dp2[0][0] = 0;
	for(int i = 0; i < G[v].size(); i++){
		int c = G[v][i];
		for(int j = 0; j <= X[v]; j++){
			if(dp2[i][j] == INF) continue;
			// cと違う色
			if(j + wsum[c] - X[c] <= X[v]){
				dp2[i + 1][j + wsum[c] - X[c]] = min(dp2[i + 1][j + wsum[c] - X[c]], dp2[i][j] + X[c]);
			}
			// cと同じ色
			if(j + X[c] <= X[v]){
				dp2[i + 1][j + X[c]] = min(dp2[i + 1][j + X[c]], dp2[i][j] + wsum[c] - X[c]);
			}
		}
	}

	ll w = INF;
	for(int j = 0; j <= X[v]; j++){
		if(dp2[G[v].size()][j] == INF) continue;
		w = min(w, (ll)X[v] - j);
	}
	if(w == INF){
		return false;
	}
	wsum[v] += w;
	return true;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N;
	cin >> N;
	for(int i = 1; i < N; i++){
		int p;
		cin >> p;
		p--;
		G[p].push_back(i);
	}
	for(int i = 0; i < N; i++){
		cin >> X[i];
	}

	if(f(0)){
		cout << "POSSIBLE" << endl;
	}
	else{
		cout << "IMPOSSIBLE" << endl;
	}
}


Measured memory_bytes: 39424
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int A,B; cin >> A >> B;
    vector<vector<char>> ans(100,vector<char>(100,'.'));
    rep(i,100)rep(j,50){
        ans[i][j] = '#';
    }
    A--; B--;
    bool ok = false;
    for(int i = 0; i < 100; i+=2){
        for(int j = 0; j < 50; j+= 2){
            if(A == 0){
                ok = true;
                break;
            }
            ans[i][j] = '.';
            A--;
        }
        if(ok) break;
    }
    bool ok2 = false;
    for(int i = 0; i < 100; i+=2){
        for(int j = 51; j < 100; j+=2){
            if(B == 0){
                ok2 = true;
                break;
            }
            ans[i][j] = '#';
            B--;
        }
        if(ok2) break;
    }
    cout << 100 << " " << 100 << endl;
    rep(i,100){
        rep(j,100){
            cout << ans[i][j];
        }
        cout << endl;
    }

}



Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define _GLIBCXX_DEBUG

using _loop_ll = long long;
#define REP(i,n) for(_loop_ll (i)=0; (i)<(_loop_ll)(n); (i)++)
#define FOR(i,a,b) for(_loop_ll (i)=(_loop_ll)(a); (i)<(_loop_ll)(b); (i)++)
#define FORR(i,a,b) for(_loop_ll (i)=(_loop_ll)(b)-1; (i)>=(_loop_ll)(a); (i)--)
 
#define ALL(v) (v).begin(),(v).end()
 
#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;

constexpr long long int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n, k;
    cin >> n >> k;
    vi h(n);
    REP(i, n) cin >> h[i];

    sort(ALL(h));

    if(n <= k){
        cout << 0 << endl;
        return 0;
    }else{
        ll ans = 0;
        REP(i, n - k) ans += h[i];
        cout << ans << endl;
    }

    return 0;
};


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

int main() {
  long long a,b,c;
  cin >>a>>b>>c;
  if(a%2==0||b%2==0|c%2==0){
    cout<<0<<endl;
    return 0;
  }
  long long kotae=min({a*b,b*c,c*a});
  cout<<kotae<<endl;
}

Measured memory_bytes: 256
/**
 * The Balance of the World
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			if (line.equals(".")) break;

			Deque<Character> stack = new ArrayDeque<Character>();
			stack.push(' ');
			for (char c : line.toCharArray()) {
				if ("([".indexOf(c) != -1) {
					stack.push(c);
				} else if (c == ')') {
					if (stack.peekFirst() == '(') {
						stack.pop();
					} else {
						stack.push(c);
					}
				} else if (c == ']') {
					if (stack.peekFirst() == '[') {
						stack.pop();
					} else {
						stack.push(c);
					}
				}
			}
			System.out.println(stack.size() == 1 ? "yes" : "no");
		} //end while
	} //end main
}

Measured memory_bytes: 25208
for e in iter(input, "-1 -1 -1"):
    
    m,f,r=map(int, e.split())

    result = ""

    if m == -1 or f == -1:
        result = "F"
    elif m + f >= 80:
        result = "A"
    elif m + f >= 65:
        result = "B"
    elif m + f >= 50:
        result = "C"
    elif m + f >= 30:
        if r >= 50:
            result = "C"
        else:
            result = "D"
    else:
        result = "F"
    
    print(result)


Measured memory_bytes: 5596
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

int main(){
	ll N;
	string S;
	cin >> N;
	cin >> S;
	ll i, j;

	ll w = 0;
	ll b = 0;

	w = count(S.begin(), S.end(), '.');
	b = N - w;

	ll ans = w;
	ll lb = 0;
	ll rw = w;
	for (i = 1; i <= N; i++){
		if (S[i - 1] == '#'){
			lb++;
		}
		else{
			rw--;
		}
		ans = min(ans, lb + rw);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication59
{
    class Program
    {
        static void Main()
        {
            Console.ReadLine();
            int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.ReadLine();
            int[] B = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int S = 0;
            for(int C = 0; C < B.Length; C++)
            {
                if (B[C] > A[A.Length / 2])
                {
                    for (int D = A.Length-1; D>-1; D--)
                    {
                        if (B[C] == A[D]) { S++; break; }
                    }
                }
                else
                {
                    for (int D = 0; D < A.Length; D++)
                    {
                        if (B[C] == A[D]) { S++; break; }
                    }
                }
            }
            Console.WriteLine(S);
        }
    }
}

Measured memory_bytes: 10140
n = int(input())
l = list(map(int,input().split()))
money = 1000
new_l = []
for i in range(n-1):
    if l[i] != l[i+1]:
        new_l.append(l[i])
new_l.append(l[n-1])
# print(new_l)

for i in range(len(new_l)-1):
    if new_l[i] < new_l[i+1]:
        div = money//new_l[i]
        money += (new_l[i+1]-new_l[i])*div
    # print(div,money)
print(money)

Measured memory_bytes: 61876
N = int(input())
S = input()
ans = 0
cnt_r = [0]*N
cnt_g = [0]*N
cnt_b = [0]*N
for i in range(N-1,-1,-1):
    if S[i] == 'R':
        cnt_r[i] += 1
    if S[i] == 'G':
        cnt_g[i] += 1
    if S[i] == 'B':
        cnt_b[i] += 1
    if i != 0:
        cnt_r[i-1] += cnt_r[i]
        cnt_g[i-1] += cnt_g[i]
        cnt_b[i-1] += cnt_b[i]
# print(cnt_r)
# print(cnt_g)
# print(cnt_b)
ans = 0
for i in range(N):
    if S[i] == 'R':
        for j in range(i+1,N):
            if S[j] == 'G':
                if j+1 >= N:
                    continue
                ans += cnt_b[j+1]

                if j + (j-i) >= N:
                    continue
                if S[j+(j-i)] == 'B':
                    ans -= 1

for i in range(N):
    if S[i] == 'R':
        for j in range(i + 1, N):
            if S[j] == 'B':
                if j + 1 >= N:
                    continue
                ans += cnt_g[j + 1]

                if j + (j - i) >= N:
                    continue
                if S[j + (j - i)] == 'G':
                    ans -= 1

for i in range(N):
    if S[i] == 'G':
        for j in range(i + 1, N):
            if S[j] == 'R':
                if j + 1 >= N:
                    continue
                ans += cnt_b[j + 1]

                if j + (j - i) >= N:
                    continue
                if S[j + (j - i)] == 'B':
                    ans -= 1

for i in range(N):
    if S[i] == 'G':
        for j in range(i + 1, N):
            if S[j] == 'B':
                if j + 1 >= N:
                    continue
                ans += cnt_r[j + 1]

                if j + (j - i) >= N:
                    continue
                if S[j + (j - i)] == 'R':
                    ans -= 1

for i in range(N):
    if S[i] == 'B':
        for j in range(i + 1, N):
            if S[j] == 'G':
                if j + 1 >= N:
                    continue
                ans += cnt_r[j + 1]

                if j + (j - i) >= N:
                    continue
                if S[j + (j - i)] == 'R':
                    ans -= 1

for i in range(N):
    if S[i] == 'B':
        for j in range(i + 1, N):
            if S[j] == 'R':
                if j + 1 >= N:
                    continue
                ans += cnt_g[j + 1]

                if j + (j - i) >= N:
                    continue
                if S[j + (j - i)] == 'G':
                    ans -= 1
print(ans)

Measured memory_bytes: 74436
import java.util.*;
import java.text.SimpleDateFormat;

public class Main {
	public static void main(String[] args) {  
  		Scanner sc = new Scanner(System.in);
		String str = sc.next();
      	String[] ary = str.split("/", 0);
      	Calendar cal1 = Calendar.getInstance();
      	cal1.set(Integer.parseInt(ary[0]),
                Integer.parseInt(ary[1]),
                Integer.parseInt(ary[2]));
      	Calendar cal2 = Calendar.getInstance();
      	cal2.set(2019, 04, 30);
      	
      	if(cal1.before(cal2)) {
        	System.out.println("Heisei");
        } else {
        	System.out.println("TBD"); 
        }
    }
}

Measured memory_bytes: 22096
#include <iostream>
#include <cstdio>
#include <cmath>
#define EQ(a,b) (abs(a - b) < 0.00001 * b)
using namespace std;

int main ()
{
    double q;
    while (cin >> q, q >= 0) {
        double p  = q / 2;
        while (!EQ((p * p * p),q)) {
            p = p - ( ((p * p * p) - q) / (3 * p * p) );
        }
        printf("%.6f\n", p);
    }

    return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << char(s1[0] + 'A' - 'a') << char(s2[0] + 'A' - 'a') << char(s3[0] + 'A' - 'a') << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <queue>
using namespace std;
typedef pair<int, int> P;
vector<vector<int>> G;
map<P, int> m;
vector<int> color;
void dfs(int s, int n){
    int co = 1;
    int pre;
    for(int j:G[s]){
        if(j < s) continue;
        if(co == n){
            color[m[P(s, j)]] = co + 1;
            pre = co + 1;
            co += 2;
        }
        else{
            color[m[P(s, j)]] = co;
            pre = co;
            co++;
        }
        dfs(j, pre);
    }
}
int main(){
    long long N;
    cin >> N;
    G.resize(N);
    color.resize(N - 1);
    for(int i = 0; i < N - 1; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
        m[P(a, b)] = i;
    }
    dfs(0, -1);
    int ans = 0;
    for(int i =0 ; i < N - 1; i++) ans = max(ans, color[i]);
    cout << ans << endl;
    for(int i = 0; i < N - 1; i++)cout<< color[i] << endl;
}

Measured memory_bytes: 16596
#include<bits/stdc++.h> 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define int long long
#define swap(x,y) (x^=y^=x^=y)

#define debug1(a) cerr<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

using namespace std;

#define mod 1000000007
long long modexpo(long long x, long long p){
    int res = 1;x = x%mod;
    while(p){
        if(p%2)res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}

// int max(int a,int b){return (a>b?a:b);} 
// int min(int a,int b){return (a<b?a:b);}


struct compare{
    bool operator() (const pair<int,int> a, const pair<int,int> b) const{
        return a.first < b.first;
    }
};

int32_t main(){
    IOS
    int l,r;
    cin >> l >> r;
    if(r-l >= 2019){
        cout << 0 << endl;
        exit(0);
    }   
    int ans = 1e18;
    for(int i = l; i <= r; i++){
        for(int j = i+1; j <= r; j++){
            int x = i%2019;
            int y = j%2019;
            x *= y;
            x %= 2019;
            ans = min(ans, x);
        }
    }
    cout << ans << endl;
} 

Measured memory_bytes: 3624
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl(1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};


void solve(){
	ll n,k;cin>>n>>k;
  vector<ll>A(n);
  vector<ll>F(n);
  rep(i,n)cin>>A[i];
  rep(i,n)cin>>F[i];
  sort(all(A));
  sort(all(F),greater<ll>());
  ll right=INF;
  ll left=-1;
  ll num,mid;
  while(right-left>1){
    mid=left+(right-left)/2;
    num=0;
    rep(i,n){
      num+=max((ll)0,A[i]-mid/F[i]);
    }
    if(!(num<=k))left=mid;
    else right=mid;
  }
  cout<<right<<endl;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	solve();
}


Measured memory_bytes: 3456
#include <cmath>
#include <iostream>
#include <iomanip>
using namespace std;

int N;
int x[8], y[8];

int v[8];

int NN = 0;

int Nf = 0;
long double s = 0.0;

int fact(int n) {
    if (!n) return 1;
    return n * fact(n - 1);
}

long double d(int i, int j) {
    return sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
}

void dfs(int m, int n) {
    if (v[n]) return;
    v[n] = 1;
    if (m >= 0) {s += d(m, n); NN++;}

    for (int i = 0; i < N; i++) {
        dfs(n, i);
    }
    v[n] = 0;
}

int main() {
    cin >> N;
    Nf = fact(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
        v[i] = 0;
    }
    for (int i = 0; i < N; i++) {
        dfs(-1, i);
    }

    long double a = s / (NN / (N - 1));
    cout << setprecision(11) << a << endl;
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    var x = readLine()!!.toLong()
    while (true) {
        if (isPrime(x)) return println(x)
        x++
    }
}

fun isPrime(n: Long): Boolean {
    for (i in 2..n / 2) {
        if (n % i == 0L) return false
    }
    return true
}

Measured memory_bytes: 31744