akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    rep(i, n) cin >> h.at(i);
    vector<int> a(m), b(m);
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        a.at(i) = x - 1;
        b.at(i) = y - 1;
    }

    vector<queue<int>> next(n);
    rep(i, m) {
        next.at(a.at(i)).push(b.at(i));
        next.at(b.at(i)).push(a.at(i));
    }

    int count = 0;
    rep(i, n) {
        bool good = true;
        while(!next.at(i).empty()) {
            int j = next.at(i).front(); next.at(i).pop();
            if(h.at(i) <= h.at(j)) {
                good = false;
                break;
            }
        }
        if(good) count++;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 71812
N = int(input()) #get 1st row
inlist = [input() for i in range(N)] #read row (add int using brackets if needed)
result = {}

def combination(a):
    x = 1
    x = a * (a-1) / 2
    return x

#make dic from input parameters
for component in inlist :
    dic = []
    for n in component:
        dic.append(n)
    dic.sort()
    dic2 = "".join(dic)
    if dic2 in result.keys():
        result[dic2] += 1
    else :
        result[dic2] = 1

#count the number
counter = 0
for v in result.values():
    counter += combination(v)

print (int(counter))

Measured memory_bytes: 24976
a,b,x=map(int,input().split())

import math
c=(a*a*b-x)*2

if c<(a*a*b):
  d=c/(a*a)
  print(math.degrees(math.atan(d/a)))
else:
  f=(2*x)/(a*b)
  print(math.degrees(math.atan(b/f)))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,cnt=0;
  cin>>n>>k;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      int l=k-i-j;
      if(l<=n&&l>=0) cnt++;
    }
  }
  cout<<cnt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i <= (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const ll INF=1e18;

int main() {
  ll n,m;
  cin >>n>>m;
  rep(i,n){
    rep(j,n-i){
      if(m==i*10000+j*5000+(n-i-j)*1000){
        cout << i<<" "<< j<<" "<<n-i-j<<endl;
        return 0;
      }
    }
  }
  cout <<"-1 -1 -1"<<endl;
}

Measured memory_bytes: 3600
/*
ID: markusz1
TASK: template
PROG: template
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ul;
typedef priority_queue<int> p_int_max;														// top is max
typedef priority_queue<int, vector<int>, greater<int>> p_int_min; // top is min
typedef priority_queue<ll> p_ll;
typedef priority_queue<double> p_double;
typedef pair<int, int> pr;
typedef map<int, int> m_int;
// ascending order
bool compare_pr_second(pr &a, pr &b) { return a.second > b.second; }

int a, b, c, x, y, sum, temp, smaller, larger;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	//freopen("template.in","r",stdin);
	//freopen("template.out","w",stdout);

	cin >> a >> b >> c >> x >> y;
	// casework
	smaller = min(x, y);
	larger = max(x, y);

	sum = a * x + b * y;	 // individual pizzas
	temp = 2 * larger * c; // buy all half-and-halfs
	if (temp < sum)
		sum = temp;

	// half-and-halfs, rest individual
	temp = 2 * smaller * c;
	if (larger == x)
		temp += a * (x - y);
	else if (larger == y)
		temp += b * (y - x);
	if (temp < sum)
		sum = temp;

	cout << sum << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

#define all(x) begin(x),end(x)

using namespace std;
using ll = long long;

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n);
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        h[i] = tmp;
    }

    sort(all(h));
    n -= k;

    ll res = 0;
    for (int i = 0; i < n; i++) {
        res += h[i];
    }
    cout << res << endl;
}


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

int main() {

    int kazu;
    int* koma;

    cin >> kazu;

    koma = new int[kazu];

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

    int ugoku;
    cin >> ugoku;

    int* ukoma = new int[ugoku];

    for (int i = 0; i < ugoku; i++) {
        cin >> ukoma[i];
        int hairetu = ukoma[i] - 1;
        if (hairetu != (kazu - 1)) {
            if (koma[hairetu + 1] != (koma[hairetu] + 1)) {
                koma[hairetu]++;
            }

        }
        else {
            koma[hairetu]++;
        }
        if (koma[hairetu] > 2019)koma[hairetu] = 2019;
    }

    for (int i = 0; i < kazu; i++) {
        cout << koma[i] << endl;
    }


    delete[] koma;
    delete[] ukoma;
    return 0;
}


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

using namespace std;

#define MOD 1000000007
#define ll long long int
#define ld long double
#define pb push_back
#define mkp make_pair
#define pii pair<int, int> 
#define pll pair<long long int, long long int>
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define fi first
#define sc second
#define deb 0

int par[1000000];
pair<pii, int > A[100001], B[100001];
pair<int, pii > arr[1000000];

int find(int x)
{
	if (x == par[x]) return x;
	return (par[x] = find(par[x]));
}

void uni(int x, int y)
{
	if ((x = find(x)) != (y = find(y))) {
		par[x] = y;
	}
}

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

	int n, i, j, k, x, y, z, a, b, c;
	cin >> n;
	for (i = 0; i < n; ++i) {
		cin >> x >> y;
		A[i] = mkp(mkp(x, y), i+1);
		B[i] = mkp(mkp(y, x), i+1);
		par[i+1] = i+1;
	}

	sort(A, A+n);
	sort(B, B+n);

	k = 0;
	for (i = 1; i < n; ++i) {
		int d = min(abs(A[i].fi.fi - A[i-1].fi.fi), abs(A[i].fi.sc - A[i-1].fi.sc));
		arr[k++] = mkp(d, mkp(A[i].sc, A[i-1].sc));
		d = min(abs(B[i].fi.fi - B[i-1].fi.fi), abs(B[i].fi.sc - B[i-1].fi.sc));
		arr[k++] = mkp(d, mkp(B[i].sc, B[i-1].sc));
	}

	sort(arr, arr+k);

	ll ans = 0;

	for (i = 0; i < k; ++i) {
		a = arr[i].sc.fi;
		b = arr[i].sc.sc;
		if (find(a) == find(b)) continue;
		uni(a, b);
		ans += arr[i].fi;
	}
	cout << ans << endl;

	return 0;
}

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

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
            var h = new HashSet<int>(s);

            Console.WriteLine(h.Count() == 2 ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13408
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define int long long
#define vi vector<int> 
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >   
#define vpl vector< pair<ll,ll> >   
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define mod %1000000007
#define ld long double
#define pll pair<ll,ll>
bool comp(P p1,P p2)
{
    if(p1.ff.ff!=p2.ff.ff)
        return p1.ff.ff<p2.ff.ff;
    else
        return p1.ss<p2.ss;
}

int32_t main()
{
     IOS;
   
     ll n;
     cin>>n;
     vl a(n),b(n);
     for(int i=0;i<n;i++)
     {
        cin>>a[i];
     }
     for(int i=0;i<n;i++)
     {
        cin>>b[i];
     }
     ll ansa=0;
     ll ansb=0;
     int ch=1;
     for(int i=0;i<n;i++)
     {
        if(a[i]<b[i])
        {
                ansa+=(b[i]-a[i])/1;
        }
        else
        {
            ansb+=a[i]-b[i];
        }
       // trace2(i,ch);
     }
     for(int i=0;i<n;i++)
     {
        if(a[i]<b[i])
        {
                int k=(b[i]-a[i])/2;
                ansb-=k;
                a[i]+=2*k;
       }
        if(ansb<=0)
            break;
      //  trace3(i,ch,ansb);
     }
   //  trace1(ansb);
     if(ansb>0)
        ch=0;

    if(ch)
        cout<<"Yes";
    else
        cout<<"No";
     return 0;
}

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

int main() {
	int n,d[100]={},max,a,cnt=0;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a;
		if(i==0 || max<a)max = a;
		d[a] = 1;
	}
	for(int i=0;i<=max;i++){
		if(d[i]==1)cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
var s:array[1..1000000] of char;
    i,n,b,c,min:integer;

begin
  readln(n);
  b := 0;
  c := 0;
  min := 0;
  for i:=1 to n do begin
    read(s[i]);
    if s[i]='.' then begin
      b := b + 1;
      c := c - 1;
      if min > c then min := c
      end
        else c := c + 1;
  end;
  writeln(min+b)
end.

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll k,sum=0;
	cin>>k;
	vector<ll>v(3);
	v.at(0)=1;
	v.at(1)=1;
	v.at(2)=1;
	for(int i=1;i<k+1;i++){
		for(int j=1;j<k+1;j++){
			for(int l=1;l<k+1;l++){
				v.at(0)=i;v.at(1)=j;v.at(2)=l;
				sum+=__gcd(__gcd(v.at(0),v.at(1)),v.at(2));
			}
		}
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	vector<vector<int>> grid(3*K + 10, vector<int>(3*K + 10, 0));
	for (int i = 0; i < N; ++i) {
		int x, y;
		char c;
		cin >> x >> y >> c;
		x = x % (2*K);
		y = y % (2*K);
		if (c == 'W') { x = (x + K) % (2*K); }
		grid[y][x] += 1;
		grid[y + K][x + K] += 1;
		grid[y + K][x] -= 1;
		grid[y][x + K] -= 1;
	}
	
	for (int i = 0; i < grid.size(); ++i) {
		for (int j = 0; j < grid[i].size() - 1; ++j) {
			grid[i][j + 1] += grid[i][j];
		}
	}
	for (int j = 0; j < grid[0].size(); ++j) {
		for (int i = 0; i < grid.size() - 1; ++i) {
			grid[i + 1][j] += grid[i][j];
		}
	}
	for (int i = 0; i < grid.size(); ++i) {
		for (int j = 0; j < grid[i].size(); ++j) {
			if ((i >= 2*K) || (j >= 2*K)) {
				int ni = i % (2*K);
				int nj = j % (2*K);
				grid[ni][nj] += grid[i][j];
			}
		}
	}

	int res = 0;
	for (int i = 0; i < 2*K; ++i) {
		for (int j = 0; j < 2*K; ++j) {
			int ni = (i + K) % (2*K);
			int nj = (j + K) % (2*K);
			int tmp = grid[i][j] + grid[ni][nj];
			res = max(res, tmp);
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 35712
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e9;

int main(){
    ll N,K,Q;
    cin>>N>>K>>Q;
    vector<int> d(N,0);

    for(int i=0;i<Q;i++){
        int x;
        cin>>x; x--;
        d.at(x)++;
    }

    for(int i=0;i<N;i++){
        if(d.at(i)>Q-K) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

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


using namespace std;
using ll = long long;

template<class T> class Segtree_Lazy {
private:
    vector<T> datA, datB;
    int n;
    T INF;
public:
    Segtree_Lazy(int n_) {
      INF = 0; // edit here
      n = 1;
      while (n < n_) n *= 2;
      datA.assign(2 * n - 1, INF);
      datB.assign(2 * n - 1, INF);
    }
    Segtree_Lazy(vector<T>& A) {
      Segtree_Lazy(A.size());
      for (int i = 0; i < A.size(); i++) {
        add(i, i + 1, A[i], 0, 0, n);
      }
    }
    void add(int a, int b, T x, int k, int l, int r) {
      if (a <= l && r <= b) {
        datA[k] += x;
      } else if (l < b && a < r) {
        datB[k] += (min(b, r) - max(a, l)) * x;
        add(a, b, x, k * 2 + 1, l, (l + r) / 2);
        add(a, b, x, k * 2 + 2, (l + r) / 2, r);
      }
    }
    void add(int a,int b,T x){
      add(a,b,x,0,0,n);
    }
    T sum(int a, int b, int k, int l, int r) {
      if (b <= l || r <= a) {
        return INF;
      } else if (a <= l && r <= b) {
        return datA[k] * (r - l) + datB[k];
      } else {
        T res = (min(b, r) - max(a, l)) * datA[k];
        res += sum(a, b, k * 2 + 1, l, (l + r) / 2);
        res += sum(a, b, k * 2 + 2, (l + r) / 2, r);
        return res;
      }
    }
    T sum(int a,int b){
      return sum(a,b,0,0,n);
    }
};

int main(){
  int n,q;cin >> n >> q;
  Segtree_Lazy<ll> SL(n);
  for(int i = 0;i < q;i++){
    int c;cin >> c;
    if(c == 0){
      int s,t;cin >> s >> t;
      s--,t--;
      ll x;cin >> x;
      SL.add(s,t + 1,x);
    }else{
      int s,t;cin >> s >> t;
      s--,t--;
      cout << SL.sum(s,t+1) << '\n';
    }
  }
}



Measured memory_bytes: 7016
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int K = 2;
	int nbPierres;
	cin >> nbPierres >> K;
	int hauteur[nbPierres];
	int meilleurSolution[nbPierres];

	for (int i = 0 ; i < nbPierres ; i++)
	{
		cin >> hauteur[i];
		meilleurSolution[i] = 1e9;
	}
	meilleurSolution[0] = 0;
	for (int i = 1 ; i < nbPierres ; i++)
	{
		for (int j = 1 ; j <= K ; j++)
		{
			if (i - j < 0) break;
			//cout<<i - j<<endl;
			meilleurSolution[i] = min(meilleurSolution[i] ,
								      meilleurSolution[i - j] + abs(hauteur[i] - hauteur[i -j]));
		}
		//cout<<meilleurSolution[i]<<endl;
	}
	cout << meilleurSolution[nbPierres - 1] << endl;
}

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

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

const ll INF = 1LL << 60;
int H, W;

vector<vector<ll>> dp(2000, vector<ll>(2000, INF));

ll max_square(vector<vector<int>> c) {
    ll ans = 0;
    for (int j = 0; j < W; j++) {
        if (c[0][j] == 1) {
            dp[0][j] = 0;
        } else {
            dp[0][j] = 1;
            ans = 1;
        }
    }
    for (int i = 1; i < H; i++) {
        if (c[i][0] == 1) {
            dp[i][0] = 0;
        } else {
            dp[i][0] = 1;
            ans = 1;
        }
    }

    
    for (int i = 1; i < H; i++) {
        for (int j = 1; j < W; j++) {
            if (c[i][j] == 1) {
                dp[i][j] = 0;
            } else {
                chmin(dp[i][j], dp[i - 1][j] + 1);
                chmin(dp[i][j], dp[i][j - 1] + 1);
                chmin(dp[i][j], dp[i - 1][j - 1] + 1);
                chmax(ans, dp[i][j]);
            }
        }
    }

    return ans * ans;
}

int main() {
    cin >> H >> W;
    vector<vector<int>> c(H, vector<int>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            scanf("%d", &c[i][j]);
        }
    }

    ll ans = max_square(c);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 49696
import math
import collections
def trial_division_sqrt(n):
    prime_count = collections.Counter()
    
    for i in range(2, int(math.sqrt(n)) + 2):
        while n % i == 0:
            n /= i
            prime_count[i] += 1
    if n > 1:
        prime_count[n] += 1
    
    return prime_count

N,P = map(int,input().split())
cnt = trial_division_sqrt(P)
sorted_cnt = cnt.most_common()#個数の降順に並び替え

ans  = 1
for i in range(len(cnt)):
    divisor_cnt = sorted_cnt[i][1] // N 
    divisor_num = sorted_cnt[i][0] 
    if  divisor_cnt >= 1:
        ans *= divisor_num ** divisor_cnt
    else:
        break

print(int(ans))

Measured memory_bytes: 3316
# coding: utf-8
# Your code here!
X,Y=map(int,input().split())

l=[300000,200000,100000]

ans=0
if X==1 and Y==1:
    print("1000000")
    exit()
if X<4:
    ans+=l[X-1]
if Y<4:
    ans+=l[Y-1]

print(ans)




Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int cmpnum(const void * n1, const void * n2) {
	if (*(int *)n1 > *(int *)n2)
	{
		return 1;
	}
	else if (*(int *)n1 < *(int *)n2)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}

int main(void) {

  char s[200001];
  scanf("%s", s);
  int length = strlen(s);
  char t[length+1];
  scanf("%s", t);
  int alp_s[26],alp_t[26];
  for (int i = 0; i < 26; i++) {
    alp_s[i] = 0;
    alp_t[i] = 0;
  }
  for (int i = 0; i < length; i++) {
    alp_s[s[i]-'a']++;
    alp_t[t[i]-'a']++;
  }
  qsort(alp_s, 26, sizeof(int), cmpnum);
  qsort(alp_t, 26, sizeof(int), cmpnum);
  for (int i = 0; i < 26; i++) {
    if (alp_s[i] != alp_t[i]) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");

  return 0;
}

Measured memory_bytes: 512
#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 pair<int, int> pii;
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<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

vector <pii> E[100010];
int down[100010];
ll ans;

void dfs(int x, int fa) {
	down[x] = 1;
	for(pii e : E[x]) if(e.Se != fa) {
		dfs(e.Se, x);
		down[x] += down[e.Se];
	}
}

int flag, n;
int ldown[100010];

void dfs2(int x, int fa) {
	for(pii e : E[x]) if(e.Se != fa) {
		dfs2(e.Se, x);
		if(flag) {
			if(ldown[e.Se] == n) ans += (ll)(n-1) * e.Fi;
			else ans += (ll)ldown[e.Se] * e.Fi;
		}
		else ans += (ll)ldown[e.Se] * e.Fi;
	}
}

void solve(){
	scanf("%d", &n);
	rep(i, n-1) {
		int x, y, z; scanf("%d%d%d", &x, &y, &z);
		E[x].pb(pii(z, y));
		E[y].pb(pii(z, x));
	}
	dfs(1, -1);
	for(int i=2;i<=n;i++) ldown[i] = 2 * min(down[i], n - down[i]);
	if(*max_element(ldown+2, ldown+1+n) == n) flag = 1;
	dfs2(1, -1);
	if(flag) printf("%lld\n", ans);
	else {
		int x = 1, h = n / 2;
		while(1) {
			int f = 0;
			for(pii e : E[x]) if(down[e.Se] < down[x] && down[e.Se] > h) {
				x = e.Se; f = 1; break;
				
			}
			if(f == 0) break;
		}
		
		int mn_E = 1e9;
		for(pii e : E[x]) mn_E = min(mn_E, e.Fi);
		printf("%lld\n", ans - mn_E);
	}
}

int main(){
	int T = 1; // scanf("%d", &T);
	while(T--) {
		solve();
	}
	
	return 0;
}


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

int main(){

  int X,Y,A,B,C;
  cin>>X>>Y>>A>>B>>C;
  
  ll p[A];
  ll q[B];
  ll r[C];
  
  rep(i,A)cin>>p[i];
  rep(i,B)cin>>q[i];
  rep(i,C)cin>>r[i];

  sort(p, p + sizeof(p)/sizeof(p[0]), greater<int>() );
  sort(q, q + sizeof(q)/sizeof(q[0]), greater<int>() );

  vector<int> s;
  rep(i,X)s.push_back(p[i]);
  rep(i,Y)s.push_back(q[i]);
  rep(i,C)s.push_back(r[i]);
  
  sort(s.begin(), s.end(), greater<int>() );
  
  ll count=0;
  rep(i,X+Y)count+=s[i];
  
  cout<<count<<endl;
}


Measured memory_bytes: 4724
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace::std;
using ll = long long;
int main() {
    int N; cin >> N;
    int res=0;
    for (int i=1;i<=N;i++){
        if (to_string(i).size()%2==1) res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
import math

def solve(X):
	ans = X
	# b^p = ansとなるansを探す
	for b in range(2, X):
		p = math.log(ans, b) # 精度で死ぬ(log(100, 10)など)
		if float.is_integer(p):
			return ans
	return 1

def solve2(X):
	# 全探索
	for x in range(X, 1, -1):
		for p in range(2, x):
			for b in range(2, x):
				bp = b**p
				if bp == x:
					return x
				if bp >= x:
					break
	return 1

if __name__ == "__main__":
	X = int(input())
	print(solve2(X))


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		int ret = 0;
		for (int x = 0; x <= K; x++) {
			for (int y = 0; y <= K; y++) {
				int z = S - x - y;
				if (0 <= z && z <= K) {
					ret++;
				}
			}
		}
		System.out.println(ret);
	}
}

Measured memory_bytes: 21972
#include<stdio.h>
int main(void)
{
    int n,a,b,c,i,flg1,m;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	    scanf("%d %d %d",&a,&b,&c);
		flg1=0;
		m=0;
		while(1){
			if(a>0&&b>0&&c>0){
			    a--;
				b--;
				c--;
				m++;
			}
			else if(a>1&&b>0){
			    a-=2;
				b--;
				m++;
			}
			else if(a>2){
			    a-=3;
				m++;
			}
			else flg1=1;
			if(flg1==1) break;
		}
		printf("%d\n",m);
	}
	return 0;
}

Measured memory_bytes: 2756
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    s = S()
    s.insert(0,">")
    n = len(s)
    s.append("<")
    f = [0]*n
    l = []
    for i in range(n):
        if s[i] == ">" and s[i+1] == "<":
            f[i] = 1
            l.append(i)
    ans = [0]*n
    for i in l:
        j = i
        while j < n-1 and not f[j+1] and s[j+1] == "<":
            ans[j+1] = max(ans[j+1],ans[j]+1)
            j += 1
    for i in l:
        j = i
        while j > 0 and not f[j-1] and s[j] == ">":
            ans[j-1] = max(ans[j-1],ans[j]+1)
            j -= 1
    print(sum(ans))
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 103564
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

int n;
int a[200] = {};

int main(){
    cin >> n;
    inrep(n,a);
    
    int cnt = 0;
    rep(i,1,n){
        if(a[i-1] == a[i]){
            cnt ++ ;
            a[i] = 20000;
        }
    }    
    P(cnt);
    
	return  0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr int MAX = 1e5 + 1;
// const int MAX = 10;
int card[MAX];          // カードに関する連結成分番号を保存.
int connection[MAX];    // 各連結成分 の カード数 を保存.
vector<int> graph[MAX]; // カードの番号を, グラフの頂点に見立てる.

// グラフを幅優先探索する.
// https://ja.wikipedia.org/wiki/幅優先探索
// ※bfsの動作確認用.
// @param s: グラフの探索開始頂点.
// @param l: 連結成分番号(※1以上).
// @return: 特に無し.
void bfs(int s, int l){
    
    // 1. 空のキュー.
    queue<int> q;
    
    // 2. 訪問済みフラグ設定.
    // ※スタート地点に, 連結成分番号を指定.
    card[s] = l;
    connection[l]++;
    
    // 3. 探索地点 s をキュー q に追加.
    q.push(s);
    while(!q.empty()){

        // 4. キューから取り出す.
        int u = q.front();
        q.pop();

        // 5. 取り出した要素を処理.
        for(auto &e : graph[u]){
            // 6. 訪問済であれば, 処理をスキップ.
            if(card[e] > 0)            continue;
            if(card[e] == 0 && e != s) card[e] = card[u], connection[l]++, q.push(e);
        }
    }
    return;
}

int main() {

    // 1. 入力情報取得.
    int N, M;
    scanf("%d %d", &N, &M);

    // 2. グラフ作成.
    for(int i = 0; i < M; i++){
        int x, y, z;
        scanf("%d %d %d", &x, &y, &z);
        x--, y--;
        // x -> y
        graph[x].push_back(y);
        // y -> x
        graph[y].push_back(x);
    }
    
    // 3. 連結成分に分解.
    int c = 0;
    for(int i = 0; i < N; i++) if(graph[i].size() > 0 && card[i] == 0) c++, bfs(i, c);
    
    // グラフ連結情報確認.
    // for(int i = 1; i <= N; i++){
    //     printf("card[%d] = %d\n", i, card[i]);
    //     printf("connection[%d] = %d\n", i, connection[i]);
    // }
    
    // 4. 後処理.
    // -> 各連結成分 ごとに, 魔法 を 1回使用する必要があることと, 
    // 連結成分に含まれないカードは, それぞれ魔法を使用する必要があると見る.
    int ans = N;
    for(int i = 1; i < N; i++){
        if(connection[i] > 0) ans -= connection[i], ans++;
        else                  break;
    }
    printf("%d\n", ans);
    return 0;

}

Measured memory_bytes: 6904
lis=list(map(int,input().split()))
mod=(10**9)+7
pascal=[]
#print(lis[0]-lis[1]+1,lis[1]-1)
rank=max(lis[0]-lis[1]+1,lis[1]+1)
for i in range(rank):
    pascal.append([])
    for j in range(i+2):
        if j==0 or j==i+1:
            pascal[i].append(1)
        else:
            pascal[i].append(pascal[i-1][j-1]+pascal[i-1][j])
#print(len(pascal[-1]))
for i in range(1,1+lis[1]):
    if i<=lis[0]-lis[1]+1:
        ans=pascal[lis[0]-lis[1]][i]*pascal[lis[1]-2][i-1]%mod
    else:
        ans=0
    print(ans)


Measured memory_bytes: 431348
s_code = list(map(int, input()))

num_1 = s_code[0]
num_2 = s_code[1]
num_3 = s_code[2]
num_4 = s_code[3]

if num_1 == num_2:
  print('Bad')
elif num_2 == num_3:
  print('Bad')
elif num_3 == num_4:
  print('Bad')
else:
  print('Good')
 


Measured memory_bytes: 2940
n,m = (int(x) for x in input().split())
a = [int(x) for x in input().split()]



popular = 0
sumVote = sum(a)
q,mod = divmod(sumVote,4*m)

if(mod == 0):
	line = q - 1
else:
	line = q

if(q < 1):
	print("Yes")
	exit()

for x in range(n):
	if(a[x] > line):
		popular += 1 
	if(popular == m):
		print("Yes")
		exit()

print("No")

Measured memory_bytes: 38384
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

a = i()
print(a+a**2+a**3)

Measured memory_bytes: 72640
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = list(input())
"""
dp = [[0 for i in range(3)] for j in range(N)]
for i in range(N):
	r,s,p = 0,0,0
	if i > 0:
		r,s,p = dp[i-1][0],dp[i-1][1],dp[i-1][2]
	m = max(r,s,p)
	if T[i] == "r":
		if i < K:
			dp[i][0] = m
			dp[i][1] = m
			dp[i][2] = m + P
		else:
			dp[i][0] = max(s,p)
			dp[i][1] = max(r,p)
			dp[i][2] = max(r,s) + P
	elif T[i] == "s":
		if i < K:
			dp[i][0] = m + R
			dp[i][1] = m
			dp[i][2] = m
		else:
			dp[i][0] = max(s,p) + R
			dp[i][1] = max(r,p)
			dp[i][2] = max(r,s)
	else:
		if i < K:
			dp[i][0] = m
			dp[i][1] = m + S
			dp[i][2] = m
		else:
			dp[i][0] = max(s,p)
			dp[i][1] = max(r,p) + S
			dp[i][2] = max(r,s)
print(max(dp[-1]))
"""
ans = 0
point = {
	"r": P,
	"s": R,
	"p": S
}
win = [False for i in range(N)]
for i in range(N):
	if i < K:
		win[i] = True
		ans += point[T[i]]
	else:
		if T[i] == T[i-K] and win[i-K]:
			continue
		win[i] = True
		ans += point[T[i]]
print(ans)

Measured memory_bytes: 4788
#include<queue>
#include<vector>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdint>
#include<iostream>
#include<algorithm>
using namespace std;
vector<int> a[200001];
bool v[100001];
int f[100001];
int son[100001];
int ans;
inline void dfs1(int d)
{
	v[d]=true;
	int i;
	for(i=0;i<a[d].size();i++)
	{
		int t=a[d][i];
		if(!v[t])
		{
			dfs1(t);
			if(f[t]==0)
				son[d]++;
			f[d]+=f[t];
		}
	}
	f[d]+=max(son[d]-1,0);
}
inline void dfs2(int d)
{
	v[d]=true;
	int i;
	for(i=0;i<a[d].size();i++)
	{
		int t=a[d][i];
		if(!v[t])
		{
			int t1=f[d],t2=f[t];
			int s1=son[d],s2=son[t];
			f[d]-=f[t];
			f[d]-=max(son[d]-1,0);
			if(f[t]==0)
				son[d]--;
			f[d]+=max(son[d]-1,0);
				
			f[t]-=max(son[t]-1,0);
			f[t]+=f[d];
			if(f[d]==0)
				son[t]++;
			f[t]+=max(son[t]-1,0);
			ans=min(ans,f[t]+1);
			dfs2(t);
			
			f[d]=t1;
			f[t]=t2;
			son[d]=s1;
			son[t]=s2;
		}
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	int s,t;
	int i;
	for(i=1;i<=n-1;i++)
	{
		scanf("%d%d",&s,&t);
		s++;
		t++;
		a[s].push_back(t);
		a[t].push_back(s);
	}
	dfs1(1);
	ans=f[1]+1;
	memset(v,false,sizeof(v));
	dfs2(1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 14208
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll MOD = 1e9 + 7;
const ll INF = 1e10;
const vector<int> dy = {-1,0,1,0};
const vector<int> dx = {0,1,0,-1};

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

    vector<ll> div;
    for (ll i = 2; i * i <= n; i ++) {
        if (n%i == 0) {
            if (n == i * i) div.push_back(i);
            else {
                div.push_back(i);
                div.push_back(n/i);
            }
        }
    }
    
    int ans = 0;
    for (ll i:div) {
        ll k = n;
        while (k%i == 0) {
            k /= i;
        }
        if (k%i == 1) ans ++;
    }

    n--;
    for (ll i = 1; i * i <= n; i ++) {
        if (n%i == 0) {
            if (n == i * i) ans ++;
            else {
                ans += 2;
            }
        }
    }
    cout << ans  << endl;   
}

Measured memory_bytes: 384
import itertools

N, M = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(M)]
P = list(map(int, input().split()))

# スイッチが付いているか付いていないかを表す集合
ans = 0
for bit in itertools.product([0, 1], repeat=N):
    for d, p in zip(data, P):
        cnt = 0
        for i in d[1:]:
            if bit[i - 1] == 1:
                cnt += 1
        if cnt % 2 != p:
            break
    else:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long int ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PLL, int> PLLI;
typedef pair <PLL, PLL> PP;
typedef pair <PII, int> PPI;
typedef pair <ll, int> PLI;
typedef unsigned int ui;
const int mod = 1e9+7;
const int inf = 1e9+9;
const ll MOD = 1e9+696969;
const long long INF = 1e18+3;

const int maxn = 15;
int dp[(1 << maxn) + 5][maxn];
int cost[maxn][(1 << maxn) + 5];

int kraw[maxn][maxn], a, b, c, n, m;

inline int getCost(int x, int y)
{
	assert((x & y) == 0);
	int ret = 0;
	for (int i=0; i<n; ++i)
		if (x & (1 << i)) ret += cost[i][y];
	return ret;
}

int main()
{
	boost;
	cin >> n >> m;
	FOR(i, 1, m)
	{
		cin >> a >> b >> c;
		--a; --b;
		kraw[a][b] = c;
		kraw[b][a] = c;
	}
	
	FOR(first, 0, n-1)
	{
		int pot = (1 << n);
		FOR(i, 0, pot - 1)
		{
			FOR(j, 0, n - 1)
				if ((1 << j) & i) cost[first][i] += kraw[first][j];
		}
	}
	
	FOR(i, 0, n-1)
		FOR(j, 0, (1 << n)) dp[j][i] = inf + inf;
	
	dp[1][0] = 0;
	int pot = (1 << n);
	for (int i=1; i<pot; ++i)
	{
		vector <int> tutaj, tam;
		FOR(j, 0, n-1)
			if (i & (1 << j)) tutaj.pb(j);
			else tam.pb(j);
	
		int sz = (int)tam.size();
		for (int help = 1; help < (1 << sz); ++help)
		{
			int S = 0;
			for (int k = 0; k < sz; ++k)
				if (help & (1 << k)) S += (1 << tam[k]);
				
			if (__builtin_popcount(help) == 1)
			{
				int st = 0;
				while (((1 << st) & help) == 0) ++st;
				int u = tam[st];
				for (auto t : tutaj) 
					if (kraw[t][u]) dp[i | S][u] = min(dp[i | S][u], dp[i][t] + getCost(S, i ^ (1 << t)));
			}
			
			for (auto t : tutaj) dp[i | S][t] = min(dp[i | S][t], dp[i][t] + getCost(S, i ^ (1 << t)));
		}
	}
	
	/*for (int i=1; i<pot; ++i)
		for (int j=0; j<n; ++j)
		{
			if (dp[i][j] != inf + inf) cout << "i : " << i << ' ' << j << " wynik: " << dp[i][j] << endl;
		}*/
		
	cout << dp[pot - 1][n - 1];
}


Measured memory_bytes: 4224
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;
const int maxn=200000+5;

int n,l,o;
int sum;
int sum1[maxn];
bool ok[maxn];
bool op;

int main (){
	int ret=1000000000;
	scanf ("%d%d",&n,&l);
	for (int i=l;i<=l+n-1;i++){
		sum+=i;
		if (i<0)
		ok[-i]=true;
		else
		sum1[i]+=i;
	}
	for (int i=0;i<o;i++){
		if (sum1[i]==0){
			op=true;
			break;
		}
	}
	if (op==true) printf("%d",sum);
	else{
	for (int i=l;i<=l+n-1;i++){
		if (i<0)
		ret=min(ret,-i);
		else 
		ret=min(ret,i);
	}
}
	if (ok[ret]==true)
	printf("%d",sum+ret);
	else
	printf("%d",sum-ret);
	return 0;
}

Measured memory_bytes: 256
import sys
from itertools import permutations, combinations, product

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return list(map(int, input().split()))
def MAP(): return map(int, input().split())

ans = []
while 1:
	d, w = MAP()
	if d == 0 and w == 0:
		break
	e = [LIST() for _ in range(d)]
	sum_max = 0
	for i in combinations(range(d), 2):
		if abs(i[0]-i[1]) == 1:
			continue
		for j in combinations(range(w), 2):
			if abs(j[0]-j[1]) == 1:
				continue
			# 堀の最小値を見つける
			min_ = 10
			for k in range(i[0], i[1]+1):
				if k == i[0] or k == i[1]:
					for l in range(j[0], j[1]+1):
						min_ = min(min_, e[k][l])
				else:
					min_ = min(min_, e[k][j[0]])
					min_ = min(min_, e[k][j[1]])
			# 内側を調べる．内側にmin_以上の値があればだめ．
			sum_ = 0
			for k in range(i[0]+1, i[1]):
				for l in range(j[0]+1, j[1]):
					# print(k, l, e[k][l])
					if e[k][l] >= min_:
						sum_ = 0
						break
					else:
						sum_ += (min_-e[k][l])
				if e[k][l] >= min_:
					break
			sum_max = max(sum_max, sum_)

	ans.append(sum_max)
for x in ans:
	print(x)



Measured memory_bytes: 5680
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"
const double PI = 3.14159265358979323846;

int main() {
	int k;
	string s;
	cin >> k;
	cin >> s;
	if (s.length() <= k) {
		cout << s << endl;
	}
	else {
		for (int i = 0; i < k; ++i) {
			cout << s[i];
		}
		cout << "..." << endl;
	}

	return 0;
}



Measured memory_bytes: 3640
s = int(input())
ans = 0
a = list()
n = s
for i in range(100000) :
    if n in a :
        print(ans+1)
        break
    if n % 2 == 0 :
        a.append(n)
        n = n / 2
        ans += 1
    else :
        a.append(n)
        n = 3 * n + 1
        ans += 1


Measured memory_bytes: 9188
import java.util.Arrays;
import java.util.Scanner;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int N = sc.nextInt();
		int[] A = new int[3 * N];
		for (int i = 0; i < A.length; i++) {
			A[i] = sc.nextInt();
		}
		Arrays.sort(A);
		long sum = 0;
		for (int i = N; i < A.length; i+=2) {
			sum += A[i];
		}
		System.out.println(sum);
	}
}

class Main {
	public static void main(String... args) {
		Scanner in = new Scanner(System.in);

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 92680
<?php
list($n) = explode(" ", trim(fgets(STDIN)));
$a =  explode(" ", trim(fgets(STDIN)));
foreach($a as $num){
    @$map[$num]++;
}
$c = 0;
foreach($map as $k => $v){
    if($v >= $k){
        $c += $v - $k;
    }else{
        $c += $v;
    }
}
echo $c;

Measured memory_bytes: 19188
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author otsuhata
 */
public class Main {
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    if(-1000 <= a && a <= 1000 && -1000 <= b && b <= 1000 && a < b) {
        System.out.println("a < b");
    }else if(-1000 <= a && a <= 1000 && -1000 <= b && b <= 1000 && a > b) {
        System.out.println("a > b");
    }else if(-1000 <= a && a <= 1000 && -1000 <= b && b <= 1000 && a == b) {
        System.out.println("a == b");
    }else {
        System.out.println("Please enter a number from -1000 to 1000.");
    }
  }    
}

Measured memory_bytes: 26068
#include <iostream>
#include <math.h>
using namespace std;
int main(int argc, const char * argv[]) {
    int num[26]={0};
    string str;
    cin>>str;
    
//    for(int i=0;i<str.length();i++){
//        str[i]++;
//    }
//    cout<<str<<endl;
    
    for(int i=0;i<str.length();i++){
        num[str[i]-'a']++;
    }
    //check
    bool flag=true;
    for(int i=0;i<26;i++){
        if(num[i]%2==1){
            flag=false;
            break;
        }
    }
    if(flag){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;

int main(){
   string s;
   cin >> s;
   if(s=="ABC") cout << "ARC" << endl;
   else cout << "ABC" << endl;
}

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

using namespace std;

bool check(const vector<int> & ary,int i,int l,int r)
{
	if(i == 10)
		return true;
	bool f = false;
	if(ary[i] > l)
	{
		f = check(ary,i+1,ary[i],r);
	}
	if(ary[i] > r)
	{
		f = f || check(ary,i+1,l,ary[i]);
	}
	return f;
}

int main (int argc, char const* argv[])
{
	int n;
	cin >> n;
	for (unsigned int i = 0; i < n; i += 1)
	{
		auto ary = vector<int>(10);
		for (unsigned int i = 0; i < 10; i += 1)
		{
			cin >> ary[i];
		}
		bool f = check(ary,0,0,0);
		if(f)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
      
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

using namespace std;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    ll n, a, b;
    cin >> n >> a >> b;

    if ((a + b) % 2 == 0) {
        cout << (b - a) / 2 << "\n";
    }
    else {
        cout << min(a + (b - a - 1) / 2, n - b + 1 + (b - a - 1) / 2);
    }

    return 0;
} 

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

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

void solve(long long X, long long K, long long D) {
  X = abs(X);
  if (X - (__int128_t)K * D >= 0) {
    cout << X - K * D << endl;
    return;
  }
  ll y = X / D;
  ll z = X % D;
  if ((K - y) % 2 == 0) {
    cout << (long long)z << endl;
  } else {
    cout << (long long)(D - z) << endl;
  }
}

int main() {
  long long X;
  scanf("%lld", &X);
  long long K;
  scanf("%lld", &K);
  long long D;
  scanf("%lld", &D);
  solve(X, K, D);
  return 0;
}


Measured memory_bytes: 3756
#!/usr/bin/env python
import string
import sys
from itertools import chain, dropwhile, takewhile

INF = float("inf")


def read(
    *shape, f=int, it=chain.from_iterable(sys.stdin), whitespaces=set(string.whitespace)
):
    def read_word():
        w = lambda c: c in whitespaces
        nw = lambda c: c not in whitespaces
        return f("".join(takewhile(nw, dropwhile(w, it))))

    if not shape:
        return read_word()
    elif len(shape) == 1:
        return [read_word() for _ in range(shape[0])]
    elif len(shape) == 2:
        return [[read_word() for _ in range(shape[1])] for _ in range(shape[0])]


def readi(*shape):
    return read(*shape)


def readi1(*shape):
    return [i - 1 for i in readi(*shape)]


def readf(*shape):
    return read(*shape, f=float)


def reads(*shape):
    return read(*shape, f=str)


def arr(*shape, fill_value=0):
    if len(shape) == 1:
        return [fill_value] * shape[0]
    elif len(shape) == 2:
        return [[fill_value] * shape[1] for _ in range(shape[0])]


def dbg(**kwargs):
    print(
        ", ".join("{} = {}".format(k, repr(v)) for k, v in kwargs.items()),
        file=sys.stderr,
    )


def main():
    N = readi()
    A = readi(N)
    print(
        " ".join(str(i) for i, _ in sorted(enumerate(A, start=1), key=lambda p: p[1]))
    )


if __name__ == "__main__":
    main()


Measured memory_bytes: 25296
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: i32,
        b: i32,
        c: i32,
    }

    let (a, b) = if a < b { (a, b) } else { (b, a) };
    if a < c && c < b {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h> 
#define MOD 1000000007
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
      #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    ll n;
    cin >> n;
    int a,b;
    for (int i = -200; i <= 200; i++){
        for(int j = -200; j <= 200;j++){
            if((pow(i,5) - pow(j,5)) == n){
                a = i;
                b = j;
            }
        }
    }
    cout << a << " " << b;
    
    cout<< endl;
}

Measured memory_bytes: 4116
#include <cstdio>
#include <algorithm>
struct E {
	int a, d;
} c[200000];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d%d", &c[i].a, &c[i].d);
	std::sort(c, c+n, [](E a, E b) {return a.d < b.d; });
	int now = 0; bool ans = true;
	for (int i = 0; i < n; i++) {
		now += c[i].a;
		if (now > c[i].d) ans = false;
	}
	puts(ans ? "Yes" : "No");
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> takoyaki(n);
  for(int i = 0; i < n; ++i){
    cin >> takoyaki[i];
  }
  int ans = 0;
  for(int i = 0; i < n - 1; ++i){
    for(int j = i + 1; j < n; ++j){
      ans += takoyaki[i] * takoyaki[j];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include<functional>
using namespace std;
typedef long long LL;
inline LL read()
{
	LL kk=0,f=1;
	char cc=getchar();
	while(cc<'0'||cc>'9'){if(cc=='-')f=-1;cc=getchar();}
	while(cc>='0'&&cc<='9'){kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}
	return kk*f;
}
const int maxn=200022;
LL x,y,asd,a,b,c;
LL ca[maxn],cb[maxn],cc[maxn],lin[maxn*3],co=0;
int main()
{
	x=read();y=read();a=read();b=read();c=read();
	for(int i=1;i<=a;++i)ca[i]=read();
	for(int i=1;i<=b;++i)cb[i]=read();
	for(int i=1;i<=c;++i)cc[i]=read();
	sort(ca+1,ca+a+1,greater<int>());
	sort(cb+1,cb+b+1,greater<int>());
	sort(cc+1,cc+c+1,greater<int>());
	asd=0;
	for(int i=1;i<=x;++i)
	{
		asd+=ca[i];lin[++co]=ca[i];
	}
	for(int i=1;i<=y;++i)
	{
		asd+=cb[i];lin[++co]=cb[i];
	}
	sort(lin+1,lin+co+1);
	int it=1,itc=1;
	while(it<=co&&itc<=c)
	{
		while(lin[it]>=cc[itc]&&it<=co)it++;
		while(lin[it]<cc[itc]&&it<=co&&itc<=c)
		{
			asd+=cc[itc]-lin[it];itc++;it++;
		}
	}
	printf("%lld\n",asd);
}

Measured memory_bytes: 6144