akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n, m; cin >> n >> m;
	vi a(n), b(m);
	cin >> a >> b;
	sort(a.rbegin(), a.rend());
	sort(b.rbegin(), b.rend());
	REP(i, n - 1)
	{
		if (a[i] == a[i + 1])
		{
			cout << 0 << endl;
			return 0;
		}
	}
	REP(i, m - 1)
	{
		if (b[i] == b[i + 1])
		{
			cout << 0 << endl;
			return 0;
		}
	}
	int pa = 0, pb = 0;
	ll ans = 1;
	for (int i = n * m; i > 0; i--)
	{
		if (pa < n && pb < m && i == a[pa] && i == b[pb])
		{
			pa++;
			pb++;
		}
		else
		{
			if (pa < n && i == a[pa])
			{
				pa++;
				ans *= pb;
			}
			else if (pb < m && i == b[pb])
			{
				pb++;
				ans *= pa;
			}
			else
			{
				ans *= pa * pb - (n * m - i);
			}
			ans %= MOD;
		}
	}
	assert(pa == n);
	assert(pb == m);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{

  string s[3];
  s[0] = "Sunny";
  s[1] = "Cloudy";
  s[2] = "Rainy";
  string t;
  cin >> t;
  rep(i, 3)
  {
    if (t == s[i])
    {
      cout << s[(i + 1) % 3] << endl;
      return 0;
    }
  }
  return 0;
}


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

#define pb push_back
#define loop(i,l,r) for(int i = (l); i < (r); i++)
#define rloop(i,r,l) for(int i = (r-1); i >= (l); i--)
#define refloop(x, v) for(auto& x : (v))
#define exists(m,e) if((m).find(e) != (m).end())
#define nexists(m,e) if((m).find(e) == (m).end())
#define sortaka(v) sort((v).begin(), (v).end())
#define rsort(v) sort((v).rbegin(), (v).rend())
#define lower_bound_index(v, x) (lower_bound((v).begin(), (v).end(), x)-(v).begin()) // returns minimum i s.t v[i] >= x
#define upper_bound_index(v, x) (upper_bound((v).begin(), (v).end(), x)-(v).begin()) // returns minimum i s.t v[i] > x
#define scanint(x) scanf("%d", &(x))
#define scanfloat(x) scanf("%f", &(x))
#define scanll(x) scanf("%lld", &(x))
#define scanchar(x) scanf("%c", &(x))
#define scanstring(x) scanf("%s", &(x))
#define printint(x) printf("%d", x)
#define printfloat(x) printf("%.9f", x)
#define printll(x) printf("%lld", x)
#define printchar(x) printf("%c", x)
#define printstring(x) printf("%s", x)
#define printintnewline(x) printf("%d\n", x)
#define printfloatnewline(x) printf("%.9f\n", x)
#define printllnewline(x) printf("%lld\n", x)
#define printcharnewline(x) printf("%c\n", x)
#define printstringnewline(x) printf("%s\n", x)
#define square(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))

typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<long long, long long>> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef vector<string> vs;
typedef vector<vector<pair<int, int>>> vvpii;
typedef vector<vector<pair<long long, long long>>> vvpll;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef long long ll;

int main(){
    ios::sync_with_stdio(0);

    ll n, x, m; cin >> n >> x >> m;
    ll ans = 0;

    vl rems(m+1);
    map<ll,int>counts;
    rems[0] = x;
    counts[x] = 1;

    for(int i = 1; i < m+1; i++){
        rems[i] = (rems[i-1]*rems[i-1])%m;
        exists(counts, rems[i]){
            counts[rems[i]]++;
        }else{
            counts[rems[i]] = 1;
        }
    }

    if(n <= m){
        for(int i = 0; i < n; i++){
            ans += rems[i];
        }
        cout<<ans<<endl;
        return 0;
    }

    ll ind = 0;
    while(counts[rems[ind]] == 1){
        ind++;
    }

    ll ind2 = ind+1;
    while(rems[ind] != rems[ind2]){
        ind2++;
    }

    ll periodlen = ind2 - ind;


    loop(i, 0, ind){
        ans += rems[i];
    }

    loop(i, 0, (n-ind)%periodlen){
        ans += rems[ind+i];
    }

    ll perans = 0;
    loop(i, ind, ind2){
        perans += rems[i];
    }
    ans += perans*((n-ind)/periodlen);

    cout<<ans<<endl;
}

Measured memory_bytes: 7216
#
# File    : D.rb
# Author  : Kazune Takahashi
# Created : 2018-6-16 21:07:15
# Powered by Visual Studio Code
#

n, m = gets.chomp.split(" ").map{|u| u.to_i}
x = []
y = []
z = []
n.times{
  s, q, r = gets.chomp.split(" ").map{|u| u.to_i}
  x << s
  y << q
  z << r
}

res = 0

for j in 0...2
  for k in 0...2
    for l in 0...2
      sum = []

      for i in 0...n
        t = 0
        if j == 0
          t += x[i]
        else
          t += -x[i]
        end
        if k == 0
          t += y[i]
        else
          t += -y[i]
        end
        if l == 0
          t += z[i]
        else
          t += -z[i]
        end
        sum << t
      end

      sum = sum.sort.reverse

      ans = 0

      for i in 0...m
        ans += sum[i]
      end

      res = [res, ans].max
    end
  end
end

puts res


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

int main(){
    long H;
    cin >> H;
    long ans = 1;
    long cnt = 0;
    while (H!=1)
    {
        H /= 2;
        cnt++;
        ans += pow(2,cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
//using namespace __gnu_pbds;
using namespace std;
typedef long long  L;

#define max_(x, y) (((x) > (y)) ? (x) : (y))
#define min_(x, y) (((x) < (y)) ? (x) : (y))
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Mx 200001
#define inf 1e15
const L MOD = 1e9+7;
const double pi = 2 * acos (0.0);

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/


//typedef tree<L,null_type,less<L>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

L a1,a2,a3,a,b,b1,b2,b3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,k,l,m,n,m1,m2,n1,n2,o,p,p1,p2,p3,p4,
q,q1,q2,q3,q4,r,s,t,u,v,x,y,z,sum,mx=-inf,mn=inf,flg,flg1,flg2,id1,id2,id3,id4,lim;

int main()
{
    scanf("%lld%lld",&n,&m);
    if(n<=m){
        printf("unsafe\n");
    }
    else printf("safe\n");
    return 0;
}

/// empty() lld lld push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long k, n, ans=0, total;
    cin>>k>>n;
    long long a[n];
    for(long long i=0;i<n;i++){
        cin>>a[i];
    }for(long long i=0;i<n-1;i++){
        long long temp=a[i+1]-a[i];
        ans=max(temp, ans);
    }long long temp=(k-a[n-1])+a[0];
    ans=max(temp, ans);
    total=k-ans;
    cout<<total<<endl;
	return 0;
}

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


int main() {

    string s;
    cin >> s;
    int cnt = 0;
    int ans = 0;
    rep(i,s.size()) {
        if (s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T') {
            ++cnt;
            ans = max(ans,cnt);
        } else {
            cnt = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>
#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222



ll edge[555][555];

void fac(ll le, ll ri, ll num) {
  ll mid = (le + ri) / 2;
  if (ri == le) return;
  FOR(i, le, mid + 1) FOR(j, mid + 1, ri + 1) {
    edge[i][j] = num;
    edge[j][i] = num;
  }
  fac(le, mid, num + 1);
  fac(mid + 1, ri, num + 1);
}

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


  cin >> n;
  fac(1, n, 1);
  FOR(i, 1, n) {
    FOR(j, i + 1, n + 1) cout << edge[i][j] << " ";
    cout << endl;
  }


  return 0;
}


Measured memory_bytes: 2688
#include<cstdio>
#include<iostream>
#include<utility>
#include<algorithm>
#include<map>
using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); i++)

int n;
map <int, int> ar;

int main()
{
    cin >> n;
    rep(i, 0, n) {
        int a;
        cin >> a;
        ar[a]++;
    }

    int ans = 0;
    for (auto itr = ar.begin(); itr != ar.end(); ++itr) {
        if (itr->first > itr->second) ans += itr->second;
        else ans += itr->second - itr->first; 
    }

    cout << ans << endl;
}

Measured memory_bytes: 4736
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N;
ll K;
ll A[200000], F[200000];

signed main(){
    cin >> N >> K;
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> F[i];
    sort(A, A+N);
    reverse(A, A+N);
    sort(F, F+N);

    ll ok = 1'000'000'000'001;
    ll ng = -1;
    while(ok-ng > 1){
        ll m = (ok+ng)/2;
        ll k = 0;
        rep(i, N){
            if(A[i]*F[i] <= m) continue;
            k += A[i] - m/F[i];
        }
        if(k <= K) ok = m;
        else ng = m;
    }
    cout << ok << endl;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <functional>
#include <queue>
#include <vector>
typedef long long lld;
typedef std::priority_queue<int> max_heap;
typedef std::priority_queue<int, std::vector<int>, std::greater<int>> min_heap;
max_heap mxh;
min_heap mnh;
int a, b, Q;
lld A, B;

// mxh: [3, 2, 1]
// mnh: [5, 8, D]
// mxh.top <= mnh.top

void update() {
    B += b;
    // Insertion
    if (mxh.empty()) {
        mxh.push(a);
    } else if (a <= mxh.top()) {
        A += mxh.top() - a;
        mxh.push(a);
    } else {
        A += a - mxh.top();
        mnh.push(a);
    }
    // Rotations
    while (mxh.size() >= (mnh.size() + 2u)) {
        mnh.push(mxh.top());
        mxh.pop();
        A -= 1LL * (mnh.top() - mxh.top()) * (mxh.size() - mnh.size());
    }
    while (mnh.size() > mxh.size()) {
        A -= 1LL * (mnh.top() - mxh.top()) * (mnh.size() - mxh.size());
        mxh.push(mnh.top());
        mnh.pop();
    }
}

int query() { return mxh.top(); }

int main() {
    scanf("%d", &Q);
    A = B = 0LL;
    for (int q = 1; q <= Q; ++q) {
        char cmd;
        scanf(" %c", &cmd);
        switch (cmd) {
        case '1':
            scanf(" %d%d", &a, &b);
            update();
            break;
        case '2':
            printf("%d %lld\n", query(), A + B);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3452
#include <cstdio>

#define cc (100.0*E)/(100.0+E)

int A, B, C, D, E, F, ma, mb;
double m;

bool v[3000][3000];

void solve(int a, int b){
    if(a + b > F || v[a][b] || (100.0 * b) / (a + b) > (100.0 * E) / (E + 100.0)) return;
    v[a][b] = true;

    double tmp = (100.0 * b) / (a + b);

    if(tmp >= m){
        m = tmp;
        ma = a;
        mb = b;
    }

    solve(a + A * 100, b);
    solve(a + B * 100, b);
    solve(a, b + C);
    solve(a, b + D);
}

int main(){
    scanf("%d %d %d %d %d %d", &A, &B, &C, &D, &E, &F);

    solve(0, 0);

    printf("%d %d\n", ma + mb, mb);

    return 0;
}


Measured memory_bytes: 6272
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef long long ll;
#define sz(a) int((a).size());
#define pb push_back;
#define all(c) c.begin(),c.end();
#define tr(c,i) for(typeof(c).begin() i = c.begin(); i != c.end(); i++);
#define present(c,x) (c.find(x) != c.end());
#define cpresent(c,x) (find(all(c),x) != c.end());


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    int a[n+1]={0};
    int c=n;
    while(k--){
        int p;
        cin>>p;
        int j;
        for(int i=1;i<=p;i++){
            cin>>j;
            if(a[j]==0){
                c--;
            }
            a[j]++;
        }
    }
    cout<<max(0,c);
	return 0;
}


Measured memory_bytes: 3644
a = [int(input()) for i in range(5)]
b = 4
c = 0
ans = 0
for i in a:
  if i % 10 == 0:
    if b > 0:
      b -= 1 
  else:
    if c == 0:
      c = i % 10
    else:
      c = min(c,i % 10)
for i in a:
  ans += (i // 10) * 10
ans = ans + b * 10 + c
print(ans)

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

using namespace std;

const int N = 1234567;

char s[N];

int main() {
  scanf("%s", s);
  int a = -1, b = -1;
  for (int i = 0; s[i]; i++) {
    if (s[i] == 'A') {
      if (a == -1) a = i;
    }
    if (s[i] == 'Z') b = i;
  }
  printf("%d\n", b - a + 1);
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int n, x;
    int* l;

    cin >> n >> x;

    l = new int[n];

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

    int count = 1;
    int d = 0;
    for(int i = 1; i <= n; i++){
        d += l[i-1];
        if(d <= x) count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<set>
#include<vector>
using namespace std;
int mod=1000000007;
int inv=(mod+1)/2;
int add(int x, int y)
{
	int c=x+y;
	if(c>=mod)c-=mod;
	return c;
}
int sub(int x, int y)
{
	int c=x-y;
	if(c<0)c+=mod;
	return c;
}
int mlt(int x, int y)
{
	long long c=x*1LL*y;
	if(c>=mod)c%=mod;
	return c;
}
vector<int>rec(vector<int>&dp, int m)
{
	vector<int>res(m+1), dpml(m+1), pref(m+1), pows(m+1), dvas(m+1);
	pows[0]=1;
	dvas[0]=1;
	for(int i=1; i<=m; i++)
	{
		pows[i] = mlt(pows[i - 1], inv);
		dvas[i] = mlt(dvas[i - 1], 2);
	}
	res[1]=add(dp[1],dp[1]);
	for(int i=1; i<=m-1; i++)
	{
		dpml[i]=mlt(dp[i], mlt(pows[i+1], i));
	}
	pref[0]=0;
	for(int i=1; i<m; i++)
		pref[i]=add(pref[i-1], dpml[i]);
	for(int i=2; i<=m; i++)
	{
		res[i]=mlt(dp[i], i+1);
	//	cout<<i<<' '<<res[i]<<endl;
		int val=pref[i-1];
		val=mlt(val, dvas[i]);
		res[i]=add(res[i], val);
	}
	return res;
}
int main()
{
	int h1, h2, m1, m2, k;
	cin>>h1>>m1>>h2>>m2>>k;
	int val=60*h2+m2-60*h1-m1-k;
	cout<<max(0,val)<<endl;
}


Measured memory_bytes: 3632
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

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

while True:
    try:
        a,b=map(int,input().split())
    except:
        break
    print(gcd(a,b),lcm(a,b))


Measured memory_bytes: 5600
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; } value
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

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

  int h, w;
  cin >> h >> w;
  vector<int> dx = { -1, -1, -1, 0, 0, 1, 1, 1 };
  vector<int> dy = { -1, 0, 1, -1, 1, -1, 0, 1 };
  vector<vector<char>> vec(h,vector<char>(w));

  REP(i,h) REP(j,w) cin >> vec[i][j];

  REP(i,h) {
    REP(j,w) {
      if(vec[i][j] == '#') continue;

      int cnt = 0;
      REP(k,8) {
        int x = i + dx[k];
        int y = j + dy[k];

        if(x < 0 || x == h) continue;
        if(y < 0 || y == w) continue;
        
        if(vec[x][y] == '#') cnt++;
      }
      vec[i][j] = (char)(cnt + '0');
    }
  }

  REP(i,h) {
    REP(j,w) {
      cout << vec[i][j];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;
set<int> divisor(int n)
{
	set<int> value;
	for( int ite=1; (ll)ite*ite<=n;ite++)
	{
		
			if (n % ite == 0)
			{
				value.insert(ite);
				if (ite * ite != n)
				{
					value.insert(n / ite);
				}
			}
		
	}
	return value;
}
/*

set<ll> divisor(ll n)
{
	set<ll> value;
	for( ll i=1; i*i<=n;i++)
	{
		
			if (n % i == 0)
			{
				value.insert(i);
				if (i * i != n)
				{
					value.insert(n / i);
				}
			}
		
	}
	return value;
}
*/

void solve()
{
	int n;
	cin>>n;
	map<int,int>cnt;
	set<int>exist;
	vector<int>a(n);
	rep(i,n){
		cin>>a[i];
		exist.insert(a[i]);
		cnt[a[i]]++;
	}
	int ans=0;
	rep(j,n){
		set<int>div=divisor(a[j]);
		bool ok=true;
		for(auto i=div.begin();i!=div.end();i++){
			if(*i==a[j]){
				if(cnt[*i]>1){
					ok=false;
				}
			}
			else if(exist.count(*i)){
				ok=false;
			}
		}
		if(ok)ans++;
	}
	cout<<ans<<endl;

}

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


Measured memory_bytes: 22668
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5;
ll a[N],sum[N];
int main() {
	ll n,m,v,p;
	scanf("%lld%lld%lld%lld",&n,&m,&v,&p);
	for(int i=1;i<=n;i++) {
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++) {
		sum[i]=sum[i-1]+a[i];
	}
	ll ans=p;
	v-=p;
	for(int i=1;i<=n-p;i++) {
		if(v<=0) ans+=(a[i]+m>=a[n-p+1]?1:0);
		else {
			ll t=a[i]+m;
			if(t>=a[n-p+1]&&t*(n-p-i+1)-sum[n-p+1]+sum[i]>=m*v) ans++;
		}
		v--;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
sx, sy, tx, ty = [int(x) for x in input().split(' ')]

rap_1 = abs(ty-sy) * ['U'] + abs(tx-sx) * ['R']
rap_1 += abs(ty-sy) * ['D'] + abs(tx-sx) * ['L']
rap_2 = ['L'] + (abs(ty-sy)+1) * ['U'] + (abs(tx-sx)+1) * ['R'] + ['D']
rap_2 += ['R'] + (abs(ty-sy)+1) * ['D'] + (abs(tx-sx)+1) * ['L'] + ['U']

print(''.join(rap_1)+''.join(rap_2))


Measured memory_bytes: 3188
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <utility>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << (#x) << ": " << (x) << endl
#define DEBUG_VEC(v)            \
    cerr << #v << ": ";         \
    REP(__i, (v).size())        \
    cerr << ((v)[__i]) << ", "; \
    cerr << endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int gcd(int x, int y) {
    if (y > x) swap(x, y);
    if (y == 0) return x;
    return gcd(y, x % y);
}


int main()
{
    ios::sync_with_stdio(false);
    int A, B, K;
    cin >> A >> B >> K;

    int g = gcd(A, B);
    vi xs;
    xs.push_back(1);
    for (int i = 2; i <= (int) sqrt(g); ++i) {
        if (g % i == 0) {
            xs.push_back(i);
            if (i * i != g) xs.push_back(g / i);
        }
    }
    xs.push_back(g);
    sort(xs.begin(), xs.end());
    cout << xs[xs.size() - K] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
#define F first
#define S second
using namespace std;

int main(){
	int M,T,P,R;
	while(cin>>M>>T>>P>>R,M){
		pair<int,pair<int,int>> ans[51];//-nans,time,team
		int pena[51][11]={0};//team,mondai
		REP(i,1,T+1){
			ans[i].F=0;
			ans[i].S.F=0;
			ans[i].S.S=-i;
		}

		REP(i,0,R){
			int m,t,p,j;
			cin>>m>>t>>p>>j;
			if(j){//WA
				pena[t][p]++;
			}else{//AC
				ans[t].F--;
				ans[t].S.F+=m+pena[t][p]*20;
			}
		}
		sort(ans+1,ans+T+1);
		cout<<-ans[1].S.S;
		REP(i,2,T+1){
			if(ans[i-1].F==ans[i].F&&ans[i-1].S.F==ans[i].S.F){
				cout<<"="<<-ans[i].S.S;
			}else{
				cout<<","<<-ans[i].S.S;
			}
		}
		p("");
	}

	return 0;
}

Measured memory_bytes: 3108
package main

import "fmt"

// 2018-10-26T10:16:19+0800
// 2018-10-26T10:20:30+0800
// 2018-10-26T10:26:34+0800
func main() {
	var N, x int
	fmt.Scanf("%d%d", &N, &x)
	O := 0
	a := make([]int, N)
	fmt.Scanf("%d", &a[0])
	if a[0] > x {
		O += a[0] - x
		a[0] = x
	}
	for i := 1; i < N; i++ {
		fmt.Scanf("%d", &a[i])
		if a[i-1]+a[i] > x {
			O += a[i-1] + a[i] - x
			a[i] = x - a[i-1]
		}
	}
	fmt.Println(O)
}

Measured memory_bytes: 6528
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n, a;

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

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        a = sc.nextInt();
        solve();
    }

    void solve() {
        System.out.println(n * n - a);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

using namespace std;

int main(){
    long long int N, A, B, ans;

    cin >> N >> A >> B;

    if(A != 0){
        ans = (N / (A + B)) * A;
        ans += min(A, N % (A + B));
    }else{
        ans = 0;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 888
<?php
fscanf(STDIN, "%d", $N);
$A = explode(" ", trim(fgets(STDIN)));
$ans = [];

$total = array_sum($A) / 2;
$x = 0;
for ($i = 0; $i < $N; $i += 2) {
    $x += $A[$i];
}
$ans[] = abs($total - $x) * 2;
for ($i = 1; $i < $N; $i++) {
    if ($i % 2 === 0) {
        $x += $A[$i - 1];
    } else {
        $x -= $A[$i - 1];
    }
    $ans[] = abs($x - $total) * 2;
}
echo implode(" ", $ans);

Measured memory_bytes: 20976
import sys
sys.setrecursionlimit(10**6)
N = int(input())
A = []
for _ in range(N):
    a,b,c = map(int,input().split())
    A.append((a,b,c))
    
# 無限大の値
INF = 10**10

# DP テーブル (値と前に選んだ活動を保持)
# a (j = 0), b (j = 1), c (j = 2)に記録
dp = [[0]*3 for _ in range(100010)]

# DP テーブル全体を初期化
for i in range(100010):
    for j in range(3):
        dp[i][j] = 0# 最大化問題

def rec(v):
    # v 日目の活動
    for w in range(3):
        # DP の値がすでに更新されていたらそのままリターン
        if dp[v][w] > 0:
            return dp[v]
        # 初期条件
        if v == 0:
            dp[v][w] = 0
            return dp[v]
        # v-1 を再帰
        res = 0
        for k in range(3):
            # 前日と活動が同じならスルー
            if w == k:
                continue
            res = max(res, rec(v-1)[k] + A[v-1][w])
            # 結果をメモして返す
            dp[v][w] = res
    return dp[v]
rec(N)
ans = max(dp[N])
print(ans)

Measured memory_bytes: 133020
function Main(args){

  const input = args.split(" ");
  const target = Number(input);

  var count = 0;
  for(var i = 1; i <= target ; i++ ) {
    if (String(i).length%2 != 0) count++;
  }
  console.log(count);


}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num1 = sc.nextInt();
        int num2 = sc.nextInt();
        int menseki = num1 * num2;
        int shu = num1*2 + num2*2;
        System.out.println(menseki + " " + shu);
    }
}


Measured memory_bytes: 26188
using System;

public class Test{
  public static void Main(){
    
    //文字列の読み込み
    string str = System.Console.ReadLine();
    
    if(str[2] == str[3] && str[4] == str[5]){
    	System.Console.WriteLine("Yes");
    } else {
    	System.Console.WriteLine("No");
    }
  }
}


Measured memory_bytes: 13140
import math

def func(x, k):
    j = 0
    while x < k:
        x *= 2
        j += 1
    return j

N, K = map(int, input().split())
P = []

for i in range(1, N+1):
    P.append(1/N * (1/2)**func(i, K))



print(sum(P))

Measured memory_bytes: 6296
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()
typedef long long ll;



int main() {
    ll a;
    string b;
    cin >> a >> b;
    string b1 = b.substr(0,1);
    string b2 = b.substr(2);
    int bnum = stoi(b1)*100 + stoi(b2);
    
    dunk(a*bnum/100);
    
    return 0;
}



Measured memory_bytes: 3624
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

string S, T;

bool same_idxs(vector<int>* v1, vector<int>* v2) {
  if (v1->size() != v2->size()) {
    return false;
  }

  for (int i = 0; i < v1->size(); i++) {
    if ((*v1)[i] != (*v2)[i]) {
      return false;
    }
  }

  return true;
}

int main() {
  cin >> S >> T;

  char R1[0x100], R2[0x100];
  for (int i = 0; i < 0xff; i++)
    R1[i] = R2[i] = -1;

  for (int i = 0; i < S.size(); i++) {
    if (R1[S[i]] < 0) {
      R1[S[i]] = T[i];
    } else if (R1[S[i]] != T[i]) {
      cout << "No" << endl;
      return 0;
    }
    if (R2[T[i]] < 0) {
      R2[T[i]] = S[i];
    } else if (R2[T[i]] != S[i]) {
      cout << "No" << endl;
      return 0;
    }
  }

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


Measured memory_bytes: 3856
//AUTHOR - NIMISH UPADHYAY
//FROM IIIT ALLAHABAD
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define UPADHYAY int t;cin>>t;while(t--)
#define pb push_back
#define NIMISH ios_base::sync_with_stdio(false);cin.tie(NULL);
int main(){
    NIMISH
    ll n,i;
    cin>>n;
    ll c[n][3],v[n][3],j;
    for(i=0;i<n;i++){
        for(j=0;j<3;j++)cin>>c[i][j];
    }
    v[0][0]=c[0][0];
    v[0][1]=c[0][1];
    v[0][2]=c[0][2];
    for(i=1;i<n;i++){
        for(j=0;j<3;j++){
            if(j==0)
            v[i][j]=c[i][j]+max(v[i-1][1],v[i-1][2]);
            if(j==1)
            v[i][j]=c[i][j]+max(v[i-1][2],v[i-1][0]);
            if(j==2)
            v[i][j]=c[i][j]+max(v[i-1][1],v[i-1][0]);
        }
    }
    cout<<max(v[n-1][0],max(v[n-1][1],v[n-1][2]));
}

Measured memory_bytes: 8292
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  vector<vector<int64_t>> x(c-a+1,vector<int64_t>(d-b+1));
  int64_t p=998244353;
  x[0][0]=1;
  for(int i=0;i<=c-a;i++){
    for(int j=0;j<=d-b;j++){
      if(i==0&&j!=0)
        x[i][j]=x[i][j-1]*a%p;
      if(i!=0&&j==0)
        x[i][j]=x[i-1][j]*b%p;
      if(i!=0&&j!=0)
        x[i][j]=(x[i][j-1]*(a+i)+x[i-1][j]*(b+j)-x[i-1][j-1]*(a+i-1)*(b+j-1)+p*c*d)%p;
    }
  }
  cout<<x[c-a][d-b]<<endl;
}

Measured memory_bytes: 73648
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

string s;
vs32 Rpos;
vs32 Gpos;
vs32 Bpos;

s64 search(vs32& pos, int l, int r)
{
    // auto itl = lower_bound(pos.begin(), pos.end(), l);
    // auto itr = lower_bound(pos.begin(), pos.end(), r);
    s64 ret = 0;
    // ret += itr - itl;
    if ((l + r) % 2 == 0)
    {
        ret -= upper_bound(pos.begin(), pos.end(), (l + r) / 2) - lower_bound(pos.begin(), pos.end(), (l + r) / 2);
    }
    return ret;
}

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

    int n;
    cin >> n;
    cin >> s;

    rep (i, n)
    {
        if (s[i] == 'R') Rpos.push_back(i);
        else if (s[i] == 'G') Gpos.push_back(i);
        else if (s[i] == 'B') Bpos.push_back(i);
    }

    s64 ans = Rpos.size() * Gpos.size() * Bpos.size();
    for (int l = 0; l < n; ++l)
    {
        for (int r = l + 1; r < n; ++r)
        {
            if (s[l] == s[r]) continue;
            if (s[l] == 'R' && s[r] == 'G')
            {
                ans += search(Bpos, l, r);
            }
            else if (s[l] == 'R' && s[r] == 'B')
            {
                ans += search(Gpos, l, r);
            }
            else if (s[l] == 'G' && s[r] == 'R')
            {
                ans += search(Bpos, l, r);
            }
            else if (s[l] == 'G' && s[r] == 'B')
            {
                ans += search(Rpos, l, r);
            }
            else if (s[l] == 'B' && s[r] == 'R')
            {
                ans += search(Gpos, l, r);
            }
            else if (s[l] == 'B' && s[r] == 'G')
            {
                ans += search(Rpos, l, r);
            }
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3676
n, m = map(int, input().split())

py = []
for i in range(m):
    p, y = map(int, input().split())
    py.append([i, p, y])
cnt = [0] * (n + 1)

sorted_py = sorted(py, key = lambda x: (x[1], x[2]))
for i in range(m):
    cnt[sorted_py[i][1]] += 1
    city_id = str(sorted_py[i][1]).zfill(6)+str(cnt[sorted_py[i][1]]).zfill(6)
    sorted_py[i].append(city_id)

sorted_py = sorted(sorted_py, key = lambda x: x[0])
for i in range(m):
    print(sorted_py[i][3])

Measured memory_bytes: 45460
import java.util.Scanner;

class Main {
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int numberOfPeople = sc.nextInt();
		int day = sc.nextInt();
		int remainingNumber = sc.nextInt();

		int eatCount = 0;
		
		for(int i = 0; i < numberOfPeople; i++) {
			eatCount += 1;
			int eatDay = sc.nextInt();
			int nextEatDay = 1 + eatDay;
			for(int d = 0; d <= day; d++) {
				if(d == nextEatDay) {
					eatCount += 1;
					nextEatDay += eatDay;
				}
			}
		}
		System.out.println(eatCount + remainingNumber);
	}
}

Measured memory_bytes: 22996
def main():
    s = int(input())
    an = list()
    a = 0
    for i in range(1000000):
        if i == 0:
            a = s
            an.append(a)
        else:
            if a % 2 == 0:
                a = int(a/2)
                an.append(a) 
            else:
                a = 3*a + 1
                an.append(a)
    for i in range(1000000):
        a = an[i]
        try:
            m = an.index(a, i+1)
            if m != -1:
                print(m+1)
                break
        except:
            continue
main()

Measured memory_bytes: 10952
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
#include <stack>
//#include <atcoder/scc>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
//using namespace atcoder;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)

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

lli gcd2(lli x, lli y)
{
    lli t;
    while (y != 0)
        t = x % y, x = y, y = t;
    return (x);
}

lli lcm2(lli x, lli y)
{
    lli xy = x * y;
    if (xy < 0)
        xy = -xy;
    return (xy / gcd2(x, y));
}
lli m = 1e9 + 7;
int main(void)
{
    int a, b;
    cin >> a >> b;
    cout << max(a * b, max(a - b, a + b)) << endl;
    return 0;
}


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
template <class T>
T GCD(T a, T b)
{
    T r;
    while (a)
        r = b, b = a, a = r % a;
    return b;
}
template <class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repe(i, n) for (ll i = 0; i <= (n); i++)
#define repd(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<ll> vl;
#define ERASE(x) x.erase(unique(ALL(x)), x.end()); // erase same elements
#define VEC(type, c, n)     \
    std::vector<type> c(n); \
    for (auto &i : c)       \
        std::cin >> i;

// input
#define INIT                          \
    std::ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define VAR(type, ...) \
    type __VA_ARGS__;  \
    MACRO_VAR_Scan(__VA_ARGS__);
template <typename T>
void MACRO_VAR_Scan(T &t)
{
    std::cin >> t;
}
template <typename First, typename... Rest>
void MACRO_VAR_Scan(First &first, Rest &... rest)
{
    std::cin >> first;
    MACRO_VAR_Scan(rest...);
}

// output
template <typename T>
void MACRO_OUT(const T t) { std::cout << t; }

#define OUT(...) MACRO_OUT(__VA_ARGS__);
#define SP std::cout << " ";
#define TAB std::cout << "\t";
#define BR std::cout << "\n";
#define ENDL std::cout << std::endl;

#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define yes() printf("yes\n")
#define no() printf("no\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
    cout << a;
    ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
    cout << a << ' ';
}

bool check = 0;
bool boo = 0;
int N = 3;
vector<int> v(N);
ll minn = INF, maxx = 0;
ll x = 0, y = 0;
int sum;
char ch;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// cout << (conditon ? (result:  == 1 ): (==0)) << endl; <- output result of if
// long long 型が表せる値の上限はおよそ 9 × 10＾18 です．
int main()
{
    INIT;
    int ans = 1000000, num;
    string s;
    cin >> s;
    rep(i, s.length() - 2)
    {
        int num = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0');
        ans = min(ans, abs(num - 753));
    }
    pr(ans);
    return 0;
}


Measured memory_bytes: 3632
import sys

MOD = 10 ** 9 + 7

def make_table(size=10**6, p=MOD):
    fac = [None] * (size + 1)
    fac[0] = 1
    for i in range(size):
        fac[i+1] = fac[i] * (i + 1) % p
    ifac = [None] * (size + 1)
    ifac[size] = pow(fac[size], p-2, p)
    for i in range(size, 0, -1):
        ifac[i-1] = ifac[i] * i % p
    return fac, ifac

fac, ifac = make_table(5*10**3)

def comb(n, r, mod=MOD):
    if r > n or r < 0:
        return 0
    return fac[n] * ifac[r] % mod * ifac[n-r] % mod

def H(n, r):
    return comb(n - 1 + r, r)

n, k = map(int, sys.stdin.readline().split())

def main():
    res = [None] * (k + 1)
    for i in range(1, k+1):
        if i > n - k + 1:
            for j in range(i, k+1):
                res[j] = 0
                break
        res[i] = H(i + 1, n - k - (i - 1)) * H(i, k - i) % MOD
    
    return res[1:]
    
if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

typedef long long i64;
typedef pair<i64,i64> P;

int c[3][3];

#define NO cout << "No";return 0;

int main()
{
	for(int i = 0;i < 3;i++)
	{
		for(int j = 0;j < 3;j++)
		{
			cin >> c[i][j];
		}
	}

	int dx[2] = {c[1][0] - c[0][0] , c[2][0] - c[1][0]};

	for(int j = 0;j < 3;j++)
	{
		for(int i = 0;i < 2;i++)
		{
			if(c[i][j] + dx[i] != c[i + 1][j])
			{
				NO
			}
		}
	}

	int dy[2] = {c[0][1] - c[0][0] , c[0][2] - c[0][1]};

	for(int i = 0;i < 3;i++)
	{
		for(int j = 0;j < 2;j++)
		{

			if(c[i][j] + dy[j] != c[i][j + 1])
			{

				NO
			}
		}
	}

	cout << "Yes";
	return 0;
				
	

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
typedef long long ll;


int main(){
  string s;
  cin >> s;
  ll minX = 1e9;
  rep(i,s.size()-2){
    string tmp;
    tmp = s.substr(i,3);
    //cout << tmp << endl;
    ll x = toInt(tmp);
    minX  = min(minX,abs(x-753));
  }
  cout << minX << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

int f(int a){
	int ret = 0;
	while(a>0){
		ret += a%10;
		a /= 10;
	}
	return ret;
}

int main(){
	int N;
	scanf("%d", &N);

	int min = 10000;
	int a;
	for(a=1;a<=N-a;a++){
		if(f(a)+f(N-a)<min){
			min = f(a)+f(N-a);
		}
	}
	printf("%d\n", min);

	return 0;
}


Measured memory_bytes: 256
def main():
	import sys
	input = sys.stdin.readline
	N = int(input())
	d = list(map(int, input().split()))
	d.sort()
	ind = int(N/2)
	if d[ind-1] == d[ind]:
		print(0)
	else:
		print(d[ind] - d[ind-1])

if __name__ == '__main__':
    main()

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

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++)
    cin >> L[i];
  sort(L.begin(), L.end());
  int sum = 0;
  for (int i = 0; i < N - 1; i++)
    sum += L[i];
  if (L[N - 1] < sum)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


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

public class Main {

  private static final char[] ACGT = {'A', 'C', 'G', 'T'};

  public static void main(String[] args) {

    String tmp = null;
    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
      tmp = br.readLine();
    } catch (IOException e) {
      e.printStackTrace();
      System.exit(1);
    }

    int result = 0;
    char[] in = tmp.toCharArray();
    for (int i = 0; i < in.length; i++) {
      int num = 0;
      for (int j = i; j < in.length; j++) {
        boolean b = false;
        for (int l = 0; l < ACGT.length; l++) {
          if (in[j] == ACGT[l]) {
            b = true;
            num++;
            break;
          }
        }
        if (!b) {
          break;
        }
      }
      if (result < num) {
        result = num;
      }
    }

    System.out.print(result);
  }
}



Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100005];
ll ans[100005];
int main()
{
	ll n;cin>>n;ll mn=2e9;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		mn=min(mn,a[i]);
	}
	mn*=2;ans[1]=mn;mn=0;
	for(int i=2;i<=n;i++)
	{
		ans[i]=a[i-1]*2-ans[i-1];
		mn=min(mn,ans[i]);
	}
	int res=(ans[1]+ans[n])/2-a[n];
	for(int i=1;i<=n;i++)
	{
		if(i%2==1)
		{
			ans[i]-=(res);
		}
		else ans[i]+=(res);
	}
	for(int i=1;i<=n;i++)
	{
		printf("%lld%c",ans[i],(i==n)?'\n':' ');
	}
	return 0;
}


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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define debug(i) cout << i << endl;
#define debugarr(a) for(auto i : a) cout << i << " ";

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

using namespace std;

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

    int n;
    cin >> n;

    ll a[n+1];
    ll b[n];

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

    ll ans = 0;

    for(int i = n-1; i >= 0; i--) {
        ll prox = min(a[i+1], b[i]);
        b[i] -= prox;
        ans += prox;

        ll at = min(a[i], b[i]);
        a[i] -= at;
        ans += at;
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    template <bool nl>
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { final(); }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
        template <bool f = nl>
        auto final() -> std::enable_if_t<f> { cout << '\n'; }
        template <bool f = nl>
        auto final() -> std::enable_if_t<!f> {}
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy<true> operator,(T&& val)
    {
        cout << val;
        return {};
    }
    proxy<false> noreturn() { return {}; }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
            }
            cout << x;
            first = false;
        }
    }
};

void prog()
{
    input in;
    output out;

    int p, q, r;
    in >> p, q, r;
    out, p + q + r - std::max({p, q, r});
}

int main()
{
    prog();
    return 0;
}


Measured memory_bytes: 256