akhauriyash/Code-Regression huggingface dataset:
numeros = input()
numeros = numeros.split()
resultado = [0,0,0]
resultado[0] = int(numeros[0]) + int(numeros[1])
resultado[1] = int(numeros[0]) - int(numeros[1])
resultado[2] = int(numeros[0]) * int(numeros[1])
print(max(resultado))

Measured memory_bytes: 3064
import numpy as np
n_m = [int(i) for i in input().split()]
ai = np.array([int(i) for i in input().split()])
n = n_m[0]
m = n_m[1]
asum = ai.sum()
thread = asum / (4 * m)
real_m = 0
for a in ai:
  if a < thread:
    continue
  else:
    real_m += 1
print("No") if real_m < m else print("Yes")


Measured memory_bytes: 12436
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_4_A
TLE
"""
import sys
from sys import stdin
from bisect import bisect_right, bisect_left
input = stdin.readline


def main(args):
    N, V = map(int, input().split())
    A = [int(x) for x in input().split()]
    B = [int(x) for x in input().split()]
    C = [int(x) for x in input().split()]
    D = [int(x) for x in input().split()]

    AB = []
    for i in A:
        for j in B:
           AB.append(i+j)
    AB.sort()

    CD = [float('-inf'), float('inf')]
    for i in C:
        for j in D:
           CD.append(i+j)
    CD.sort()

    count = 0
    for ab in AB:
        i = bisect_left(CD, V - ab)
        j = bisect_right(CD, V - ab)
        count += max((j-i), 0)

    print(count)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 102980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int a,b,sum=0;
	vector<pair<int,int>>v;
	for(int i=0;i<5;i++)
	{	
		cin>>a;
		if(a%10)v.push_back(make_pair(10-(a%10),a));
		else v.push_back(make_pair(0,a));
	}
	sort(v.begin(),v.end());
	for(int i=0;i<5;i++)
	{
		if(i<4)sum+=v[i].first+v[i].second;
		else sum+=v[i].second;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    now=1
    flg = 0
    path = [1]
    pathcheck ={1}
    for i in range(min(k,n)):
        now = a[now-1]
        if now in pathcheck:
            flg = -1
            path.append(now)
            break
        path.append(now)
        pathcheck.add(now)


    if flg == 0:
        print(now)
        exit()

    x1 = path.index(now)
    x2 = len(path)-1
    x3 = (k-x1)%(x2-x1)
    print(path[x1+x3])

if __name__ == '__main__':
    main()

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

int main() {
long long n,m;
cin>>n>>m;
if (n == 1 && m == 1) cout<<"1";
else if (n == 1) cout<<(m-2);
else if (m == 1) cout<<(n-2);
else cout<<((n-2)*(m-2));
return 0;
}

Measured memory_bytes: 256
h,w,k=map(int,input().split())

mo=10**9 +7
p=[-1]*(w+1)
p[0]=1
p[1]=2
def pat(x):
    if x<0 or x>=w:
        return 1
    else:
        if p[x]!=-1:
            return p[x]
        else:
            return pat(x-2)+pat(x-1)

a=[[0 for i in range(w)] for i in range(h+1)]
a[0]=[1]+[0]*(w-1)
for i in range(1,h+1):
    for j in range(0,w):
        if j>0: a[i][j]+=a[i-1][j-1]*pat(j-2)*pat(w-j-2)
        a[i][j]+=a[i-1][j]*pat(j-1)*pat(w-1-j-1)
        if j<w-1: a[i][j]+=a[i-1][j+1]*pat(j-1)*pat(w-j-3)
print(a[h][k-1] % mo)

Measured memory_bytes: 3064
main = do
  [sx,sy,tx,ty] <- map read . words <$> getLine :: IO [Int]
  let hori = tx-sx
  let vert = ty-sy
  let there1 = replicate vert 'U' ++ replicate hori 'R'
  let back1 = replicate vert 'D' ++ replicate hori 'L'
  let there2 = "L" ++ replicate vert 'U' ++ "UR" ++ replicate hori 'R' ++ "D"
  let back2 = "R" ++ replicate vert 'D' ++ "DL" ++ replicate hori 'L' ++ "U"
  putStrLn $ there1 ++ back1 ++ there2 ++ back2

Measured memory_bytes: 1020
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>

#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/range/numeric.hpp>

#ifdef _MSC_FULL_VER
#include"randomizer.hpp"
#include"debug_print.hpp"
#endif

#include<cstdlib>
#include<ctime>

namespace lib
{
	template<class T>using pair = std::pair<T, T>;
	template<class T>constexpr T pow(T base, std::uint64_t p)
	{
		T ret = T(1);
		for (std::uint64_t i = 0; i <= 63; ++i)
		{
			if (((1ull << i) & p) != 0)
			{
				ret *= base;
			}
			base *= base;
		}
		return ret;
	}
	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;

	struct union_find
	{
		std::vector<int> upper;
		union_find(std::size_t size):upper(size, -1) {}

		int group(int index)
		{
			if (upper[index] == -1)
			{
				return index;
			}
			else
			{
				return upper[index] = group(upper[index]);
			}
		}

		bool merge(int x, int y)
		{
			auto gx = group(x);
			auto gy = group(y);
			if (gx != gy)
			{
				upper[gx] = gy;
				return true;
			}
			return false;
		}

		auto get()
		{
			std::map<int, std::set<int>> ret;
			for (int i = 0; i < upper.size(); ++i)
			{
				ret[group(i)].emplace(i);
			}
			return ret;
		}

		auto tops()
		{
			std::set<int> ret;
			for (int i = 0; i < upper.size(); ++i)
			{
				ret.emplace(group(i));
			}
			return ret;
		}

		bool is_same_group(int x, int y)
		{
			return group(x) == group(y);
		}
	};
}

namespace out
{
	namespace detail
	{
		template<class>struct void_out
		{
			typedef void type;
		};
		template<class T>auto write(std::ostream& ost, T const& val)
			->typename void_out<decltype(ost << val)>::type
		{
			ost << val;
		}
		template<class T, class... Ts>void write(std::ostream& ost, T const& val, Ts const&... nexts)
		{
			write(ost, val);
			ost << " ";
			write(ost, nexts...);
		}
	}
	void write_line()
	{
		std::cout << std::endl;
	}
	template<class...Ts>void write_line(Ts const&... args)
	{
		detail::write(std::cout, args...);
		write_line();
	}
	template<class Range>void write_range(Range const& rng)
	{
		for (auto const& v : rng)
		{
			write_line(v);
		}
	}
}
namespace adaptor = boost::adaptors;

void Main()
{
	int N;
	std::string str;
	std::cin >> N;
	std::cin >> str;
	int R = 0, B = 0;
	for (auto c : str)
	{
		if (c == 'R')
		{
			++R;
		}
		else
		{
			++B;
		}
	}
	if (B < R)
	{
		out::write_line("Yes");
	}
	else
	{
		out::write_line("No");
	}
}

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


Measured memory_bytes: 256
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define fi(a, b, c, d) for(int a = b; i < c; i += d)
#define fl(a, b, c, d) for(ll a = b; i < c; i += d)
#define quit exit(0)

ll N, K, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;


int main() {
	ll ans = 0;
	scanf("%lld %lld", &N, &M);
	ans += N * (N - 1) / 2;
	ans += M * (M - 1) / 2;
	printf("%lld\n", ans);
	return 0;
}
/*
	Powered by Buggy Plugin
*/




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

#define ONLINE_JUDGE
#define ll long long
#define PI 3.14159265359
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define pb(a) push_back(a)

//////////// Solution /////////////////////////////////

const int MAXN = 1e5+1;

void solve() {
	int h[MAXN];
    ll dp[MAXN];
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> h[i];
    }
    dp[0] = 0;
    dp[1] = 0;
    for (int i = 2; i <= n; ++i) {
        dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
        if (i > 2) {
            dp[i] = min(dp[i], dp[i-2]+abs(h[i]-h[i-2]));
        }
    }

    cout << dp[n] << '\n';
}

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
		FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
		clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
		fclose(FIN);
		cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 1408
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
long long N, k, arr[200005], res;
int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> N;
	for (int i = 0; i < N; i++) cin >> arr[i];
	for (int i = 1; i < N; i++) {
		if (arr[i] < arr[i - 1]) {
			res += arr[i - 1] - arr[i];
			arr[i] = arr[i - 1];
		}
	}
	cout << res;
}

Measured memory_bytes: 5216
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

int n, a[100010], b[100010];
int ta[100010], tb[100010];
int p[100010], z[1000010];
int Find(int x){return p[x] == x ? x : p[x] = Find(p[x]);}

void solve() {
	scanf("%d", &n);
	rep(i, n) scanf("%d", a+i);
	rep(i, n) scanf("%d", b+i);
	rep(i, n) ta[i] = a[i], tb[i] = b[i];
	rep(i, n) ta[n] ^= ta[i], tb[n] ^= tb[i];
	a[n] = ta[n], b[n] = tb[n];
	sort(ta, ta+1+n);
	sort(tb, tb+1+n);
	rep(i, n+1) if(ta[i] != tb[i]) {
		puts("-1");
		return;
	}
	vector <int> xs;
	rep(i, n+1) xs.pb(ta[i]);
	sort(all(xs));
	xs.resize(unique(all(xs)) - xs.begin());
	rep(i, n+1) a[i] = (int)(lower_bound(all(xs), a[i]) - xs.begin() + 1);
	rep(i, n+1) b[i] = (int)(lower_bound(all(xs), b[i]) - xs.begin() + 1);
	int ans = 0;
	rep(i, n+5) p[i] = i, z[i] = 1;
	rep(i, n+1) if(a[i] != b[i]) {
		int x = Find(a[i]), y = Find(b[i]);
		if(x != y) {
			p[x] = y;
			z[y] += z[x];
		}
		++ans;
	}
	for(int i=1;i<=sz(xs);i++) {
		if(z[i] > 1 && p[i] == i) {
			if(Find(a[n]) == i) {
				if(a[n] != b[n]) ans--;
			}
			else ++ans;
		}
	}
	printf("%d\n", ans);
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
};

Measured memory_bytes: 6520
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  int sum = 0;
  rep(i, M) {
    cin >> A[i];
    sum += A[i];
  }

  int ans = N - sum;
  if (ans < 0)
    ans = -1;
  cout << ans << endl;
}

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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0) 

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }
    
    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
	string p = "keyence";
	string s; cin >> s;
	int n = s.size();
	int r0 = 7;
	FOR(i,7) {
		if (s[i] != p[i]) {
			r0 = i;
			break;
		}
	}
	int r1 = 7;
	FOR(i,7) {
		if (s[n-i-1] != p[6-i]) {
			r1 = i;
			break;
		}
	}
	cout << ((r0+r1 >= 7) ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int f[12000];
int i,j,n,t;

int main()
{
	scanf("%d",&n);
	f[0]=1;
	for (i=1;i<=n;i++)
	{
		scanf("%d",&t);
		for (j=10000;j>=t;j--)
			if (f[j-t])
				f[j]=1;
	}
	for (i=10000;i>0;i--)
		if ((i%10) && (f[i]))
		{
			printf("%d\n",i);
			return 0;
		}
	printf("0\n");
	return 0;
}

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

int main() {
  int N,M,X,Y;
  cin>>N>>M>>X>>Y;
  
  int x[110];
  int y[110];
  
  for(int i=0;i<N;++i){
    cin>>x[i];
  }
  
  for(int i=0;i<M;++i){
    cin>>y[i];
  }
  
  int x_max=X;
  int y_min=Y;
  
  for(int i=0;i<N;++i){
    if(x_max<x[i])
      x_max=x[i];
  }
  
  for(int i=0;i<M;++i){
    if(y[i]<y_min)
      y_min=y[i];
  }
  
  if(y_min>x_max)
    cout<<"No War"<<endl;
  else
    cout<<"War"<<endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,z,w=map(int,input().split())
    A=list(map(int,input().split()))
    dp=[[None]*2 for _ in range(n+1)] # dp[i][turn] 消費枚数i,turnの手から始まるときの最適解

    def dfs(i,turn):
        if(dp[i][turn] is not None): return

        # i+1からn-1のdp[1-turn]を埋めておく(i=n-1のときterminate)
        for j in range(i+1,n):
            dfs(j,1-turn)

        res=-INF if(turn==0) else INF
        if(turn==0):
            for j in range(i+1,n):
                res=max(res,dp[j][1])
            y=A[i-1] if(i!=0) else w
            res=max(res,abs(A[-1]-y))
        else:
            for j in range(i+1,n):
                res=min(res,dp[j][0])
            x=A[i-1] if(i!=0) else z # x=zとなることは無い
            res=min(res,abs(A[-1]-x))
        dp[i][turn]=res

    dfs(0,0)
    print(dp[0][0])
resolve()

Measured memory_bytes: 5620
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
index = 0
Min = 1000
for i in range(n):
    A = t-h[i]*0.006
    if abs(a-A) < Min:
        Min = abs(a-A)
        index = i
print(index+1)

Measured memory_bytes: 38256
N,M = map(int, input().split())
PY = [list(map(int, input().split())) for _ in range(M)]

for i in range(M):
    PY[i].append(i)

PY.sort(key = lambda x:(x[0], x[1]))

prefecture = 0
cnt = 1
for i in range(M):
    if prefecture != PY[i][0]:
        prefecture = PY[i][0]
        cnt = 1
    else:
        cnt += 1
    PY[i].append(cnt)

PY.sort(key = lambda x:x[2])

for i in range(M):
    print('{:06}{:06}'.format(PY[i][0], PY[i][3]))








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

int main() {
  int n,m;
  string word;
  cin >> n;
  map<string, int> counter;
  for(int i=0; i<n; i++){
    cin >> word;
    if(counter.find(word) != counter.end()){
      counter[word]++;
    } else {
      counter[word]=1;
    }
  }
  
  cin >> m;
  for(int i=0; i<m; i++){
    cin >> word;
    if(counter.find(word) != counter.end()){
      counter[word]--;
    } else {
      counter[word]=-1;
    }
  }
  
  int max = 0;
  map<string, int>::iterator it;
  for(it = counter.begin(); it != counter.end(); it++){
    if(it->second > max){
      max = it->second;
    }
  }
  
  cout << max << endl;
  
}


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

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

int main() {
    int n, k;
    int res=0;
    cin >> n >> k;
    vector<int> p(n);
    rep(i,n){
        cin >> p[i];
    }
    sort(p.begin(),p.end());

    rep(i,k){
        res+=p[i];
    }

    cout << res << "\n";
}

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

int n;
int x[25],y[25],r[25],c[25];
int cover[25];
bool check[1<<25];
int cnt,comb,a,b;
int m,ans;
int u;

double dis(int i,int j){
  return sqrt( (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j]) * (y[i]-y[j]) );
}

void cov(int a){
  cover[a] = -1;
  for(int j=a-1;j>=0;j--){
    if(dis(a,j)<r[a]+r[j] && u>>j & 1){
      cover[a] = j;
      break;
    }
  }
} 

  
void rec(void){
  int cnt;
  for(int i=1;i<=4;i++){
    cnt = 0;
    for(int j=0;j<n;j++){
      if( (u>>j & 1) && cover[j]<0 && c[j] == i)cnt++;
    }
    if(cnt==6){
      for(int j=0;j<n;j++){
	if(c[j] == i)u -= 1<<j;
      }
      for(int j=0;j<n;j++)cov(j);

      ans += 6;
      m = max(m,ans);
      if(!check[u]){
	rec();
	check[u] = true;
      }
      ans -= 6;

      for(int j=0;j<n;j++){
	if(c[j] == i)u += 1<<j;
      }
      for(int j=0;j<n;j++)cov(j);
    }else{
      for(int j=0;j<n;j++){
	if( (u>>j & 1) && cover[j]<0 && c[j] == i){
	  for(int k=j+1;k<n;k++){
	    if( (u>>k & 1) && cover[k]<0 && c[k] == i){
	      u -= 1<<j;
	      u -= 1<<k;
	      for(int l=0;l<n;l++)cov(l);

	      ans += 2;
	      m = max(m,ans);
	      if(!check[u]){
		rec();
		check[u] = true;
	      }
	      ans -= 2;

	      u += 1<<j;
	      u += 1<<k;
	      for(int l=0;l<n;l++)cov(l);
	    }
	  }
	}
      }
    }
  }
}



int main(){
  while(1){
    cin >> n;
    if(!n)break;

    for(int i=0;i<n;i++)cin >> x[i] >> y[i] >> r[i] >> c[i];

    u = (1<<n) - 1;
    for(int i=0;i<(1<<n);i++)check[i] = false;
    for(int i=0;i<n;i++)cov(i);

    
    m = 0;
    ans = 0;
    rec();

    cout << m << endl;
  }
}

Measured memory_bytes: 16000
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
typedef  pair<int,int> P;

//union findで実装してあげて、最大個数所属している山を探す
struct UnionFind
{
vector<int>d;
UnionFind(int n):d(n,-1){}

int find(int x)
{
if(d[x]<0)return x;
return d[x]=find(d[x]);
}

int unite(int x,int y)
{
x=find(x);y=find(y);
if(x==y)return false;
if(d[x]>d[y])swap(x,y);
d[x]+=d[y];
d[y]=x;
return true;
}

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

}

int size(int x)
{
return -d[find(x)];
}

};



int main()
{
int n, m;
cin>>n>>m;
UnionFind uf(n);
rep(i,m)
{
int a,b;
cin>>a>>b;a--;b--;
uf.unite(a,b);

}

int ans=0;
rep(i,n)
{
ans=max(ans,uf.size(i));

}
cout <<ans;
}

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

int main() {
    long long X;
    cin >> X;
    long long num = X / 100;
    long long remain = X % 100;
    int needNum = 0;
    for (int j = 5; j > 0; j--) {
        if (remain / j > 0) {
            needNum += remain / j;
            remain = remain % j;
        }
    }
    if (needNum > num) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
/* #defineと書くとマクロが定義できる
   rep(i,n) { //処理 }　と書くとn回ループが回せるようにしている*/
#define rep(i,n) for (int i=0; i<n; i++)
using namespace std;
using ll = long long;

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

  int hapi = 0;
  hapi += n / 500 * 1000;

  n = n % 500;

  hapi += n /5 * 5;

  cout << hapi << endl;

  



  
  
}


Measured memory_bytes: 256
N = input()
H = [int(x) for x in input().split()]
ans = 0
cur = 0
h_ = 0
for h in H:
  if h_ >= h:
    cur += 1
  else:
    ans = max(ans, cur)
    cur = 0
  h_ = h
ans = max(ans, cur)
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll N, D, ans = 0;
  cin >> N >> D;
  D *= D;
  rep(i, N){
    ll x, y;
    cin >> x >> y;
    ll tmp = x*x + y*y;
    if (tmp <= D)
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6+10 , OO = 0x3f3f3f3f ;
const int mod = 1e9 + 7;
 
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define xloop(i,a,b) for(int i = int(a);i <= int(b);i++)
#define range(vec) for(auto &x : vec) cin >> x;
#define ALL(v) ((v).begin()) , ((v).end())
#define SZ(v)  ((int)((v).size()))
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction

int n;

int main()
{
   // startTime = (double)clock();
    #ifndef ONLINE_JUDGE
        //freopen("in.in", "r", stdin);
        //freopen("out.in", "w", stdout);
    #endif
	//ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    string s , t;
    int cnt = 0;
    cin >> s >> t;
    int len = s.size();
    for(int i = 0 ; i < len ; ++i){
        if(s[i] == t[i])
            continue;
        else 
            cnt++;
    }
    cout << cnt << "\n";


    return 0;
}

Measured memory_bytes: 3876
#!/usr/bin/env python
from collections import defaultdict, deque
import math
from math import factorial
import fractions
import re
import bisect

BIGNUM = 10 ** 9 + 7

def main():
    #K, X = map(int, input().split())
    N = int(input())
    #Hs = list(map(int, input().split()))

    Ss = []
    for i in range(N):
        Ss.append(input().strip())

    counter = defaultdict(int)
    for s in Ss:
        key = "".join(sorted(s))
        counter[key] += 1

    count = 0
    for key in counter:
        num = counter[key]
        if num > 1:
            count += int(num * (num - 1) / 2)

    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 26988
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int [] List = new int [N];
        for(int i=0;i<N;i++) List[i] = sc.nextInt();
        boolean flag = true;
        int num = 0, opt = 0;
        while(flag){
            flag = false;
            for(int i=N-1;i>num;i--){
                if(List[i]<List[i-1]){
                    int now = List[i];
                    List[i] = List[i-1];
                    List[i-1] = now;
                    flag = true;
                    opt++;
                }
            }
            num++;
        }
        for(int i=0;i<N;i++){
            if(i<N-1) System.out.print(List[i]+" ");
            else System.out.println(List[i]);
        }
        System.out.println(opt);
    }
}


Measured memory_bytes: 26388
#include <iostream>
#include <cmath>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i_, __start, __end) for(ll i_=(ll)__start; i_<(ll)__end; i_++)
#define print(_a) cout << _a << endl;
#define printarray(a, len) rep(ii,0,len) cout << a[ii] << " ";
#define printarray2(aa, len) rep(ij,0,len) printarray(aa[ij], aa[ij].size()); print("");

int p = 1000000007;
ll fact[1000005];
 
ll inverse(ll base){
    int e = p-2;
    ll res = 1;
    while (e > 0){
        if (e & 1) res = (res*base)%p;
        base = (base*base) % p;
        e /= 2;
    }
    return res;
}
 
ll comb(int n, int r){
    // returns nCr mod p
    fact[0] = 1;
    for (int i=1; i<=n; i++) fact[i] = (i*fact[i-1])%p;
    return fact[n] * inverse(fact[r]) % p * inverse(fact[n-r]) % p;
}

int main(){
    ll x, y, k, n, m, ans=0;
    cin >> x >> y;
    if((x+y) % 3 != 0){
      print(0);
      exit(0);
    }
    k = (x+y) / 3;
    n = (2*y - x) / 3;
    m = k - n;
    if(n < 0 || m < 0){
      print(0);
      exit(0);
    }

    print(comb(k, n));
  
  return 0;
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
  ll k; cin >> k;
    ll x = 7%k;
    for(int i=1; i<=k; ++i)
    {
        if(!x)
        {
            cout << i << endl;
            return 0;
        }
        x = (x*10+7)%k;
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3640
// Example program
#include <iostream>
#include <string>
#include <bits/stdc++.h>

using namespace std;

int main()
{
  string S;
  int A,B;
  
  cin >> A >> B;
  cin >> S;
  
  if(S.length()!=A+B+1)
  {
      cout << "No" <<  "\n";
  }
  else
  {
      int Aok = 1;
      int Hok = 1;
      int Bok = 1;
  for (int i=0;i<A;i++)
  {
      if (S[i]!='0' && S[i]!='1' && S[i]!='2' && S[i]!='3' && S[i]!= '4' && S[i]!= '5' && S[i]!= '6' && S[i]!= '7' && S[i]!= '8' && S[i]!= '9')
      {
          Aok = 0;
      }
  }
  if (S[A]!='-')
  {
      Hok = 0;
  }
  for (int i=A+1;i<A+B+1;i++)
  {
      if (S[i]!='0' && S[i]!='1' && S[i]!='2' && S[i]!='3' && S[i]!= '4' && S[i]!= '5' && S[i]!= '6' && S[i]!= '7' && S[i]!= '8' && S[i]!= '9')
      {
          Bok = 0;
      }
  }
  
  if (Aok==1 && Bok==1 && Hok==1)
  {
      cout << "Yes" << "\n";
  }
  else 
  cout << "No" << "\n";
  }
  
  return 0;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(0,A+1):
    for j in range(0,B+1):
        for k in range(0,C+1):
            if 500*i+100*j+50*k==X:
                count = count+1
print("{}".format(count))


Measured memory_bytes: 3060
/*
      HET PAGHADAR
      DA-IICT
      @HET262
*/
 
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<ll> vec; 
#define inf LLONG_MAX
#define bp __builtin_popcountll
#define pb push_back
#define ff first
#define ss second
#define P pair<ll,ll>
#define N 1000005
#define mod 1000000007
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int32_t main()
{
      
      FAST;
      
      ll n,m;
      cin>>n>>m;
      
      
      if(n<m)
      {
            for(int i=0;i<m;i++)    cout<<n;
      }
      else
      {
            for(int i=0;i<n;i++)    cout<<m;
            
      }
      
      
}


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

int main(){
  int N,sz,BC=0,AC=0,BA=0,AB=0;
  cin>>N;
  string S;
  for(int i=0;i<N;i++){
    cin>>S;
    sz=S.size();
    if(S[0]=='B'){
      BC++;
    }
    if(S[sz-1]=='A'){
      AC++;
    }
    if(S[0]=='B'&&S[sz-1]=='A'){
      BA++;
    }
    for(int j=1;j<sz;j++){
      if(S[j-1]=='A'&&S[j]=='B')
        AB++;
    }
  }
  if(min(BC,AC)==0){
    cout<<AB<<endl;
  }else if(BC==BA&&AC==BA&&BA){
    cout<<BC-1+AB<<endl;
  }else{
    cout<<min(BC,AC)+AB<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int kai (string S){
  string Sa;
  Sa=S;
  rep(i,S.length()){
    if(S[i] != Sa[S.length()-1-i]) return 0;
  }
  return 1;
}
int main() {
  string S,aki="",aku="";
  int as;
  cin>>S;
  as=S.length();
  rep(i,as/2){
    aki+=S[i];
  }
  rep(i,as/2){
    aku+=S[(as+1)/2+i];
  }

 if(kai(S)){
    if(kai(aki)){
      if(kai(aku)){
        cout<<"Yes";
        return 0;
      }
    }
  }
  cout<<"No"; 
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <numeric>
#include <set>

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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()
#define ll long long
#define MOD 1000000007


int main() {
	float a, b;
	cin >> a >> b;
	cout << a / b << endl;
}


Measured memory_bytes: 256
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#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 rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr ll inf = INT32_MAX / 2;
constexpr ll INF = LLONG_MAX / 2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int A, B;
    cin >> A >> B;
    cout << 6 - A - B << endl;
}

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

using namespace std;

vector<long long> d;
vector<long long> p;

void init_v(int digit) {
        for(int i = 0;i < digit; i++) {
                long long num = (1LL << i);
                if(i % 2 == 1) num *= -1;
                p.push_back(num);
                if(i >= 2) num += d[i - 2];
                d.push_back(num);
        }

}

int get_digit(long long num) {
        for(int i = 0 ;i < d.size(); i++) {
                if(num > 0 && d[i] >= num) return i;
                if(num < 0 && d[i] <= num) return i;
        }
        return -1;
}
int main() {
        long long num;
        cin >> num;
        string s;
        if(num == 0) s = "0";
        while(num != 0) {
                int r = num % (-2);
                if( r < 0) r += 2;
                s = to_string(r) + s;
                num = (num - r) / -2;
        }
        cout << s << endl;
}

Measured memory_bytes: 256
import java.util.*;

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

        int ans = x - t;

        if(ans < 0){
            System.out.println(0);
        } else {
            System.out.println(ans);
        }
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }
}


Measured memory_bytes: 21712
#include<bits/stdc++.h>
using namespace std;
int main(){
string a,b;
cin>>a>>b;
	if(a>b&&a.length()>b.length())
	cout<<"GREATER";
	else if(a>b&&a.length()==b.length())
	cout<<"GREATER";
	else if(a==b&&a.length()>b.length())
	cout<<"GREATER";
	else if(a>b&&a.length()<b.length())
	cout<<"LESS";
	else if(a<b&&a.length()<b.length())
	cout<<"LESS";
	else if(a<b&&a.length()==b.length())
	cout<<"LESS";
	else if(a==b&&a.length()<b.length())
	cout<<"LESS";
	else
	cout<<"EQUAL";


}

Measured memory_bytes: 256
#n=int(input())
a,b,c=map(int,input().split())
#t=int(input())
#al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

mx=max(a,b,c)
dif=3*mx-(a+b+c)
if dif%2==0:
    ans=dif//2
else:
    ans=dif//2+2
print(ans)


Measured memory_bytes: 9032
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<double> t(n);
    for (int i = 0; i < n; i++) cin >> t[i];
    vector<double> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];

    vector<double> vv(n + 1);
    for (int i = 1; i < n; i++) {
        vv[i] = std::min(v[i - 1], v[i]);
    }

    for (int i = 1; i <= n - 1; i++) {
        vv[i] = std::min(vv[i], vv[i - 1] + t[i - 1]);
    }
    for (int i = n - 1; i >= 1; i--) {
        vv[i] = std::min(vv[i], vv[i + 1] + t[i]);
    }

    double s = 0;

    for (int i = 0; i < n; i++) {
        double v1 = std::min(vv[i], vv[i + 1]);
        double v2 = std::max(vv[i], vv[i + 1]);
        double t1 = v[i] - v1;
        double t2 = v[i] - v2;
        if (t1 + t2 < t[i]) {
            s += t1 * (v1 + v1 + t1) + t2 * (v2 + v2 + t2) + (t[i] - t1 - t2) * v[i] * 2;
        } else {
            s += (v2 - v1) * (v1 + v2);
            double tt = (t[i] - (v2 - v1));
            s += tt * (v2 + v2 + tt / 2);
        }
    }
    s *= 0.5;

    cout << std::setprecision(20);
    cout << s;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
// Welcome to my source code!

static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c) {
    stack<int> S;
    S.push(r);
    color[r] = c;
    while (!S.empty()) {
        int u = S.top(); S.pop();
        for (int i = 0; i < G[u].size(); i++) {
            int v = G[u][i];
            if (color[v] == NIL) {
                color[v] = c;
                S.push(v);
            }
        }
    }
}

void assignColor() {
    int id = 1;
    for (int i = 0; i < n; i++) color[i] = NIL;
    for (int u = 0; u < n; u++) {
        if (color[u] == NIL) dfs(u, id++);
    }
}

int main() {
    int s, t, m, q;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    assignColor();
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> s >> t;
        if (color[s] == color[t]) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
}


Measured memory_bytes: 9020
W, H, N = map(int, input().split(' '))

area = []
area_w = []
for h in range(H):
    for w in range(W):
        area_w.append(0)
    area.append(area_w)
    area_w = []

for n in range(N):
    X,Y,a = map(int, input().split(' '))
    if a == 1:
        for h in range(H):
            for x in range(X):
                area[h][x] = 1
    elif a == 2:
        for h in range(H):
            for x in range(X,W):
                area[h][x] = 1 
    elif a == 3:
        for y in range(Y):
            for w in range(W):
                area[y][w] = 1
    else:
        for y in range(Y,H):
            for w in range(W):
                area[y][w] = 1
sum_area = 0
for h in range(H):
    sum_area += sum(area[h])

ans = H*W - sum_area
print(ans)

Measured memory_bytes: 9280
#include<iostream>
#include<vector>
#include <algorithm>

int main() {
	int N, M, K;
	std::cin >> N >> M >> K;
	std::vector<long> A(++N), B(++M);

	for (int i = 1, a; i < N && std::cin >> a; i++)
		A.at(i) = A.at(i - 1) + a;
	for (int i = 1, b; i < M && std::cin >> b; i++)
		B.at(i) = B.at(i - 1) + b;

	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (A.at(i) > K)
			break;
		int b = std::upper_bound(B.begin(), B.end(), K - A.at(i)) - B.begin();
		ans = std::max(ans, i + b - 1);
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 6440
#include<iostream>
#include<algorithm>
 
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[202020];
    int b[202020];
    int c[202020];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<n;i++){
        cin>>c[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    sort(c,c+n);
    int i=0, j=0, k=0;
    long long int arc[202020], arc2[202020];
 
    for(int x = 0; x<n;x++){
        while(i<n && a[i]<b[x]){
            i++;
        }
        arc[x] = i;
        if(x)arc[x]+=arc[x-1];
    }
    long long int ans=0;
    i=0;
    for(int x = 0; x<n;x++){
        while(i<n && b[i]<c[x]){
            i++;
        }
        if(i>0)
            arc2[x] = arc[i-1];
        else continue;
        ans+=arc2[x];
    }
    
    cout<<ans<<endl;
    
    return 0;
}


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

int main(){

	int n;
	cin >> n;
	vector< vector<int> > a( 3 , vector<int>(n,-1) );
	for(int i=0;i<n;i++){
		cin >> a[0][i] >> a[1][i] >> a[2][i];
	}

	vector< vector<int> > dp( 3 , vector<int>(n,-1) );
	dp[0][n-1] = a[0][n-1];
	dp[1][n-1] = a[1][n-1];
	dp[2][n-1] = a[2][n-1];

	for(int i=n-2;i>=0;i--){
		dp[0][i] = a[0][i] + max( dp[1][i+1] , dp[2][i+1] );
		dp[1][i] = a[1][i] + max( dp[0][i+1] , dp[2][i+1] );
		dp[2][i] = a[2][i] + max( dp[0][i+1] , dp[1][i+1] );
	}

	cout << max( max( dp[0][0] , dp[1][0] ) , dp[2][0] ) << "\n";


	return 0;
}

Measured memory_bytes: 2940
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    L, R = LI()
    diff = R - L
    L %= 2019
    R = min(L + diff, R % 2019 + 2019)
    ans = inf
    for i in range(L, R):
        for j in range(L + 1, R + 1):
            ans = min(ans, (i * j) % 2019)
    print(ans)

main()



Measured memory_bytes: 65004
#include <stdio.h>
 
int main(void){
  int N,X,i;
  scanf("%d",&N);
  scanf("%d",&X);
 
  int L[N];
  for (i= 0; i < N; i++) {
    scanf("%d",&L[i]);
  }
 
  int sum = 0;
  int ans = N+1;
  for (i = 0; i < N; i++) {
    sum += L[i];
    if(sum > X){
      ans = i+1;
      break;
    }
  }
     printf("%d\n", ans);
     return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(int argc, char** argv){
  int h, m, s, input;
  cin >> input;
  h = input/3600;
  input = input%3600;
  m = input / 60;
  s = input % 60;
  cout << h << ":" << m << ":" << s << endl;
  return 0;
}

Measured memory_bytes: 1164
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 500

vector<vector<int>> a;
map<vector<int>, int> cnt, mul;

void norm(vector<int> &a){
	vector<int> b(a);
	rep(i, 4){
		if(b<a) a = b;
		rotate(b.begin(), b.begin()+1, b.end());
	}
}

int main(){
	int n;
	cin>>n;
	a = vector<vector<int>>(n, vector<int>(4));
	rep(i, n){
		rep(j, 4) cin>>a[i][j];
	}
	rep(i, n) norm(a[i]);
	//sort(all(a));
	rep(i, n) ++cnt[a[i]];
	rep(i, n){
		vector<int> b(a[i]);
		if(mul[b]) continue;
		rep(j, 4){
			if(b==a[i]) ++mul[b];
			rotate(b.begin(), b.begin()+1, b.end());
		}
	}
	ll res = 0;
	rep(i, n){
		--cnt[a[i]];
		vector<int> ai(a[i]);
		rep(j, i){
			--cnt[a[j]];
			vector<int> aj(a[j]); swap(aj[1], aj[3]);
			rep(k, 4){
				rotate(aj.begin(), aj.begin()+1, aj.end());
				vector<vector<int>> b(4, vector<int>(4));
				bool sk = false;
				rep(l, 4){
					b[l][1] = ai[(l+0)%4];
					b[l][0] = ai[(l+1)%4];
					b[l][3] = aj[(l+1)%4];
					b[l][2] = aj[(l+0)%4];
					norm(b[l]);
					if(!cnt.count(b[l])) sk = true;
				}
				if(sk) continue;
				ll r = 1;
				rep(l, 4){
					r *= cnt[b[l]]--*mul[b[l]];
				}
				res += r;
				rep(l, 4) ++cnt[b[l]];
			}
			++cnt[a[j]];
		}
		++cnt[a[i]];
	}
	cout<<res/3<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 29;
constexpr lint   INFL = 1LL << 61;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int a, b;
  cin >> a >> b;
  cout << max({a + b, a - b, a * b}) << endl;
  return 0;
}

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

using namespace std;

#define int long long

typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define DEL(v, n) v.erase(v.begin() + (n))

// -1 out
int DP[17][17];

signed main()
{
    while(true)
    {
        REP(i, 17)
            REP(h, 17)
                memset(&DP[i][h], 0, sizeof(int));

        int A, B;
        cin >> A >> B;

        if(A == 0 && B == 0) break;

        int N;
        cin >> N;

        REP(i, N)
        {
            int x, y;
            cin >> x >> y;
            DP[x - 1][y - 1] = -1;
        }

        if(DP[0][0] == -1)
        {
            cout << 0 << endl;
            break;
        }

        DP[0][0] = 1;

        REP(a, A)
        {
            REP(b, B)
            {
                int plus = 0;
                if(DP[a][b] == -1) continue;
                if(a == 0 && b == 0) continue;
                if(a != 0)
                {
                    if(DP[a - 1][b] != -1)
                    {
                        plus += DP[a - 1][b];
                    }
                }
                if(b != 0)
                {
                    if(DP[a][b - 1] != -1)
                    {
                        plus += DP[a][b - 1];
                    }
                }
                DP[a][b] = plus;
            }
        }

        cout << DP[A -1][B-1] << endl;
    }
    return 0;
}



Measured memory_bytes: 3052
import bisect
while True:
    N,M=map(int,raw_input().split())
    if N==M==0:break
    L=[input() for i in range(N)]
    L.append(0)
    S=set(i+j for i in L for j in L)
    B=sorted(S)
    t=bisect.bisect(B,M)-1
    maxInt=max(i+B[bisect.bisect(B,M-i)-1] for i in B[:t])
    print maxInt

Measured memory_bytes: 89288
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
    	double a, b, c, d, e, f;
	double x, y;
	while(cin >> a >> b >> c >> d >> e >> f){
		x= (double)((e*c-b*f)/(a*e-b*d));
		y= (double)(-(d*c)+a*f)/(a*e-b*d);
		if (x==0)x=0;
		if (y==0)y=0;
		printf("%.3f %.3f\n", x, y);
	}
	return 0;
}

Measured memory_bytes: 3068