akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];

    vi hh = a;
    sort(all(hh));
    hh.erase(unique(all(hh)), hh.end());
    sort(all(a));

    if(hh.size() == 1) {
        if(hh[0] == n-1 or hh[0] * 2 <= n) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else if(hh.size() > 2) {
        cout << "No" << endl;
    } else {
        if(hh[1] - hh[0] != 1) cout << "No" << endl;
        else {
            auto itr = equal_range(all(a), hh[0]);
            int num = itr.second - itr.first;
            int nnu = n-num;
            if(nnu >= (hh[1]-num) * 2 and hh[1] > num) {
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        }
    }
}

Measured memory_bytes: 3992
#include<iostream>
#include<algorithm>
using namespace std;
using ll=long long;
ll N,M,K;
bool p[1000001];
int main(){
    cin>>N>>M>>K;
    for(int i{1};i<=M;++i){
        int res{N*i};p[res]=1;
        for(int j{1};j<=N;++j){
            res+=M-i*2;
            if(res>=0)p[res]=1;
        }
    }
    for(int i{1};i<=N;++i){
        int res{M*i};p[res]=1;
        for(int j{1};j<=M;++j){
            res+=N-i*2;
            if(res>=0)p[res]=1;
        }
    }
    cout<<(p[K]?"Yes":"No")<<endl;
}
        


Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;

int a[100];
int b[100];

int main() {
  int n,m,x,y;
  cin >> n >> m >> x >> y;
  rep(i, n)
    cin >> a[i];
  rep(i, m)
    cin >> b[i];
  sort(a, a+n);
  sort(b, b+m);
  int st = a[n-1];
  int ed = b[0];
  while(st++ < ed){
    if(x < st && st <= y){
      cout << "No War" << endl;
      return 0;
    }
  }
  cout << "War" << endl;
}



Measured memory_bytes: 256
def main():

    n, ma, mb = map(int, input().split())
    ABC = []
    for i in range(n):
        a, b, c = map(int, input().split())
        ABC.append((a, b, c))

    M = 401
    INF = 10**18
    dp = [[[INF]*M for i in range(M)] for j in range(n+1)]
    dp[0][0][0] = 0
    import copy
    for i in range(n):
        dp[i+1] = copy.deepcopy(dp[i])
        a, b, c = ABC[i]
        for j in range(M):
            for k in range(M):
                nj = j+a
                nk = k+b
                if 0 <= nj < M and 0 <= nk < M:
                    dp[i+1][nj][nk] = min(dp[i+1][nj][nk], dp[i][j][k]+c)

    import math
    ans = INF
    for j in range(1, M):
        for k in range(1, M):
            g = math.gcd(j, k)
            if j//g == ma and k//g == mb:
                ans = min(ans, dp[n][j][k])
    if ans == INF:
        print(-1)
    else:
        print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 182636
#include<iostream>
using namespace std;
int coord[21][21];
int loc_i=10,loc_j=10;

void func_Juge(char c,int l){
  if(c=='N'){
    for(int i=0;i<l;i++){
      loc_i++;
      if(coord[loc_i][loc_j]==1)coord[loc_i][loc_j]=0;
    }
  }else if(c=='S'){
    for(int i=0;i<l;i++){
      loc_i--;
      if(coord[loc_i][loc_j]==1)coord[loc_i][loc_j]=0;
    }
  }else if(c=='E'){
    for(int i=0;i<l;i++){
      loc_j++;
   if(coord[loc_i][loc_j]==1)coord[loc_i][loc_j]=0;
    }
  }else if(c=='W'){
    for(int i=0;i<l;i++){
      loc_j--;
      if(coord[loc_i][loc_j]==1)coord[loc_i][loc_j]=0;
    }
  }
}

int main(){
  int N,M;
 
  while(1){
    cin>>N;
    loc_i=10;
    loc_j=10;
    if(N==0)break;

    for(int i=0;i<21;i++){
      for(int j=0;j<21;j++){
	coord[i][j]=0;
      }
    }

    for(int i=0;i<N;i++){
	int x,y;
	cin>>x>>y;
	coord[y][x]=1;
    }

    cin>>M;
    for(int i=0;i<M;i++){
      char c;
      int l;
      cin>>c>>l;
      func_Juge(c,l);
  }

    int flag=1;
    for(int i=0;i<21;i++){
      for(int j=0;j<21;j++){
	if(coord[i][j]!=0){
	  flag=0;
	  break;
	}
      }
    }

    if(flag==0)cout<<"No"<<endl;
    else if(flag==1)cout<<"Yes"<<endl;
  }   

  return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n,a,b;
    cin>>n;
    vector<int>x(n),y(n);
    for(int i=0;i<n;i++)cin>>x[i];
    y=x;
    sort(y.begin(),y.end());
    a=y[n/2-1],b=y[n/2];
    for(int i=0;i<n;i++)cout<<(x[i]<=y[n/2-1]?y[n/2]:y[n/2-1])<<endl;
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N;
	string S;
	cin >> N >> S;
	ll x = 0;
	ll res = 0;
	REP(i, N){
		x += (S[i]=='I'?+1:-1);
		res = max(res, x);
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define F first
#define S secon
int main(){
  string s,t;
  cin>>s>>t;
  int p=0,f=0;
  for(int i=s.size()-t.size();i>=0;i--){
    p=0;
    r(j,t.size()){
      if(s[i+j]==t[j]||s[i+j]=='?')p++;
    }
    if(p==t.size()){
      r(j,t.size())s[i+j]=t[j];f++;
      break;f++;
    }
  }
  if(f){
  r(i,s.size()){
    if(s[i]=='?')cout<<'a';
    else cout<<s[i];
  }cout<<endl;}
  else cout<<"UNRESTORABLE"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,minj,count=0;
  int a[101]={};
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
 
  for(int i=0;i<n;i++){
    minj=i;
    for(int j=i;j<n;j++)if(a[j]<a[minj])minj=j;
    if(i!=minj){
      swap(a[i],a[minj]);// 関数をかく。
      count++;
    }
  }
  for(int i=0;i<n-1;i++)cout<<a[i]<<' ';
  cout<<a[n-1]<<endl<<count<<endl;
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N, M;
vector<pii> g[100];
int d[100][2];

int main() {
	while (cin >> N >> M, N || M) {
		REP(i, N) g[i].clear();
		
		REP(i, M) {
			int a, b, c;
			scanf("%d %d %d", &a, &b, &c);
			a--; b--;
			g[a].push_back(pii(b, c));
			g[b].push_back(pii(a, c));
		}
		
		vector<pii> add_edge;
		REP(i, N) {
			queue<int> que;
			REP(j, g[i].size()) que.push(g[i][j].fi);
			
			bool done[100] = {};
			while (!que.empty()) {
				int u = que.front(); que.pop();
				REP(j, g[u].size()) done[g[u][j].fi] = true;
			}
			
			REP(j, N) if (done[j]) add_edge.push_back(pii(i, j));
		}
		
		REP(i, add_edge.size()) {
			pii &e = add_edge[i];
			g[e.fi].push_back(pii(e.se, 0));
		}
		
		fill(d[0], d[N], INF);
		
		priority_queue<pip, vector<pip>, greater<pip> > pq; // cost, pos, state
		pq.push(pip(0, pii(0, 0)));
		d[0][0] = 0;
		
		while (!pq.empty()) {
			pip now = pq.top(); pq.pop();
			
			int cost = now.fi;
			int u = now.se.fi;
			int s = now.se.se;
			
			if (d[u][s] < cost) continue;
			
			REP(i, g[u].size()) {
				int v = g[u][i].fi;
				int c = g[u][i].se;
				
				if (c == 0) {
					if (s == 0 && chmin(d[v][1], cost)) pq.push(pip(cost, pii(v, 1)));
				}
				else {
					if (chmin(d[v][s], cost + c)) pq.push(pip(cost + c, pii(v, s)));
				}
			}
		}
		
		int ans = min(d[N - 1][0], d[N - 1][1]);
		cout << ans << endl;
	}

	
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    int a = 0;
    for (int i = 0; i < 3; i++) {
        if(s.at(i) == 'o')a++;
    }
    cout << 700 + 100*a <<endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef pair<ll,P>  PP;
typedef vector<ll> Vector;
typedef vector<Vector> DVector;
typedef priority_queue<PP, vector<PP>, greater<PP>> PPQueue;

#define fi          first
#define se          second
#define sfi         se.fi
#define sse         se.se
#define pb          push_back
#define INF         INT_MAX
#define MOD         1000000007
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define uni(x)      x.erase(unique(all(x)),x.end())
#define ub(x,y)     (upper_bound(all(x),y)-x.begin())
#define lb(x,y)     (lower_bound(all(x),y)-x.begin())
#define rep(i,n)    repl(i,0,n-1)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<ll>())
#define mkp(x,y)    make_pair(x,y)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)
ll n,a,b;
Vector v;

//// コンビネーション(using double)
double comb(int n,int r){
  if(n<r)return 0.0;
  if(n-r<r)r=n-r;
  double res=1;
  for(int i=0;i<r;i++){
    res*=n;
    n--;
    res/=i+1;
  }
  return res;
}

int main(){
  cin.sync_with_stdio(false);
  cout.precision(20);
  cin >> n >> a >> b;
  v.resize(n);
  rep(i,n)cin >> v[i];
  dsort(v);
  double sum = 0;
  rep(i,a)sum+=v[i];
  cout << fixed << sum/(double)a << endl;

  ll x = 0,y = 0;
  rep(i,n){
    if(v[i] == v[a-1]){
      x++;
      if(i<a)y++;
    }
  }

  ll cnt = 0;
  if(y == a)repl(i,a,b)cnt+= comb(x,i);
  else cnt += comb(x,y);
  cout << cnt << endl;
}


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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    int A;
    string B;
    cin >> A >> B;
    string b_s = B.substr(0, 1) + B.substr(2, 2);
    int b_i = atoi(b_s.c_str());
    int ans = A * b_i;
    ans /= 100;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3656
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    int n,a;
    cin >> n >> a;
    cout << n*n-a << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <math.h>
#include <string>
#include <map>
#include <functional>
#include <algorithm>
#include <stack> 
#include <iomanip>
#include <stdio.h>
#include <set>
#include <array>
using namespace std; 

long long zeroes(long long n) {
	if (n % 2 || n < 10) return 0;
	long long tmp = n;
	long long res = 0;
	long long power = 0;
	long long max = 1;
	while (tmp >= 10) {
		++power;
		max *= 10;
		tmp /= 10;
	}
	max *= tmp;
	for (int i = 0; i < power; ++i) {
		res += (power - i) * tmp;
		tmp *= (9 + (i > 0));
	}
	return res + zeroes(n - max);
}

void dfs_a(int v, int turn, const vector<vector<int>>& graph, vector<int>& aoki) {
	if (aoki[v] >= 0) return;
	aoki[v] = turn++;
	for (auto u : graph[v])
		dfs_a(u, turn, graph, aoki);
}

void dfs_t(int v, int turn, const vector<vector<int>>& graph, const vector<int>& aoki, vector<int>& taka) {
	if (taka[v] >= 0 || aoki[v] <= turn) return;
	taka[v] = turn++;
	for (auto u : graph[v])
		dfs_t(u, turn, graph, aoki, taka);
}

int main()
{
	int n, u, v;
	cin >> n >> u >> v;
	--u;
	--v;
	vector<vector<int>> graph(n);
	for (int i = 0; i < n - 1; ++i) {
		int x, y;
		cin >> x >> y;
		--x; --y;
		graph[x].push_back(y);
		graph[y].push_back(x);
	}
	vector<int> aoki(n, -1);
	vector<int> taka(n, -1);
	dfs_a(v, 0, graph, aoki);
	dfs_t(u, 0, graph, aoki, taka);
	int max = 0;
	for (int i = 0; i < n; ++i) {
		if (taka[i] >= 0 && aoki[i] > max)
			max = aoki[i];
	}
	cout << max - 1 << endl;
	return 0;
}


Measured memory_bytes: 10624
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MOD=1e9+7;
static const ll MAX=101010;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/




int main(void) {
  ll i, j, k;
  
  ll N;
  cin >> N;
  string s;
  cin >> s;
  
  ll cnt[26]={};
  for(i=0; i<N; i++) cnt[s[i]-'a']++;
  
  ll ans=1;
  for(i=0; i<26; i++) moC(ans, *, cnt[i]+1);
  ans--;
  pt(ans);
  
}




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

int main() {
  int A,B,X;
  cin>>A>>B>>X;
  if(A>X){
    cout<<"NO"<<endl;
  }
  else{
    if(A+B>=X){
      cout<<"YES"<<endl;
    }
    else{
      cout<<"NO"<<endl;
    }
  }
}


Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
print(
    ''.join(
        [
            'U' * (ty - sy),
            'R' * (tx - sx),
            'D' * (ty - sy),
            'L' * (tx - sx + 1),
            'U' * (ty - sy + 1),
            'R' * (tx - sx + 1),
            'D',
            'R',
            'D' * (ty - sy + 1),
            'L' * (tx - sx + 1),
            'U'
        ]
    )
)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << endl
#define RETURN(x)    \
  cout << x << endl; \
  return 0
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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;
}

signed main() {
  init();
  ll K, S;
  cin >> K >> S;

  ll ans = 0;
  rep(x, K + 1) {
    rep(y, K + 1) {
      ll z = S - x - y;
      if (0 <= z && z <= K
       && x + y + z == S) ans++;
    }
  }
  ANS;
  return 0;
}

Measured memory_bytes: 3628
from sys import stdin

def ans():
    _in = [_.rstrip() for _ in stdin.readlines()]
    X = int(_in[0])  # type:int
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    for A in range(-118,120):
        for B in range(-119,A):
            if A**5-B**5 == X:
                break
        else:
            continue
        break
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(A, B)


if __name__ == "__main__":
    #main()
    ans()

Measured memory_bytes: 63664
stdins = input().split()
x = int(stdins[0])
y = int(stdins[1])

ans = "No"
for n_tr in range(0, x + 1):
    n_km = x - n_tr
    if y == n_tr*2 + n_km*4:
        ans = "Yes"
        break

print(ans)


Measured memory_bytes: 9144
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60
#define MOD 1000000007

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j
#define fix(i) fixed << setprecision(i)
#define so(a) sort(begin(a), end(a))
#define soR(a) sort(begin(a), end(a), greater<ll>())
#define sum(a) accumulate(begin(a), end(a), 0)


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; }

int main(){
    ll N, K;
    cin >> N >> K;
    
    ll temp = N % K;
    cout << min(temp, abs(K - temp)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long N=40+2,MAX=(1<<17)+10,MOD=1e9+7;
long long n,x,y,z,f[N][MAX],sum=1,tot,cnt,ans;
void init(){
	scanf("%lld%lld%lld%lld",&n,&x,&y,&z);
}
void work(){
	for(int i=0;++i<=n;(sum*=10)%=MOD);
	cnt=(1<<x+y+z)-1;
	tot=(1<<x-1)|(1<<x+y-1)|(1<<x+y+z-1);
	f[0][0]=1;
	for(int i=0;++i<=n;) for(int j=-1;++j<=cnt;) for(int h=0;++h<=10;
		ans=(j<<h)|(1<<h-1),ans&=cnt,(ans&tot)==tot?:(f[i][ans]+=f[i-1][j])%=MOD);
	for(int i=-1;++i<=cnt;((sum-=f[n][i])+=MOD)%=MOD);
}
void prin(){
	printf("%lld",sum);
}
int main(){
	init();
	work();
	prin();
	return 0;
}

Measured memory_bytes: 42240
#include<bits/stdc++.h>
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    cout<<a*b<<nl;
    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final List<Integer> list = new ArrayList<>();
    final List<Integer> list2 = new ArrayList<>();
    //final List<Long> list3 = new ArrayList<>();

    int a = sc.nextInt();
    int b = sc.nextInt();

    if(b >= a){
        System.out.println(a);
    }else{
        System.out.println(a - 1);
    }

    

   

    

    




    







}
}

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

int main() {
  int a, b, flag=0;
  string s, message;
  cin >> a >> b;
  cin >> s;
  for (int i = 0; i <= a+b; i++) {
    if (i == a) {
      if (s[i] != '-') {
	flag = 1;
	break;
      }
    }
    else if (isdigit(s[i])==0) {
      flag = 1;
      break;
    }
  }
  if (flag == 1) message = "No";
  else message = "Yes";
  cout << message << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val a = Array(n) { sc.nextLong() }
    val dp = Array(n + 1) { Array(n + 1) { 0L } }
    val b = (0 until n).map { a[it] to it }.sortedByDescending { it.first }.toList()
    for (m in 0 until n) {
        for (i in 0..m) {
            val j = m - i
            dp[i + 1][j] = maxOf(dp[i + 1][j], dp[i][j] + b[m].first * Math.abs(b[m].second - i))
            dp[i][j + 1] = maxOf(dp[i][j + 1], dp[i][j] + b[m].first * Math.abs(b[m].second - (n - 1 - j)))
        }
    }
    var max = 0L
    for (i in 0..n) {
        max = maxOf(max, dp[i][n - i])
    }
    println(max)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


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

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

typedef long long ll;
typedef long long int64;

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

  vector<int> l(n);
  for(int& val: l) cin >> val;

  int p = 0;
  int cnt = 1;

  for(int i=1; i<n+1; i++){
    p += l[i-1];
    if(p > x) break;
    cnt++;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]

use std::cmp;
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::ops::*;
use std::process::exit;
use std::str::FromStr;

pub const MOD: usize = 1000000007;

fn main() {
    let n: usize = input();
    let s1: Vec<_> = input::<String>().chars().collect::<Vec<_>>();
    let s2: Vec<_> = input::<String>().chars().collect::<Vec<_>>();

    let mut v = Vec::new();
    let mut i = 0;
    while i < n {
        if s1[i] == s2[i] {
            v.push(true);
            i += 1;
        } else {
            v.push(false);
            i += 2;
        }
    }

    let mut ans = if *v.first().unwrap() {
        3
    } else {
        6
    };

    for (a, b) in v.windows(2).map(|x| (x[0], x[1])) {
        ans *= match (a, b) {
            (true, true) => 2,
            (true, false) => 2,
            (false, true) => 1,
            (false, false) => 3,
        };
        ans %= MOD;
    }

    println!("{}", ans);
}

pub fn input<T: FromStr>() -> T {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}

pub fn input_vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>()
}

pub fn input_lines<T: FromStr>(l: usize) -> Vec<T> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input());
    }
    res
}

pub fn input_lines_two<T: FromStr, U: FromStr>(l: usize) -> Vec<(T, U)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_two());
    }
    res
}

pub fn input_lines_three<T: FromStr, U: FromStr, V: FromStr>(l: usize) -> Vec<(T, U, V)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_three());
    }
    res
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}


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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
        static void SolveA()
        {
            var o = ReadAndParseIntArr();
            int x = o[0];
            int y = o[1];
            int z = o[2];
            long ans = (long)Math.Floor((double)(x - z) / (y + z));
            Console.WriteLine(ans);
        }
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if( x == 2) { return true; }
            if( x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while( i * i <= x)
            {
                if( x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }

        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

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

using namespace std;

int main(){
        int n;
        cin >> n;
        vector <int> v(n);
        for(int i = 0; i < n ; i++){
                cin >> v[i];
        }
        sort(v.begin(),v.end());
        reverse(v.begin(),v.end());

        stack <double> st;
        
        for(int i = 0; i < n; i++){
                st.push(v[i]);        
        }
        while(st.size() > 1){
                double a = st.top();
                st.pop();
                double b = st.top();
                st.pop();
                st.push((a+b)/2);
        }
        cout << st.top() << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"bufio"
	"os"
	"strings"
	"strconv"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	input :=  splitAndAtoi(nextLine(stdin))
	a, b := input[0], input[1]

	as := strconv.Itoa(a)
	r1 := loopString(as, b)

	bs := strconv.Itoa(b)
	r2 := loopString(bs, a)

	if (r1 <= r2) {
		fmt.Printf("%s", r1)
	}else {
		fmt.Printf("%s", r2)
	}
}


func loopString(a string, bi int) string {
	r := ""
	for i := 0; i < bi; i++ {
		r += a
	}
	return r
}

func splitAndAtoi(s string) []int {
	ss := strings.Split(s, " ")
	var r []int
	for _, s := range ss {
		i, _ := strconv.Atoi(s)
		r = append(r, i)
	}

	return r
}

func nextNumber(s *bufio.Scanner) int {
	i, _ := strconv.Atoi(nextLine(s))
	return i
}

func nextLine(s *bufio.Scanner) string {
	s.Scan()
	return s.Text()
}

func debug(s string) {
	fmt.Println(s)
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<ll>
#define vvint vector<vint>
#define P pair<ll,ll>
#define INT_MAX 2147483647
#define MOD 1000000007
#define PI 3.14159265358979323846
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;

#define MAX 1000000000000



int main(void) {
	ll n; cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n;i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			ans += i;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3680
#include <iostream>
#include <algorithm>

#include <cmath>
#include <string>

using namespace std;

int main() {

  int start = -1;
  int end = -1;
  string s;

  cin >> s;

  // for (unsigned int i = 0; i < s.length(); ++i) {
  //   if (i % 2 == 0) {
  //     cout << s[i];
  //   }
  // }

  for (unsigned int i = 0; i < s.length(); ++i) {
    if (s[i] == 'A' && start == -1) {
      start = i;
    }
    if (s[i] == 'Z') {
      end = i;
    }
  }
  
  
  cout << end - start + 1 << endl;
  
  return 0;
}


Measured memory_bytes: 640
N,P = map(int,input().split())
A = list(map(lambda x:int(x)%2,input().split()))
DP = [[0]*1000 for i in range(N+1)]
DP[0][0] = 1
for i in range(1,N+1):
    DP[i][0] = 1
    x = A[i-1]
    if x==0:
        DP[i][1] = DP[i-1][1]
    else:
        DP[i][1] = DP[i-1][1]+DP[i-1][0]
    for j in range(2,900):
        if x==0:
            DP[i][j] = DP[i-1][j-2]+DP[i-1][j]
        else:
            DP[i][j] = DP[i-1][j-1]+DP[i-1][j]
cnt = 0
for i in range(1000):
    if i%2==P:
        cnt += DP[N][i]
print(cnt)

Measured memory_bytes: 3444
def solve():
  k, n = list(map(int, input().split()))
  a = list(map(int, input().split()))

  dist = [a[i + 1] - a[i] for i in range(n - 1)]
  dist.append(a[0] + k - a[n - 1])
  
  max_dist = max(dist)
  
  print(k - max_dist)

if __name__ == "__main__":
  solve()

Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl
#define INF 1000000000000000000LL

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << ", ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main()
{
	ll n,pp,qq,cnt=0;
	ll a[]={1,2,3,4,5,6,7,8};
	cin >> n;
	vll p(n),q(n);
	rep(i,n) cin >> p[i];
	rep(i,n) cin >> q[i];
	do{
		cnt++;
		bool bp=true,bq=true;
		rep(i,n){
			if(a[i]!=p[i]) bp=false;
			if(a[i]!=q[i]) bq=false;
		}
		if(bp) pp=cnt;
		if(bq) qq=cnt;
	}while(next_permutation(a,a+n));
	cout << abs(pp-qq) << endl;
	return 0;
}


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

int main(){
	int n ; cin >> n ;
	int u = n/100 ;
	int l = n%100 ;
	string s ;
	if(1<=u&&u<=12&&1<=l&&l<=12) s = "AMBIGUOUS" ;
	else if(1<=u&&u<=12) s = "MMYY" ;
	else if(1<=l&&l<=12) s = "YYMM" ;
	else s = "NA" ;
	cout << s << endl ;
}

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

int ar[1234];

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

   string s; cin >> s;
   for (size_t i = 0; i < s.size(); i++)
   {
      ar[s[i]]++;
   }
   int y = 1;
   for (size_t i = 0; i < 1234; i++)
   {
      if (1 < ar[i])
         y = 0;
   }
      cout << (y ? "yes": "no")<< "\n";
   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, a, b;
	
	scanf("%d", &n);
	scanf("%d", &a);
	scanf("%d", &b);
	
	if (n * a <= b){
		printf("%d\n", n * a);
	}
	else if (n * a > b){
		printf("%d\n", b);
	}
	
	return (0);
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>

using namespace std;


int main(){
    while(true){
        bool arr[1000000]={false};
        int n,a,b;
        cin >> n >> a >>b;
        if(n==0&&a==0&&b==0)return 0;
        if(a>b){
            int t=b;
            b=a;
            a=t;
        }

        arr[a]=true;
        arr[b]=true;
        

        while(true){
            bool f1=false,f2=false;

            for(int i=1;i<=n-a;i++){
                if(arr[i] && !arr[i+a]){
                    f1=true;
                    arr[i+a]=true;
                }
            }
            for(int i=1;i<=n-b;i++){
                if(arr[i] && !arr[i+b]){
                    f2=true;
                    arr[i+b]=true;
                }
            }
            if(!(f1||f2))break;
        }
        int ans=0;
        for(int i=1;i<=n;i++){
            if(!arr[i])ans++;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1840
import sys
def s():
 n,k=map(int,input().split())
 w=list(map(int,sys.stdin.readlines()))
 def f():
  c=t=0
  for j in w:
   t+=j
   if t>m:
    t=j
    c+=1
    if c>=k:return 0
  return 1
 l,r=max(w),sum(w)
 while l<r:
  m=(l+r)//2
  if f():r=m
  else:l=m+1
 print(r)
if'__main__'==__name__:s()


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

int main(int argc, char const *argv[])
{
	int n,k;
	cin>>n>>k;
	long long a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	multiset<long long> b;
	for (int i = 0; i < n; ++i)
	{
		long long s=0LL;
		for (int j = i; j < n; ++j)
		{
			s+=a[j];
			b.insert(s);
		}
	}
	long long ans=0LL;
	for (int i = 50; i >= 0; --i)
	 {
	 	int cnt=0;
	 	for (auto v:b)
	 	{
	 		if ((v&(1LL<<i))>0)
	 		{
	 			++cnt;
	 		}
	 	}
	 	if (cnt>=k)
	 	{
	 		ans+=(1LL<<i);
	 		for (auto itr = b.begin(); itr != b.end();)
	 		{
	 			if (((*itr)&(1LL<<i))==0LL)
	 			{
	 				itr=b.erase(itr);
	 			}
	 			else
	 			{
	 				++itr;
	 			}
	 		}
	 	}
	} 
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 25728
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n, sum = 0;
  cin >> n;
  
  rep(i, n)
  {
    int l, r;
    cin >> l >> r;
    sum += (r-l+1);
  }

  cout << sum <<endl;

}


Measured memory_bytes: 3564
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const int mod=1e9+7;
const vi emp;
const int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int n;

int main(){
	cin>>n;
	int sum=0;
	vi a;
	int flag;
	for(int i=1;i<=n;i++){
		sum+=i;
		a.push_back(i);
		if(sum>=n){
			flag=sum-n;
			break;
		}
	}
	for(int i=0;i<a.size();i++) if(a[i]!=flag) cout<<a[i]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int n; cin >> n;
  vi arr(2*n);
  rep(i,2*n) cin >> arr[i];
  sort(all(arr));
  int ans = 0;
  rep(i,n) ans += arr[2*i];
  cout << ans << endl;
  return 0;
}


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

int main() {
    int N,M; cin>>N>>M;
    vector<int> num(N,1);
    vector<bool> red(N,false);
    red[0]=true;

    for(int i=0;i<M;i++){
        int x,y; cin>>x>>y;
        if(red[x-1]==true)red[y-1]=true;
        num[x-1]=num[x-1]-1;
        num[y-1]=num[y-1]+1;
        if(num[x-1]==0)red[x-1]=false;
    }
    int count=0;
    for(int i=0;i<N;i++){
        if(red[i]==true)count++;
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main()
{
	char a[100];
	int i,j,t;
	while(~scanf("%d%d",&i,&j))
	{
	for(int y=0;y<j+2;y++)
		printf("#");
		printf("\n");
		for(int s=0;s<i;s++) 
		{
				scanf("%s",&a);
				int k=strlen(a);
		    		printf("#");
				printf("%s",a);
				printf("#\n");
	}
		for(int y=0;y<j+2;y++)
		printf("#");
		printf("\n");
		
	}
}

Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
using namespace std;
const long long NR=110;
char s[NR];
long long l,k,ans,n,a[NR],b[NR];
bool flag;
int main()
{
	scanf("%s\n%lld",s,&k);
	while(s[l])
	{
		l++;
	}
	for(long long i=0;i<l;i++)
	{
		a[i+1]=s[i]-'0';
	}
	if(k==1)
	{
		for(long long i=1;i<=l;i++)
		{
			for(long long x=1;x<=9;x++)
			{
				long long tmp=b[i];
				b[i]=x;
				flag=1;
				for(long long w=1;w<=l;w++)
				{
					if(b[w]>a[w])
					{
						flag=0;
						break;
					}
					if(b[w]<a[w])
					{
						flag=1;
						break;
					}
				}
				ans+=flag;
				b[i]=tmp;
			}
		}
		printf("%lld",ans);
		return 0;
	}
	if(k==2)
	{
		for(long long i=1;i<=l;i++)
		{
			for(long long j=i+1;j<=l;j++)
			{
				for(long long x=1;x<=9;x++)
				{
					for(long long y=1;y<=9;y++)
					{
						long long tmp=b[i],TMP=b[j];
						b[i]=x;
						b[j]=y;
						flag=1;
						for(long long w=1;w<=l;w++)
						{
							if(b[w]>a[w])
							{
								flag=0;
								break;
							}
							if(b[w]<a[w])
							{
								flag=1;
								break;
							}
						}
						ans+=flag;
						b[i]=tmp;
						b[j]=TMP;
					}
				}
			}
		}
		printf("%lld",ans);
		return 0;
	}
	for(long long i=1;i<=l;i++)
	{
		for(long long j=i+1;j<=l;j++)
		{
			for(long long k=j+1;k<=l;k++)
			{
				long long L,r,mid;
				L=0;
				r=729;
				while((r-L)>1)
				{
					mid=(L+r)>>1;
					long long tmp=b[i],TMP=b[j],temp=b[k];
					b[i]=(mid/81)+1;
					b[j]=((mid/9)%9)+1;
					b[k]=(mid%9)+1;
					flag=1;
					for(long long w=1;w<=l;w++)
					{
						if(b[w]>a[w])
						{
							flag=0;
							break;
						}
						if(b[w]<a[w])
						{
							flag=1;
							break;
						}
					}
					b[i]=tmp;
					b[j]=TMP;
					b[k]=temp;
					if(flag)
					{
						L=mid;
					}
					else
					{
						r=mid;
					}
				}
				ans+=(L+1);
				long long tmp=b[i],TMP=b[j],temp=b[k];
					b[i]=b[j]=b[k]=1;
					flag=1;
					for(long long w=1;w<=l;w++)
					{
						if(b[w]>a[w])
						{
							flag=0;
							break;
						}
						if(b[w]<a[w])
						{
							flag=1;
							break;
						}
					}
					b[i]=tmp;
					b[j]=TMP;
					b[k]=temp;
					if(flag==0)
					{
						ans--;
					}
			}
		} 
	}
	printf("%lld",ans);
	return 0;
}

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

using namespace std;

    template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
    if ((first == last) || (first == k) || (last == k))
        return false;
    Iterator itr1 = first;
    Iterator itr2 = last;
    ++itr1;
    if (last == itr1)
        return false;
    itr1 = last;
    --itr1;
    itr1 = k;
    --itr2;
    while (first != itr1)
    {
        if (*--itr1 < *itr2)
        {
            Iterator j = k;
            while (!(*itr1 < *j)) ++j;
            std::iter_swap(itr1,j);
            ++itr1;
            ++j;
            itr2 = k;
            std::rotate(itr1,j,last);
            while (last != j)
            {
                ++j;
                ++itr2;
            }
            std::rotate(k,itr2,last);
            return true;
        }
    }
    std::rotate(first,k,last);
    return false;
}

int main(){
    vector<int> v;
    for(int i=0; i < 10; i++) v.push_back(i);

    int n, s;
    while(cin >> n >> s){
        int ret = 0;
        do{
            int sum = 0;
            for(int j=0; j < n; j++) sum += v[j]*(j+1);
            if(sum < s) continue;
            else if(sum == s){ret++; continue;}
            vector<int> vv;
            for(int i=0; i < n; i++) vv.push_back(v[i]);
            do{
                int sum = 0;
                for(int j=0; j < n; j++) sum += vv[j]*(j+1);
                if(sum == s) ret++;
            }while(next_permutation(vv.begin(), vv.end()));
        }while(next_combination(v.begin(), v.begin()+n, v.end()));
        cout << ret << endl;
    }
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    ll ans=0;
    ans+=(ll)(n/k)*(n/k)*(n/k);
    if (k%2==0){
        ll c = (n+k/2)/k;
        ans+=c*c*c;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc129/tasks/abc129_c
# 典型的なDP


from copy import deepcopy


def full(shape, full_value):
    if isinstance(shape, tuple):
        if len(shape) == 2:
            return [[full_value] * shape[1] for _ in range(shape[0])]
        else:
            import numpy as np
            return np.full(shape, full_value).tolist()
    else:
        return [full_value] * shape


MOD = 10**9 + 7
# dp[i]をi段目までの通りの数とする。
N, M = list(map(int, input().split()))
to_zero = full((N + 1), False)
for _ in range(M):
    to_zero[int(input())] = True  # 床が抜けているところ

# dpテーブルの用意
dp = full((N + 1), -1)
dp[0] = 1
dp[1] = 0 if to_zero[1] else 1
for i in range(2, N + 1):
    dp[i] = 0 if to_zero[i] else dp[i - 2] + dp[i - 1]
    if dp[i] > MOD:
        dp[i] %= MOD

print(dp[-1])


Measured memory_bytes: 8180
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    long a[n+2];
    long sum = 0;
    a[0] = a[n+1] = 0;
    for(int i = 1;i<=n;i++){
        cin >> a[i];
        sum+=abs(a[i]-a[i-1]);
    }
    sum+=abs(a[n]);
    for(int i = 1;i<=n;i++){
        cout << sum-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]) << endl;
    }
}

Measured memory_bytes: 2048
#include<stdio.h>
#include<stdlib.h>

int main(){
  int n,t,a,i,mini;
  double kionsa,min=1000.0;
  scanf("%d\n%d %d\n",&n,&t,&a);
  int h[n];
  for(i=0;i<n;i++){
    scanf("%d ",&h[i]);
    kionsa=fabs(t-0.006*h[i]-a);
    if(kionsa<min){
      min=kionsa;
      mini=i;
    }
  }
  printf("%d",mini+1);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ok cout<<"ok"<<endl
#define dbg(x) cout<<(#x)<<" is "<<x<<endl
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
using namespace std;
typedef long long ll;
const int N=2*100009;
int main()
{
   fastio;
   int k,n,i,ans,ar[N];
   cin>>k>>n;
   for(i=1; i<=n; i++) cin>>ar[i];

   ans=ar[n]-ar[1];
   for(i=2; i<=n; i++)
   {
   	 ans=min(ans,k-ar[i]+ar[i-1]);
   }	
   cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1000000007;

void add(ll &a, ll b) {
    a += b;
    while(a >= MOD) a -= MOD;
}

int main(){
    ll N;
    string S;
    cin >> N >> S;
    ll ans = 0;
    ll cnt[26] = {};
    for(ll i = N - 1; i >= 0; i--){
        ll cha = (ll)S[i] - 97;
        cnt[cha]++;
        ll c = 1;
        for(ll j = 0; j < 26; j++)
            if(cha != j)
                add(c,c*cnt[j]);
        add(ans,c);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 512