akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

#define MAX_DATA 401

struct data {
    int mom;
    int hou;
};

int board[MAX_DATA][MAX_DATA];
int mimasita[MAX_DATA][MAX_DATA];
struct data dataset[MAX_DATA];
int n, l, ans_x1, ans_y1, ans_x2, ans_y2;

void cl_array(void);
void tansaku(int num, int x, int y);
void make_board(void);
void search_ans(int x, int y);

int main(void) {
    int i, j, ans;
    scanf("%d",&n);
    while(n != 0) {
        cl_array();
        for(i = 1; i < n; i++) {
            scanf("%d %d",&dataset[i].mom, &dataset[i].hou);
        }
        make_board();
        //puts("探索終了");
        search_ans(200, 200);
        printf("%d %d\n",ans_x2-ans_x1+1, ans_y2-ans_y1+1);
        scanf("%d",&n);
    }
    return 0;
}

void make_board(void) {
    int i;
    board[200][200] = 0;
    for(i = 1; i < n; i++) {
        tansaku(i, 200, 200);
    }
}

void tansaku(int num, int x, int y) {
    if(board[x][y] == -1 || x < 0 || y < 0
            || x >= MAX_DATA || y >= MAX_DATA || mimasita[x][y] == num) {
        return;
    }
    mimasita[x][y] = num;
    if(board[x][y] != dataset[num].mom) {
        tansaku(num, x-1, y);
        tansaku(num, x, y-1);
        tansaku(num, x+1, y);
        tansaku(num, x, y+1);
    } else {
        if(dataset[num].hou == 0) {
            board[x-1][y] = num;
        } else if(dataset[num].hou == 1) {
            board[x][y+1] = num;
        } else if(dataset[num].hou == 2) {
            board[x+1][y] = num;
        } else if(dataset[num].hou == 3) {
            board[x][y-1] = num;
        }
        return;
    }
}

void cl_array(void) {
    int i, j;
    ans_x1 = 401;
    ans_x2 = -1;
    ans_y1 = 401;
    ans_y2 = -1;
    for(i = 0; i < MAX_DATA; i++) {
        for(j = 0; j < MAX_DATA; j++) {
            mimasita[i][j] = 0;
            board[i][j] = -1;
        }
    }
}

void search_ans(int x, int y) {
    int i, j;
    for(i = 0; i < MAX_DATA; i++) {
        for(j = 0; j < MAX_DATA; j++) {
            if(board[i][j] != -1) {
                if(i < ans_x1) {
                    ans_x1 = i;
                }
                if(i > ans_x2) {
                    ans_x2 = i;
                }
                if(j < ans_y1) {
                    ans_y1 = j;
                }
                if(j > ans_y2) {
                    ans_y2 = j;
                }
            }
        }
    }
}

Measured memory_bytes: 1872
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/math/tools/minima.hpp>

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

namespace adaptor = boost::adaptors;
using namespace std;
using boost::math::tools::brent_find_minima;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::split;
using boost::algorithm::replace_all;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

// TOP

void	Main()
{
	int	n;
	cin >> n;

	vector<int>	A(n + 1);
	for (int i = 0; i < n + 1; i++)
		cin >> A.at(i);

	vector<int>	B(n + 1);
	for (int i = 0; i < n; i++)
		cin >> B.at(i);

	ll cnt;
	cnt = 0;
	for (int i = n - 1; i >= 0; i--)
	{
		if (A.at(i + 1) >= B.at(i))
		{
			cnt += B.at(i);
			continue;
		}
		else
		{
			B.at(i) -= A.at(i + 1);
			cnt += A.at(i + 1);
			if (A.at(i) >= B.at(i))
			{
				A.at(i) -= B.at(i);
				cnt += B.at(i);
			}
			else
			{
				cnt += A.at(i);
				A.at(i) = 0;
			}
		}
	}
	cout << cnt << endl;
}
// END

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


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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

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

    int V, E; cin >> V >> E;
    vector<tuple<int, int, ll>> e(E);
    REP(i, E)
    {
        int a, b;
        ll c; cin >> a >> b >> c;
        a--; b--;
        e[i] = mt(a, b, -c);
    }

    vl dist(V, INFL);
    dist[0] = 0;

    REP(i, V)
    {
        REP(j, E)
        {
            int a, b;
            ll c;
            tie(a, b, c) = e[j];
            if(dist[a] == INF) continue;
            if(chmin(dist[b], dist[a] + c) && i == V-1 && b == V-1)
            {
                cout << "inf" << endl;
                return 0;
            }
        }
    }
    cout << -dist[V-1] << endl;
}

Measured memory_bytes: 3680
void main() {
	auto N = ri;
	auto d = readAs!(int[]);
	d.sort();
	writeln(d[$ / 2] - d[$ / 2 - 1]);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 4544
#include <stdio.h>
#define MAX 45

void Fibonacci(int n){
    int F[MAX];
    int i;
    F[0] = 1;
    F[1] = 1;
    for(i=2;i<=n;i++){
        F[i] = F[i-2] + F[i-1];
    }
    printf("%d\n",F[n]);
};
int main(){
    int n;
    scanf("%d",&n);
    Fibonacci(n);
    return 0;
}

Measured memory_bytes: 596
import math
def plot(x,y):
    print(f'{x:.8f} {y:.8f}')
def Koch(n, x1,y1,x2,y2):
    if n==0:
        plot(x1,y1)
        return
    sx=(2*x1+x2)/3
    sy=(2*y1+y2)/3
    tx=(x1+2*x2)/3
    ty=(y1+2*y2)/3
    ux=(tx-sx)*(1/2)-(ty-sy)*(math.sqrt(3)/2)+sx
    uy=(tx-sx)*(math.sqrt(3)/2)+(ty-sy)*(1/2)+sy
    
    Koch(n-1, x1,y1, sx,sy)
    Koch(n-1, sx,sy, ux,uy)
    Koch(n-1, ux,uy, tx,ty)
    Koch(n-1, tx,ty, x2,y2)
    
n=int(input())
Koch(n, 0,0, 100,0)
plot(100,0)


Measured memory_bytes: 5752
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <limits>

using namespace std;

int main(){
  int N,M;
  cin >> N >> M ;

  int num[4];
  
  for(int i=1; i<=3; i++)num[i]=-1;
  for(int i=0; i<M;i++){
    int s,c;
    scanf("%d %d", &s, &c);
    if(num[s]==-1 || num[s]==c){
      num[s]=c;
    }else{
      cout << -1 << endl;
      return 0;
    }
  }

  if(N !=1 && num[1]==-1)num[1]=1;
  if(N !=1 && num[1]==0){
    cout << -1 << endl;
    return 0;
  }

  for(int i=1; i<=N;i++){
    if(num[i]==-1)num[i]=0;
    printf("%d",num[i]);
  }
  printf("\n");
  return 0;


}

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

//===
struct UnionFind {
    vector<int> parent;

    UnionFind(){}
    
    UnionFind(int nmemb)
    {
        init(nmemb);
    }

    void init(int nmemb)
    {
        parent.clear();
        parent.assign(nmemb, -1);
    }

    int root(int x)
    {
        if (parent[x] < 0) {
            return x;
        }
        return parent[x] = root(parent[x]);
    }

    bool same(int x, int y)
    {
        return root(x) == root(y);
    }

    void unite(int x, int y)
    {
        x = root(x);
        y = root(y);

        if (x == y) return;

        parent[x] += parent[y];
        parent[y] = x;
        
        return;
    }
};
//===

int main()
{
    UnionFind uf;
    int n, q;
    int com, x, y;

    cin >> n >> q;
    uf.init(n);
    for (int i = 0; i < q; i++) {
        cin >> com >> x >> y;

        if (com == 0) {
            uf.unite(x, y);
        }
        else {
            if (uf.same(x, y)) {
                cout << 1 << endl;
            }
            else {
                cout << 0 << endl;
            }
        }
    }

    return 0;
}



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

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (1e10)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);}} premain;


const int MAX_ROW = 25*25+10; // to be set appropriately
const int MAX_COL = 25*25+10; // to be set appropriately
struct BitMatrix {
    int H, W;
    bitset<MAX_COL> val[MAX_ROW];
    BitMatrix(int m = 1, int n = 1) : H(m), W(n) {}
    inline bitset<MAX_COL>& operator [] (int i) {return val[i];}
};

int GaussJordan(BitMatrix &A, bool is_extended = false) {
    int rank = 0;
    for (int col = 0; col < A.W; ++col) {
        if (is_extended && col == A.W - 1) break;
        int pivot = -1;
        for (int row = rank; row < A.H; ++row) {
            if (A[row][col]) {
                pivot = row;
                break;
            }
        }
        if (pivot == -1) continue;
        swap(A[pivot], A[rank]);
        for (int row = 0; row < A.H; ++row) {
            if (row != rank && A[row][col]) A[row] ^= A[rank];
        }
        ++rank;
    }
    return rank;
}

int linear_equation(BitMatrix A, vector<int> b, vector<int> &res) {
    int m = A.H, n = A.W;
    BitMatrix M(m, n + 1);
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) M[i][j] = A[i][j];
        M[i][n] = b[i];
    }
    int rank = GaussJordan(M, true);

    // check if it has no solution
    for (int row = rank; row < m; ++row) if (M[row][n]) return -1;

    // answer
    res.assign(n, 0);
    for (int i = 0; i < rank; ++i) res[i] = M[i][n];
    return rank;
}


int main() {
	int M, N, D;
	
	while(true) {
		cin >> M >> N >> D;
		if ((0 == M) && (0 == N) && (0 == D)) {
			break;
		}

		BitMatrix A(M*N, M*N);
		vector<int> b(M*N);

		REP(i, M) REP(j, N) {
			REP(x, M) REP(y, N) {
				int d = abs(x-i) + abs(y-j);
				if (d == D) {
					A[i+M*j][x+M*y] = 1;
				}
			}
			A[i+M*j][i+M*j] = 1;
		}

		REP(j, N) REP(i, M) {
			int s;
			cin >> s;
			b[i+M*j] = s;
		}

		vector<int> res(M*N);
		int rank = linear_equation(A, b, res);
		if (-1 == rank) {
			print(0);
		} else {
			print(1);
		}
	}
}



Measured memory_bytes: 3296
#include <iostream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#define rep(i,N) for(int i=0;i<((int)N);i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
int main(void){
  long N;
  cin>>N;
  int a[N];
  for(int i=0;i<N;i++){
      cin>>a[i];
  }
  long sum=0;
  for(int i=0;i<N;i++){
      sum+=a[i];
  }
  long sunuke=0; long kuma=0; long min=1000000000000;
   for(int i=0;i<N-1;i++){
      sunuke+=a[i];
      kuma=sum-sunuke;
      if(abs(sunuke-kuma)<min) {min=abs(sunuke-kuma);}
   }
   cout<<min;
   return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

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

bool query(std::vector<int> && q) {
	cout << "? ";
	for(auto v: q) cout << v << " ";
	cout << endl;

	std::string t; cin >> t;
	if(t == "-1") std::abort();
	return (t == "Red");
}

std::vector<int> get_segment(int s, int len, int i, int j) {
	std::vector<int> q;
	for(int k = s; k < s + len; k++) {
		if(i != j and k == i) continue;

		q.push_back(k + 1);
	}
	if(i != j) q.push_back(j + 1);
	return q;
}

char c(bool f) {
	return (f ? 'R' : 'B');
}

int main() {
	int n; scanf("%d", &n);

	// 1
	bool now = query(get_segment(0, n, 0, 0));

	// 7
	int L = 1, R = n + 1; // [L, R)
	while(std::abs(L - R) > 1) {
		int mid = (L + R) >> 1;

		auto ret = query(get_segment(mid, n, 0, 0));
		if(now == ret) L = mid;
		else R = mid;
	}

	// 1
	int bound = (query(get_segment(L, n, 0, 0)) != now ? L - 1 : L);
	// [bound, bound + n) != [bound + 1, bound + n + 1)
	// [bound, bound + n) == now

	// 2
	assert(query(get_segment(bound, n, 0, 0)) != query(get_segment(bound + 1, n, 0, 0)));

	std::string ans(2 * n, '?');
	ans[bound]	   = c(now);
	ans[bound + n] = c(!now);
	
	// 198
	for(int i = 0; i < 2 * n; i++) {
		if(i == bound or i == bound + n) continue;
		
		if(bound + 1 <= i and i < bound + n) {
			auto ret = query(get_segment(bound + 1, n, i, bound));

			ans[i] = (now == ret ? c(!now) : c(now));
		} else {
			auto ret = query(get_segment(bound + 1, n, bound + n, i));

			ans[i] = (now == ret ? c(now) : c(!now));
		}
	}

	cout << "! " << ans << endl;
	return 0;
}


Measured memory_bytes: 724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
	int h,w,a,b;
	cin >> h >> w >> a >> b;
	rep(i,h){
		rep(j,w){
			int x = (i<b)^(j<a);
			cout << x;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define ld long double
#define MOD 1000000007
#define nl cout << bl
#define rt ll Q[100005] = {0}
#define mp make_pair
#define test() \
    ull t;     \
    cin >> t;  \
    while (t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define s(ar, n) sort(ar, ar + n)
#define rs(ar, n) sort(ar, ar + n, greater<ll>())
#define oa(a, n)               \
    for (ll i = 0; i < n; i++) \
        cout << a[i] << " ";
#define cn(a, n)               \
    for (ll i = 0; i < n; i++) \
        cin >> a[i];
#define ov(a, n)                    \
    for (ll i = n - 1; i >= 0; i--) \
        cout << a[i] << " ";        \
    nl
#define ovp(a, n)              \
    for (ll i = 0; i < n; i++) \
        cout << a[i].ff << " " << a[i].ss << bl;
#define maxa(ar, N) *max_element(ar, ar + N)
#define mina(ar, N) *min_element(ar, ar + N)
#define present(c, x) ((c).find(x) != (c).end())
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
typedef pair<int, int> pii;
ll fast_exp(ll base, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
            res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return res % MOD;
}
ll fib(ll n)
{
    if (n < 2)
        return n;
    ll a = 0, b = 1, pre;
    int i = 1;
    while (i < n)
    {
        pre = (a + b) % MOD;
        a = b;
        b = pre;
        i++;
    }
    return pre;
}
ll fac(ll n)
{
    if (n % 2 == 0)
        return 2;

    for (ll i = 3; i * i <= n; i += 2)
    {
        if (n % i == 0)
            return i;
    }

    return n;
}
ll fact(ll n)
{
    if (n > 1)
        return n * fact(n - 1);
    else
        return 1;
}
bool sortbysec(const tuple<int, int, int> &a,
               const tuple<int, int, int> &b)
{
    return (get<1>(a) < get<1>(b));
}

int main()
{
    int x, n;
    cin >> x >> n;
    int a[n];
    int mn = INT_MAX;
    int mx = INT_MIN;
    unordered_set<int> st;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        mn = min(mn, a[i]);
        mx = max(mx, a[i]);
        st.insert(a[i]);
    }
    for (int i = 0; i <= x; i++)
    {
        if (st.count(x - i) == 0)
        {
            cout << x - i << "\n";
            return 0;
        }
        if (st.count(x + i) == 0)
        {
            cout << x + i << "\n";
            return 0;
        }
    }
}

Measured memory_bytes: 3648
package main

import (
	"strings"
	"fmt"
	"bufio"
	"strconv"
	"os"
)

// print
func p(input interface{}) {
	fmt.Println(input)
}

// test
func Test_solve() {
	input := `

0 0 2 0
3
-1 1
0 1
1 1
`
	input = strings.Trim(input, "\n")

	solve(bufio.NewScanner(strings.NewReader(input)))
}

func projection(p1, p2, p []float64) []float64 {
	// p - p1
	v1 := []float64{
		p[0] - p1[0],
		p[1] - p1[1],
	}
	// p2 - p1
	v2 := []float64{
		p2[0] - p1[0],
		p2[1] - p1[1],
	}

	dot := v1[0]*v2[0] + v1[1]*v2[1]
	// cross := v1[0]*v2[1] - v1[1]*v2[0]
	normal := v2[0] * v2[0] + v2[1] * v2[1]

	a := dot / normal

	result := []float64{
		p1[0] + v2[0] * a,
		p1[1] + v2[1] * a,
	}
	return result
}

func reflection(p1, p2, p []float64) []float64 {
	prj := projection(p1, p2, p)
	// p - p1
	v1 := []float64{
		p[0] - p1[0],
		p[1] - p1[1],
	}

	// p to reflection
	toCrossPoint := []float64{
		2 * (prj[0] - v1[0]),
		2 * (prj[1] - v1[1]),
	}

	result := []float64{
		p[0] + toCrossPoint[0],
	    p[1] + toCrossPoint[1],
	}

	return result
}

// solve
func solve(sc *bufio.Scanner) {
	sc.Scan()
	elements := strings.Split(sc.Text(), " ")

	n := len(elements)
	p1p2 := make([]float64, n)
	for i := 0; i < n; i++ {
		// @hack: not good xD
		pInt, _ := strconv.Atoi(elements[i])
		p1p2[i] = float64(pInt)
	}

	sc.Scan()
	n, _ = strconv.Atoi(sc.Text())

	for i := 0; i < n; i++ {
		sc.Scan()
		pElms := strings.Split(sc.Text(), " ")
		pp := make([]float64, 2)

		// @hack not cool XD
		v, _ := strconv.Atoi(pElms[0])
		pp[0] = float64(v)
		v, _ = strconv.Atoi(pElms[1])
		pp[1] = float64(v)

		result := projection(p1p2[:2], p1p2[2:], pp)
		fmt.Printf("%.10f %.10f", result[0], result[1])

		if i < n - 1 {
			fmt.Println()
		}
	}
}

// main
func main() {
    solve(bufio.NewScanner(os.Stdin))
}



Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++)
    {
        cin >> A.at(i);
    } 
    int sum=0; 
    for(int i=0; i<N; i++)
        {
            for(int j=i+1; j<N; j++)
            {
                sum+=A.at(i)*A.at(j);
            }
        }
    cout << sum <<endl;
}


Measured memory_bytes: 256
import sys

def insertionSort( nums, n, g ):
	cnt = 0
	i = g
	while i < n:
		v = nums[i]
		j = i - g
		while 0 <= j and v < nums[j]:
			nums[ j+g ] = nums[j]
			j -= g
			cnt += 1
		nums[ j+g ] = v
		i += 1
	return cnt
		
def shellSort( nums, n ):
	g = []
	val =0
	for i in range( n ):
		val = 3*val+1
		if  n < val:
			break
		g.append( val )
	
	g.reverse( )
	m = len( g )
	print( m )
	print( " ".join( map( str, g ) ) )
	cnt = 0
	for i in range( m ):
		cnt += insertionSort( nums, n, g[i] )
	print( cnt )
    
n = int( sys.stdin.readline( ) )
nums = []
for i in range( n ):
	nums.append( int( sys.stdin.readline( ) ) )

cnt = 0
shellSort( nums, n )
print( "\n".join( map( str, nums ) ) )

Measured memory_bytes: 125620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	    LinkedList<String> stack = new LinkedList<String>();
		
		try {
			String[] param = in.readLine().split(" ");
			
			int i = 0;
			while (i < param.length) {
				while ((param[i].equals("+") == false)
						&& (param[i].equals("-") == false) && (param[i].equals("*") == false)) {
					stack.push(param[i]);
					i++;
				}
				int b = Integer.parseInt(stack.pop());
				int a = Integer.parseInt(stack.pop());
				
				if (param[i].equals("+")) {
					stack.push(String.valueOf(a + b));
				} else if (param[i].equals("-")) {
					stack.push(String.valueOf(a - b));
				} else {
					stack.push(String.valueOf(a * b));
				}
				i++;
			}
			
			System.out.println(stack.pop());
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 24472
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
#define ALL(a)  (a).rbegin(),(a).rend()
const int MOD = 1000000007;
ll a = 0, y, s = 0, w, n, m;
int main() {
    cin >> n >> m >> w;
    if (w < 1000000000) {
        rep(i, n) {
            if (i < m) cout << w << " ";
            else if (i != n - 1) cout << w + 1 << " ";
            else cout << w + 1 << endl;
        }
    }
    else {
        rep(i, n) {
            if (i < m) cout << w << " ";
            else if (i != n - 1) cout << 1 << " ";
            else cout << 1 << endl;
        }
    }
}

Measured memory_bytes: 1280
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
const int N = 20;
double dist[N][N];
double solve(int n,int m){
  double ret=0;
  rep(i,(1<<n)){
    double tmp=0;
    if (__builtin_popcount(i) != m)continue;
    rep(j,n){
      if (((1<<j)&i) == 0)continue;
      rep(k,j){
        if (((1<<k)&i) == 0)continue;
        tmp+=dist[k][j];
      }
    }
    ret=max(ret,tmp);
  }
  return ret;
}

double compute(double a){return a*a;}

int main(){
  int n,m;
  while(cin>>n>>m){
    double r[n],g[n],b[n];
    rep(i,n)cin>>r[i]>>g[i]>>b[i];
    rep(i,n){
      rep(j,n){
        dist[i][j]=compute(r[i]-r[j])+
          compute(g[i]-g[j])+
          compute(b[i]-b[j]);
      }
    }
    printf("%.12lf\n",solve(n,m));
  }
}

Measured memory_bytes: 936
k = int(input())

def func(k):
    number = 7 % k
    for i in range(k):
        if number == 0:
            return i+1
        number = (10 *number + 7) % k 
    return -1
    
if k % 2 == 0 or k % 5 == 0:
    print(-1)
else:
    print(func(k))


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


const int N=600009;

char s[N];

struct bigint
{
	int len;
	int a[N];
	inline int sum()
	{
		int ret=0;
		for(int i=1;i<=len;i++)
			ret+=a[i];
		return ret;
	}
	bigint operator + (int b)
	{
		bigint ret;
		ret.len=len;
		for(int i=1;i<=len;i++)
			ret.a[i]=a[i];

		ret.a[1]+=b;
		int p=1;
		while(ret.a[p]>=10)
		{
			ret.a[p+1]+=ret.a[p]/10;
			ret.a[p]%=10;
			p++;
		}
		if(p>ret.len)ret.len=p;
		return ret;
	}
};

inline void read(bigint &x)
{
	scanf("%s",s+1);
	x.len=strlen(s+1);
	for(int i=1;i<=x.len;i++)
		x.a[i]=(s[x.len-i+1]-'0')*9;
	for(int i=1;i<=x.len;i++)
		if(x.a[i]>=10)
		{
			x.a[i+1]+=x.a[i]/10;
			x.a[i]%=10;
			if(i+1>x.len)x.len=i+1;
		}
}

inline void print(bigint x)
{
	for(int i=x.len;i>=1;i--)
		putchar(x.a[i]+'0');
	puts("");
}

int main()
{
	if(fopen("vj.in","r"))
	{
		freopen("vj.in","r",stdin);
		freopen("vj.out","w",stdout);
	}

	bigint x;
	read(x);

	int l=1,r=x.sum(),ans=1,mid;

	while(l<=r)
	{
		mid=l+r>>1;
		int tmp=(x+mid*9).sum();
		if((x+mid*9).sum()<=9*mid)
			ans=mid,r=mid-1;
		else
			l=mid+1;
	}

	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, C;
	cin >> N >> C;
	vector<int> A(N);
	int res = 0;
	int s, t, c;
	vector<vector<pair<int, int> > >vp(C);
	for (int i = 0; i < N; i++) {
		cin >> s >> t >> c;
		c--;
		vp[c].push_back(make_pair(s, t));
	}
	vector<pair<int, int> > ps;
	int st = 0;
	for (int i = 0; i < C; i++) {
		if (vp[i].size() > 0) {
			sort(vp[i].begin(), vp[i].end());
			ps.clear();
			st = vp[i][0].first;
			for (int j = 0; j < (int)vp[i].size() - 1; j++) {
				if (vp[i][j].second != vp[i][j + 1].first) {
					ps.push_back(make_pair(st, vp[i][j].second));
					st = vp[i][j + 1].first;
				}
			}
			ps.push_back(make_pair(st, vp[i].back().second));
			swap(ps, vp[i]);
		}
	}
	vector<int> sum(100005, 0);
	for (int i = 0; i < C; i++) {
		for (int j = 0; j < (int)vp[i].size(); j++) {
			sum[vp[i][j].first]++;
			sum[vp[i][j].second + 1]--;
		}
	}
	for (int i = 1; i < 100004; i++) {
		sum[i] += sum[i - 1];
		res = max(res, sum[i]);
	}
	cout << res << endl;
}

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

int N;
int edge_color[100005];
int max_color;

struct edge {
	int edge_id;
	int next_node;
};

vector<edge> e[100005];

void dfs( int node, int parent_node, int used_color ){
	int color = 0;
	for ( auto it : e[node] ){
		if ( it.next_node == parent_node )
			continue;
		if ( color == used_color )
			color++;
		edge_color[it.edge_id] = color;
		dfs( it.next_node, node, color );
		color++;
	}
	max_color = max( max_color, color );
}


int main(){
	cin >> N;
	
	for ( int i = 0; i < N-1; i++ ){
		int aa, bb;
		cin >> aa >> bb;
		aa--;
		bb--;
		
		e[aa].push_back({i,bb});
		e[bb].push_back({i,aa});
	}
	
	dfs( 0, -1, -1 );
	
	cout << max_color << endl;
	for ( int i = 0; i < N-1; i++ ){
		cout << (edge_color[i]+1) << endl;
	}
	
	return 0;
}



Measured memory_bytes: 9344
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
a = inpl()
a.sort()
print(sum(a[:k]))

Measured memory_bytes: 10536
#ABC167c

N, M, X = map(int, input().split())
book_list = []
for i in range(N):
    book_list.append(list(map(int, input().split())))

ans = 99999999
for i in range(2 ** N):
    bag = []
    for j in range(N):
        if ((i >> j) & 1):
            bag.append(book_list[j])
    total_cost = 0
    skill = [0] * M
    enough = [0] * M
    for subject in bag:
        total_cost += subject[0]
        for k in range(M):
            skill[k] += subject[k+1]
            if skill[k] >= X:
                enough[k] = 1
    if 0 not in enough:
        if ans > total_cost:
            ans = total_cost

if ans == 99999999:
    print(-1)
else:
    print(ans)


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

int main() {
  char b, n;
  cin >> b;
  for (int i = 0; i < 3; i++) {
    cin >> n;
    if (b == n) {
      cout << "Bad";
      return 0;
    }
    b = n;
  }
  cout << "Good";
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

long N;
int min = 753;

int abst(int a, int b);

int main(void){
	if(scanf("%ld",&N));
	while(N >= 100){
		if(abst(N%1000, 753) < min){min = abst(N%1000, 753);}
		N /= 10;
	}
	printf("%d\n", min);
	return 0;
}

int abst(int a, int b){
	return a<b?b-a:a-b;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define en "\n"
#define LL long long
#define ITER(i,a) for( typeof(a.begin()) i=a.begin();i!=a.end();i++)
#define mod 1000000007
#define mpp make_pair
#define mes(a,b) memset((a),(b),sizeof((a))
typedef map<int,int> MI;
typedef pair<int,int> pairs;
typedef vector<int> VI;
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long int n,d,ans=0;
    cin>>n>>d;
    d=(d*1ll*d);
    while(n--)
    {
        int x,y;
        cin>>x>>y;
        long long int p=(x*1ll*x)+(y*1ll*y);
        
        if(p<=d)
        ans++;
        else
        ans=ans;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3640
N = int(input())
X = [int(T) for T in input().split()]
SortX = sorted(X)
MedL  = SortX[(N//2)-1]
MedR  = SortX[(N//2)]
if MedL==MedR:
    Disp = [str(MedL)]*N
    print('\n'.join(Disp))
else:
    Disp = [0]*N
    for T in range(0,N):
        if X[T] <=MedL:
            Disp[T] = str(MedR)
        else:
            Disp[T] = str(MedL)
    print('\n'.join(Disp))

Measured memory_bytes: 36408
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

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

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class FDivisionOrSubstraction {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      ll n; cin >> n;
      ll ans = 0;
      ll s = 1e+7;
      for(ll i=2; i<min(s, n); i++) {
        ll tmp = n;
        while(tmp%i==0) {
          tmp/=i;
        }
        if (tmp%i == 1) {
          ans++;
        }
      }

      for(ll i=s; i<n; i++) {
        ll p = n/i;
        ll r = n%i;
        if (r%p == 1) {
          ans++;
        }
        if (p == 2) {
          ans++;
          break;
        }
        i = n/p;
      }

      ans++;
      cout << ans << endl;
    }
};

signed main() {
  FDivisionOrSubstraction solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
   
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int T;
	T=1;
	while(T--)
	{
		int h,w;
		cin>>h>>w;
		vector<int>vis(w+1);
		int m;
		cin>>m;
		int p[m];
		int x,y;
		int row[h+1]={0};
		vector<int>s[h+1];
		vector<int>vec;
		vector<int>bec;
		int col[w+1]={0};
		for(int i=0;i<m;i++)
		{
			cin>>x>>y;
			s[x].pb(y);
			row[x]++;
			col[y]++;
		}
		int mx=0;
		for(int i=1;i<=h;i++)
		{
			if(row[i]>mx)
			{
				mx=row[i];
			}
		}
		int ans=mx;
		for(int i=1;i<=h;i++)
		{
			if(row[i]==mx) vec.pb(i);
		}
		mx=0;
		for(int i=1;i<=w;i++)
		{
			if(col[i]>mx)
			{
				mx=col[i];
			}
		}
		 ans+=mx-1;
		int no=0;
		for(int i=1;i<=w;i++)
		{
			if(col[i]==mx) 
			{
				vis[i]=1;
				no++;
			}
		}
		int N;
		for(int i=0;i<vec.size();i++)
		{
			x=vec[i];
			N=0;
			for(int j=0;j<s[x].size();j++)
			{
				if(vis[s[x][j]]==1) N++;
			}
			if(N<no) 
			{
				ans++;
				break;
			}
		}
		cout<<ans<<"\n";
	}
	return 0;
}

Measured memory_bytes: 25208
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
      String s1 = "ABC";
      String s2 = "ARC";
      boolean t1 = true;
      boolean t2 = true;
		for(int i = 0;i<s.length();i++){
         if(s.charAt(i)!=s1.charAt(i)){
            t1 = false;
            break;
         }
      }
      	for(int i = 0;i<s.length();i++){
         if(s.charAt(i)!=s2.charAt(i)){
            t2 = false;
            break;
         }
      }
       if(t1==true){
          System.out.println(s2);
           }
       if(t2==true){
          System.out.println(s1); 
          }
	}
}


Measured memory_bytes: 35588
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>
#include <cctype>

#define MAX_SIZE 100000000
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  int N; cin>>N;
  int cnt = 0;
  for(int i = 1; i <= N; i += 2) {
    int diviser = 0;
    for(int j = 1; j <= N; j++) {
      if(i % j == 0) {
        diviser++;
      }
    }

    if(diviser == 8) {
      cnt++;
    }
  }

  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>

using namespace std;

const ll N = 3e5+100;
const ll MOD = 1e9+7;

int main()
{
	
	ll a,b;
	cin >> a >> b;
	for(ll i =1;i<=100000;i++){
		ll x = i;
		x *= 8;
		x/=100;
		ll y = i;
		y /=10;
		if(x == a && y == b) return cout << i << endl,0;
	}	

	cout << "-1\n";



	return 0;
}

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

void solve()
{
	string s;
	cin>>s;
	int len=s.length();
	int  flag=0;
	for(int i=0;i < len ;i++){
        if(s[i] != s[len-i-1]){
            flag = 1;
            break;
   		}
   	}
   	len=(len-1)/2;
   	for(int i=0;i<len;i++)
   	{
   		if(s[i] != s[len-i-1]){
            flag = 1;
            break;
   		}
   	}
   	len=s.length();
   	for(int i=((len+3)/2)-1;i<len;i++)
   	{
   		if(s[i] != s[len-i-1]){
            flag = 1;
            break;
   		}
   	}
   	if(!flag)
   	cout<<"Yes";
   	else cout<<"No";
   	
   	
}
int main()
{
//	int t;cin>>t;
//	while(t--)
	solve();
}


Measured memory_bytes: 256
a1 = [int(i) for i in input().split()]
a2 = [int(i) for i in input().split()]
a3 = [int(i) for i in input().split()]
n = int(input())
for _ in range(n):
    b = int(input())
    if b in a1:
        a1[a1.index(b)] = 0
    elif b in a2:
        a2[a2.index(b)] = 0
    elif b in a3:
        a3[a3.index(b)] = 0
k = sum(a1) * sum(a2) * sum(a3)
for i in range(3):
    k *= a1[i] + a2[i] + a3[i]
k *= (a1[0] + a2[1] + a3[2]) * (a1[2] + a2[1] + a3[0])
if k == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import java.awt.*;
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);

		int n=s.nextInt();
		ArrayList<Point> a=new ArrayList<>();
		ArrayList<Point> b=new ArrayList<>();
		for(int i=0;i<n;++i) {
			Point e=new Point(s.nextInt(),s.nextInt());
			a.add(e);
			b.add(e);
		}
		a.sort(Comparator.comparingInt(o->o.x));
		b.sort(Comparator.comparingInt(o->o.y));

		System.err.println(a);
		System.err.println(b);

		int r=n==1?1:Integer.MAX_VALUE;

		for(int i=0;i<n;++i){
			for(int j=i+1;j<n;++j){
				long dx=a.get(j).x-a.get(i).x;
				long dy=a.get(j).y-a.get(i).y;

				int t=Math.min(f(a,dx,dy),f(b,dx,dy));
				r=Math.min(r,t);
				//System.err.println(t+" "+dx+" "+dy);
			}
		}
		System.err.println();
		System.out.println(r);
	}

	private static int f(ArrayList<Point> a,long dx,long dy){
		ArrayList<Point> l=new ArrayList<>();
		int t=0;
		for(Point p:a){
			if(l.stream().noneMatch(q->(p.x==q.x+dx&&p.y==q.y+dy)||(p.x==q.x-dx&&p.y==q.y-dy)))
				++t;
			l.add(p);
		}
		return t;
	}
}

Measured memory_bytes: 41848
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		for (int i = 0; i < n; i++) {
			int[] line = convertInt(sc.nextLine().split(" "));
			sort(line);
			if ((line[2] * line[2]) == ((line[0] * line[0]) + (line[1] * line[1]))) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
	}

	public static void sort(int[] array) {
		int n = array.length;
		for (int i = 0; i < n; i++) {
			for (int j = 1; j < n; j++) {
				if (array[j] < array[j - 1]) {
					int box = array[j - 1];
					array[j - 1] = array[j];
					array[j] = box;
				}
			}
		}
	}

	public static int[] convertInt(String[] str) {
		int n = str.length;
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = Integer.parseInt(str[i]);
		}
		return array;
	}
}

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

struct UnionFind
{
    vector<int> par, rank;
    
    UnionFind(int n){
        par.resize(n);
        rank.resize(n);
        for(int i = 0; i < n; i++){
            par[i] = i;
            rank[i] = 0;
        }
    }
    
    int find(int i){
        if(i == par[i]) return i;
        return par[i] = find(par[i]);
    }
    
    bool same(int i, int j){
        return find(i) == find(j);
    }
    
    void unite(int i, int j){
        if(same(i, j)) return;
        i = find(i), j = find(j);
        if(rank[i] < rank[j]) par[i] = j;
        else{
            par[j] = i;
            if(rank[i] == rank[j]) rank[i]++;
        }
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.unite(a, b);
    }
    int ans = -1;
    for(int i = 0; i < n; i++){
        if(uf.find(i) == i) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  if(A+B <= 2*C){
    cout << A*X+B*Y << endl;
  }else{
    if(X<=Y){
      if(2*C <= B){
        cout << 2*C*Y << endl;
      }else{
        cout << 2*C*X+(Y-X)*B << endl;
      }
    }else{
      if(2*C <= A){
        cout << 2*C*X << endl;
      }else{
        cout << 2*C*Y+(X-Y)*A << endl;
      }
    }
  }
}

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

typedef long long ll;

int main(){
  while(1){
  map<ll,ll> M;
  ll n;
  cin>>n;
  if(n==0){break;}
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    M[a]++;
  }
  bool done=false;
  for(auto i=M.begin();i!=M.end();i++){
    if((*i).second>n/2){cout<<(*i).first<<endl; done=true; break;}
  }
  if(!done){cout<<"NO COLOR"<<endl;}
  }

    return 0;
}



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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec[i];
  }
  sort(vec.begin(),vec.end());
  
  int a=0;
  for(int i=0;i<K;i++){
    a +=vec[i];
  }
  cout << a <<endl;
}


Measured memory_bytes: 3556
// https://atcoder.jp/contests/abc095/tasks/abc095_a
"use strict"
function Main(input) {
  const params = input.split('');
  const total = params.reduce((acr, cur) => {
    if (cur === "o") {
      return acr + 100;
    }

    return acr;
  }, 700);

  console.log(total);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <stdio.h>
int min(int a, int b){
    return a<b ? a : b;
}

int main(void){
    int p, q, r;
    scanf("%d%d%d", &p, &q, &r);
    int ans = min(r+q, min(p + q, p + r));
    printf("%d\n", ans);
    return 0; 
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
#define pii pair<string, int>
using namespace std;
struct query
{
    string restaurant;
    int score;
    int entry;
};
bool comparator(struct query a, struct query b)
{
    if(a.restaurant == b.restaurant)
        return a.score > b.score;
    else return a.restaurant < b.restaurant;
}
main()
{
    int n, p;
    string s;
    cin >> n;
    struct query ara[n];
    for(int i = 0; i < n; i++)
    {
        cin >> s >> p;
        ara[i].restaurant= s;
        ara[i].score = p;
        ara[i].entry = i + 1;
    }
    sort(ara, ara+n, comparator);
    for(int i = 0; i < n; i++)
        cout << ara[i].entry << endl;
    //main();
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

ll extended_factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
        ans %= (ll)(1e9+7);
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

char alphabet[] = {
    'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
};


int main(){
    ll N,M;
    cin >> N >> M;
    if (abs(N-M)>=2){
        cout << 0 << endl;
        return 0;
    }
    if (N==M){
        // cout << "N == M" << endl;
        cout << (extended_factorial(N) * extended_factorial(M) * 2)%((ll)1e9+7) << endl;
        return 0;
    }else{//1個差
        cout << (extended_factorial(N) * extended_factorial(M))%((ll)1e9+7) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	for(int i=0;i<=20;i++)
		for(int j=0;j<=20;j++) {
			if(i*4+j*7==n) {
				cout<<"Yes";
				return 0;
			} 
		}
	cout<<"No";
	return 0; 
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    vector<int> a(3);
    int sum = 0;
    rep(i,3) {
        cin >> a[i];
        sum+=a[i];
    }
    cout << (sum >= 22 ? "bust" :"win") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,cnt,ans;
  cin >> n;
  ans=0;
  for(int i=1;i<=n;i+=2){
    cnt=0;
    for(int j=1;j<=i;j++){
      if(i%j==0){
        cnt+=1;
      } 
    }
    if(cnt==8){
      ans+=1;
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
import numpy as np
n, k, q = map(int, input().split())
member = [k - q] * n
member = np.array(member)
for _ in range(q):
    i = int(input()) - 1
    member[i] += 1
for point in member:
    if point > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 15932
n = int(input())
a = list(map(int,input().strip().split()))

import collections

c = sorted(collections.Counter(a).items(), reverse=True)

leng_1 = 0
for leng,count in c:
  if count >=4:
    if leng_1 != 0:
      print(leng_1 * leng)
      exit()
    else:
      print(leng**2)
      exit()
  elif count >=2:
    if leng_1 != 0:
      print(leng_1*leng)
      exit()
    else:
      leng_1 = leng
print(0)

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

using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    if(a==b) cout<<"Draw"<<endl;
    else if(a==1||b==1){
        if(a<b) cout<<"Alice"<<endl;
        else cout<<"Bob"<<endl;
    }
    else{
        if(a>b) cout<<"Alice"<<endl;
        else cout<<"Bob"<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll n;
    cin >> n;
    vector<ll> mp(26, 0);
    rep(i, 0, n){
        string s;
        cin >> s;
        vector<ll> t(26, 0);
        for(auto e : s){
            t[e-'a']++;
        }
        rep(j, 0, 26){
            if(i != 0) mp[j] = min(mp[j], t[j]);
            else mp[j] = t[j];
        }
    }
    rep(i, 0, 26){
        rep(j, 0, mp[i]) cout << (char)('a' + i);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;
void swap(int &a, int &b);

int main()
{
	double r;
	cin >> r;
	double area, circ;

	area = r*r*M_PI;
	circ = 2.0*M_PI*r;

	cout << fixed << setprecision(6) << area << " " << circ << endl;

}

void swap(int &a, int &b)
{
	int temp = a;
	a = b;
	b = temp;
	return;
}




Measured memory_bytes: 3272
#include <iostream>
#include <queue>
#include <map>

using namespace std;

typedef pair<int, int> P;

int n, q;
int fish[1000001];

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

    priority_queue<P> pq;

    for(int i = 0; i < q; i++) {
        int a, v;
        cin >> a >> v;
        fish[a] += v;
        pq.push(P(fish[a], a * (-1)));

        while(!pq.empty()) {
            P p = pq.top();
            if (fish[p.second * (-1)] == p.first) {
                cout << p.second * (-1) << " " << p.first << endl;
                break;
            }
            pq.pop();
        }
    }

    return 0;
}

Measured memory_bytes: 7648