akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int n;
typedef long long i64;
vector<i64> a;

int main()
{
	cin >> n;
	a.assign(n , 0);
	rep(i,0,n-1) cin >> a[i];
	
	int force;
	bool dec = false;
	int result = 1;

	rep(i,1,n - 1)
	{
		if(a[i - 1] == a[i])
			continue;
		if(dec == false)
		{
			force = abs(a[i] - a[i - 1]) / (a[i] - a[i - 1]);
			dec = true;
		}
		else
		{
			if(force != abs(a[i] - a[i - 1]) / (a[i] - a[i - 1]))
			{
				result++;
				dec = false;
			}
		}
	}
	cout << result << endl;
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i,j,k) for(int i = j; i <= k; i ++)
#define FORD(i,j,k) for(int i = j; i >= k; i --)
#define mp make_pair
#define N 300005
#define bit(x,y) (x>>y)&1
//#define f first
//#define s second
//#define int long long
using namespace std;

const int MOD=1e9+7;
int n;
string s;
long long res = 1;
void solve()
{
    int kt = 1;
    long long Count = 0;
    FOR(i,1,2 * n)
    {
        if(s[i] == 'B') /// odd
        {
            if(Count % 2)
            {
                res *= Count;
                res %= MOD;
                Count --;
            }
            else Count ++;
        }
        else /// even
        {
            if(Count % 2 == 0)
            {
                res *= Count;
                res %= MOD;
                Count --;
            }
            else Count ++;
        }
        if(Count < 0) kt = 0;
    }
    FOR(i,1,n)
    {
        res *= i;
        res %= MOD;
    }
    if(Count == 0 && kt == 1) cout << res;
    else cout << 0;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("A.inp","r",stdin);
    //freopen("A.out","w",stdout);
    cin >> n;
    cin >> s;
    s = ' ' + s;
    solve();
    return 0;
}
///https://atcoder.jp/contests/jsc2019-qual/tasks/jsc2019_qual_c


Measured memory_bytes: 788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
#define inf (ll)1e9

#define debugone(x) cout << #x << " " << x << "\n"; cout.flush();
#define debugtwo(x) cout << #x << "-------------" << "\n";for(auto &it: x) cout << it << " ";cout << "\n"; cout.flush();
#define debugthree(x, i, j) cout << #x << "------------" << "\n";cout << "from " << i << " to " << j << "\n";for(ll k=i; k<=j; k++) cout << x[k] << " ";cout << "\n"; cout.flush();



int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
			
	int r, g, b, n;
	cin >> r >> g >> b >> n;

	int res = 0;

	for(int i = 0; i<=n; i++){
		for(int j=0; j<=n; j++){
			int x = r * i + g * j;
			int rem = n - x;
			if(rem >= 0 && rem%b == 0){
				res++;
			}
		}
	}

	cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>
#include <queue>
#include <list>


#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define vint vector<int>
#define INF 1e13

using namespace std;
typedef long long  ll;

int main(){
    int n;
    cin >> n;
    REP(i, 1, 10){
        REP(j, 1, 10){
            if(i*j == n){
                p("Yes");
                return 0;
            }
        }
    }

    p("No");
}



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

int main() {
 	long long int N, M;
  	cin >> N >> M;
  
  	if (N % 2 == 1){
      	for (int i = 0; i < M; i++){
          	cout << i + 1 << " " << M * 2 - i << endl;
        }
    }
  
  	if (N % 2 == 0){
      	for (int i = 0; i < M; i++){
          	if (M * 2 - i * 2 + 1 > N / 2) cout << i + 1 << " " << M * 2 - i + 2 << endl;
          	else cout << i + 1 << " " << M * 2 - i + 1 << endl;
        }
    }
}


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

typedef vector< vector<int> > vvi;
typedef vector< vector<bool> > vvb;
typedef vector< vector<char> > vvc;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef long long ll;

int main(){
    ll a,b,n;
    cin >> a >> b >> n;
    ll ans;
    ll i;
    if(n<b){
        i=n;
        ans=a*i/b-a*(i/b);
    }else{
        i=b-1;
        ans=a*i/b-a*(i/b);
    }
    /*
    for(int i=1;i<=n;i++){
        ll temp=a*i/b-a*(i/b);
        cout << temp << endl;
        ans=max(ans,temp);
    }
    */
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
int main(){
  int a,b,c,x,y;  cin>>a>>b>>c>>x>>y;

  ll asum=a*x+b*y, bsum=x*2*c, csum=y*2*c;
  if(x==y){
    cout<<min(asum,bsum)<<"\n";
  }else{
    if(x>y){
      csum+=(x-y)*a;
      cout<<min(asum,min(bsum,csum))<<"\n";
    }else{
      bsum+=(y-x)*b;
      cout<<min(asum,min(bsum,csum))<<"\n";
    }
  }
}


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

typedef long long ll;

ll n, W;
ll w[110], v[110];
ll dp[110][100010];
ll inf = 1e18;

int main() {
    cin >> n >> W;
    for (int i = 0; i < n; i++) cin >> w[i] >> v[i];
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= 100000; j++) {
            dp[i][j] = inf;
        }
    }
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= 100000; j++) {
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            if (j + v[i] <= 100000) 
                dp[i+1][j + v[i]] = min(dp[i+1][j + v[i]], dp[i][j] + w[i]);
        }
    }
    ll ans = 0;
    for (ll i = 0; i <= 100000; i++) {
        if (dp[n][i] <= W)
            ans = max(ans, i);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 80128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9

using namespace std;

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

int main() {
    string S;
    cin >> S;
    int len = (int)S.length();
    
    bool used[26];
    fill(used, used + 26, false);
    
    if (len != 26) {
        for (int i = 0; i < 26; ++i) {
            used[S[i] - 'a'] = true;
        }
        for (int i = 0; i < 26; ++i) {
            if (!used[i]) {
                cout << S << char(i + 'a') << endl;
                return 0;
            }
        }
    } else {
        for (int k = 24; k >= 0; --k) {
            char last = S[k];
            char min_c = 'a' + 26;
            for (int i = k + 1; i < 26; ++i) {
                if (last < S[i]) {
                    min_c = min(min_c, S[i]);
                }
            }
            if (min_c != 'a' + 26) {
                for (int j = 0; j < k; ++j) {
                    cout << S[j];
                }
                cout << min_c << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int N;
char A[100003];

long long f(int s, int e) {
  long long a = 0, b = 0, c = 0;
  for (int i=s; i<=e; i++) {
    if      (A[i] == 'J') a += 1;
    else if (A[i] == 'O') b += a;
    else                  c += b;
  }
  return c;
}

int main() {
  scanf("%d", &N);
  scanf("%s", A+1);
  A[0] = 'J';
  A[N+1] = 'I';

  long long s = f(1, N);
  long long d = 0, na = 0, nb = 0;
  for (int i=1; i<=N; i++) {
    if (A[i] == 'I') nb++;
  }
  for (int i=1; i<=N; i++) {
    if      (A[i] == 'J') na++;
    else if (A[i] == 'I') nb--;
    d = max(d, na*nb);
  }
  printf("%lld\n", max({s+d, f(1, N+1), f(0, N)}));
  return 0;
}

Measured memory_bytes: 2820
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    List<int>[] G;
    bool b;
    bool[] us;
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int N = int.Parse(Console.ReadLine());
        if(N == 2){
            sb.Append("Second\n");
            return;
        }
        G = new List<int>[N];
        for(int i=0;i<N;i++){
            G[i] = new List<int>();
        }
        for(int i=0;i<N-1;i++){
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]) - 1;
            int b = int.Parse(str[1]) - 1;
            G[a].Add(b);
            G[b].Add(a);
        }
        us = new bool[N];
        if(G[0].Count == 1){
            if(dfs(G[0][0]) == 1){
                b = true;
            }
        }
        else{
            if(dfs(0) == 1){
                b = true;
            }
        }
        sb.Append((b ? "First" : "Second")+"\n");
    }
    int dfs(int v){
        us[v] = true;
        if(G[v].Count == 1){
            return 1;
        }
        int state = 0;
        for(int i=0;i<G[v].Count;i++){
            int t = G[v][i];
            if(!us[t]){
                int j = dfs(t);
                if(state == 0){
                    if(j == 1){
                        state = 1;
                    }
                }
                else{
                    if(j == 1){
                        b = true;
                    }
                }
            }
        }
        if(state == 1){
            return 0;
        }
        else{
            return 1;
        }
    }
}

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


int main(){
 
  string s; cin>>s;
  int max=0;
  int count=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G'){
      count++;
      if(max<count)max=count;
    }else{
      count=0;
    }
  }
  cout<<max<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define int ll
#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
int read(){
	int i;
	scanf("%lld",&i);
	return i;
}
using vi=vector<int>;
#define PB push_back
#define ALL(x) x.begin(),x.end()
using pi=pair<int,int>;
string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}
const int inf=LLONG_MAX/3;

signed main(){
	int n=read(),k=read();
	string s=readString();
	int cx=0,cy=0;
	map<pi,int> ps;
	ps[pi(cx,cy)];
	for(auto c:s){
		if(c=='E')
			cx++;
		if(c=='W')
			cx--;
		if(c=='N')
			cy++;
		if(c=='S')
			cy--;
		ps[pi(cx,cy)];
	}
	if(cx==0&&cy==0){
		int ans=0;
		for(auto p:ps){
			int x=p.first.first,y=p.first.second;
			ans+=ps.count(pi(x+1,y))*ps.count(pi(x,y+1))*ps.count(pi(x+1,y+1));
		}
		cout<<ans<<endl;
		return 0;
	}
	{
		map<pi,int> tmp;
		for(auto p:ps){
			int x=p.first.first,y=p.first.second;
			if(cx<0)x*=-1;
			if(cy<0)y*=-1;
			if(cx==0)swap(x,y);
			tmp[pi(x,y)];
		}
		swap(ps,tmp);
		if(cx<0)cx*=-1;
		if(cy<0)cy*=-1;
		if(cx==0)
			swap(cx,cy);
	}
	map<pi,vector<pi>> waf;
	for(auto p:ps){
		int x=p.first.first,y=p.first.second;
		int z=x/cx;
		int u=x-z*cx,v=y-z*cy;
		if(u<0){
			u+=cx;
			v+=cy;
			z--;
		}
		waf[pi(u,v)].PB(pi(z,z+k));
		if(u==0)
			waf[pi(cx,v+cy)].PB(pi(z-1,z+k-1));
	}
	for(auto& w:waf){
		vector<pi> qs,res;
		for(auto d:w.second){
			qs.PB(pi(d.first,-1));
			qs.PB(pi(d.second,1));
		}
		int last=-inf,sum=0;
		sort(ALL(qs));
		for(auto q:qs){
			int e=sum;
			sum+=q.second;
			if(e==0)last=q.first;
			else if(sum==0)res.PB(pi(last,q.first));
		}
		w.second=res;
	}
	int ans=0;
	const auto Hogloid=[&](vector<pi>const  (&seg)[4]){
		vector<pi> qs;
		REP(i,4)
			for(auto d:seg[i]){
				qs.PB(pi(d.first,1));
				qs.PB(pi(d.second,-1));
			}
		sort(ALL(qs));
		int last=-inf,sum=0;
		sort(ALL(qs));
		for(auto q:qs){
			int e=sum;
			sum+=q.second;
			if(e<4)last=q.first;
			else if(sum<4)ans+=q.first-last;
		}
	};
	for(auto w:waf){
		int x=w.first.first,y=w.first.second;
		if(x<cx&&waf.count(pi(x+1,y))*waf.count(pi(x,y+1))*waf.count(pi(x+1,y+1)))
			Hogloid({w.second,waf[pi(x+1,y)],waf[pi(x,y+1)],waf[pi(x+1,y+1)]});
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 25808
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>

using namespace std;

#define sz(a) static_cast<int>((a).size())
#define f first
#define s second
#define els(v) for (auto &el : (v))


#ifdef KIRYA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) {
    cerr << _s << " = " << _h << "\n";
}

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;

    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;

    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

const int64_t INF = static_cast<int64_t>(1e9) + 7;
const int64_t LINF = INF * INF;
const int Maxn = static_cast<int>(1e6) + 17;

const int Mod = 1e9 + 7;

template<typename T, typename T1>
T mod(T x, T1 p) {
    x %= p;
    if (x < 0)
        x += p;
    return x;
}

// x must be relatively prime to p
template<typename T>
T inverse(T x, T p) {
    x = mod(x, p);
    if (x == 1)
        return x;
    return mod(1LL * (-p / x) * (inverse(p % x, p)) , p);
}
int fact[Maxn];
int ifact[Maxn];
int inv[Maxn];

int NcR(int n, int r) {
    int ret = (1LL * ifact[n - r] * ifact[r]) % Mod ;
    ret = (1LL * ret * fact[n]) % Mod;
    return ret;
}

void solve() {
    fact[0] = 1;
    for(int i = 1; i < Maxn; i++) {
        fact[i] = 1LL * fact[i - 1] * i % Mod;
    }
    ifact[0] = 1;
    for(int i = 1; i < Maxn; i++) {
        ifact[i] = 1LL * ifact[i - 1] * inverse(i, Mod) % Mod;
    }

    // x must be relatively prime to p

    ifact[0] = 1;
    for(int i = 1; i < Maxn; i++) {
        inv[i] = inverse(i, Mod);
        ifact[i] = (1LL * ifact[i - 1] * inv[i]) % Mod;
    }

    int x, y;
    cin >> x >> y;
    int sum = x + y;
    if (sum % 3 != 0) {
        cout << "0\n";
        return;
    }
    int topy = sum / 3;
    int topx = 2 * topy;
    int choose = topx - x;
    if (choose < 0 || choose > sum / 3) {
        cout << "0\n";
        return;
    }
    cout << NcR(sum / 3, choose) << '\n';
}

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

    int q = 1;

    for (int i = 0; i < q; ++i) {
        solve();
    }
}

Measured memory_bytes: 12032
a = 10**9
b = 10**9-1
s = int(input())
t,m = s//a,s%a
rd = t+m
rc = m
if rd <= 10**9:
  print(0,0,a,rc,b,rd)
else:
  rc -= a
  rd -= b
  print(0,-rc,a,0,b,rd-rc)

Measured memory_bytes: 3060
def mySum(L, indexs):
    result = 0
    for i in indexs:
        if (L >> i & 1):
            result += 1
    return result


N, M = map(int, input().split())
S = []
for _ in range(M):
    S.append(list(map(lambda a: int(a)-1, input().split()))[1:])
P = list(map(int, input().split()))
count = 0
for bi in range(1 << (N)):
    for i, s in enumerate(S):
        if P[i] != (mySum(bi, s)) % 2:
            break
    else:
        count += 1
print(count)


Measured memory_bytes: 3064
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/operators.hpp>
#include <boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	std::string str;
	std::cin >> str;
	std::deque<char> deque(str.begin(), str.end());
	bool flag = false;
	int Q;
	std::cin >> Q;
	for (auto _ : boost::irange(0, Q))
	{
		int T;
		std::cin >> T;
		if (T == 1)
		{
			flag = !flag;
		}
		else
		{
			int f;
			char c;
			std::cin >> f >> c;
			if (flag)
			{
				f = 3 - f;
			}
			if (f == 1)
			{
				deque.emplace_front(c);
			}
			else
			{
				deque.emplace_back(c);
			}
		}
	}
	if (flag)
	{
		for (auto c : deque|adaptor::reversed)
		{
			std::cout << c;
		}
	}
	else
	{
		for (auto c : deque)
		{
			std::cout << c;
		}
	}
	std::cout << std::endl;
}

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

Measured memory_bytes: 976
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <list>
#include <iomanip>

using namespace std;

#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
#define rep(i,a,n) for(Int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(Int (i)=(a); (i)<=(n); (i)++)
const int MAX_N = 1000000;
const Int MAX_N_Int = 1000000000000;

template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}

bool isPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}


Int fact_mod(Int n, Int mod) {
    Int f = 1; repq(i,2,n) f = f * (i % MOD) % MOD;
    return f;
}

// 繰り返し二乗法 (modの世界での累乗)
Int mod_pow(Int x, Int n, Int mod) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;
}

// 組み合わせ nCr を求める
Int combination_mod(Int n, Int r, Int mod) {
    if(r > n-r) r = n-r;
    if(r == 0) return 1;
    Int a = 1;
    rep(i, 0, r) a = a * ((n-i) % mod) % mod;
    Int b = mod_pow(fact_mod(r, mod), mod-2, mod);
    return (a % mod) * (b % mod) % mod;
}

int main() {
    //COMinit();
    IOS;
    prec;
    Int a,b,c,d,n,m,k,x,y=0,ans=0,ans1=0;
    string str,s="",t,u;
    cin>>n>>s>>k;
    t=s[k-1];
    for (int i = 0; i < n; ++i) {
        if(s[i]!=s[k-1])cout<<"*";
        else cout<<s[i];
    }



    cout<<endl;
    return 0;
}




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

using namespace std;

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

int main(){
  string s;
  cin >> s;

  rep(i, 1 << 3) {
    int tmp = s[0] - '0';
    string stmp;
    stmp += s[0];
    rep(j, 3) {
      if ((i >> j) & 1) {
        tmp += s[j+1] - '0';
        stmp += "+";
        stmp += s[j+1];
      } else {
        tmp -= s[j+1] - '0';
        stmp += "-";
        stmp += s[j+1];
      }
    }
    if (tmp == 7) {
      cout << stmp << "=7" << endl;
      exit(0);
    }
  }
}

Measured memory_bytes: 256
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for b in B:
    ans += bisect.bisect_left(A,b)*(N-bisect.bisect_right(C,b))
print(ans)

Measured memory_bytes: 23328
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

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


int main(){
    ios::sync_with_stdio(false);
    string s,t; cin >> s>> t;
    bool ans=false;
    rep(i,s.size()){
        if(s==t){
            ans=true;
            break;
        } else{
            s=s.back()+s.substr(0,s.size()-1);
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	int K;
	long result = 0;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		K = Integer.parseInt(tokens[0]);

	}

	long getNext(Queue<String> que) {
		String str = que.poll();
		long result = Long.parseLong(str);
		int last = Integer.parseInt(str.substring(str.length() - 1, str.length()));
		for (int i = last - 1; i <= last + 1; ++i) {
			if (i < 0 || i >= 10) {
				continue;
			}
			que.add(str + Integer.toString(i));
		}
		return result;
	}

	void calc() {
		Queue<String> que = new ArrayDeque<>();
		for (int i = 1; i < 10; ++i) {
			que.add(Integer.toString(i));
		}
		int count = 0;
		while (count < K) {
			result = getNext(que);
			++count;
		}
	}

	void showResult() {
		System.out.println(result);
	}

}


Measured memory_bytes: 55084
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int A, B, C;		//生地の値段、トッピングの値段、生地のカロリー。
		int N = sc.nextInt();				//トッピングの種類数。
		int[] topping = new int[N];
		A = sc.nextInt();
		B = sc.nextInt();
		C = sc.nextInt();
		for(int i=0; i<N; i++){
			topping[i] = sc.nextInt();
		}
		sort_down00(topping, N);
		for(int i=0; i<N; i++){
			if((C/A) <= ((C+topping[i])/(A+B))){
				C += topping[i];
				A += B;
			}
			else{
				break;
			}
		}
		System.out.println((int)C/A);

	}
	
	static void sort_down00(int[] data, int n){
		int i;
		int idx;
		int work;
		for(i=0; i<n; i++){
			idx = max_idx00(data, i, n);
			work = data[i];
			data[i] = data[idx];
			data[idx] = work;
		}
		return;
	}
	
	static int max_idx00(int[] data, int from, int to){
		int i;
		int idx = from;
		for(i=from; i<to; i++){
			if(data[idx] < data[i]){
				idx = i;
			}
		}
		return idx;
	}

}

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

using namespace std;

int mov(int num,vector<int> &v)
{
  int val=v[num];
  if(v.size()<=num+1)
    return 0;
  if(v[num+1]==val)
    return 0;
  else if(v[num+1]==0){
    v[num+1]=val;
    v[num]=0;
    return 1;
  }
  else if(v.size()>=num+3 && v[num+2]==0){
    v[num+2]=val;
    v[num]=0;
    return 2;
  }
  return 0;

}

int main()
{
  int n,a,b,c,d,i;
  string str;
  bool fa=true,fb=true;

  cin >> n >> a >> b >> c >> d;
  cin >> str;

  a--;
  b--;
  c--;
  d--;

  vector<int> v(n);

  i=0;
  for(auto s:str){
    if(s=='.')
      v[i++]=0;
    else
      v[i++]=1;
  }


  v[a]=2;
  v[b]=3;

  while(a!=c || b!=d){
    int buf,buf2;
    if(fa==false && fb==false)
      break;
    if(c<d){
      buf=mov(b,v);
      if(buf==0){
        fb=false;
        buf2=mov(a,v);
        if(buf2==0)
          fa=false;
        a+=buf2;
      }

      b+=buf;
    }
    else{
      buf=mov(a,v);
      if(buf==0){
        fa=false;
        buf2=mov(b,v);
        if(buf2==0)
          fb=false;
        b+=buf2;
      }
      a+=buf;
    }
  }

  if(a==c && b==d)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;


  return 0;
}

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

int main(void)
{
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; i++)
    {
        cin >> A.at(i);
    }
    sort(A.begin(), A.end(), greater<int>());

    int a = 0, b = 0;
    for (int i = 0; i < n; i++)
    {
        if (i % 2 == 0)
        {
            a += A.at(i);
        }
        else
        {
            b += A.at(i);
        }
    }

    cout << (a - b) << endl;
}

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

int main()
{
ll x ;
cin >> x ;
auto f = [](ll y) { return y*y*y*y*y; };
rep(i,2000)rep(j,2000){
  if(f(i-1000)-f(j-1000)==x){
    cout << i-1000<<' '<<j-1000 << endl;
    return 0;
    
  }
}

return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  if(n <= 999)cout << "ABC" << endl;
  else cout << "ABD" << endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split(" "))

# result = True
masu = [['.' for i in range(W+2)] for j in range(H+2)]
for h in range(H):
    s = "."+input()+"."
    masu[h+1] = s

# print(masu)

for h in range(1,H+1):
    for w in range(1,W+1):
        if masu[h][w] == "#":
            if "#" == masu[h+1][w] or "#" == masu[h][w+1] or "#" == masu[h-1][w] or "#" == masu[h][w-1]:
                pass
            else:
                # result = False
                print("No")
                exit()

print("Yes")



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=4e2+10;
char a[N][N];
ll h,w,vis[N*N],Cnt[N*N],Dot[N*N],pre[N*N];
int dir[4][2]={
       {-1,0},
    {0,-1},{0,1},
        {1,0}
};
int Hash(int x,int y){
    return (x-1)*w+y;
}
int Find(int x){
    return x==pre[x]?x:Find(pre[x]);
}
void Merge(int x,int y){
    int fx=Find(x);
    int fy=Find(y);
    if(fx!=fy){
        pre[fy]=fx;
        Cnt[fx]+=Cnt[fy];
        Dot[fx]+=Dot[fy];
    }
}
bool check(int x,int y){
    return (x<1||y<1||x>h||y>w)?false:true;
}
int main()
{

    scanf("%lld%lld",&h,&w);
    for(int i=1;i<=h*w+10;i++){
        pre[i]=i;
    }
    for(int i=1;i<=h;i++){
        scanf("%s",a[i]+1);
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            Cnt[Hash(i,j)]++;
            if(a[i][j]=='.'){
                Dot[Hash(i,j)]++;
            }
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            for(int k=0;k<4;k++){
                int tx=i+dir[k][0];
                int ty=j+dir[k][1];
                if(check(tx,ty)&&a[i][j]!=a[tx][ty]){
                    int Fx=Hash(i,j);
                    int Fy=Hash(tx,ty);
                    Merge(Fx,Fy);
                }
            }
        }
    }
    ll ans=0;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            int t=Hash(i,j);
            int Father=Find(t);
            if(!vis[Father]){
                ans=ans+(Cnt[Father]-Dot[Father])*Dot[Father];
                vis[Father]=1;
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 5504
# -*- coding: utf-8 -*-

N = int(input())
xu = [None] * N
for i in range(N):
    x, u = input().split()
    xu[i] = [float(x), u]

rate = 380000.0

ans = 0
for (x, u) in xu:
    if u == "BTC":
        ans += x * rate
    else:
        ans += x

print(ans)


Measured memory_bytes: 3060
import sys
from collections import deque
 
N, M = list(map(int,input().split()))
AB = [ list(map(int,input().split())) for _ in range(M)] #Nは頂点、Mは辺数、ABはつながっている部屋
 


count = 0
for sub in range(M):
    graph = [[] for _ in range(N + 1)] #本来は頂点数さえあればいいけど、添え字処理の都合でN+1個
    for i in range(len(AB)): #つながっている頂点セット
        if i == sub:
            continue
        else:
            graph[AB[i][0]].append(AB[i][1])
            graph[AB[i][1]].append(AB[i][0]) #有行グラフだとこの行はなくていい
     
    # bfs
    queue = deque([1]) #queue = 訪れるリスト 今回は1からスタート固定だけど、出発点がいろいろある場合はループ
    signposts = [0] * (N + 1) #これはこの問題特有。
    visit = []
    while queue: #訪れるリストがあるうちは繰り返す
        u = queue.popleft() #先入れ先出し、つまり幅優先。popにすれば深さ優先
        visit.append(u)
        for v in graph[u]: #頂点uにある隣接頂点をチェック
            if (v not in visit) and (v not in queue): #この問題特融だが、おとずれたチェックとしてvisitリストが必裕　おとずれていなかったらこの分岐に入る
                queue.append(v) #訪れるリストに頂点を追加

    if len(visit)!= N:
        count +=1
print(count)


Measured memory_bytes: 74448
N, A, B = map( int, input().split())
hmax = 0
H = [ int( input()) for _ in range(N)]
#hmax = max(H)
L = 0
R = 10**9+1#hmax//B + 1
add = A-B
while L != R:
    now = (L+R)//2
    need = 0
    for i in range(N):
        r = H[i] - now*B
        if r > 0:
            need += (r-1)//add+1
    if need <= now:#うまくいくとき
        R = now
    else:#うまくいかないとき
        L = now+1#うまく行かないので+1している．これがないと無限ループが発生する。
print(L)

Measured memory_bytes: 7072
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define vl vector<ll>
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define sz size()
#define en end()
#define ro return 0
#define br break
#define con continue;
#define um unordered_map<ll,ll>
#define ms(x) memset(x , 0 , so x)
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define forr(i,a,b) for(ll i=a;i<b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
int main()
{
    ios;
    ll a , b , c ;
    cin >> a >> b >> c ;
    cout << min(a*b , c) << el ;

}


























Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
#include <numeric>
#include <sstream>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
int main(int argc, char const *argv[])
{
	int l,r,d;
	scanf("%d%d%d",&l,&r,&d);
	int ans = 0;
	for(int i = l;i <= r; ++i)
	{
		ans += (i % d == 0);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3756
#include <iostream>
using namespace std;
long gcd(long a,long b){
    if(a<b){swap(a,b);}
    if(!b){return a;}
    return gcd(b,a%b);
}

int main(){
    long T,A,B,C,D,s,i;
    cin>>T;
    for(i=0;i<T;i++){
        cin>>A>>B>>C>>D;
        bool res=true;
        if(B>A){res=false;}
        else if(B<=A && B>D){res=false;}
        else if((B<=A || B<=D) && C>=B){res=true;}
        else{
            long g=gcd(B,D);
            if(B-g+A%g>C){res=false;}
        }
        if(res){cout<<"Yes"<<endl;}
        else{cout<<"No"<<endl;}
    }
    return 0;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
L = []

for i in range(H):
    S = list(input())
    L.append(S)

dx = [1,0,-1,1,-1,1,0,-1]
dy = [1,1,1,0,0,-1,-1,-1]

for i in range(H):
    for j in range(W):
        if L[i][j] == ".":
            cnt = 0
            for k in range(8):
                x = i + dx[k]
                y = j + dy[k]
                if x >= 0 and x < H and y >= 0 and y < W and L[x][y] == "#":
                    cnt += 1
            L[i][j] = cnt
for i in L:
    print("".join(map(str,i)))

Measured memory_bytes: 3064
import java.util.*;

class Main{
    int a,b;
    int n,m;
    int [][] flg = new int[24][60];

    Main(){
        Scanner sc = new Scanner(System.in);
        n=sc.nextInt();
        for(int i=0;i<n;i++){
            a=sc.nextInt();
            b=sc.nextInt();
            flg[a][b]=1;
        }
        m=sc.nextInt();
        for(int i=0;i<m;i++){
            a=sc.nextInt();
            b=sc.nextInt();
            flg[a][b]=1;
        }
        int cnt=0;
        for(int i=0;i<24;i++){
            for(int j=0;j<60;j++){
                if(flg[i][j]==0)continue;
                cnt++;
                if(cnt>1)System.out.print(" ");
                System.out.print(i+":"+j/10+j%10);                
            }
        }
        System.out.println();

    }

    public static void main(String[] args){
        new Main();
    }
}

Measured memory_bytes: 20604
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))

int main()
{
	int n, k;
	string s;
	cin >> n >> k >> s;
	vector<int> nums;
	int now = 1;
	int cnt = 0;
	rep(i, 0, (int)s.size() - 1)
	{
		if (s[i] == (char)(now + '0')) ++cnt;
		else
		{
			nums.push_back(cnt);
			now = 1 - now;
			cnt = 1;
		}
	}
	nums.push_back(cnt);
	if (nums.size() % 2 == 0)nums.push_back(0);
	int add = 2 * k;
	int ans = 0;
	for (int i = 0; i < (int)nums.size(); i += 2)
	{
		int temp = 0;
		int left = i;
		int right = min(left + add, (int)nums.size() - 1);
		rep(j, left, right)
		{
			temp += nums[j];
		}
		ans = max(ans, temp);
	}
	cout << ans << endl;
}



Measured memory_bytes: 1020
import sys

N = int(input())
A = list(map(int, sys.stdin.readline().rsplit()))
B = list(map(int, sys.stdin.readline().rsplit()))
C = [0] * N

s = 0
minus = 0
res = 0
for i in range(N):
    c = A[i] - B[i]
    C[i] = c
    s += c
    if c < 0:
        minus += c
        res += 1

if s < 0:
    print(-1)
else:
    C.sort(reverse=True)
    s = 0
    for i, c in enumerate(C):
        if s + minus >= 0:
            print(res + i)
            exit()
        s += c


Measured memory_bytes: 18420
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int H,W;
  cin>>H>>W;
  vector<string> A(H);
  for(string &S:A)
    cin>>S;
  vector<vector<int>> B(H,vector<int>(W,-1));
  for(int i=0;i<H;i++){
    int cnt=0;
    vector<int> C(0);
    for(int j=0;j<W;j++){
      if(A[i][j]=='#'){
        for(int k:C)
          B[i][k]+=cnt;
        cnt=0;
        C={};
      }else{
        cnt++;
        C.push_back(j);
      }
    }
    for(int j:C)
      B[i][j]+=cnt;
  }
  for(int i=0;i<W;i++){
    int cnt=0;
    vector<int> C(0);
    for(int j=0;j<H;j++){
      if(A[j][i]=='#'){
        for(int k:C)
          B[k][i]+=cnt;
        cnt=0;
        C={};
      }else{
        cnt++;
        C.push_back(j);
      }
    }
    for(int j:C)
      B[j][i]+=cnt;
  }
  int ans=0;
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      ans=max(ans,B[i][j]);
  cout<<ans<<endl;
}

Measured memory_bytes: 42256
#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 true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

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

    vector<ll> a(N);
    for(int i=0; i<N; i++) cin >> a[i];
    sort(a.begin(), a.end(), greater<ll>());

    if(a[N-1] >= 0){
        ll ans = 0;
        for(int i=0; i<N-1; i++) ans += a[i];
        ans -= a[N-1];
        cout << ans << endl;

        ll tmp = a[N-1];
        for(int i=N-2; i>=1; i--){
            cout << tmp << " " << a[i] << endl;
            tmp = tmp - a[i];
        }
        cout << a[0] << " " << tmp << endl;
        return 0;

    } else {
        int npos;
        for(int i=0; i<N; i++){
            if(a[i] < 0){
                npos = i;
                break;
            }
        }

        if(npos == 0){
            ll ans = 0;
            for(int i=N-1; i>0; i--) ans -= a[i];
            ans += a[0];
            cout << ans << endl;

            ll tmp = a[0];
            for(int i=1; i<N; i++){
                cout << tmp << " " << a[i] << endl;
                tmp = tmp - a[i];
            }
        } else {
            ll ans = 0;
            for(int i=0; i<N; i++){
                if(a[i] > 0) ans += a[i];
                else ans -= a[i];
            }
            cout << ans << endl;
            ll tmp = a[npos];
            for(int i=npos-1; i>0; i--){
                cout << tmp << " " << a[i] << endl;
                tmp = tmp - a[i];
            }
            a[npos] = tmp;

            tmp = a[0];
            for(int i=npos; i<N; i++){
                cout << tmp << " " << a[i] << endl;
                tmp = tmp - a[i];
            }

        }
    }
}

Measured memory_bytes: 2688
#include<iostream>
#include<math.h>
#include<algorithm>
 
#define long long long
 
using namespace std;
 
long n, m;
long w[101], v[101], dp[101][100000];
 
long cal(int idx, int weight) {
    if (idx > n) return 0;
    if (dp[idx][weight] != -1) return dp[idx][weight];
    dp[idx][weight] = 0;
 
    if (weight + w[idx] <= m) dp[idx][weight] = max(cal(idx + 1, weight), cal(idx + 1, weight + w[idx]) + v[idx]);
    else dp[idx][weight] = cal(idx + 1, weight);
    return dp[idx][weight];
}
 
void FastInput()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
}
 
void Input()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i ++) cin >> w[i] >> v[i];
    for (int i = 1; i <= n; i ++)
        for (int j = 0; j <= 100000; j ++) dp[i][j] = -1;
}
 
void Solve()
{
    cout << cal(1,0);
}
 
int main()
{
    FastInput();
    Input();
    Solve();
}

Measured memory_bytes: 81720
import qualified Data.ByteString.Char8 as BC
import Data.IORef
import Control.Monad(forM_, when)
import Data.Maybe(fromJust)

main :: IO()
main = BC.getContents >>= solve.map (fst.fromJust.BC.readInt).tail.BC.lines >>= print

solve :: [Int] -> IO Int
solve (x:y:xs) = do
                  a <- newIORef (y - x)
                  b <- newIORef (min x y)
                  forM_ xs $ \z -> do
                    a' <- readIORef a
                    b' <- readIORef b
                    when (z - b' > a') $ writeIORef a (z - b')
                    when (z < b')      $ writeIORef b z
                  readIORef a

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

int main() {
  int a, b;
  cin >> a >> b;
  int cnt = 0;

  for (int i = a; i <= b; i++) {
    string k = to_string(i);
    bool flag = true;
    for (int j = 0; j < 2; j++) {
      if (k[j] != k[4-j]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int N;
vector<vector<vector<int>>> t(4, vector<vector<int>>(3, vector<int>(10, 0)));

int main() {
  cin >>N;
  rep(i, N){
    int b,f,r,v; cin >>b >>f >>r >>v; b--; f--; r--;
    t[b][f][r] += v;
  }
  rep(b, 4){
    rep(f, 3){
      rep(r, 10){
        cout <<" " <<t[b][f][r];
      }
      cout <<endl;
    }
    if (b < 3){
      cout <<"####################" <<endl;
    }
  }
}



Measured memory_bytes: 3156
/*Never Give up 14390*/
/*
Problem     :
Verdict     :
Time        :
Memory      :
*/
#include<bits/stdc++.h>
using namespace std;
#define sf(a)          scanf("%d",&a)
#define sff(a,b)         scanf("%d%d",&a,&b)
#define sfff(a,b,c)         scanf("%d%d%d",&a,&b,&c)
#define sffff(a,b,c,d)         scanf("%d%d%d%d",&a,&b,&c,&d)
#define sl(a)          scanf("%lld",&a)
#define sll(a,b)         scanf("%lld%lld",&a,&b)
#define slll(a,b,c)         scanf("%lld%lld%lld",&a,&b,&c)
#define sllll(a,b,c,d)         scanf("%lld%lld%lld%lld",&a,&b,&c,&d)
#define sc(a) scanf("%c",&a)
#define sz(a)              a.size()
#define ff first
#define ss second
#define all(a)          a.begin(), a.end()
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pf         printf
#define pf1(a)        pf("%d\n",a);
#define PI  acos(-1)
#define ll           long long
#define ull        unsigned long long
#define pb        push_back
#define vi           vector<int>
#define vl           vector<ll>
#define li            list<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define mp         map
#define nl         cout<<endl
#define en        pf("Entered\n")
#define en1      pf("Entered 2\n")
#define gcd(a,b) __gcd(a,b)
#define sp  ' '
#define f0(a,n) for(int a=0;a<n;a++)
#define f1(a,n) for(int a=1;a<=n;a++)
#define MOD 1000000007


#define one cout<<"one"<<endl
#define two cout<<"two"<<endl
#define three cout<<"three"<<endl
#define four cout<<"four"<<endl
#define five cout<<"five"<<endl
#define six cout<<"six"<<endl


// priority_queue<int, vector<int>, greater<int> > Q;//for smaller values

#define MAX    100000

//int dx[] = {-1, 0, 1, 0};
//int dy[] = {0, 1, 0, -1};
//int dx[]= {1,1,0,-1,-1,-1,0,1};/*8 side move*/
//int dy[]= {0,1,1,1,0,-1,-1,-1};/*8 side move*/
//int dx[]={1,1,2,2,-1,-1,-2,-2};/*knight move*/
//int dy[]={2,-2,1,-1,2,-2,1,-1};/*knight move*/

//'A'=65,'Z'=90 'a'=97 'z'=122 '0'=48



int main()
{
    faster
    int t;
    //  cin>>t;
    t=1;
    while(t--)
    {
        int n;
        cin>>n;
        int arr[n*2];
        f0(i,2*n)cin>>arr[i];
        sort(arr,arr+2*n);
        ll sum=0;
        for(int i=0; i<2*n; i+=2)sum+=arr[i];
        cout<<sum<<endl;


    }



    return 0;
}
/*
Ref:

*/


Measured memory_bytes: 3648
n,m = gets.split.map(&:to_i)
sc = m.times.map{ gets.split.map(&:to_i) }

1000.times do |i|
    k = i.to_s
    if k.size == n and sc.all?{|t| k[t[0]-1] == t[1].to_s}
        puts k
        exit
    end
end

p -1

Measured memory_bytes: 1788
#include<iostream>

int GCD(int a,int b){
	while(b!=0){
		int c=b;
		b=a%b;
		a=c;
	}
	return a;
}

int main(){
	int a,b;
	while(std::cin>>a>>b){
		int c=GCD(a,b);
		std::cout<<c<<" "<<(a/c)*(b/c)*c<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 1156
/* author:hellojim */
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int a[200100];
int b[200100];
int numa[200100];
int numb[200100];
int n;
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	cin>>n;
	rep(i,n)cin>>a[i],numa[a[i]]++;
	rep(i,n)cin>>b[i],numb[b[i]]++;
	sort(a,a+n);
	sort(b,b+n);
	rep(i,200001)if(numa[i]+numb[i]>n)
	{
		cout<<"No\n";
		return 0;
	}
	reverse(b,b+n);
//	int now=-1;
	rep(i,n)
	{
		if(a[i]==b[i])
		{
			for(int j=0;j<n;j++)
			{
				if(b[j]!=a[i]&&b[i]!=a[j])
				{
					swap(b[j],b[i]);
					//now=j;
					break;
				}
			}
		}
	}
	cout<<"Yes\n";
	rep(i,n)cout<<b[i]<<" ";
	cout<<endl;
	return 0;
}



Measured memory_bytes: 6776
function spilitInput(input) {
  var splited = [];
  var rows = input.split('\n');
  for (var i = 0; i < rows.length; i += 1) {
    splited.push(rows[i].split(' '));
  }
  return splited;
}
function Main(input) {
  var splited = spilitInput(input);
  var a = 500;
  var b = 100;
  var c = 50;
  var a_max = splited[0][0];
  var b_max = splited[1][0];
  var c_max = splited[2][0];
  var y = splited[3][0];

  var success_counter = 0;
  
  for (var ax = 0; ax <= a_max; ax += 1) {
  for (var bx = 0; bx <= b_max; bx += 1) {
  for (var cx = 0; cx <= c_max; cx += 1) {
    if ((a*ax) + (b*bx) + (c*cx) == y) success_counter+=1;
  }
  }
  }
  
  console.log(success_counter);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 32396