akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<long> vl;
typedef vector<vector<long> > vvl;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

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

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    int A, B;
    cin >> A >> B;

    cout << ceil(float(B - 1) / float(A - 1)) << endl;
    return 0;
}


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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 1e5 + 5;

typedef pair<int,int>   ii;

struct Edge {
    int v, c;
    Edge(int _v,int _c) : v(_v), c(_c)  {}
};

vector<Edge> E;
vector<int>  g[N];

int addEdge(int u,int v,int c)  {
    g[u].pb(sz(E)); E.pb(v,c);
    g[v].pb(sz(E)); E.pb(u,0);

    return  sz(E) - 1;
}

int S, T;
int d[N];
int p[N];

bool bfs()  {
    for(int i = 0 ; i <= T ; ++i)
        d[i] = -1,
        p[i] = 0;

    queue<int>  q;
    q.push(S);  d[S] = 0;

    while (q.size())    {
        int u = q.front();  q.pop();
        for(int i : g[u])   {
            int v = E[i].v;
            if (E[i].c == 0)    continue;
            if (d[v] < 0)   {
                d[v] = d[u] + 1;
                q.push(v);
            }
        }
    }

    return  d[T] >= 0;
}

int dfs(int u,int F)    {
    if (u == T || F == 0)   return  F;
    for(int &i = p[u] ; i < sz(g[u]) ; ++i)  {
        int j = g[u][i];
        int v = E[j].v;
        if (E[j].c == 0 || d[v] != d[u] + 1)
            continue;
        int res = dfs(v,min(E[j].c,F));
        if (res)    {
            E[j].c -= res;  j ^= 1;
            E[j].c += res;  return  res;
        }
    }
    return  0;
}

int MaxFlow()   {
    while (bfs())
    while (dfs(S,N));

    int ans = 0;

    for(int i : g[T])
        ans += E[i].c;

    return  ans;
}

int a[N], ca[N];
int b[N], cb[N];

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

    int n;  cin >> n;

    for(int i = 0 ; i < n ; ++i)    cin >> a[i];
    for(int i = 0 ; i < n ; ++i)    cin >> b[i];

    int tot = 0;

    for(int i = 0 ; i < n ; ++i)    if(!ca[i])  {
        ca[i] = ++tot;

        for(int j = a[i] ; j != i ; j = a[j])
            ca[j] = tot;
    }
    for(int i = 0 ; i < n ; ++i)    if(!cb[i])  {
        cb[i] = ++tot;

        for(int j = b[i] ; j != i ; j = b[j])
            cb[j] = tot;
    }
    S = 0;
    T = tot + 1;

    int ans = n;

    for(int i = 0 ; i < n ; ++i)    {
        if (a[i] == i && b[i] == i) {
            ans--;
            continue;
        }
        if (a[i] != i && b[i] == i) {   addEdge(ca[i],T,1); continue;   }
        if (a[i] == i && b[i] != i) {   addEdge(S,cb[i],1); continue;   }

        if (a[i] == b[i])   {
            addEdge(ca[i],cb[i],1);
            addEdge(cb[i],ca[i],1);
        }
        else
            addEdge(ca[i],cb[i],1);
    }
    cout << ans - MaxFlow() << endl;
}

Measured memory_bytes: 13804
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define debug(x) cerr<<#x<<": "<<x<<'\n'

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int inf = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int G[110][110] = {};
int d[110] = {};
int main(){
    int n;
    cin >> n;
    rep(i,n)rep(j,n) G[i][j]=-1;
    rep(i,n){
        int t,m;
        cin >> t >> m;
        rep(j,m){
            int a,b;
            cin >> a >> b;
            G[t][a] = b;
        }
    }

    rep(i,n) d[i] = 900010000;
    d[0] = 0;
    while(true){
        bool update = false;
        rep(i,n){
            rep(j,n){
                if(i==j) continue;
                if(G[i][j] != -1 && d[i] + G[i][j] < d[j]){
                    d[j] = d[i]+G[i][j];
                    update = true;
                }
            }
        }
        if(!update) break;
    }

    rep(i,n){
        cout << i << " " << d[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3084
from bisect import bisect_left
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    ans += bisect_left(l, l[i]+l[j]) - j - 1
print(ans)


Measured memory_bytes: 3188
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
#define ull unsigned long long
const int MAXN=20;
const int base=233;
char ch[2*MAXN];
int bin[MAXN];
map<ull,int> mp;
int main()
{
//	freopen("a.in","r",stdin);
	bin[1]=1;for(int i=2;i<MAXN;i++)bin[i]=bin[i-1]<<1;
	int n=read();scanf("%s",ch+1);
	for(int i=0;i<bin[n+1];i++)
	{
		ull sum=0;
		for(int j=1;j<=n;j++)if(i&bin[j])
			sum=(sum*base+ch[j]-'a'+1);
		sum=(sum*base+79);
		for(int j=1;j<=n;j++)if(!(i&bin[j]))
			sum=(sum*base+ch[j]-'a'+1);
		++mp[sum];
	}LL ans=0;
	for(int i=0;i<bin[n+1];i++)
	{
		ull sum=0;
		for(int j=1;j<=n;j++)if(i&bin[j])
			sum=(sum*base+ch[2*n-j+1]-'a'+1);
		sum=(sum*base+79);
		for(int j=1;j<=n;j++)if(!(i&bin[j]))
			sum=(sum*base+ch[2*n-j+1]-'a'+1);
		ans+=mp[sum];
	}pr2(ans);
	return 0;
}


Measured memory_bytes: 33024
#include <bits/stdc++.h>
using namespace std;
char a[100001],b[100001];
int main()
{
	gets(a);
	int l=strlen(a);
	for(int i=0;i<l;i++)
	{
		b[l-i-1]=a[i];
		if(a[i]=='b') a[i]='d';
		else if(a[i]=='d') a[i]='b';
		else if(a[i]=='p') a[i]='q';
		else if(a[i]=='q') a[i]='p';
	}
	for(int i=0;i<l;i++)
		if(a[i]!=b[i]) puts("No"),exit(0);
	puts("Yes");
	return 0;
}

Measured memory_bytes: 384
## coding: UTF-8
from decimal import *
from itertools import permutations, combinations,combinations_with_replacement,product

s = input().split()
t = [int(p) for p in s]

#print(t)
A = t[0]
B = t[1]
K = t[2]



a = max(0, A - K)
#print(a)

b = min(B, B - K + A)
if(b < 0):
    b = 0
#print(b)
print('{} {}'.format(a, b))

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

int a[100010];

int main(){
	int n; scanf("%d", &n);
	int maxj = -0x3f3f3f3f, minj = 0x3f3f3f3f;
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
		maxj = max(maxj, a[i]);
		minj = min(minj, a[i]);
	}
	if (maxj - minj > 1){
		printf("No\n");
		return 0;
	}
	if (maxj == minj){
		if (maxj * 2 <= n || maxj + 1 == n) printf("Yes\n");
		else printf("No\n");
		return 0;
	}
	int tot = maxj, all = n;
	for (int i = 0; i < n; i++){
		if (a[i] == minj) tot--, all--;
	}
	if (tot > 0 && tot * 2 <= all) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define Int int64_t
using namespace std;
#define BITS 62
const Int M=(Int)(1e9+7);

inline Int mmul(Int a,Int b){if(a>=M)a=a%M;if(b>=M)b=b%M;if(a*b>=M)return(a*b)%M;return(a*b);}
inline Int madd(Int a, Int b){if(a>=M)a=a%M;if(b>=M)b=b%M;if(a+b>=M)return(a+b)%M;return(a+b);}
Int N;

int main()
{
   cin>>N;
   vector<Int> A(N);
   for(auto &x:A) cin>>x;
   Int ans=0;
   
    for(int i=0;i<BITS;++i){
        Int nums0=0,nums1=0;
        for(int j=0;j<N;++j){
            if(A[j]%2==0) ++nums0;
            else ++nums1;
            A[j]>>=1LL;
        }
        Int init=mmul(nums0,nums1);
        ans=madd(ans,mmul((1LL<<i),init));
        
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 5552
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define chmax(x, y) x = max(x, y)
using namespace std;
//using ll = long long;
//using P = pair<int, int>;

int par[200003];
int rank_[200003];

void init(int n) {
  rep(i,n) {
    par[i] = i;
    rank_[i] = 0;
  }
}

int root(int x) {
  return par[x] == x ? x : par[x] = root(par[x]);
}

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

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

  if (rank_[x] < rank_[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (rank_[x] == rank_[y]) rank_[x]++;
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  init(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    unite(a, b);
  }
  
  vector<int> tot(n);
  rep(i,n) tot[root(i)]++;
  int ans = 0;
  rep(i,n) chmax(ans, tot[i]);
  cout << ans <<endl;
  return 0;
}

Measured memory_bytes: 5556
#include <bits/stdc++.h>
#define LSOne(S) ((S) & (-S))
using namespace std;

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second #define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  ll copias[100001];
  mset(copias, 0);
  
  ll n, a, b, k;
  cin >> n >> k;
  while (n--) {
    cin >> a >> b;
    copias[a] += b; 
  }
  ll soma, i;
  soma = copias[1];
  i = 1;
  while (soma < k) {
    i++;
    soma += copias[i];
  }
  cout << i << ende;
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#define lowbit(o) o&(-o)
#define N 100005
#define M 200005
using namespace std;
int i,j,k,l,s,n,m,x,y,s1,s2,s3,tot,last[N],Next[M],to[M],v[N][2];
struct node {
	int x,y;
}q[M];
inline void add(int x,int y) {
	Next[++tot]=last[x]; last[x]=tot; to[tot]=y;
}
inline void work() {
	int l=0,r=1; q[1].x=1,q[1].y=0;
	v[1][0]=1;
	while (l<r) {
		++l;
		for (int i=last[q[l].x];i;i=Next[i]) if (!v[to[i]][q[l].y^1]) q[++r].x=to[i],q[r].y=q[l].y^1,v[to[i]][q[l].y^1]=1;
	}
}
int main() {
	scanf("%d%d",&n,&m);
	for (i=1;i<=m;i++) scanf("%d%d",&x,&y),add(x,y),add(y,x);
	work();
	for (i=1;i<=n;i++) if (v[i][0]&&v[i][1]) s1++;
	else if (v[i][0]) s2++;
	else s3++;
	printf("%lld\n",1ll*s1*(s1-1)/2+1ll*s2*s1+1ll*s3*s1+1ll*s2*s3-m);
}


Measured memory_bytes: 4480
A, B, K = map(int, input().split())

if B-A+1 >= 2*K :
    for i in range(A,A+K) :
        print(i)
    for i in range(B-K+1,B+1) :
        print(i)
else :
    for i in range(A,B+1) :
        print(i)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fr first
#define sc second
#define pb push_back
#define maxheap priority_queue<int>
#define minheap priority_queue<int, vector<int>, greater<int> >
const int INF = 1e9+7;
const int MAXN = 5e5 + 200;
const  long double eps = 1e-16;
const long double pi = acos(-1.0);
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


void solve(){
    char ch;
    cin >> ch;
    cout << char(int(ch) + 1) << endl;
}

int main() {
ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
cout.setf(ios::fixed), cout.precision(10);
 //freopen("input.in", "r", stdin);
// freopen("output.out", "w", stdout);
 int step;
 step = 1;
  for (int i = 1; i <= step; i++){
         solve();
    }
}


Measured memory_bytes: 256
//by xxj
//更努力，只为了我们想要的明天。   ——大壮《我们不一样》
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#define fi first
#define se second
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define lowbit(x) x&-x

#if (__cplusplus==201103L)
#include<unordered_map>
#else
#include<tr1/unordered_map>
namespace std{
	using std::tr1::unordered_map;
}
#endif

using namespace std;
const int inf=1e9+7;
const ll linf=1e18+7;
const ll hh=523;
//const int mod=;
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while (ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll lread(){
	int f=1;
	ll x=0;
	char ch=getchar();
	while (ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
unordered_map<int,int> f[100007];
deque<pair<pii,int> > dq;
int n,m;
int d[100007];
vector<pii> g[100007];
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	n=read();
	m=read();
	for (int i=0;i<m;i++){
		int x,y,c;
		x=read();
		y=read();
		c=read();
		x--;
		y--;
		c--;
		//cout<<x<<' '<<y<<' '<<c<<endl;
		g[x].push_back(mp(y,c));
		g[y].push_back(mp(x,c));
	}
	for (int i=0;i<n;i++){
		d[i]=inf;
	}
	dq.push_back(mp(mp(0,-1),0));
	d[0]=0;
	while (!dq.empty()){
		pair<pii,int> x=dq.front();
		int u=x.fi.fi;
		int c=x.fi.se;
		int t=x.se;
		dq.pop_front();
		if (t!=d[u]){
			continue;
		}
		//cout<<u<<' '<<c<<' '<<t<<endl;
		if (u==n-1){
			printf("%d\n",t);
			return 0;
		}
		//dq.pop_front();
		for (int i=0;i<g[u].size();i++){
			int v=g[u][i].fi;
			int c1=g[u][i].se;
			int t1=(c1!=c)+t;
			//cout<<v<<' '<<c1<<' '<<t1<<endl;
			if (t1<d[v]){
				d[v]=t1;
				f[v][c1]=t1;
				if (c1==c){
					//cout<<6789876<<endl;
					dq.push_front(mp(mp(v,c1),t1));
				}
				else{
					dq.push_back(mp(mp(v,c1),t1));
				}
			}
			else if(t1==d[v]){
				if (f[v].find(c1)!=f[v].end() && f[v][c1]==t1){
					continue;
				}
				f[v][c1]=t1;
				if (c1==c){
					dq.push_front(mp(mp(v,c1),t1));
				}
				else{
					dq.push_back(mp(mp(v,c1),t1));
				}
			}
		}
		//cout<<endl;
	}
	printf("-1\n");
	return 0;
}
/*
input:
*/


Measured memory_bytes: 31360
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<limits.h>

int main(){
    int A,B,C,K;
    scanf("%d %d %d %d",&A,&B,&C,&K);
    if(A>=K) printf("%d",K);
    else if(A+B>=K) printf("%d",A);
    else printf("%d",A-(K-A-B));
}


Measured memory_bytes: 1728
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
        string S;

        cin >> S;

        if(S.size() == 2){
                cout << S << endl;
        }else if(S.size() == 3){
                reverse(S.begin(),S.end());
                cout << S << endl;
        }

        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll=long long;
using pint=pair<int,int>;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define el '\n'
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define ceil_div(a,b) ((a+(b-1))/b)
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
#define $in(v,n) ;rep(II,0,n)cin>>v[II]
inline void IN(void){return;}
template<typename F,typename... R>inline void IN(F& f, R&... r){cin>>f;IN(r...);}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}


int main(){
    int n,k,q; IN(n,k,q);
    vector<int> a(n,k);
    rep(i,0,q){
    	int t; cin >> t; t--;
    	a[t]++;
    }
    rep(i,0,n){
    	if(a[i]<=q) puts("No");
    	else puts("Yes");
    }
    return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    (a *= a) %= MOD;
    n >>= 1;
  }
  return res;
}

const ll maxf = 10000000;
ll fact[maxf+5];

void fact_init(){
  fact[0] = 1;
  for(ll i=1; i<=maxf; i++){
    fact[i] = (fact[i-1] * i) % MOD;
  }
}

ll comb(ll a, ll b){
  if(a<b || a<0 || b<0) return 0;
  if(fact[0] == 0) fact_init();
  return (fact[a] * modpow((fact[a-b]*fact[b])%MOD, MOD-2)) % MOD;
}

ll naive_comb(ll a, ll b){
  ll res = 1;
  for (ll i = a; i > a - b; i--) res = res * i % MOD;
  for (ll i = 1; i <= b; i++) res = (res * modpow(i, MOD-2)) % MOD;
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll x,y; cin>>x>>y;
  if((x+y)%3){
    cout<<0<<endl;
    return 0;
  }
  
  if((-x+2*y)%3 || (2*x-y)%3){
    cout<<0<<endl;
    return 0;
  }
  ll a=(-x+2*y)/3, b=(2*x-y)/3;
  // if(a<0 || b<0){
  //   cout<<0<<endl;
  //   return 0;
  // }
  
  // cout<<a<<' '<<b<<endl;
  cout<<comb(a+b,a)<<endl;
  
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  while(true){
  int a,b,ans=-1;
  cin >> a >> b;
  if (a==0 && b==0) break;
  vector<int> d(a);
  rep(i,a) cin >> d[i];
  rep(i,a){
    rep(j,a){
      if (i==j) continue;
      if (d[i]+d[j]<=b) ans=max(ans,d[i]+d[j]); 
    }
  }
  if (ans==-1) cout << "NONE" << endl;
  else cout << ans << endl;
  }
}



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

int main()
{
    int i,a[5];
    for(i=0;i<5;i++)
    {
        cin>>a[i];
        if(a[i]==0)
        {
            cout<<i+1<<endl;
        }
    }
    return 0;
}


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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

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

    int cnt_2 = 0, cnt_4 = 0;
    REP(i, N) {
        int a;
        std::cin >> a;
        if(a % 4 == 0) {
            ++cnt_4;
        } else if(a % 2 == 0) {
            ++cnt_2;
        }
    }
    if(cnt_2 == 0) {
        std::cout << ((cnt_4 >= (N-cnt_4-cnt_2-1)) ? "Yes" : "No") << std::endl;
    } else {
        std::cout << ((cnt_4 >= (N-cnt_4-cnt_2)) ? "Yes" : "No") << std::endl;   
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k;
	cin >> n >> k;
	vector<ll> v(n), ans(n, 0);
	for(auto&x: v) cin >> x;
	for(int i = n - 2;i >= 0; --i){
		ll mindist = 1e9+7LL;
		for(int j = i + 1; j < min(i + k + 1, n); ++j){
			mindist = min(mindist, abs(v[i] - v[j]) + ans[j]);
		}
		ans[i] = mindist;
	}
	cout << ans[0] << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using INT=mp::cpp_int;
using namespace std;
using ll=long long;
using vec=vector<ll>;
using vect=vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
INT LCM(INT x,INT y){
  INT z=gcd(x,y);
  return x*y/z;
}
ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}
INT modinv(INT a, INT m) {
    INT b = m, u = 1, v = 0;
    while (b) {
        INT t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int main() {
  cout << fixed << setprecision(30);
  ll n,m;
  cin>>n>>m;
  vec x(m);
  vec y(m);
  loop(i,m){
    ll a,b;
    cin>>a>>b;
    x[i]=a-1;
    y[i]=b-1;
  }
  vec ans(n,0);
  ans[0]=1;
  vec quantity(n,1);
  loop(i,m){
    if(ans[x[i]])ans[y[i]]=1;
    if(quantity[x[i]]==1)ans[x[i]]=0;
    quantity[x[i]]--;
    quantity[y[i]]++;   
  }
  putout(sum(ans));
}

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

int main()
{
    string A;
    string B;
    cin>>A;
    cin>>B;
    int a,b;
    cin>>a>>b;
    string C;
    cin>>C;
    if(A==C)
        a--;
    if(B==C)
        b--;
    cout<<a<<" "<<b<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

        while(true){
		String input_line = input.readLine();

		String[] number = input_line.split(" ");

		// 1???until_num?????°
		int until_num = Integer.parseInt(number[0]);

		// 1???until_num??????????????°?????????????¶?????????°
		int num_sum = Integer.parseInt(number[1]);
		 if(until_num ==0&&num_sum==0){
	        	break;
	        }
		int count=0;
		for(int first_num=1; first_num<=until_num ; first_num++){
			for(int second_num=first_num+1; second_num<=until_num; second_num++){
				for(int third_num=second_num+1; third_num<=until_num; third_num++){
					int three_sum=first_num+second_num+third_num;
					if(three_sum==num_sum){
						count++;
					}
				}
			}

		}
		System.out.println(count);
        }

}

}

Measured memory_bytes: 24924
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#define N 300
#define M 300
using namespace std;

int K[N], A[N][N];
int c[M];

int main(void)
{
    int n, m;
    int i, j;
    int o;

    scanf("%d %d", &n, &m);
    for(i = 1; i <= n; i ++)
    {
        scanf("%d", &K[i]);
        for(j = 1; j <= K[i]; j ++)
        {
            scanf("%d", &A[i][j]);
            ++ c[A[i][j]];
        }
    }

    for(i = 1, o = 0; i <= m; i ++)
        o += c[i] == n;
    printf("%d\n", o);

    return 0;
}

Measured memory_bytes: 256
N = str(input())
n,mods = 0,[1]+[0]*2018
d = 1
for i in reversed(N):
  n = (n+int(i)*d)%2019
  mods[n] += 1
  d = (d*10)%2019

print(sum([i*(i-1)//2 for i in mods]))

Measured memory_bytes: 9292
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, l = map(int, readline().split())
    a = list(map(int, readline().split()))
    b = [a[i] + a[i + 1] for i in range(n - 1)]

    last = -1
    for i, x in enumerate(b, 1):
        if x >= l:
            last = i
            break

    if last == -1:
        print("Impossible")
    else:
        print("Possible")
        for i in range(1, last):
            print(i)
        for i in range(n - 1, last, -1):
            print(i)
        print(last)


if __name__ == '__main__':
    main()


Measured memory_bytes: 91604
#include<bits/stdc++.h>
namespace ZDY{
    #pragma GCC optimize(3)
    #define il __inline__ __attribute__ ((always_inline))
    #define rg register
    #define ll long long
    #define ull unsigned long long
    #define db double
    #define sht short
    #define MB template <class T>il
    #define Fur(i,x,y) for(int i=x;i<=y;++i)
    #define Fdr(i,x,y) for(int i=x;i>=y;--i)
    #define fl(i,x) for(int i=head[x],to;to=e[i].to,i;i=e[i].nxt)
    #define clr(x,y) memset(x,y,sizeof(x))
    #define cpy(x,y) memcpy(x,y,sizeof(x))
    #define fin(s) freopen(s".in","r",stdin)
    #define fout(s) freopen(s".out","w",stdout)
    #define fcin ios::sync_with_stdio(false)
    #define l2(n) (int(log2(n)))
    #define inf 0x3f3f3f3f
    MB T ABS(T x){return x>0?x:-x;}
    MB T MAX(T x,T y){return x>y?x:y;}
    MB T MIN(T x,T y){return x<y?x:y;}
    MB T GCD(T x,T y){return y?GCD(y,x%y):x;}
    MB void SWAP(T &x,T &y){T t=x;x=y;y=t;}
}using namespace ZDY;using namespace std;
namespace IO{const char* ln="\n";const int str=1<<20;struct IN{char buf[str],*s,*t;bool _;IN():s(buf),t(buf),_(0){}il char gc(){return s==t&&((t=(s=buf)+fread(buf,1,str,stdin))==s)?EOF:(*s++);}IN&operator>>(char&ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)_=1;else ch=c;return *this;}IN& operator>>(char* ch){clr(ch,0);if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;*ch=c;ch++;while((c=gc())!=EOF&&!isspace(c))*ch=c,ch++;if(c==EOF)_=1;return *this;}IN& operator>>(string& ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;ch+=c;while((c=gc())!=EOF&&!isspace(c))ch+=c;if(c==EOF)_=1;return *this;}template<typename T>IN&operator>>(T&x){if(_)return *this;char c=gc();bool ff=0;while(c!=EOF&&(c<'0'||c>'9'))ff^=(c=='-'),c=gc();if(c==EOF){_=1;return *this;}x=0;while(c!=EOF&&'0'<=c&&c<='9')x=(x<<3)+(x<<1)+c-48,c=gc();if(c==EOF)_=1;if(ff)x=-x;return *this;}}in;struct OUT{char buf[str],*s,*t;OUT():s(buf),t(buf+str){}~OUT(){fwrite(buf,1,s-buf,stdout);}void pt(char c){(s==t)?(fwrite(s=buf,1,str,stdout),*s++=c):(*s++=c);}OUT&operator<<(const char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(string s){for(int i=0;s[i];i++)pt(s[i]);return *this;}template<typename T>OUT&operator<<(T x){if(!x)return pt('0'),*this;if(x<0)pt('-'),x=-x;char a[30],t=0;while(x)a[t++]=x%10,x/=10;while(t--)pt(a[t]+'0');return *this;}}out;}using namespace IO;
#define N 100011
#define int ull
int n,m;
priority_queue<int>q;
signed main(){
	fcin;
	cin>>n>>m;
	int x;
	Fur(i,1,n)cin>>x,q.push(x);
	while(m--){
		if(q.empty())break;
		int x=q.top();q.pop();
		x>>=1ll;
		q.push(x);
	}
	int ans=0;
	while(!q.empty())ans+=q.top(),q.pop();
	cout<<ans<<endl;
}

Measured memory_bytes: 1400
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for(int n=0;n<N;n++) a[n]=sc.nextInt();
        Arrays.sort(a);
        
        int remove=0;
        int sameElement=1;
        for(int n=1;n<N;n++){
        	if(a[n]==a[n-1]){
        		sameElement++;
        	}else{
        		if(sameElement>=a[n-1]) remove += (sameElement-a[n-1]);
        		else remove += sameElement;
        		sameElement=1;
        	}
        }
        if(sameElement>=a[N-1]) remove += (sameElement-a[N-1]);
        else remove += sameElement;
        
        System.out.println(remove);
        
        
    }
}

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

int main(){
  int a[3];
  string ans;
  cin>> a[0] >> a[1] >> a[2];

  sort(a,a+3);

  if(a[0]+a[1] == a[2]){ans = "Yes";}
  else{ans = "No";}
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main (void){
  int i;
  int x[3000];
  int y[3000];
  for(i = 0 ; i<3000 ; i++){
    scanf("%d %d\n",&x[i],&y[i]);
    if(x[i] == 0 && y[i] == 0){
      break;
    }
  }

  for(int j = 0; j<i ; j++){
      if(x[j] < y[j]){
        printf("%d %d\n",x[j],y[j]);
      }else{
        printf("%d %d\n",y[j],x[j]);
      }
    }
  return 0;
}


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

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;

    vector<pair<int, int> > D;

    for(int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;

        D.push_back({a, b});
    }

    sort(D.begin(), D.end());

    ll ans = 0LL;
    int j = 0;

    while(m > 0) {
        if(D[j].second > m) {
            ans += 1LL * D[j].first * m;
            m = 0;
        }
        else {
            ans += 1LL * D[j].first * D[j].second;
            m -= D[j].second;
        }
        j++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 1400
#include <stdio.h>

int main(void){

	
	int a,i,b[100];

	scanf("%d",&a);
	for(i=0;i<a;i++){
		scanf("%d",&b[i]);
	}

	for(i=a-1;i>=0;i--){
	printf("%d",b[i]);
	if(i!=0){
		printf(" ");
	}
	}

	printf("\n");

	return 0;
}

Measured memory_bytes: 600
x = parse(Int64, readline())
# println(x)

coin500 = 0
coin100 = 0
coin50  = 0
coin10  = 0
coin5   = 0

coin500 = div(x, 500)
x = x - 500*coin500

coin5 = div(x, 5)
x = x - 5*coin5

println(1000coin500 + 5coin5)


Measured memory_bytes: 111076
/*  -*- coding: utf-8 -*-
 *
 * b.cc: D: Simple Knapsack
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;
const int MAX_DW = 3;
const int MAX_K = MAX_DW * MAX_N;

/* typedef */

typedef long long ll;
typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

int wis[MAX_N], vis[MAX_N];
int dp[MAX_N + 1][MAX_N + 1][MAX_K + 1];

/* subroutines */

inline void setmax(int &a, int b) { if (a < b) a = b; }

/* main */

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

  for (int i = 0; i < n; i++) scanf("%d%d", &wis[i], &vis[i]);
  ll w0 = wis[0];
  int maxj = w / w0;
  for (int i = 0; i < n; i++) wis[i] -= w0;

  memset(dp[0], -1, sizeof(dp[0]));
  dp[0][0][0] = 0;

  for (int i = 0; i < n; i++) {
    int &wi = wis[i], &vi = vis[i];
    memcpy(dp[i + 1], dp[i], sizeof(dp[i]));
    for (int j = 0; j <= i && j <= maxj; j++) {
      int maxk = MAX_DW * j;
      for (int k = 0; k <= maxk; k++)
	if (dp[i][j][k] >= 0 && w0 * (j + 1) + (k + wi) <= w)
	  setmax(dp[i + 1][j + 1][k + wi], dp[i][j][k] + vi);
    }
  }

  int maxdp = 0;
  for (int j = 0; j <= n; j++)
    for (int k = 0; k <= MAX_K; k++)
      setmax(maxdp, dp[n][j][k]);
  printf("%d\n", maxdp);
  return 0;
}


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

#define ll unsigned long long int
#define pb push_back
#define mk make_pair
#define mod 1000000007
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;cin>>n;
    int pro=__gcd(n,360);
    pro=(360*n)/pro;
    pro=pro/n;
    cout<<pro;
    return 0;
}


Measured memory_bytes: 3640
/*
How to lambda
  ex) sort(ALL(cont),[](dat a,dat b){return a.l<b.l;});
lower_bound/upper_bound
  1 2 2 2 3 3
    ^lb   ^ub */
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)

#define TEST_ID 1
#define fopn(STR,MODE) fopen((STR).c_str(),MODE)
#define ASSERT(A,B) \
if(A!=B) {\
cerr<< "At line:"<< __LINE__ << endl;\
cerr<< #A << "is '" << A << "'" <<endl;\
cerr<<#B<<"is '"<<B<<"'"<<endl;\
throw "Assertion failed";\
    }

using namespace std;
typedef long long ll;
typedef long double ld;
int N;
ll L[300];
int main() {
    vector<char> buf(1<<24);
    fread(&buf[0],1,buf.size(),stdin);
    istringstream ist(&buf[0]);
    stringstream ost;
    ost<< fixed << setprecision(15);

    ist>>N;
    N*=2;
    REP(i,N)
        ist>>L[i];
    sort(L,L+N);
    ll ans=0;
    REP(i,N/2) {
        ans +=min(L[i*2],L[i*2+1]);
    }
    ost<<ans<<endl;
    string o=ost.str();
    fwrite(o.c_str(),1,o.size(),stdout);
    return 0;
}


Measured memory_bytes: 16640
n = int(input())

d = {}
for i in range(n):
    s = input()
    if s in d.keys():
        d[s] += 1
    else:
        d[s] = 1

m = max(d.values())
keys = [key for key, val in d.items() if val == m]

for i in sorted(keys):
    print(i)

Measured memory_bytes: 32988
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string T,S;
    int a=0;
    cin >>T>>S;
    for(int i=0;i<=2;i++){
    if(T.at(i)==S.at(i)){
        a=a+1;
    }
    }
    cout<<a<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#define INF 10000005

typedef long long ll;

using namespace std;

int calc_digits(ll n){   //桁数計算
    int digits = 0;
    
    while(n > 0)
    n /= 10, digits++;

    return digits;
}

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

    int ans = calc_digits(n);
    for (ll a = 1LL; a * a <= n; a++){
        if(n % a != 0) continue;
        const ll b = n / a;

        const int current = max(calc_digits(a), calc_digits(b));
        if (ans > current){
            ans = current;
        }
    }

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

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

using namespace std;

#define _int64 long long

int a[3000];
_int64 d[1<<17];
_int64 lim[33];

int main()
{
  int n,x,y,i,j,tot;
  _int64 tmp,tt;
  scanf("%d",&n);
  for (i=0;i<n;i++)
    scanf("%d",&a[i]);
  tot=0;
  for (i=0;i<n;i++)
    tot+=a[i];
  memset(d,0,sizeof(d));
  d[0]=1;
  lim[0]=0;
  for (i=1;i<=32;i++)
    lim[i]=lim[i-1]+lim[i-1]+1;
  for (i=0;i<n;i++)
  {
    x=a[i]/32;
    y=a[i]%32;
    //cout<<"x:"<<x<<" "<<y<<endl;
    for (j=(1<<17)-1;j>=0;j--)
      if (d[j]>0)
      {
        tt=d[j];
        if (j+x<(1<<17))
        {
          tmp=((tt&lim[32-y])<<y);
          //cout<<"j+x:"<<j+x<<" "<<tmp<<endl;
          d[j+x]|=tmp;
        }
        if ((j+x+1<(1<<17))&&(y>0))
        {
          tmp=(tt>>(32-y));
          //cout<<"j+x+1:"<<j+x+1<<" "<<tmp<<endl;
          d[j+x+1]|=tmp;
        }
      }
  }
  for (i=0;i<(1<<17);i++)
    for (j=0;j<32;j++)
    {
      if ((((1LL<<j))&d[i])>0)
      {
        //cout<<i*32+j<<endl;
        if (i*32+j+i*32+j>=tot)
        {
          printf("%d\n",i*32+j);
          return 0;
        }
      }
    }
  return 0;
}

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

using namespace std;

//#define _FILES
#define PB push_back
#define MP make_pair
#define X first
#define Y second
const int MAXN = 200005;

int a[MAXN];

int main()
{
    ios_base::sync_with_stdio(false);

    #ifdef _FILES
        freopen("","r",stdin);
        freopen("","w",stdout);
    #endif // _FILES
    int n, k;
    cin >> n >> k;
    for (int i=0;i<n;i++)
    {
        cin >> a[i];
    }

    sort(a, a + n);
    vector<int> d;
    int counter = 1;
    for (int i=1;i<n;i++)
    {
        if (a[i] != a[i-1])
        {
            d.push_back(counter);
            counter = 1;
        }
        else
        {
            counter++;
        }
    }
    d.push_back(counter);
    sort(d.begin(), d.end());
    if (d.size() <= k)
    {
        cout << 0 << endl;
        return 0;
    }

    int ans = 0;
    for (int i=0;i<d.size()-k;i++)
    {
        ans += d[i];
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 2168
// Template
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
#include <complex>
#define rep(i, x) for (int i = 0; i < (x); ++i)
#define rng(i, x, y) for (int i = (x); i < (y); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
void solve();
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    
    ll ans = 0;
    while (true) {
        bool flag = false;
        rep(i, n) {
            ll k = a[i] / n;
            a[i] -= k * n;
            rep(j, n) {
                if (j != i) a[j] += k;
            }
            if (k) flag = true;
            ans += k;
        }
        if (!flag) break;
    }
    
    cout << ans << "\n";
    return;
}


Measured memory_bytes: 3604
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include <ios>
#include <iomanip>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef tuple<ll,ll,ll> Tl;



int atcoder(){
    //入力
    ll a,b,c;
    cin >> a >> b >> c;
    cout << (a+b)*c/2 << ENT;
    
    return 0;
}

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


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

s = list(input())

for i, posi in enumerate(s):
    num = i+1
    if num % 2 == 0 and posi == 'R':
        print('No')
        exit(0)
    elif num % 2 != 0 and posi == 'L':
        print('No')
        exit(0)

print('Yes')


Measured memory_bytes: 9100
import itertools
import math

n=int(input())
town=[]
for i in range(n):
    town.append([int(i) for i in input().split()])

dist_sum=0
for per in itertools.permutations(town,n):
    for i in range(n-1):
        dist_sum += math.sqrt((per[i][0]-per[i+1][0])**2+(per[i][1]-per[i+1][1])**2)
print(dist_sum/math.factorial(n))




Measured memory_bytes: 9132
a,b,c=map(int,input().split())
ans="No"
if a==b:
    if a==c:
        pass
    else:
        ans="Yes"
elif a==c:
    if a==b:
        pass
    else:
        ans="Yes"
elif b==c:
    if b==a:
        pass
    else:
        ans="Yes"
print(ans)

Measured memory_bytes: 3060
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

const MOD: usize = 1e+9 as usize + 7;
fn main() {
    let n = read::<usize>();
    let mut ans = 0;
    let mut dcnts = vec![0; 2 * n + 10];
    let mut cnt = 1;
    let mut dcnt = 0;
    for i in 0..n * 2 {
        dcnt = (dcnt + dcnts[i]) % MOD;
        cnt = (cnt + dcnt) % MOD;
        if i < n - 1 {
            ans = (ans + cnt * (n - 1) % MOD * (n - 1)) % MOD;
            dcnts[i + 3] = (dcnts[i + 3] + cnt) % MOD;
            dcnts[i + n + 2] = (dcnts[i + n + 2] + MOD - cnt) % MOD;
        } else if i == n - 1 {
            ans = (ans + cnt * n) % MOD;
        } else {
            ans = (ans + dcnt) % MOD;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 20732