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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
vector<bool>solve(string a,string b){
  ll na=a.size(),nb=b.size();
  vector<bool>ret(na+nb+1);
  rep(i,0,nb+na+1){
    bool sw=true;
    rep(j,0,na){
      ll k=j-i+nb;
      //cout<<i spa j spa k<<endl;
      if(k>=0&&k<nb&&a[j]!='?'&&b[k]!='?'&&a[j]!=b[k]){
        //cout<<i spa j spa k spa a[i] spa b[k]<<endl;
        sw=false;
      }
    }
    ret[i]=sw;
  }
  return ret;
}
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  string a,b,c;cin>>a>>b>>c;
  ll na=a.size(),nb=b.size(),nc=c.size();
  auto ab=solve(a,b);
  auto ac=solve(a,c);
  auto bc=solve(b,c);
  res=INF;
  //debug(ab,ab.size());
  //debug(bc,bc.size());
  //debug(ac,ac.size());
  ll sz=4005;
  rep(i,-sz,sz){
    ll k=i+nb;
    if(k>=0&&k<ab.size()&&!ab[k])continue;
    rep(j,-sz,sz){
      ll kb=j-i+nc;
      if(kb>=0&&kb<bc.size()&&!bc[kb])continue;
      ll ka=j+nc;
      if(ka>=0&&ka<ac.size()&&!ac[ka])continue;
      //cout<<i spa j<<endl;
      chmin(res,max({na,i+nb,j+nc})-min({0LL,i,j}));
    }
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};
 
int main(){
  int r,g,b;
  cin>>r>>g>>b;
  int temp;
  temp=100*r+10*g+b;
  if(temp%4==0){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}

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

 
int main() {
   int n;
   cin>>n;
   vector<int> W(n);
   int sum=0;
   rep(i,n){
        int w;
        cin>>w;
        sum+=w;
        W[i]=w;
   }

    int s1=0,s2=0,ans=10101010;
   rep(i,n-1){
       s1+=W[i];
       s2=sum-s1;
       ans=min(ans,abs(s1-s2));
   }

   cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

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

    ll r;
    cin >> r;
    cout << 6.28318530717958623200*r << endl;
}

Measured memory_bytes: 3808
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vi a(m);
    for (int i = 0; i < m; ++i) {
        cin >> a[i];
    }
    int left = 0;
    int right = 0;
    for (auto &aa : a) {
        if (aa < x)
            left++;
        else if (aa > x)
            right++;
    }
    cout << min(left, right) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

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

	cout << a + a * a + a * a * a << endl;
	return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<list>
#include<deque>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<numeric>

using namespace std;

using ll = int64_t;

/// <summary>
/// 単純なcoutの時に使う
/// </summary>
#define co(a) cout<<a<<"\n"


/// <summary>
/// [beg, end)の範囲を，添え字indexでループするfor文に置換します
/// </summary>
#define rep(i,a) for(ll i=0; i<a; ++i)
#define reps(i, a, b) for(ll i = a; i < b; ++i)

/// <summary>
/// 迷路等で使う方向のベクトル
/// </summary>
const vector<ll> dx = { 0, 1, 0, -1 }, dy = { 1, 0, -1, 0 };

/// <summary>
/// デバッグ時に使う
/// </summary>
#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

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

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

	ll hoge = 0;
	ll count = 0;
	
	if (N < 10) {
		cout << N << endl;
	}
	else if (N < 100) {
		cout << 9 << endl;
	}
	else if (N < 1000) {
		hoge = N / 100;
		cout << N - 100 + 10 << endl;
	}
	else if (N < 10000) {
		hoge = N / 1000;
		cout << 909 << endl;
	}
	else if (N < 100000) {
		hoge = N / 10000;
		cout << N - 10000 + 910 << endl;
	}
	else {
		cout << 90909 << endl;
	}
}



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

using namespace std;

int main(int argc, char const* argv[])
{
    int n, ar[100], swapc = 0;

    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n;

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

    for (int i = 0; i < n - 1; i++) {
        int minj = i;
        for (int j = i + 1; j < n ; j++) {
            if(ar[j] < ar[minj]){
                minj = j;
            }
        }
        if(minj != i){
            swap(ar[i], ar[minj]);
            swapc++;
        }
    }

    for (int i = 0; i < n - 1; i++) {
        cout << ar[i] << " ";
    }
    cout << ar[n - 1] << endl;
    cout << swapc << endl;

    return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char c;
    cin >> c;
    if(c<='Z') cout << 'A';
    else  cout << 'a';
    return 0;
}

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

int main() {
    int n,x;
    cin >> n >> x;
    vector<int>a(n);
    rep(i,n) {
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int count = 0;
    rep(i,n) {
        if(x >= a[i]) {
            count++;
            x -= a[i];
        }
    }
    if(count == n && x) count--;
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;

int main() {
    cin.sync_with_stdio(0); cin.tie(0); 
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
        int n,m;cin>>n>>m;
        string a,b;
        rep(i,n)a.pb(m+'0');
        rep(i,m)b.pb(n+'0');
        if(a>b)cout<<b;
        else cout<<a;
    }
    return 0;   
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1e18
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<int,int>
#define T tuple<int,int,int> 
using namespace std;

struct Edge{
    int to,a,b;
    Edge(int to, int a, int b):to(to),a(a),b(b){}
};

struct Data{
    int v,s; ll x;
    Data(int v, int s, ll x):v(v),s(s),x(x){}
    bool operator<(const Data& a) const{
        return x > a.x;
    }
};

vector<Edge> res[50];
ll dp[50][2510];

int main(){
    int n,m,s; cin >> n >> m >> s;
    rep(i,m){
        int u,v,a,b; cin >> u >> v >> a >> b;
        u--; v--;
        res[u].emplace_back(v,a,b);
        res[v].emplace_back(u,a,b);
    }
    vector<int> c(n),d(n);
    rep(i,n) cin>> c[i] >> d[i];

    rep(i,n)rep(j,2510) dp[i][j]=INF;
    s=min(s,2505);

    priority_queue<Data> q;

    auto push = [&](int v, int s, ll x){
        if(s<0) return;
        if(dp[v][s]<=x) return;
        dp[v][s]=x;
        q.emplace(v,s,x);
    };
    push(0,s,0);
    while(!q.empty()){
        Data hoge = q.top();
        q.pop();
        int v=hoge.v, s=hoge.s;
        ll x = hoge.x;
        if(dp[v][s]!=x) continue;
        //両替
        int ns=min(s+c[v],2505);
        push(v,ns,x+d[v]);
        // 移動
        for(Edge e : res[v]){
            push(e.to, s-e.a, x+e.b);
        }
    }
    for(int i=1; i<n; i++){
        ll ans=INF;
        rep(j,2510){
            ans=min(ans,dp[i][j]);
        }
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 6244
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#ifdef DEBUG
#include <boost/core/demangle.hpp>
#define dump(x) cerr << "L" << __LINE__ << ": in " << __PRETTY_FUNCTION__ << " \e[32;1m" << boost::core::demangle(typeid(x).name()) << "\e[37m" << " " << (#x) << " = " << (x) << "\e[m" << endl;
#else
#define dump(x)
#endif
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T> ostream& operator<<(ostream &os, vector<T> &v){os << "{";ITR(i,v){if(i!=v.begin())os << ","; os << *i;}os << "}"; return os;}
template <typename T, typename U> ostream& operator<<(ostream& os, pair<T,U> &p){os << "(" << p.first << "," << p.second << ")"; return os;}

template <typename T> T& chmin(T &a, const T &b){return a = min(a,b);}
template <typename T> T& chmax(T &a, const T &b){return a = max(a,b);}

const LLI inf = 1e18;

template <typename T = int>
T minimum_power_2(T n){
  T i = 1;
  while(i<n) i = (i<<1);
  return i;
}

template <typename T> class SegmentTree{
private:
  int size;
  vector<T> vec;
  T e;
  function<T(T,T)> f, upd;
  
  T aux(int x, int y, int i, int l, int r){
    if(r<=x || y<=l) return e;
    else if(x<=l && r<=y) return vec[i];
    else return f(aux(x,y,i*2+1,l,(l+r)/2), aux(x,y,i*2+2,(l+r)/2,r));
  };

public:
  SegmentTree(int n, T e, function<T(T,T)> f, function<T(T,T)> upd):
    size(minimum_power_2(n)*2-1), vec(size, e), f(f), e(e), upd(upd){}
  void update(int i, T x){
    int j = i+(size+1)/2-1;
    vec[j] = upd(vec[j], x);
    --j;
    while(j>=0){
      vec[j/2] = f(vec[(j/2)*2+1], vec[(j/2)*2+2]);
      (j /= 2) -= 1;
    }
  }

  T find(int x, int y){return aux(x,y,0,0,(size+1)/2);}
};

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

  int N; cin >> N;
  vector<LLI> h(N), a(N); cin >> h >> a;
  
  SegmentTree<LLI> seg(N+1, 0LL, [](LLI a, LLI b){return max(a,b);}, [](LLI a, LLI b){return b;});

  REP(i,N){
    LLI t = seg.find(0,h[i]+1);
    seg.update(h[i], t+a[i]);
    dump(t);
  }

  cout << seg.find(0,N+1) << endl;
  
  return 0;
}


Measured memory_bytes: 7552
#include<bits/stdc++.h>
#define rpt(n) for(register int ttxyc=0;ttxyc<n;++ttxyc)
using namespace std;
int n,a,ans;map<int,int>m;
main()
{
    scanf("%d",&n);
    rpt(n)scanf("%d",&a),++m[a];
    for(map<int,int>::iterator i=m.begin();i!=m.end();++i)
    {
        pair<int,int>now=*i;
        if(now.first>now.second)ans+=now.second;
        else ans+=now.second-now.first;
    }
    printf("%d\n",ans);
}/**/

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define f first
#define s second
#define mp make_pair
#define sz size()
#define ll long long
int n;
int a[(int)1e5+10];
int dp[(int)1e5+10];
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for(int i = 1; i <= n; ++i) cin >> a[i];
	for(int i = 0; i <= n; ++i) dp[i] = 1e9;
	dp[1] = 0;
	dp[2] = abs(a[2] - a[1]);
	for(int i = 3; i <= n; ++i) {
		dp[i] = min(dp[i], dp[i - 1] + abs(a[i] - a[i - 1]));
		dp[i] = min(dp[i], dp[i - 2] + abs(a[i] - a[i - 2]));
	}
	cout << dp[n];
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/
ll modpow(ll x, ll n, ll mod)
{
    if (n == 0)
        return 1;
    ll res = modpow(x * x % mod, n / 2, mod);
    if (n & 1)
        res = res * x % mod;
    return res;
}
int main()
{
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    /*  for (int i = 1; i * i <= N; i++) {
        if (!(N % i)) {
            int j = N / i;

            ll l = 1;
            ll r = ll(1e9);

            while (r >= l) {
                ll mid = l + (r - l) / 2;

          ll tmp = 5*
          if(
            }
        }

*/
    for (int i = 0; i < 1000; i++) {
        for (int j = 0; j < 10000; j++) {
            if (i * i * i * i * i + j * j * j * j * j == N) {
                cout << i << ' ' << -j << endl;
                return 0;
            }
            if (i * i * i * i * i - j * j * j * j * j == N) {
                cout << i << ' ' << j << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3652
open Batteries
(* 文字列をcharのlistにする *)
let explode s = List.init (String.length s) (String.get s)
let n = List.rev (read_line() |> explode) |> List.hd
let _ = (if n = '2' || n = '4' || n = '5' || n = '7' || n = '9' then "hon" else if n = '3' then "bon" else "pon") |> print_endline

Measured memory_bytes: 5248
X,Y,Z,K = map(int,input().split())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
A = A[::-1]
B = B[::-1]
C = C[::-1]

ab = []
for i in range(X):
    for j in range(Y):
        ab.append(A[i]+B[j])
ab.sort()
ab=ab[::-1][:K]

ans = []
for k in range(Z):
    for v in ab:
        ans.append(C[k]+v)

ans.sort()
for i in range(K):
    print(ans[-1-i])

Measured memory_bytes: 134440
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
long long GCD(long long a,long long b){
    if(b==0)return a;
    return GCD(b,a%b);
}
long long LCM(long long a,long long b){
    return a*b/GCD(a,b);
}
long long modMult(long long a, long long b, long long m) {
  long long res = 0;
  long long exp = a % m;
  while (b) {
    if (b & 1) {
      res += exp;
      if (res > m) res -= m;
    }
    exp <<= 1;
    if (exp > m) exp -= m;
    b >>= 1;
  }
  return res;
}
long long powMod(long long a, long long b, long long m) {
  long long res = 1;
  long long exp = a % m;
  while (b) {
    if (b & 1) res = modMult(res, exp, m);
    exp = modMult(exp, exp, m);
    b >>= 1;
  }
  return res;
}
//powMod(a,b,MOD)
//O(log(b))?
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll h,w;
    cin>>h>>w;
    VV vec(h,V(w));
    rep(i,h){
        string s;
        cin>>s;
        rep(j,w){
            if(s[j]=='.'){
                vec[i][j]++;
            }
        }
    }
    VV dp(h,V(w));
    dp[0][0]=1;
    
    rep(i,h){
        rep(j,w){
            if(i==0&&j==0){
                continue;
            }
            if(i==0){
                if(vec[i][j-1]){
                    dp[i][j]=dp[i][j-1];
                }
            }else if(j==0){
                if(vec[i-1][j]){
                    dp[i][j]=dp[i-1][j];
                }
            }else{
                if(vec[i][j-1]){
                    dp[i][j]=dp[i][j-1];
                }
                if(vec[i-1][j]){
                    dp[i][j]+=dp[i-1][j];
                }
            }
            dp[i][j]%=MOD;
        }
    }
    cout<<dp[h-1][w-1]<<endl;
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
#define mod 1000000007
#define S second
#define F first
using namespace std;
string s;
int mypow(int a,int b,int c){
	if(b==1) return a%c;
	if(b%2) return a*mypow(a,b-1,c)%c;
	int d=mypow(a,b/2,c);
	return d*d%c;
}
signed main(){
	cin>>s;
	int a=INT_MAX;
	f(i,s.size()-2){
		a=min(a,abs(('7'-s[i])*100+('5'-s[i+1])*10+('3'-s[i+2])));
	}
	cout<<a<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.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 MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define ll long long

const int MOD = 1e9 + 7;

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

}

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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector < int >a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

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

	cout << a.back() - a.front() << endl;

	return 0;
}


Measured memory_bytes: 256
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args) {
		try {
			System.setIn(new FileInputStream("src/aoj1172/input.txt"));
			// System.setOut(new PrintStream(new FileOutputStream("src/aoj1172/result.txt")));
		} catch (FileNotFoundException e) {
		}
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		for (;;) {
			int n = sc.nextInt();
			if (n == 0) break;
			int ans = 0;
			for (int i = n + 1; i <= 2 * n; i++) {
				if (isPrime(i))
					ans++;
			}
			System.out.println(ans);
		}
	}

	private boolean isPrime(int n) {
		for (int d = 2; d * d <= n; d++)
			if (n % d == 0)
				return false;
		return true;
	}

	void tr(Object... os) {
		System.err.println(deepToString(os));
	}
}

Measured memory_bytes: 12000
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;


#define INF 100007
/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N;
	
	cin >> N;

	string s[N];
	int a[26];
	int b[26];
	memset(a, 0, sizeof(a));
	//memset(b, 0, sizeof(b));
	rep(i, 26)
	{
		b[i] = INF;
	}
	rep(i, N)
	{
		cin >> s[i];
		for(int j = 0; j < s[i].size(); j++)
		{
			a[s[i][j] - 'a']++;
		}
		for (int k = 0; k < 26; k++)
		{
			b[k] = min(a[k], b[k]);
		}
		
		memset(a, 0, sizeof(a));
	}

	bool flg = false;
	rep(i, 26)
	{
		char tmp = 'a';
		while(b[i] > 0)
		{
			tmp = i + 'a';
			cout << tmp;
			b[i]--;
			flg = true;
		}
	}

	if (!flg)
	{
		cout << " ";
	}
	
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define pb push_back
#define mp make_pair
const int mod=1e9+7;
void solve()
{
    vector<int> V(5);
    for(int i=0;i<5;i++)
    cin>>V[i];
    for(int i=0;i<5;i++)
    {
      if(V[i]==0)
      {
        cout<<i+1<<endl;
        return;
      }
    }
}

int main()
{
  fastio
  solve();
}


Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
//#define int long long
//----------------------------------------------------
int w, h, n;
bool a[100][100];
signed main() {
	cin >> w >> h >> n;
	for (int i = 0; i < n; i++) {
		int x, y, z;
		cin >> x >> y >> z;
		if (z == 1) {
			for (int i = 0; i < h; i++) {
				for (int j = 0; j <= x - 1; j++) {
					a[i][j] = 1;
				}
			}
		}
		if (z == 2) {
			for (int i = 0; i < h; i++) {
				for (int j = x; j < w; j++) {
					a[i][j] = 1;
				}
			}
		}
		if (z == 3) {
			for (int i = 0; i <= y - 1; i++) {
				for (int j = 0; j < w; j++) {
					a[i][j] = 1;
				}
			}
		}
		if (z == 4) {
			for (int i = y; i < h; i++) {
				for (int j = 0; j < w; j++) {
					a[i][j] = 1;
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (!a[i][j]) ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        List<String> list = new ArrayList<String>();
        String[] mark = {"S", "H", "C", "D"};

        for(int i = 0; i < 4; i++){
            for(int j = 0; j < 13; j++){
                list.add(mark[i] + " " + (j + 1));
            }
        }

        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.nextLine());

        for(int i = 0; i < n; i++){
            list.remove(sc.nextLine());
        }

        for(String str : list){
            System.out.println(str);
        }
    }
}


Measured memory_bytes: 26188
fn read() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().to_string()
}

fn main() {
    let _ = read();
    let hs: Vec<i32> = read().split(' ').map(|x| x.parse().unwrap()).collect();
    let mut ans = 0;
    let mut pre = 0;
    for h in hs {
        ans += std::cmp::max(h - pre, 0);
        pre = h;
    }
    println!("{}", ans);
}


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

const int N = 20, mod = 1000000007;

void reduce(int &x) { x += x >> 31 & mod; }
int n, m, k, dp[2][1 << N - 1], ans, q[N][N];

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> m >> k;
	for (int i = 0; i < m; ++i)
		for (int j = 0; j < n; ++j) q[i][j] = -1;
	for (int i = 0, a, b, c; i < k; ++i)
		std::cin >> a >> b >> c, q[a - 1][b - 1] = c;
	int now = 0, lst = 1;
	dp[now][0] = 1;
	for (int t = 0; t < m; ++t) {
		for (int j = 0; j < n - 1; ++j) {
			std::swap(now, lst), std::memset(dp[now], 0, sizeof dp[0]);
			for (int k = 0; k < 1 << n - 1; ++k) if (int v = dp[lst][k]) {
				if (q[t][j] != 1 && !(k >> j & 1)) reduce(dp[now][k] += v - mod);
				if (q[t][j] != 0)
					if (k >> j & 1) reduce(dp[now][k] += v - mod);
					else {
						int p = k & -1 << j; p &= p - 1, p |= k & ~(-1 << j) | 1 << j;
						reduce(dp[now][p] += v - mod);
					}
			}
		}
	}
	for (int s = 0; s < 1 << n - 1; ++s)
		reduce(ans += dp[now][s] - mod);
	std::cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 4352
import copy
n = int(input())
A = []
for ni in range(n):
    A.append(input().split())
B = copy.deepcopy(A)
B.sort(key = lambda x: int(x[1]))

def Partition(A, p, r):
    i = p - 1
    for j in range(p, r):
        if int(A[j][1]) <= int(A[r][1]):
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i+1, A

def QuickSort(A, p, r):
    if p >= r:
        return None
    else:
        q, A = Partition(A, p, r)
        QuickSort(A, p, q-1)
        QuickSort(A, q+1, r)
        return A

QuickSort(A, 0, n-1)
if A == B:
    print("Stable")
else:
    print("Not stable")
for ni in range(n):
    print(*A[ni], sep=" ")



Measured memory_bytes: 49792
/********************/
/* K B G D E L T A */
/*     DA-IICT      */
/********************/
 
#include<bits/stdc++.h>
using namespace std;
using   ll=long long;
using   ld=long double;
#define fast           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl           "\n"
#define F(i,n)         for(ll i=0;i<n;i++)
#define rep(i,a,b,c)   for(ll i=a;i<b;i+=c)
#define repp(i,a,b)    for(ll i=a;i>=b;i--)
#define pb             push_back
#define mp             make_pair
#define vll            vector<ll>
#define f              first
#define s              second
#define pll            pair<ll,ll>
#define ALL(v)         v.begin(),v.end()
#define ALLR(v)        v.rbegin(),v.rend()
#define pii            3.14159265358979323
 
void solve()
{
	ll a,b;
	
	cin>>a>>b;
	
	ll tt=__gcd(a,b);
	
	cout<<(ll)(a*b)/tt;
}

 
signed main(){
 
    fast;
 
    ll t;
    
    t=1;
    
    while(t--)
    {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s[100005];
map<string,ll> p;
int main(){
    ll n,ans=0;
    cin>>n;
    for(ll i=1;i<=n;i++){
        cin>>s[i];
        sort(s[i].begin(),s[i].end());
        p[s[i]]++;
    }
    for(auto x:p){
        ans+=(x.second*(x.second-1))/2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 18176
a,b,m = map(int, input().split())

ai = list(map(int, input().split()))
bi = list(map(int, input().split()))
tmp_min = min(ai) + min(bi)

for i in range(m):
    x,y,c = map(int, input().split())
    z = ai[x-1] + bi[y-1] - c
    if z < tmp_min:
        tmp_min =  z

print(tmp_min)

Measured memory_bytes: 24764
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
template<typename T>void max_self(T &a,T b){a=max(a,b);}
template<typename T>void min_self(T &a,T b){a=min(a,b);}
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=4e5+10,oo=0x3f3f3f3f,MOD=1e9+7;
const long double PI = acos(-1),eps=1.0e-14;

void solve(){
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    loop(n,i,0)
        cout<<s[i]<<t[i];
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <map>
#include <string>

using namespace std;

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

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define quick                    \
    ios::sync_with_stdio(false); \
    cin.tie(0);
#define time cerr << (0.1 * clock()) / CLOCKS_PER_SEC << endl;
#define mod 1000000007
typedef long long ll;
typedef pair<ll, ll> pl;
#define forn(n) for (ll i = 0; i < ll(n); i++)

void solve() {
    ll n;
    cin >> n;
    vector<ll> v(n);
    forn(n) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    ll ans = 0;
    map<int, int> m;
    m[v[0]]++;
    for (int i = 1; i < n; ++i) {
        auto temp = *(m.rbegin());
        ans += temp.ff;
        temp.ss--;
        if (!temp.ss) {
            m.erase(temp.ff);
        } else {
            m[temp.ff]--;
        }
        m[v[i]] += 2;
    }
    cout << ans << '\n';
}

int main() {
    quick;
    solve();
    // ll t;
    // cin >> t;
    // while (t--) {
    //     solve();
    // }
}

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

int main(){
  long int N,M,count;
  long int ans=0;
  cin>>N>>M;
  vector<pair<long int, long int>> AB(N);
  for(int i=0; i<N; ++i){
    cin>>AB.at(i).first>>AB.at(i).second;
  }
  sort(AB.begin(), AB.end());
  for(int i=0; i<N; ++i){
    if(count+AB[i].second>M){
      ans += (M-count)*AB[i].first;
      break;
    }
    else{
      ans += AB[i].first*AB[i].second;
      count += AB[i].second;
    }
  }
  cout<<ans<<endl;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String stra = input.readLine( );
		int a = Integer.parseInt(stra);
		String strb = input.readLine( );
		int b = Integer.parseInt(strb);
		String strh = input.readLine( );
		int h = Integer.parseInt(strh);

		int answer = (a + b) * h / 2;
		System.out.print(answer);

	}

}


Measured memory_bytes: 8144
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int a,b;
    cin>>a>>b;
    if(a+b>=24)cout<<a+b-24<<endl;
    else cout<<a+b<<endl;
}

Measured memory_bytes: 256
n, K = map(int, input().split())
A = [x-1 for x in list(map(int, input().split()))]

current = 0
d = dict()
d[current] = d.get(current, 0) + 1
pattern = [0]
cnt = K

while True:
    current = A[current]
    if d.get(current) == 2:
        break
    else:
        if d.get(current) == None:
            d[current] = d.get(current, 0) + 1
        else:
            d[current] = d.get(current) + 1
        pattern.append(current)
        cnt -= 1
        if cnt == 0:
            break

if cnt == 0:
    print(pattern[-1]+1)
else:
    loop = len([key for key, value in d.items() if value == 2])
    not_loop = len([key for key, value in d.items() if value != 2])
    pattern = pattern[not_loop:]
    ans_position = (K - not_loop) % loop

    print(pattern[ans_position]+1)

Measured memory_bytes: 32372
a=int(input())
b=int(input())
c=int(input())
x=int(input())

ans=0
for i in range(a+1):
    fee=500*i
    if fee>x:
        break
    for j in range(b+1):
        fee=500*i+100*j
        if fee>x:
            break
        for k in range(c+1):
            fee=500*i+100*j+50*k
            if fee==x:
                ans+=1
            elif fee>x:
                break
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define LL long long
#define maxn 1000009
#define mod 1000000007
using namespace std;
LL jc[maxn],ny[maxn],f[maxn];
inline LL C(int n,int m){
  if(n<m) return 0;
  return jc[n]*ny[m]%mod*ny[n-m]%mod;
}
inline int qpow(LL x,int y){
  LL ans=1;
  while(y){
    if(y&1) ans=ans*x%mod;
    y>>=1,x=x*x%mod;
  }
  return ans;
}
int main(){
  int n,m;LL ans=0;
  scanf("%d",&n);
  m=(n+1)/2;jc[0]=ny[0]=1;
  for(int i=1;i<=n;i++) jc[i]=jc[i-1]*i%mod,ny[i]=qpow(jc[i],mod-2);
  for(int i=m;i<n;i++) f[i]=C(i-1,n-i-1)*jc[i]%mod*jc[n-i-1]%mod;
  for(int i=n-1;i>=m;i--) f[i]=(f[i]-f[i-1]+mod)%mod,ans+=f[i]*i%mod,ans%=mod;
  printf("%lld",ans);
  return 0;
}


Measured memory_bytes: 21632
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

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

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

int main(){
  int n;
  cin >> n;
  int a[1000];
  FOR(i,n){
    cin >> a[i];
  }
  sort(a,a+n);
  int ans=n;
  for(int i=1;i<n;i++){
    if(a[i]==a[i-1]){
      ans--;
    }
  }
  cout << ans << endl;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define asort(x) sort(x.begin(),x.end())

int main() {
    int n, k, sum = 0;
    cin >> n >> k;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    asort(p);
    rep(i,k) sum += p[i];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3624
const input = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/);
let A = input[1].split(' ').map(Number);
let N = Number(input[0]);
console.log(A.join(' '));
for (let i=1; i < N; i++) {
    let v = A[i];
    let j = i - 1;
    while (j >= 0 && A[j] > v) {
        A[j+1] = A[j];
        j--;
    }
    A[j+1] = v;
    console.log(A.join(' '));
}


Measured memory_bytes: 16608
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // scanner
        Scanner sc = new Scanner(System.in);

        // ロード
        int N = Integer.parseInt(sc.next());

        // 出力
        System.out.println("ABC" + String.format("%03d", N));

        // scanner
        sc.close();
    }
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int sum=a+b+c;
  int n=max({a,b,c});
  int goal;
  if(n%2==sum%2){
    goal=3*n;
  }
  else{
    goal=3*n+3;
  }
  cout << (goal-a-b-c)/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <set>
#include <map>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int N, A, B;
    cin >> N >> A >> B;
//    vector<int> vec(N);
//    REP(i, N) cin >> vec[i];
    
    // calculation
    if (A + B > N) {
        cout << min(A, B) << ' ' << N - ((N-A)+(N-B)) << "\n";
    } else if (A+B == N){
        cout << min(A, B) << ' ' << 0 << "\n";
    } else if (A+B < N) {
        cout << min(A, B) << ' ' << 0 << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())
mod = 10**9 + 7


def nCr(n, r, mod):
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod


print((pow(2, n, mod)-1-nCr(n, a, mod)-nCr(n, b, mod)) % mod)

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

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

  vector<vector<int>> a(M, vector<int>(2));
  for (int i = 0; i < M; i++)
  {
    cin >> a[i].at(0) >> a[i].at(1);  
  }
  vector<int> ans(N);
  for (int  i = 0; i < M; i++)
  {
      int k, l;
      k = a[i].at(0) - 1;
      l = a[i].at(1) - 1;
      ans[k]++;
      ans[l]++;
  }
  
  for (int i = 0; i < N; i++)
  {
      cout << ans[i] << endl;
  }
  
  
  
  return 0;
  
}


Measured memory_bytes: 256
////////////////////////////////////////////
///                                      ///
///        Template ver. 1.2. rapel      ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define endl '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

vector<pair<int,int> > res;

void hora(int tc) {
	int n;
	cin>>n;
	for(int i = 1;i <= n;i++) {
		for(int j = i + 1;j <= n;j++) {
			if(i + j == n + (1 - n % 2)) continue;
			else res.pb({i, j});
		}
	}
	cout<<res.size()<<endl;
	for(auto x: res) cout<<x.F<<" "<<x.S<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    char a;cin>>a;
    if(a>='a')cout<<"a\n";
    else cout<<"A\n";
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=1e9+5;
const int N=2e5+5;
const ll oo=1e18+5;
const ll mod=1e9+7;

int n;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll sum=0;
	cin>>n;
	for(int i=1;i<=n;++i){
		if(i%3==0||i%5==0) continue;
		sum+=i;
	}
	cout<<sum;
	return 0;
}


Measured memory_bytes: 3616