akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int64_t N;
    int64_t A;
    map<int64_t,int64_t> m;

    cin >> N;
    for(int i=0;i<N;i++) {
        cin >> A;
        m[A]++;
    }

    for(auto it:m) {
        if(it.second > 1) {
            cout << "NO\n";
            return 0;
        }
    }
            cout << "YES\n";
    return 0;
}


Measured memory_bytes: 12800
#include <stdio.h>

int main(void)
{
	int hen1, hen2, tai;
	int ct_c;
	int ct_h;
	
	ct_c = ct_h = 0;
	while (scanf("%d,%d,%d", &hen1, &hen2, &tai) != EOF){
		if (tai * tai - (hen1 * hen1 + hen2 * hen2) == 0){
			ct_c++;
		}
		else if (hen1 == hen2){
			ct_h++;
		}
	}
	
	printf("%d\n%d\n", ct_c, ct_h);
	
	return (0);
}

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

struct Guy {
    long long dates;
    long long sat;
};
long long dp[1<<16];

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

        vector<Guy> guys;
        for (int i=0; i<N; ++i) {
            int M, L, S, E;
            cin >> M >> L;

            Guy g;
            g.dates = 0;
            g.sat = L;

            for (int j=0; j<M; ++j) {
                cin >> S >> E;
                for (int k=S; k<E; ++k) {
                    g.dates |= (1LL << (k-6));
                }
            }
            guys.push_back(g);
        }

        long long res = 0;

        fill(dp, dp+(1<<16), 0LL);
        dp[0] = 0;
        for (Guy& g: guys) {
            for (long long i=0; i<(1<<16); ++i) {
                if ((i & g.dates) == 0) {
                    dp[i | g.dates] = max(dp[i | g.dates], dp[i] + g.sat);
                    res = max(res, dp[i | g.dates]);
                }
            }
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 3528
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int N;
    cin >> N;
    int a[N+2], b[N+2];
    a[0] = b[0] = 0;
    long long sum = 0LL;
    for(int i=1; i<=N; i++){
        cin >> a[i];
        b[i] = abs(a[i - 1] - a[i]);
        sum += b[i];
    }
    a[N+1] = 0;
    b[N+1] = abs(a[N]);
    sum += b[N+1];
    for(int i=1; i<=N; i++) {
        long long ans = sum - b[i] - b[i+1] + abs(a[i-1]-a[i+1]);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 2048
import random


def is_prime3(q, k=50):
    q = abs(q)
    if q == 2:
        return True
    if q < 2 or q & 1 == 0:
        return False

    # n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1) >> 1
    while d & 1 == 0:
        d >>= 1

    # 判定をk回繰り返す
    for i in range(k):
        a = random.randint(1, q-1)
        t = d
        y = pow(a, t, q)
        # [0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q-1 and t & 1 == 0:
            return False
    return True


X = int(input())

while not is_prime3(X):
    X += 1

print(X)

Measured memory_bytes: 4592
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	cout << min(a,k)-min(max(0,k-a-b),c);
	return 0;
}


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

using namespace std;

typedef long long ll;
const ll mx = 1000006;
ll sam[mx], pic[mx];

int main() {
    ll n;
    cin >> n;
    vector<ll>v;
    ll c1 = 0, c4 = 0, c2 = 0;
    for (ll i = 0; i < n; i++) {
        ll x;
        cin >> x;
        if(x % 2 != 0) {
            c1++;
        }
        else if(x % 4 == 0) {
            c4++;
        }
        else if(x % 2 == 0) {
            c2++;
        }
    }

    if(c2 == 0) {
        if(c1  <= c4 + 1) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    else {
        if(c1 <= c4) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
	int a, b;
	std::cin >> a >> b;
	int max = a + b;
	if (a - b > max)
		max = a - b;
	if (a * b > max)
		max = a * b;

	std::cout << max << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

    int num_500 = X / 500;
    X -= num_500 * 500;
    int num_5 = X / 5;

    cout << num_500 * 1000 + num_5 * 5 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n,k,i,o;
  double t,ans=0;
  scanf("%d%d",&n,&k);
  for (i=1;i<=n;i++){
    o=i;
    t=1;
    while (o<k) {
      o*=2;
      t/=2;
    }
    ans+=t;
  }
  ans/=n;
  printf("%.12lf\n",ans);
  return 0;
}

Measured memory_bytes: 128
// This code wrote by chtholly_micromaker(MicroMaker)
#pragma GCC optimize("Ofast,O3,inline")
#pragma GCC target("avx,avx2")
#include <bits/stdc++.h>
#define reg register
#define ALL(x) (x).begin(),(x).end()
#define mem(x,y) memset(x,y,sizeof x)
#define sz(x) (int)(x).size()
#define ln puts("")
#define lsp putchar(32)
#define pb push_back
#define MP make_pair
#define dbg(x) cerr<<">"<<__func__<<"\tLine: "<<__LINE__<<' '<<#x<<": "<<x<<endl
using namespace std;
const int MaxN=100050;
template <class t> inline void read(t &s){s=0;
reg int f=1;reg char c=getchar();while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
while(isdigit(c))s=(s<<3)+(s<<1)+(c^48),c=getchar();s*=f;return;}
template<class t,class ...A> inline void read(t &x,A &...a){read(x);read(a...);}
template <class t> inline void write(t x){if(x<0)putchar('-'),x=-x;
int buf[21],top=0;while(x)buf[++top]=x%10,x/=10;if(!top)buf[++top]=0;
while(top)putchar(buf[top--]^'0');return;}
inline void setIn(string s){freopen(s.c_str(),"r",stdin);return;}
inline void setOut(string s){freopen(s.c_str(),"w",stdout);return;}
inline void setIO(string s=""){setIn(s+".in");setOut(s+".out");return;}
template <class t>inline bool checkmin(t&x,t y){if(x>y){x=y;return 1;}return 0;}
template <class t>inline bool checkmax(t&x,t y){if(x<y){x=y;return 1;}return 0;}
inline int lowbit(int x){return x&(-x);}
int n,m;
int col[MaxN],scc;
vector<int> E[MaxN];
inline void dfs(int u)
{
	for(auto v:E[u])if(!col[v])
	{
		col[v]=scc;
		dfs(v);
	}
	return;
}
signed main(void)
{
	int n,m;read(n,m);
	reg int u,v;
	for(int i=1;i<=m;++i)
	{
		read(u,v);
		E[u].pb(v);
		E[v].pb(u);
	}
	for(int i=1;i<=n;++i)
		if(!col[i])
			col[i]=++scc,dfs(i);
	write(scc-1),ln;
	return 0;
}

/*
 * Check List:
 * 1. Input / Output File (USACO and OI and UVa)
 * 2. long long 
 * 3. Special Test such as n=1
 * 4. Array Size
 * 5. Memory Limit (OI) int is 4 and longlong is 8
 * 6. Mod (a*b%p*c%p not a*b*c%p  ,  (a-b+p)%p not a-b )
 * 7. Name ( int k; for(int k...))
 * 8. more tests , (T=2 .. more)
 * 9. blank \n after a case
*/






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

int abs(int a)
{
    return a >= 0? a: -a;
}

int main(void)
{
    int n;
    priority_queue<int> q;
    scanf("%d", &n);
    while (n--) {
        int a;
        scanf("%d", &a);
        q.push(a);
    }
    int sum[2] = {0};
    int i = 0;
    while (!q.empty()) {
        sum[i & 1] += q.top();
        q.pop();
        i++;
    }
    printf("%d\n", abs(sum[0] - sum[1]));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#define rep(i, n) repr((i), 0, (n))
#define repr(i, a, t) reps((i), (a), (t), 1)
#define reps(i, a, t, s) for (long long (i) = (a); (i) < (long long)(t); (i) += (s))
#define rrep(i, n) rrepr((i), (n) - 1, 0)
#define rrepr(i, a, t) rreps((i), (a), (t), 1)
#define rreps(i, a, t, s) for (long long (i) = (a); (i) >= (long long)(t); (i) -= (s))
#define each(v, c) for (auto &&(v) : (c))
using namespace std;
namespace mp = boost::multiprecision;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ml = mp::cpp_int;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;

/**
 * https://ja.wikipedia.org/wiki/クヌース–モリス–プラット法
 * 文字列検索
 */
class KMP {
 private:
  string needle;
  vector<ll> kmp;

 public:
  explicit KMP(const string &needle) : needle(needle), kmp(needle.size() + 2, 0) {
    // 部分マッチテーブルを構築
    kmp[0] = -1;
    kmp[1] = 0;
    {
      ll i = 2;
      ll j = 0;
      while (i < needle.size()) {
        if (needle[i - 1] == needle[j]) {
          kmp.at(i++) = ++j;
        } else if (j > 0) {
          j = kmp.at(j);
        } else {
          kmp.at(i++) = 0;
        }
      }
    }
  }

  /**
   * @param haystack
   * @param m The position of the current character in haystack
   * @param i The position of the current character in needle
   */
  ll index_of(const string &haystack, ll m = 0, ll i = 0) {
    while (m + i < haystack.size()) {
      if (needle.at(i) == haystack.at(m + i)) {
        if (++i == needle.size()) {
          return m;
        }
      } else {
        m += i - kmp.at(i);
        if (i > 0) {
          i = kmp.at(i);
        }
      }
    }
    return -1;
  }

  /**
   * ret[i]: haystack[i] 以降の文字列の最初が needle と同じなら true
   * @param haystack
   */
  vector<ll> search(const string &haystack) {
    vector<ll> ret(haystack.size(), false);

    ll m = 0;
    ll i = 0;
    while (m + i < haystack.size()) {
      m = index_of(haystack, m, i);
      if (m < 0) break;
      ret.at(m) = true;
      m += needle.size() - kmp.at(needle.size() - 1) - 1;
      i = max(0ll, kmp.at(needle.size() - 1));
    }
    return ret;
  }
};

ll dfs(ll i, const vector<ll> &matches, vector<ll> &memo, ll size) {
  if (memo[i]) {
    return memo[i];
  }
  memo[i] = -1;
  if (!matches[i]) {
    return memo[i] = 0;
  }
  ll r = dfs((i + size) % memo.size(), matches, memo, size);
  return memo[i] = r >= 0 ? r + 1 : -1;
}

ll solve() {
  string s, t;
  cin >> s >> t;

  while (s.size() < t.size()) {
    s += s;
  }
  s += s;

  KMP kmp = KMP(t);
  vector<ll> matches = kmp.search(s);
  vector<ll> memo(s.size() / 2, 0);
  ll ans = 0;
  rep (i, memo.size()) {
    if (!memo[i]) {
      ll r = dfs(i, matches, memo, t.size());
      if (r < 0) {
        return -1;
      }
      ans = max(r, ans);
    }
  }
  return ans;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ifstream ifs;
  if (getenv("LOCAL") != nullptr) {
    ifs.open("src/_in.txt");
    cin.rdbuf(ifs.rdbuf());
  }

  cout << solve() << endl;

}

Measured memory_bytes: 46172
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

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

int main()
{
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << max(max(max(a*c,b*d),max(a*d,b*c)),max(a*d,b*c)) << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

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

    vector<int> L(N);
    for (int i = 0; i < N; i++)
    {
        cin >> L[i];
    }
    sort(L.begin(), L.end());
    // for (int i = 0; i < N; i++)
    // {
    //     printf("%d ", L[i]);
    // }

    ll ans = 0;
    // a と bを固定 -> c < a + b
    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            // c の動ける範囲の右端を求める
            int k = lower_bound(L.begin(), L.end(), L[i] + L[j]) - L.begin();

            // c の動ける範囲は、([j + 1], k)
            ans += max(k - (j + 1), 0);
        }
    }
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 3620
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




























int main(){
    ll n;
    cin >> n;
    vector<ll> v(100005);
    ll sum = 0;
    REP(i, n){
        ll a;
        cin >> a;
        v[a]++;
        sum += a;
    }
    ll q;
    cin >> q;
    REP(i, q){
        ll b, c;
        cin >> b >> c;
        sum += v[b] * c - v[b] * b;
        v[c] += v[b];
        v[b] = 0;
        cout << sum << endl;
    }
}


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

int main(){
  int n;
  cin >> n;
  vector<int>A(n);
  vector<int>B(n);
  vector<int>C(n-1);
  for(int i=0;i<n;i++)
    cin >> A.at(i);
  for(int i=0;i<n;i++)
    cin >> B.at(i);
  for(int i=0;i<n-1;i++)
    cin >> C.at(i);
  int ans=0,memo=n;
  for(int i=0;i<n;i++){
    ans+=B.at(A.at(i)-1);
    if(memo+1==A.at(i)-1)
      ans+=C.at(memo);
    memo=A.at(i)-1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  constexpr int inf = 1e9;

  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  V<> dp(1 << n, inf);
  dp[0] = 0;
  while (m--) {
    int a, b; cin >> a >> b;
    int T = 0;
    while (b--) {
      int c; cin >> c, --c;
      T |= 1 << c;
    }
    auto ndp = dp;
    for (int S = 0; S < 1 << n; ++S) if (dp[S] < inf) {
      ndp[S | T] = min(ndp[S | T], dp[S] + a);
    }
    swap(dp, ndp);
  }
  if (dp.back() < inf) {
    cout << dp.back() << '\n';
  } else {
    cout << -1 << '\n';
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
int N;
int Ma;
int Mb;
vector<int> a;
vector<int> b;
vector<int> c;
ll dp[51][510][510];

int main() {
    cin >> N >> Ma >> Mb;
    a.resize(N);
    b.resize(N);
    c.resize(N);
    REP(i, N) { cin >> a[i] >> b[i] >> c[i]; }
    // dp[現在の個数][現在のAの重さ][現在のBの重さ] = 価格の最小値
    REP(i, 51) {
        REP(j, 510) {
            REP(k, 510) { dp[i][j][k] = INF; }
        }
    }
    // http://drken1215.hatenablog.com/entry/2019/02/15/205900
    dp[0][0][0] = 0;
    REP(i, N) {
        REP(wa, 500) {
            REP(wb, 500) {
                if(dp[i][wa][wb] >= INF) {
                    continue;
                }
                chmin(dp[i + 1][wa][wb], dp[i][wa][wb]);
                chmin(dp[i + 1][wa + a[i]][wb + b[i]], dp[i][wa][wb] + c[i]);
            }
        }
    }
    // cout << "hoge" << endl;
    ll res = INF;
    for(int wa = 1; wa < 500; wa++) {
        for(int wb = 1; wb < 500; wb++) {
            if(wa * Mb != wb * Ma) {
                continue;
            }
            chmin(res, dp[N][wa][wb]);
        }
    }
    if(res < INF) {
        cout << res << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 103936
text = input()
n = int(input())

for _ in range(n):
    command = input().split() 
    if command[0] == "replace" :
        text = text[:int(command[1])] + command[3] + text[int(command[2])+1:]
        #print(text)
    elif command[0] == "print" :
        print(text[int(command[1]):int(command[2])+1])
        
    elif command[0] == "reverse" :
        rev_text = text[int(command[1]):int(command[2])+1]
        text = text.replace(text[int(command[1]):int(command[2])+1],rev_text[::-1])


Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
# define rep(i,n) for(int i=0;i<n;i++)
int p[200005];
int size_a[200005];
int find(int x){
    if(x ==p[x])
        return x;
    return p[x] = find(p[x]);
}
void uni(int u,int v){
    int pu =find(u);
    int pv =find(v);
    if(pu==pv)
    return;
    else{
        p[pu] = pv;
        size_a[pv]+=size_a[pu];
        size_a[pu]=0;
    }
}
void solve(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        p[i]=i;
        size_a[i]=1;
    }

    rep(i,m){
        int u,v;
        cin>>u>>v;
        uni(u,v);
    }
    int ans =0;
    for(int i=1;i<=n;i++)
    ans=max(ans,size_a[i]);
    cout<<ans<<endl;


}
int main()
{
    int t;
    //cin>>t;
    
    t=1;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 5104
/*
Write a program which prints the central coordinate (px, py) and the radius r of a circumscribed circle of a triangle which is constructed by three points (x1, y1)(x2, y2)(x3, y3) on the plane surface.
 */

#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>

using namespace std;

 /*
http://zo3kirin3.net/?p=297
http://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q104383420
http://www.nn.iij4u.or.jp/~hsat/misc/math/centre/circumcentre.html
 */

int main() {
	int n; cin >> n;
	vector<double> x(3), y(3), x2(3), y2(3);		// x,yªÀWÌXgAx2,y2ªÀWÌñæÌXg
	
	for (int p=0; p<n; p++) {
		cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2];
		for (int i=0; i<3; i++) {
			x2[i] = x[i]*x[i];
			y2[i] = y[i]*y[i];
		}
		
		// eÓÌ·³ðßéBO½ûÌèðp
		double a, b, c, a2, b2, c2;
		a2 = abs((x[2]-x[1])*(x[2]-x[1]) + (y[2]-y[1])*(y[2]-y[1]));
        b2 = abs((x[0]-x[2])*(x[0]-x[2]) + (y[0]-y[2])*(y[0]-y[2]));
        c2 = abs((x[1]-x[0])*(x[1]-x[0]) + (y[1]-y[0])*(y[1]-y[0]));
		a = sqrt(a2); b = sqrt(b2); c = sqrt(c2);
		
		// ÊÏBwÌö®ðpB
		double s, S2;
		s = (a+b+c) / 2;
		S2 = s * (s-a) * (s-b) * (s-c);
		
		// OSðßéBö®ÍWeby[WðQÆ©xNgâÁÄÈ¢©çà¾Å«È¢c
		double px, py;
		px = (a2*(b2+c2-a2)*x[0] + b2*(c2+a2-b2)*x[1] + c2*(a2+b2-c2)*x[2]) / (16 * S2);
        py = (a2*(b2+c2-a2)*y[0] + b2*(c2+a2-b2)*y[1] + c2*(a2+b2-c2)*y[2]) / (16 * S2);
        
        // oÍB®`µÄoÍ·éB¼aÍ¼üÌûö®ÅB
        cout << setprecision(3) << fixed << px << " " << py << " " << sqrt(abs((px-x[0])*(px-x[0])+(py-y[0])*(py-y[0]))) << endl;
    }
	
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int N, A, B;
  cin >> N >> A >> B;
  int X;
  cin >> X;
  i64 ans = 0;
  rep(i, N - 1) {
    int Y;
    cin >> Y;
    i64 a = (i64) A * (Y - X);
    if (a < B) {
      ans += a;
    } else {
      ans += B;
    }
    X = Y;
  }
  cout << ans << endl;
}


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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

//写経

ll N;
ll L[4000];

void input() {
	cin>>N;
	for (int i = 1; i <= N; i++) cin>>L[i];
}

void solve() {
	input();
	vector<ll> v(N);
	for (int i = 0; i < N; i++) v[i] = L[i + 1];
	sort(v.begin(), v.end());
	ll ans = 0;
	for (ll mid = N - 1; mid >= 0; mid--) {
		for (ll low = mid - 1; low >= 0; low--) {
			auto itr = lower_bound(v.begin(), v.end(), v[mid] + v[low]);
			ll ng = distance(itr, v.end());
			ans += (N - 1 - mid) - ng;
		}
	}
	cout<< ans <<endl;
	return;
}

int main(void){
	solve();
	
	return 0;
}

Measured memory_bytes: 256
//ITP1_5_D
//????????????  20???

using System;
using System.Collections.Generic;

class ITP1_5_D
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());

        call(n);

    }

    private static void call(int n)
    {
        for(int i = 1;i <= n; i++)
        {
            //?????????s????????????
            string s = i.ToString();

            //i????????§?????????????????????s???3?????????????????????
            if ((i % 3) == 0 || s.IndexOf("3") >= 0)
            {
                Console.Write(" "+ i);
            }

        }
        Console.Write("\r\n");
    }
}

Measured memory_bytes: 9716
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProConB_Path
{
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
            //int a = int.Parse(Console.ReadLine());
            // スペース区切りの整数の入力
            int[] a = new int[6];
            string[] input = Console.ReadLine().Split(' ');
            a[0] = int.Parse(input[0]);
            a[1] = int.Parse(input[1]);
            string[] input2 = Console.ReadLine().Split(' ');
            a[2] = int.Parse(input2[0]);
            a[3] = int.Parse(input2[1]);
            string[] input3 = Console.ReadLine().Split(' ');
            a[4] = int.Parse(input3[0]);
            a[5] = int.Parse(input3[1]);

            int count1 = 0;
            int count2 = 0;
            int count3 = 0;
            int count4 = 0;
            for(var i = 0; i < 6; i++)
            {
                switch (a[i])
                {
                    case 1:
                        count1++;
                        break;
                    case 2:
                        count2++;
                        break;
                    case 3:
                        count3++;
                        break;
                    case 4:
                        count4++;
                        break;
                }
            }
            if ((count1 <= 2)&& (count2 <= 2) && (count3 <= 2) && (count4 <= 2)){
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


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

int main(int argc, const char * argv[]) {
    char a, b;
    
    cin >> a >> b;
    
    if ( (a=='H' && b=='H') || (a=='D' && b=='D') ) {
        cout << 'H' << endl;
    }else{
        cout << 'D' << endl;
    }
    
    return 0;
}


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

using namespace std;
typedef unsigned long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
 	ll cost;
 };
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = 10000000;
/****** define constant end ********/
/****** define variable start ******/
long double a;
long double b;
/******* define variable end *******/
int solve() {
	cin >> a >> b;
	cout << (ll)floor(a * b) << endl;
	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 3744
#include<stdio.h>

int field[20][20] = {0};

void move_robot(int M){
  int i, j, distance, robo_x = 10, robo_y = 10;
  char direction[10];
  
  for(i = 0; i < M; i++){
    scanf("%s %d", direction, &distance);
    switch(direction[0]){
    case 'N':
      for(j = 0; j <= distance; j++){
	field[robo_x][robo_y + j] = 0;
      }
      robo_y += distance;
      break;

    case 'S':

      for(j = 0; j <= distance; j++){
	field[robo_x][robo_y - j] = 0;
      }
      robo_y -= distance;
      break;

    case 'E':
      for(j = 0; j <= distance; j++){
	field[robo_x + j][robo_y] = 0;
      }
      robo_x += distance;
      break;

    case 'W':

      for(j = 0; j <= distance; j++){
	field[robo_x - j][robo_y] = 0;
      }
      robo_x -= distance;
      break;

    default:
      break;
    }
  }
  for(i = 0; i < 20; i++){
    for(j = 0; j < 20; j++){
      if(field[i][j] == 1){
	printf("No\n");
	return ;
      }
    }
  }
  
  printf("Yes\n");
  return ;
  
}

int main(void){
  int N, M, i, j, x, y;
  while(1){
    scanf("%d", &N);
    if(N == 0){
      break;
    }

    for(i = 0; i < 20; i++){
      for(j = 0; j < 20; j++){
	field[i][j] = 0;
      }
    }

    for(i = 0; i < N; i++){
      scanf("%d %d", &x, &y);
      field[x][y] = 1;
    }

    scanf("%d", &M);
    move_robot(M);
  }
  return 0;
}

Measured memory_bytes: 584
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
ans = [[0]*w for _ in range(h)]

for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            ans[i][j] = '#'
            if i > 0 and j > 0 and ans[i-1][j-1] != '#':
                ans[i-1][j-1] += 1
            if i > 0 and ans[i-1][j] != '#':
                ans[i-1][j] += 1
            if i > 0 and j < w-1 and ans[i-1][j+1] != '#':
                ans[i-1][j+1] += 1
            if j > 0 and ans[i][j-1] != '#':
                ans[i][j-1] += 1
            if j < w-1 and ans[i][j+1] != '#':
                ans[i][j+1] += 1
            if i < h-1 and j > 0 and ans[i+1][j-1] != '#':
                ans[i+1][j-1] += 1
            if i < h-1 and ans[i+1][j] != '#':
                ans[i+1][j] += 1
            if i < h-1 and j < w-1 and ans[i+1][j+1] != '#':
                ans[i+1][j+1] += 1

for k in range(h):
    for m in range(w):
        print(str(ans[k][m]), end='')
    print()

Measured memory_bytes: 3572
#include<stdio.h>

int main()
{
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x + r<=W && 0<=x - r && y + r<=H && 0<= y - r){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 584
#include <iostream>

using namespace std;

int main()
{
  int f, s, el;
  f = 0;
  s = 0;
  for (int i = 0; i  <3; i++) 
  {
	cin >> el;
    if (el == 5) f++;
    else if (el == 7) s++;
    
  }
  if (f == 2 && s == 1) cout << "YES" << endl;
  else cout << "NO" << endl;

  
}

Measured memory_bytes: 256
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
#define SZ(x) (int)((x).size())
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
  };
} fast_ios_;

struct Point {
  int x, y;
};

int cross(const Point& a, const Point& b, const Point& c) {
  return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
}

double sqr(double x) {
  return x * x;
}

int main() {
  vector<Point> p(3);
  for (int i = 0; i < 3; ++i) {
    cin >> p[i].x >> p[i].y;
  }
  double S = 0.5 * cross(p[0], p[1], p[2]);
  if (S < 0) S = -S;
  vector<double> len(3);
  for (int i = 0; i < 3; ++i) {
    int j = (i + 1) % 3;
    len[i] = sqrt(sqr(p[i].x - p[j].x) + sqr(p[i].y - p[j].y));
  }
  sort(len.begin(), len.end());
  double r = S / (2 * S / len[2] + 0.5 * (len[0] + len[1] + len[2]));
  cout << r << '\n';
  return 0;
}


Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define aint(a) a.begin(),a.end()
#define UB upper_bound
#define LB lower_bound
const int NUM = 2e5 + 5;

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1; 
    //cin>>num_tests;
    while(num_tests-->0){
        int N, K; cin >> N >> K;
    int pre = 0;
    int suf = 0;
    int ans = 0;
    FOR(i, 1, N+2) {
        pre += i-1;
        suf += N+1-i;
        pre %= mod; suf %= mod;
        if (i >= K) {
            ans += suf - pre + 1 + mod;
            ans %= mod;
        }
    }
        cout << ans;
    }   
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int a[3];
int main(){
	int ans=0;
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if((a[0]+a[1])%2==0){
		ans=(a[1]-a[0])/2+(a[2]-a[1]);
	}
	else{
		a[1]++;
		a[2]++;
		ans=1+((a[1]-a[0])/2+(a[2]-a[1]));
	}
	cout<<ans;
}

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

int main(void){
  long long int n, a, b, x[100010], cost[100010];
  cin >> n >> a >> b;
  for(int i=0;i<n;++i){
    cin >> x[i];
  }
  cost[0] = 0;
  for(int i=1;i<n;++i){
    cost[i] = (x[i]-x[i-1])*a;
  }
  long long int ans = 0;
  for(int i=0;i<n;++i){
    if(cost[i] < b) ans += cost[i];
    else ans += b;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
s = input()
d = {}
flag = 1
for i in s:
    d.setdefault(i, 0)
    d[i] += 1


for j in d.values():
    if j % 2 != 0:
        flag = 0
        break
    
if flag == 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9064
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll A;
  double B;
  cin >> A >> B;
  ll B100 = (ll)(B * 100 + 0.001);
  cout << A * B100 / 100 << endl;
  return 0;
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

template<class T>
class Dinic {
private:
    const T INF;

    struct edge {
        T to, cap, rev;
        edge(T to, T cap, T rev) :to(to), cap(cap), rev(rev) {}
    };

    T V;
    vector<vector<edge>> g;
    vector<T> level;      // sourceからの距離
    vector<T> itr;       // どこまで調べ終わったか

public:
    Dinic(T V) :INF(1e9+7), V(V), g(V, vector<edge>()) {}

    void add_edge(T from, T to, T cap) {
        g[from].emplace_back(to, cap, g[to].size());
        g[to].emplace_back(from, 0, g[from].size()-1);
    }

    // sourceからの最短路を幅優先で探索
    void bfs(T s) {
        level = vector<T>(V, -1);
        queue<T> que;
        que.push(s);
        level[s] = 0;
        while (que.size()) {
            int v = que.front(); que.pop();
            for (edge &e : g[v]) {
                if (e.cap > 0 and level[e.to] < 0) {
                    level[e.to] = level[v] + 1;
                    que.push(e.to);
                }
            }
        }
    }

    // v->tの増加路を探す
    T dfs(T v, T t, T f) {
        if (v == t) return f;
        for (T& i = itr[v]; i < g[v].size(); ++i) {
            edge& e = g[v][i];
            if (e.cap > 0 and level[v] < level[e.to]) {
                int d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    g[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    T max_flow(T s, T t) {
        T flow = 0, f;
        while (true) {
            bfs(s);
            if (level[t] < 0) return flow;
            itr = vector<T>(V, 0);
            while ((f = dfs(s, t, numeric_limits<T>::max())) > 0) {
                flow += f;
            }
        }
    }
};

int H, W;
int in(int r, int c) {
    return r*W+c+2;
}
int out(int r, int c) {
    return (H*W)+(r*W+c)+2;
}

int main() {
    cin >> H >> W;
    string board[101];
    rep(i, H) cin >> board[i];
    int s = 0, t = 1, inf = 1e9+7;
    Dinic<int> flow(H*W*2+5);
    rep(r, H) rep(c, W) {
        if (r == 0 or r == H-1 or c == 0 or c == W-1) {
            if (board[r][c] == 'X') {
                cout << -1 << endl;
                return 0;
            }
            flow.add_edge(out(r,c), t, inf);
        }
        if (board[r][c] == 'X') flow.add_edge(s, out(r,c), inf);
        flow.add_edge(in(r,c), out(r,c), (board[r][c] == 'X' ? inf : 1));
        if (r > 0) flow.add_edge(out(r,c), in(r-1,c), inf);
        if (c > 0) flow.add_edge(out(r,c), in(r,c-1), inf);
        if (r+1<H) flow.add_edge(out(r,c), in(r+1,c), inf);
        if (c+1<W) flow.add_edge(out(r,c), in(r,c+1), inf);
    }
    cout << flow.max_flow(s, t) << endl;
    return 0;
}


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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
#define int long long
const int INF = 1e9;

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, k;
    cin >> n >> k;
    int ans = 0;
    int m = (ll)1e9 + 7LL;

    for (int i = k; i <= n+1; i++){
      int mn = (i * (i-1LL)) / 2LL;
      int mx = (n * (n+1LL) - (n-i+1) * (n-i)) / 2;
      ans += (mx - mn + 1);
      ans %= m;
    }
    
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define int long long int
#define inf 1000000000000
#define hell (int)(1e9+7)

using namespace std;

void solve(){
    int s,w;
    cin>>s>>w;
    if(w>=s)
        cout<<"unsafe";
    else
        cout<<"safe";
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}


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

int main () {
        int N;
        long power;

        cin >> N;

        power = 1;
        for(int i = 0; i < N; i++) {
                power += power * i;
                power %= 1000000007;
        }

        cout << power << endl;

        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

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

    vector<int> v(n+2);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &v[i+1]);
    }
    vector<int> z = v;
    sort(z.begin(), z.end());
    z.erase(unique(z.begin(), z.end()), z.end());
    auto f = [&](int x){ return lower_bound(z.begin(), z.end(), x) - z.begin(); };
    vector<int> s(z.size()+1, 0);
    for (int i = 0; i < n+1; ++i) {
        int a = f(min(v[i], v[i+1])), b = f(max(v[i], v[i+1]));
        s[a]++; s[b]--;
    }
    for (int i = 0; i < z.size(); ++i) {
        s[i+1] += s[i];
    }
    cout << *max_element(s.begin(), s.end()) /2 << "\n";
    return 0;
}



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

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

  long long n;
  cin >> n;
  double v;
  vector<double> vec;
  for(int i=0;i<n;i++){
    cin >> v;
    vec.push_back(v);
  }
  for(int i=0;i<n-1;i++){
    sort(vec.begin(), vec.end());
    vec.push_back((vec[0]+vec[1])/2ll);
    vec.erase(vec.begin());
    vec.erase(vec.begin());
  }
  cout << vec[0] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;
long long dp [2][(unsigned int)(1e5 + 1)];
int main()
{
    int n, w;
    cin >> n >> w;
    pair<long long, long long> arr [n];
    for (int i = 0 ; i < n; ++i) 
    {
        long long a, b;
        cin >> a >> b;
        arr[i] = make_pair(a, b);
    }
    for (int i = 0; i <= 1; ++i)
    {
        dp[i][0] = 0;
    }
    for (int i = 0; i <= w; ++i)
    {
        dp[0][i] = 0;
    }
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= w; ++j)
        {
            if (j - arr[i - 1].first >= 0) {
                dp[i % 2][j] = max(arr[i - 1].second + dp[(i + 1) % 2][j - arr[i -1].first], dp[(i + 1) % 2][j]);
            } else {
                dp[i % 2][j] = dp[(i + 1) % 2][j];
            }
            // cout << dp[i % 2 ][j] << "\t";
        }
        // cout << endl;
    }
    // long long val = 0;
    // for (int i = 0; i < n + 1; ++i) {
    //     for (int j = 0; j <= w; ++j)
    //     {
    //         val = max(val, dp[i][j]);
    //         cout << dp[i][j] << "\t";
    //     }
    //     cout << endl;
    // }
    cout << dp[n % 2][w] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main() {
  int x, y;
  cin >> x >> y;
  if (y % 2 == 1) {
    puts("No");
  } else if (y >= 2 * x && y <= 4 * x) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 3608
import collections
import math
import operator as op
from functools import reduce
import numpy as np
import math
import bisect
import heapq


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


def main():
    N = get_input(int)
    AB = []
    for _ in range(N):
        A, B = get_inputs(int)
        AB.append((A, B))
    AB.sort(key=lambda x: x[1])

    cur_time = 0
    for A, B in AB:
        cur_time += A
        if cur_time > B:
            print('No')
            return
    print('Yes')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 41020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll l, r;
  cin >> l >> r;
  ll mx = min(r + 1, l + 2019);
  ll ans = 1e18;
  rep2(i, l, mx - 1) rep2(j, l + 1, mx) ans = min(ans, (i * j) % 2019);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string str1,str2,str3;
    cin>>str1;
    
    for(int i=0; i<(str1.length()-1)/2; i++){
        str2+=str1[i];
    }
    for(int i=(str1.length()+3)/2-1; i<str1.length(); i++){
        str3+=str1[i];
    }
    
    string rs1=str1, rs2=str2, rs3=str3;
    reverse(rs1.begin(), rs1.end());
    reverse(rs2.begin(), rs2.end());
    reverse(rs3.begin(), rs3.end());
    
    if(str1==rs1 && str2==rs2 && str3==rs3){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3620
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');

while (line = lines.shift()) {
  let seconds = parseInt(line);
  let minutes = Math.floor(seconds / 60);
  const hours = Math.floor(minutes / 60);
  seconds = seconds - (hours * 60 * 60);
  minutes = Math.floor(seconds/60);
  seconds = seconds - (minutes * 60);
  const time = `${hours}:${minutes}:${seconds}`;
  console.log(time);
} 


Measured memory_bytes: 15104
N = int(input())
s = list(input())
c_list = [['W','W'],['W','S'],['S','W'],['S','S']]

for c in c_list:
    for current in range(1,N):
        pre = current-1
        if ((c[current] == 'W' and s[current] == 'o') or (c[current] == 'S' and s[current] == 'x')):
            if(c[pre] == 'W'):
                c.append('S')
            else:
                c.append('W')
        elif ((c[current] == 'W' and s[current] == 'x') or (c[current] == 'S' and s[current] == 'o')):
            c.append(c[pre])
    if(c[0] == c[N]):
        if ((c[0] == 'W' and s[0] == 'o') or (c[0] == 'S' and s[0] == 'x')):
            if(c[1] != c[N-1]):
                print(''.join(c[0:N]))
                quit()
        else:
            if(c[1] == c[N-1]):
                print(''.join(c[0:N]))
                quit()
    """
    if ((c[0] == 'W' and s[0] == 'o') or (c[0] == 'S' and s[0] == 'x')):
        if (c[N-1] != c[1]):
            print(''.join(c[0:N]))
            quit()
    else:
        if (c[N-1] == c[1]):
            print(''.join(c[0:N]))
            quit()
    """
print(-1)


Measured memory_bytes: 7544
s = input()
n = len(s)
chk = [[0] for i in range(n)]
cc = set()
d = {}
cnt = 0
for i,si in enumerate(s):
  if not si in cc:
    d[si] = cnt
    cnt += 1
    cc.add(si)
  chk[d[si]].append(i+1)
#print(chk)
ans = n//2
for j in chk:
  p = 0
  j = j + [n+1]
  for k in range(len(j)-1):
    p = max(p,j[k+1]-j[k]-1)
    if p >= ans:
      break
    if k == len(j)-2:
      ans = min(p,ans)
print(ans)

Measured memory_bytes: 3064
#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))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
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 double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

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

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N;
  cin >> N;
  map<string, ll> m;
  rep(i, N) {
    string s;
    cin >> s;
    m[s]++;
  }

  ll max = 0;
  for (auto mm : m) {
    if (max < mm.second) {
      max = mm.second;
    }
  }

  for (auto mm : m) {
    if (max == mm.second) {
      COUT(mm.first);
    }
  }

  return 0;
}

Measured memory_bytes: 25216