akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'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'};
char moji2[26]={'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'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int ans = 0;
    string s;
    cin >> s;
    int n = s.length();
    REP(i,n){
        if(2 * i >= n) break;
        if(s[i] != s[n-1-i]) ans ++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
s = [input() for _ in range(n)]

d = {}
for i in s:
    if i not in d:
        d[i] = 1
    else:
        d[i] += 1
        
m = max(d.values())

l = []
for k in d.keys():
    if d[k] == m:
        l.append(k)

l_s = sorted(l)
                
for ans in l_s:
    print(ans)

Measured memory_bytes: 38440
#abc096c
import sys

h,w=map(int,raw_input().split())
s=['.'*(w+2)]
for i in xrange(h):
 t='.'
 t+=raw_input()
 t+='.'
 s.append(t)
s.append('.'*(w+2))
for i in xrange(1,h+1):
 for j in xrange(1,w+1):
  if s[i][j]=='#':
   if s[i-1][j]=='#' or s[i+1][j]=='#' or s[i][j-1]=='#' or s[i][j+1]=='#':
    continue
   else:
    print 'No'
    sys.exit()
print 'Yes'


Measured memory_bytes: 2568
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;

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

int lminus(int f){
	return -(f-2);
}

int lprod(int f1, int f2){
	if(f1 == 0 || f2 == 0) return 0;
	if(f1 == 1 || f2 == 1) return 1;
	return 2;
}

int lplus(int f1, int f2){
	if(f1 == 2 || f2 == 2) return 2;
	if(f1 == 1 || f2 == 1) return 1;
	return 0;
}


int evaluate(string s){
	if(s.size() == 0) return 0;

	if(s.size() == 1){
		return s[0] - '0';
	}

	if(s[0] == '-'){
		return lminus(evaluate(s.substr(1)));
	}

	if(s[0] == '('){
		int f1begin = 1, f1len;
		int f2begin, f2len;

		int i = 1;
		int nest = 1;
		char c = ' ';
		for(i = 1; ; i++){
			if(nest == 1){
				if( s[i] == '*' ){
					c = '*';
					f1len = i-1;
					f2begin = i+1;
				}
				if( s[i] == '+' ){
					c = '+';
					f1len = i-1;
					f2begin = i+1;
				}
			}
			if(s[i] == ')') nest--;
			if(s[i] == '(') nest++;
			if(nest == 0)break;
		}
		f2len = i - f2begin;

		if(c == '*') return lprod(evaluate(s.substr(f1begin, f1len)), evaluate(s.substr(f2begin, f2len)));
		if(c == '+') return lplus(evaluate(s.substr(f1begin, f1len)), evaluate(s.substr(f2begin, f2len)));
		return -1;
	}

}

string repl(const string &s, char from, char to){
	string t = s;
	rep(i, t.size()){
		if(t[i] == from) t[i] = to;
	}
	return t;
}

int main(){
	string s;

	while(cin >> s, !(s.size() == 1 && s[0] == '.')){
		int cnt = 0;

		for(char i = '0'; i <= '2'; i++){
			for(char j = '0'; j <= '2'; j++){
				for(char k = '0'; k <= '2'; k++){
					cnt += (evaluate(repl(repl(repl(s, 'P', i), 'Q', j), 'R', k)) == 2);
				}
			}
		}

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 1192
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <cstdlib>
#include <memory>
#include <queue>
#include <cassert>
#include <cmath>
#include <ctime>
#include <complex>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

#define ws ws_____________________
#define y1 y1_____________________
#define y0 y0_____________________
#define left left_________________
#define right right_______________
#define next next_________________
#define prev prev_________________
#define hash hash_________________

#define pb push_back
#define fst first
#define snd second
#define mp make_pair 
#define sz(C) ((int) (C).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define all(C) begin(C), end(C)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef long double ld;
typedef complex<double> cd;

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define FILE_NAME "a"


int n, m;
vvi g;

bool read() {
	if  (scanf("%d%d", &n, &m) < 2) {
		return 0;
	}
	g.clear();
	g.resize(n);
	forn(i, m) {
		int a, b;
		scanf("%d%d", &a, &b);
		--a;
		--b;
		g[a].pb(b);
		g[b].pb(a);
	}
	return 1;
}



bool solve() {
	for (int v = 1; v + 1 < n; ++v) {
		bool was_s = 0;
		bool was_t = 0;
		for (int to : g[v]) {
			if  (to == 0) {
				was_s = 1;
			}
			if  (to == n - 1) {
				was_t = 1;
			}
		}
		if  (was_s && was_t) {
			return 1;
		}
	}
	return 0;
}

int main() {
#ifdef LOCAL
	freopen(FILE_NAME ".in", "r", stdin);
	// freopen(FILE_NAME ".out", "w", stdout);
#endif

	while (read()) {
		puts(solve() ? "POSSIBLE" : "IMPOSSIBLE");
	}

#ifdef LOCAL
	cerr.precision(5);
	cerr << "Time: " << fixed << (double) clock() / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}


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

//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("avx,avx2")

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define dbg(x) cerr<<#x<<" : "<<x<<endl

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
const ll INF = 1e18+1;
const ll MOD = 1000000007L;
clock_t time_p=clock();
void timer(){time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}

template <typename Arg1> ostream& operator << (ostream& out, const vector<Arg1> &a) {out<<"[ ";for(const auto &x:a)out<<x<<" ";return out<<"]";}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin>>n;
    cout<<(n*(n-1))/2<<endl;
    timer();
    return 0;
}


Measured memory_bytes: 256
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# クエリでは根だけにカウンターの値を足して、最後に上から足していく(imos法みたいに)
N, Q = lr()
graph = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b = lr()
    graph[a].append(b)
    graph[b].append(a)

counter = [0] * (N+1) # 1-indexed
for _ in range(Q):
    p, x = lr()
    counter[p] += x

root = 1
stack = [(root, None)]
while stack:
    cur, parent = stack.pop()
    c = counter[cur]
    for child in graph[cur]:
        if child == parent:
            continue
        counter[child] += c
        if len(graph[child]) > 1:
            stack.append((child, cur))

print(*counter[1:])


Measured memory_bytes: 89420
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int N;
vector <int>t, v;
vector<int>tab;
const LL INF = 12345678901234;
LL memo[234*234][234];
LL dp(int sec, int sp) {
	if (sp < 0)return -INF;
	if (sec == 0) {
		if (sp != 0)return -INF;
		return 0;
	}
	if (memo[sec][sp] != -1)return memo[sec][sp];
	if (sp > tab[sec - 1])return -INF;
	LL a = dp(sec - 1, sp + 1) + (sp + sp + 1);//減速
	LL b = dp(sec - 1, sp) + (sp + sp);//等速
	LL c = dp(sec - 1, sp - 1) + (sp + sp - 1);//加速
	LL res = max(b, c);
	if (sp + 1 <= tab[sec - 1])res = max(res, a);
	return memo[sec][sp] = res;
}

int main(void)
{
	cin >> N;
	int sum = 0;
	for (int i = 0; i < N; ++i) {
		int a; cin >> a;
		a *= 2;
		t.push_back(a);
		sum += a;
	}
	for (int i = 0; i < N; ++i) {
		int a; cin >> a;
		a *= 2;
		v.push_back(a);
		for (int j = 0; j < t[i]; ++j) {
			tab.push_back(a);
		}
	}
	memset(memo, 0xff, sizeof(memo));
	LL ans = dp(sum, 0);
	cout.precision(15);
	cout << (long double)ans / 8 << endl;
	return 0;
}


Measured memory_bytes: 103164
#include <iostream>
#include <string>
using namespace std;

int main()
{
    int n;
    cin >> n;
    string input;
    string arr[4]{ "AC", "WA", "TLE", "RE" };
    int result[4] { 0, 0, 0, 0 };
    for (int i = 0; i < n; i++) {
        cin >> input;
        if (input == "AC") {
            result[0]++;
            continue;
        }
        if (input == "WA") {
            result[1]++;
            continue;
        }
        if (input == "TLE") {
            result[2]++;
            continue;
        }
        if (input == "RE") {
            result[3]++;
            continue;
        }
    }
    for (int i = 0; i < 4; i++) cout << arr[i] << " x " << result[i] << "\n";
}

Measured memory_bytes: 3620
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

func main() {
	N := readi()
	N = N
	M := readi()
	L := make([]int, M)
	R := make([]int, M)
	for i := 0; i < M; i++ {
		L[i] = readi()
		R[i] = readi()
	}

	l := 0
	m := INF
	for i := 0; i < M; i++ {
		l = max(l, L[i])
		m = min(m, R[i])
	}

	ans := 0
	for i := l; i <= m; i++ {
		ans++
	}
	fmt.Println(ans)
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func comb(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

func permutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}

func isPrime(n int) bool {
	if n == 1 {
		return false
	}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

func divisor(n int) (res []int) {
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if i*i != n {
				res = append(res, n/i)
			}
		}
	}
	sort.Ints(res)
	return
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7

	COMB_MAX = 510000
)

var (
	readString func() string
)

var (
	fac  = [COMB_MAX]int{}
	finv = [COMB_MAX]int{}
	inv  = [COMB_MAX]int{}
)

func init() {
	readString = newReadString(os.Stdin)
}

func combInit() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for i := 2; i < COMB_MAX; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
		finv[i] = finv[i-1] * inv[i] % MOD
	}
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
#define MOD 998244353 //1000000007

ll gcd(ll A, ll B){
    if(A<B) swap(A,B);
    while(B){
        ll w = A%B;
        A = B;
        B = w;
    }
    return A;
}

ll lcm(ll A, ll B){return A*B/gcd(A,B);}

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

    // solution comes here

    ll N, K, ans=1e15;
    cin >> N >> K;
    vl x(N+10);
    for(ll i=1; i<=N; i++) {
        cin >> x[i];
        if(i>=K) {
            ans = min(ans, abs(x[i]-x[i-K+1]) + min(abs(x[i]), abs(x[i-K+1])));
        }
    }

    cout << ans << nl;
}

Measured memory_bytes: 1024
def resolve():
    import sys
    input = sys.stdin.readline
    # row = [int(x) for x in input().rstrip().split(" ")]
    # n = int(input().rstrip())
    w = input().rstrip()

    import string

    result = {alp: True for alp in string.ascii_lowercase}

    for c in w:
        result[c] = not result[c]

    if all(result.values()):
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 71876
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll sumeven = 0, sumodd = 0;
    rep(i, n) cin >> a[i];
    rep(i, n)
    {
        if (a[i] % 2 == 0)
            sumeven++;
        else
            sumodd++;
    }
    if (sumodd % 2 == 0)
    {
        cout << "YES" << endl;
        return 0;
    }
    else
    {
        cout << "NO" << endl;
        return 0;
    }

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

int main(void){
	int n=in(),m=in(),a,b,s[200000],t[200000],ns=0,nt=0,i,j;
	rep(i,m){
		a=in();
		b=in();
		if(a==1)s[ns++]=b;
		if(b==n)t[nt++]=a;
	}
	sort(t,nt);
	rep(i,ns){
		if(bsearch(&s[i],t,nt,sizeof(int),cmp)){
			puts("POSSIBLE");
			return 0;
		}
	}
	puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 1404
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

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

const int MOD = 1e9+7;
const int INF = 1e9;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    double N,M,d;
    cin>>N>>M>>d;

    double ans = (M-1)*2*(N-d)/(N*N);
    if(d == 0){
        ans = (M-1)/N;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
  val s = readString()
  println(buildString {
    for (i in s.indices) {
      if (i % 2 == 0) append(s[i])
    }
  })
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLong() = readString().toLong()
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 31768
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
    int N;
    cin >> N;
    pr(N*N*N);
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        // スペース区切りの整数の入力
        int a = sc.nextInt();
        int b = sc.nextInt();
        int menseki = a * b;
        int syu = 2 * (a + b);

        // 出力
        System.out.print(menseki + " ");
        System.out.println(syu);
    }
}


Measured memory_bytes: 25820
# クラスかるほう
# 　貪欲に辺ごとにソートをしてとけばいい
W, H = map(int, input().split())
d = []
for i in range(W):
    x = int(input())
    d.append((x, 0))

for j in range(H):
    y = int(input())
    d.append((y, 1))
d.sort()
X = H+1
Y = W+1

ans = 0

for que in d:
    weight, pos = que
    if pos <1:
        ans += X*weight
        Y -= 1
    else:
        ans += Y*weight
        X -= 1
print(ans)

Measured memory_bytes: 24540
#include <bits/stdc++.h>
#include <bitset>
#include <algorithm>
#define int long long
using namespace std;
#define mod 1000000007
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
bool vis[30000005], vis1[3000005];
vector<int> vec[3000005];
// v1, vec1[3000005];
//int child[2000005];
//int divi[2000005];

// int dis[100005] = {0};
// int h[100005];
// int p[100005];
// int dp[100005][100];
// bool f = 0;
// int bad[100005], good[100005];
// int p5[100005];
int final_sum[200005], max_sum[10005];
//int level[200005];
//int time1 = 0;
void dfs(int node)
{
    vis[node] = 1;
    //level[node] = time1;
    //time1++;
    for (int i = 0; i < vec[node].size(); i++)
    {
        if (!vis[vec[node][i]])
        {
            //  if (bit[vec[node][i]]            {

            dfs(vec[node][i]);
            final_sum[node] += final_sum[vec[node][i]];
        }
    } //  if ()
      //   if (b == 0)
      //  count1[b][node] += count1[b][vec[node][i]];
      //}
      // time1--;
}

int32_t main()
{
    int n, x, t;
    cin >> n >> x >> t;
    int p = (n / x) + bool(n % x);
    cout << p * t << "\n";
    return 0;
}

Measured memory_bytes: 73964
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();

        int[] x = new int[N];

        for(int i =0; N > i; i++){
            x[i] = sc.nextInt();     
        }
        int tmp = 0;
        int a =  0;

        for(int j = 0; N  > j; j++){  
            int b = Math.abs(X - x[j]);
            if(a == 0){
                a = b;
            }else{
                while ((tmp = b % a) != 0) {
                    b = a;
                    a = tmp;
                }
            }
        }
        System.out.println(a);
    }

}

Measured memory_bytes: 48088
package main

import (
	"fmt"
	"math"
	"strconv"
	"strings"
)

func main() {
	var a string
	fmt.Scan(&a)

	list := []int{}
	aa := strings.Split(a, "")
	for _, item := range aa {
		a, _ := strconv.Atoi(item)
		list = append(list, a)
	}

	pattern := math.Pow(2, 3)

	for i := 0; i < int(pattern); i++ {
		exp := make([]int, 3, 3)
		tmp := list[0]
		for j := 0; j < 3; j++ {
			v := (uint16(i) >> uint16(j)) & 1
			exp[j] = int(v)
			switch v {
			case 0x0:
				tmp += list[j+1]
			case 0x01:
				tmp -= list[j+1]
			}
		}
		if tmp == 7 {
			fmt.Printf("%#v", list[0])
			for j := 0; j < 3; j++ {
				fmt.Printf("%v%v", Expression(exp[j]), list[j+1])
			}
			fmt.Println("=7")
			return
		}
	}
}

func Expression(i int) string {
	if i == 0 {
		return "+"
	}
	return "-"
}


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

namespace ConsoleApplication6
{
    //ONLINE JUDGE (ITP1_6_C)

    class Program
    {

        static void Output(int[,] house)            //????£??????\????????°?????????
        {
            for (int i = 0; i < 3; ++i)
            {
                for (int j = 0; j < 10; ++j)
                {
                    if (house[i, j] != 0)
                    {
                        Console.Write(" {0}", house[i, j]);
                    }
                    else
                    {
                        Console.Write(" 0");
                    }
                }
                Console.WriteLine();
            }
        }

        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int n = int.Parse(str);

            int[,] a = new int[3,10];           //4?£??????????????????¨???
            int[,] b = new int[3,10];
            int[,] c = new int[3,10];
            int[,] d = new int[3,10];


            for (int i = 0; i < n; ++i)         //n???????????±?????????????????????
            {
                string[] strArray = Console.ReadLine().Split(' ');
                int build = int.Parse(strArray[0]);
                int floor = int.Parse(strArray[1]);
                int room = int.Parse(strArray[2]);
                int person = int.Parse(strArray[3]);

                switch(build)                   //?£???§???????????????
                {
                    case 1:
                        a[floor-1, room-1] += person;
                        break;
                    case 2:
                        b[floor-1, room-1] += (person);
                        break;
                    case 3:
                        c[floor-1, room-1] += (person);
                        break;
                    case 4:
                        d[floor-1, room-1] += (person);
                        break;
                }

            }
            Output(a);
            Console.WriteLine("####################");
            Output(b);
            Console.WriteLine("####################");
            Output(c);
            Console.WriteLine("####################");
            Output(d);
           
        }
    }
}

Measured memory_bytes: 5668
<?php
    fscanf(STDIN,"%d",$N);
    fscanf(STDIN,"%d",$K);
    $x_list = explode(" ",trim(fgets(STDIN)));

 	$sum = 0;

    foreach($x_list as $x){
        $sum_A = 2*$x;
        $sum_B = abs(2*($x-$K));
        $sum += min($sum_A,$sum_B);
    }
    
    echo $sum."\n";
    
    
?>
    

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  int n, m;
  cin >> n >> m;
  vii r(n, vi(0));
  rep(i,m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    r[a].push_back(b);
    r[b].push_back(a);
  }
  for(int x : r[0]){
    for(int y : r[x]){
      if(y == n-1){
        cout << "POSSIBLE" << endl;
        return 0;
      }
    }
  }
  cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 13168
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;

bool is_integer(double A){
    if(floor(A) == A){
        return true;
    }
    else{
        return false;
    }
}
//A19:55 - 
//B 
int main()
{
    int K;
    cin >> K;
    if(K%2 == 0){
        cout << (K / 2)*(K / 2) << endl;
    }
    else{
        int kari;
        kari = K / 2 + 1;
        cout << (kari)*(K / 2) << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T> void read(T &x){
	char c=getchar();x=0;int f=1;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}x*=f;
}
int n,r,b;
string s;
int main(){
	read(n);
	cin>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='R')r++;
		else b++;
	}
	if(r>b)cout<<"Yes\n";
	else cout<<"No\n";return 0;
}

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

int main()
{
    int n , t , m , p , x;
    string s;
    vector<long> v;
    long sum = 0;
    cin >> n ;
    for(int i = 0 ; i < n ; i++){
        cin >> t;
        v.push_back(t);
        sum += t;
    }
    cin >> m;
    for(int i = 0 ; i < m ; i++){
        cin >> p >> x;
        cout << (sum - v[p-1] + x ) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
char str[100001];
int main(void)
{
	int k,n,t,i;
	scanf("%s%d",str,&k);
	for(i=0;str[i]!='\0';i++){
		n=str[i]-'a';
		t=(26-n)%26;
		if(t<=k) str[i]='a',k-=t;
	}
	if(k) str[i-1]=str[i-1]+k%26;
	puts(str);
	return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;

namespace arc082_a
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = GetInt();
            var AL = GetIntList();
            var AD = new Dictionary<int, int>();
            foreach (var a in AL)
            {
                if (!AD.ContainsKey(a - 1)) AD.Add(a - 1, 0);
                if (!AD.ContainsKey(a)) AD.Add(a, 0);
                if (!AD.ContainsKey(a + 1)) AD.Add(a + 1, 0);
                AD[a - 1]++;
                AD[a]++;
                AD[a + 1]++;
            }
            Console.WriteLine(AD.Values.Max());
        }

        public static string GetStr() => Console.ReadLine();
        public static int GetInt() => int.Parse(Console.ReadLine());
        public static long GetLong() => long.Parse(Console.ReadLine());
        public static double GetDouble() => double.Parse(Console.ReadLine());
        public static decimal GetDecimal() => decimal.Parse(Console.ReadLine());

        public static List<string> GetStrList() => Console.ReadLine().Split(' ').ToList();
        public static List<int> GetIntList() => Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
        public static List<long> GetLongList() => Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
        public static List<double> GetDoubleList() => Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToList();
        public static List<decimal> GetDecimalList() => Console.ReadLine().Split(' ').Select(x => decimal.Parse(x)).ToList();

    }
}


Measured memory_bytes: 23776
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

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


ull E = 1000000007;
ull e = 10007;
const double pi = 3.14159265359;


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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int main() {
    int N;
    cin >> N;
    vector<int> A;
    for (int i = 0; i < N; ++i) {
        int tmp;
        cin >> tmp;
        A.push_back(tmp);
    }
    int ans = A[0];
    for (int i = 1; i < N; ++i) {
        ans = gcd(ans, A[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

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

template<typename T>
void chmax(T &a, T b) {
    a = max(a, b);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ar[3] = {0};
    REP(i, 0, n) {
        int a;
        cin >> a;
        a %= 3;
        ar[a]++;
    }
    if (ar[1] == 0 && ar[2] == 0) {
        cout << 1 << endl;
    } else {
        int ans = 0;
        REP(i, 1, 3) {
            if (ar[i] == 0) continue;
            int res = ar[0] + 1;
            int sum = i;
            int br[3] = {ar[0], ar[1], ar[2]};
            br[i]--;
            bool update = true;
            while (update) {
                update = false;
                REP(j, 1, 3) {
                    if (sum == j && br[j]) {
                        sum = (sum + j) % 3;
                        br[j]--;
                        res++;
                        update = true;
                    }
                }
            }
            if (br[1] || br[2]) {
                res++;
            }
            chmax(ans, res);
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3224
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void b_1_dimensional_world_tale(void) {
	int X, n, Y, m;
	int x[110];
	int y[110];

	string judge = "No War";

	cin >> n >> m >> X >> Y;
	for (int i = 0; i < n; i++) cin >> x[i];
	for (int i = 0; i < m; i++) cin >> y[i];

	x[n] = X;
	y[m] = Y;

	sort(x, x + n+1);
	sort(y, y + m+1);

	//if (X > Y) {
	//	judge = "War";
	//}

	if (y[0]-x[n]<1) {
		judge = "War";
	}
	

	cout << judge << endl;
}

int main()
{
	b_1_dimensional_world_tale();
    return 0;
}

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

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

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

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int N, K;
int a[1111];
vec<int> cand;

int func(int mask) {
   int cnt = 0;
   for (int i = 0; i < cand.size(); i++) {
      if ((cand[i] & mask) == mask) {
         cnt++;
      }
   }
   return cnt;
}

signed main() {
   cin >> N >> K;
   rep (i, N) {
      cin >> a[i];
   }

   for (int i = 0; i < N; i++) {
      int sum = 0;
      for (int j = i; j < N; j++) {
         sum += a[j];
         cand.push_back(sum);
      }
   }

   int mask = 0;
   for (int i = 40; i >= 0; i--) {
      if (func(mask | (1LL << i)) >= K) {
         mask |= (1LL << i);
      }
   }
   cout << mask << endl;

   return 0;
}

Measured memory_bytes: 6512
N, A, B = gets.split.map(&:to_i)
C = (A - B).to_f
H = N.times.map { gets.to_i }

def f(ac)
  remain_hp = H.map { |h| h - ac * B }

  remain_hp.each do |h|
    next if h <= 0

    c = (h / C).ceil
    ac -= c

    return false if ac < 0
  end

  true
end

ok = 10 ** 9
ng = 0

while (ok - ng).abs > 1
  mid = (ok + ng) / 2

  if f(mid)
    ok = mid
  else
    ng = mid
  end
end

puts ok


Measured memory_bytes: 26548
#include <iostream>
#include <string>
using namespace std;

int main()
{
	int s1, s2;
	while( cin >> s1 >> s2 && ( s1 || s2 ) ){
		int topSeller = 0;
		int topSales = ( s1 + s2 );
		for( int i = 1; i < 5; ++i ){
			cin >> s1 >> s2;
			if( topSales < s1 + s2 ){
				topSeller = i;
				topSales = s1 + s2;
			}
		}
		cout << (char)( topSeller + 'A' ) << " " << topSales << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

class UnionFind {
public:
    vl parent;  //親ノード
    vl Siz;  //集合の大きさ

    // コンストラクタ
    UnionFind(ll n): parent(n), Siz(n, 1LL) {
        rep(i, n) {
            parent[i] = i;
        }
    }

    // n要素で初期化
    void init(ll n) {
        parent.resize(n);
        Siz.assign(n, 1);
        rep(i, n) {
            parent[i] = i;
        }
    }

    // xの属する集合の根を求める
    ll root(ll x) {
        if(parent[x] == x) {
            return x;
        }
        else {
            return parent[x] = root(parent[x]);
        }
    }

    // xとyの属する集合を併合
    void unite(ll x, ll y) {

        x = root(x);
        y = root(y);

        if(x == y) {
            return;
        }

        if(Siz[x] < Siz[y]) {
            swap(x, y);
        }

        Siz[x] += Siz[y];
        parent[y] = x;
    }
    
    // xとyが同じ集合に属するかどうか
    bool same(ll x, ll y) {
        return root(x) == root(y);
    }

    // xの属する集合の要素数を求める
    ll size(ll x) {
        return Siz[root(x)];
    }
};

int main() {
    ll n, m;
    cin >> n >> m;

    UnionFind Uni(n);
    Uni.init(n);

    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        Uni.unite(a, b);
    }

    set<ll> st;
    rep(v, n) {
        st.insert(Uni.root(v));
    }

    ll renketuseibun = st.size();  // 連結成分の個数
    
    out(renketuseibun - 1);
    re0;
}

Measured memory_bytes: 8400
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main()
{
    ll H, cnt = 0;
    cin >> H;
    while (H > 1)
    {
        H /= 2;
        cnt++;
    }
    ll ans = 1;
    rep(i, cnt + 1)
    {
        ans *= 2;
    }
    cout << ans - 1;
    return 0;
}

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

int main()
{
	int a, b, c;
	std::cin >> a >> b >> c;
	if ( ((a==b) && (b==c) && (c==a)) ||
		 ((a!=b) && (b!=c) && (c!=a)) )
	{
		std::cout << "No" << std::endl;
	}
	else
	{
		std::cout << "Yes" << std::endl;
	}
	return 0;
}


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

using namespace std;


#define PI 3.14159265
#define int long long



main(){

	string s, t, u;

	cin >> s >> t;

	int a, b; cin >> a >> b;

	cin >> u;

	if(s == u) a--;
	if(t == u) b--;


	cout << a << " " << b << endl;
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
N, C, K = map(int,input().split())
T = sorted([int(input()) for _ in range(N)])
ans, cnt = 0, 0
st = T[0]
for i in range(N):
  if T[i] > st + K or cnt == C:
    ans += 1
    cnt = 1
    st = T[i]
  else:
    cnt += 1
print(ans+1)

Measured memory_bytes: 8280
#include <stdio.h>
int prime(void);
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INFTY 100000000
#define MAX 100

int n,M[MAX][MAX];

int main(){
  int i,j,edge,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&edge);
      if(edge==-1)M[i][j]=INFTY;
      else M[i][j]=edge;
    }
  }
  sum=prim();
  printf("%d\n",sum);
  return 0;
}


int prim(){
  int u,v,minv,i,sum=0;
  int d[MAX],p[MAX],color[MAX];

  for(i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=WHITE;
  }

  d[0]=0;

  for(;;){
    minv=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i]&&color[i]!=BLACK){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK&&M[u][v]!=INFTY){
	if(d[v]>M[u][v]){
	  d[v]=M[u][v];
	  p[v]=u;
	  color[v]=GRAY;
	    }
      }
    }
  }
  for(i=0;i<n;i++){
    if(p[i]!=-1)sum+=M[i][p[i]];
  }
  return sum;
}
  

Measured memory_bytes: 636
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

bool inter(int x1, int y1, int r1, int x2, int y2, int r2){
  int dx = x1-x2, dy = y1-y2;
  return dx*dx+dy*dy < (r1+r2)*(r1+r2);
}

int N;
char dp[1<<24];

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

  while(cin>>N, N){
	VI xs(N), ys(N), rs(N), cols(N);
	REP(i,N) cin >> xs[i] >> ys[i] >> rs[i] >> cols[i];

	VVI prev(N);
	REP(i,N) FOR(j,i+1,N){
	  if(inter(xs[i], ys[i], rs[i], xs[j], ys[j], rs[j]))
		prev[j].PB(i);
	}

	fill(dp, dp+(1<<24), -1);
	char ans = 0;
	dp[0] = 0;
	for(int b=0;b<1<<N;++b){
	  if(dp[b] < 0) continue;
	  for(int j=0;j<N;++j){
		if(b>>j&1) continue;
		for(int k=j+1;k<N;++k){
		  if(b>>k&1 || cols[j] != cols[k]) continue;
		  bool ok = true;
		  for(int x: prev[j])
			if((b>>x&1) == 0) ok = false;
		  for(int x: prev[k])
			if((b>>x&1) == 0) ok = false;
		  if(ok){
			int b_ = b|(1<<j)|(1<<k);
			dp[b_] = max(dp[b_], (char)(dp[b]+2));
			ans = max(ans, dp[b_]);
		  }
		}
	  }
	}
	
	cout << (int)ans << endl;
  }

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const long long INF=INT_MAX/4;
const long long MOD=1'000'000'007;
const double EPS=1e-14;
const bool DEBUG=true;

const string YES = "YES";
const string NO = "NO";
const string Yes = "Yes";
const string No = "No";

template<class T>
void debug(T head){
    if(DEBUG){
        cout<<head<<endl;
    }
}

template <class Head, class... Body>
void debug(Head head, Body... body){
    if(DEBUG){
        cout<<head<<" ";
        debug(body...);
    }
}

/////


void answer(){
    long a, b, c, d;
    cin>>a>>b>>c>>d;
    long answer1 = a*c;
    long answer2 = a*d;
    long answer3 = b*c;
    long answer4 = b*d;
    cout<<max(max(answer1, answer2), max(answer3, answer4))<<endl;

    return;
}

/////

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.precision(16);

    answer();

    return 0;
}


Measured memory_bytes: 3652
cards = []

cards.append(list(map(int, input().split())))
cards.append(list(map(int, input().split())))
cards.append(list(map(int, input().split())))

N = int(input())
for _ in range(N):
    a = int(input())
    for row in cards:
        if a in row:
            row[row.index(a)] = 0

for row in cards:
    if sum(row) == 0:
        print('Yes')
        break
else:
    for row in zip(*cards):
        if sum(row) == 0:
            print('Yes')
            break
    else:
        if sum([cards[0][0], cards[1][1], cards[2][2]]) == 0:
            print('Yes')
        elif sum([cards[0][2], cards[1][1], cards[2][0]]) == 0:
            print('Yes')
        else:
            print('No')

Measured memory_bytes: 3064
#define ll long long
#define pi acos(-1.0)
#define Go "\n"
#define bye return 0
#define Afor(i,b) for(int i=0;i<b;i++)
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N,i,s=0;
    cin>>N;
    for(i=1;i<=N;i++)
    {
        if(i%3!=0&&i%5!=0)
        {
            s=s+i;
        }
    }
    cout<<s<<Go;
    bye;

}


Measured memory_bytes: 3612
m, d = map(int, input().split())

result = 0
if d < 12:
    print(0)
    exit()
for i in range(1, m+1):
    for j in range(12, d+1):
        a1 = j % 10
        ba10 = j // 10
        if a1 >= 2 and ba10 >= 2:
            if i == a1 * ba10:
                result+=1

print(result)

Measured memory_bytes: 39536
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        k: usize, n: usize,
        arr: [usize; n],
    }

    let mut a = arr.clone();
    a.push(a[0]+k);
    let mut max_sep = 0;
    for i in 0..n {
        let d = a[i+1] - a[i];
        if max_sep < d { max_sep = d }
    }
    println!("{}", k-max_sep)
}


Measured memory_bytes: 6680
#include <iostream>

int main() {
    int m, f, r;

    while (std::cin >> m >> f >> r) {
        if (m == -1 && f == -1 && r == -1) {
            break;
        }

        int sum = m + f;
        if (m == -1 || f == -1 || sum < 30) {
            std::cout << 'F' << std::endl;
            continue;
        }

        if (sum >= 80) {
            std::cout << 'A' << std::endl;
            continue;
        }

        if (sum >= 65) {
            std::cout << 'B' << std::endl;
            continue;
        }

        if (sum >= 50 || r >= 50) {
            std::cout << 'C' << std::endl;
            continue;
        }

        std::cout << 'D' << std::endl;
    }
}


Measured memory_bytes: 3116