akhauriyash/Code-Regression huggingface dataset:
/*
 * wafuIroha.cpp
 *
 *  Created on: 2020/02/23
 *      Author: black
 */
#include <iostream>
using namespace std;

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

	if ((a == 'a') || (a == 'e') || (a == 'i') || (a == 'o') || (a == 'u')){
		cout << "vowel" << endl;
	}
	else{
		cout << "consonant" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,x,n;
    cin>>n;
    while(1)
    {
        x=0;
        for(i=2;i<=n;i++)
        {

            if(n%i==0)
            {
                break;
            }
            //c++;
        }
        if(i==n)
        {
            cout<<n;
            break;
        }
        n++;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
const int maxn = 10;
char s[maxn];
int main()
{
	scanf("%s", &s);
	int len = strlen(s);
	bool flag = false;
	for(int i = 0; i < len - 1; ++i)
		if(s[i] == 'A' && s[i + 1] == 'C')
		{
			flag = true; break;
		}
	puts(flag ? "Yes" : "No");
	return 0;
}

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

int main() {
  
  string S; int Q; cin >> S >> Q;
  
  int countOne = 0;
  
  deque<char> frontDeque, backDeque;
  
  for (int i = 0; i < Q; i++) {
    
    int T; cin >> T;
    
    if (T == 1) countOne++;
    
    if (T == 2) {
      
      int F; char C; cin >> F >> C;
      
      if (F == 1) {
        if (countOne % 2 == 0) frontDeque.push_back(C);
        if (countOne % 2 == 1) backDeque.push_back(C);
      }
      
      if (F == 2) {
        if (countOne % 2 == 0) backDeque.push_back(C);
        if (countOne % 2 == 1) frontDeque.push_back(C);
      }
      
    }
    
  }
  
  if (countOne % 2 == 0) {
    for (int i = frontDeque.size() - 1; 0 <= i; i--) cout << frontDeque.at(i);
    cout << S;
    for (int i = 0; i < backDeque.size(); i++) cout << backDeque.at(i);
  }
  
  if (countOne % 2 == 1) {
    for (int i = backDeque.size() - 1; 0 <= i; i--) cout << backDeque.at(i);
    reverse(S.begin(), S.end());
    cout << S;
    for (int i = 0; i < frontDeque.size(); i++) cout << frontDeque.at(i);
  }
  
  cout << endl;
  
}

Measured memory_bytes: 3920
N, K = map(int, input().split())
List = []
void = 0
cnt = 0
for i in range(int(K)):
    void = int(input())
    List.append(list(map(int, input().split())))

arr = [int(x) for y in List for x in y]

for k in range(1,N+1):
    if k in arr:
        pass
    else:
        cnt += 1

print(cnt)


Measured memory_bytes: 9088
#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[]) {
    // insert code here...

    double y,z,n,w,c;
    scanf("%lf %lf %lf %lf",&y,&z,&n,&w);
    c=sqrt(((n-y)*(n-y))+((w-z)*(w-z)));
    printf("%f\n", c);
    return 0;
}



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

string S, T;
int main(){
	cin >> S >> T;
	int num = 0;
	for(int i = 0; i < 3; i++){
		if(S[i] == T[i]){
			num++;
		}
	}
	cout << num << endl;
}

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

using namespace std;
using ll = long long int;

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

    vector<int> index(n);
    iota(index.begin(), index.end(), 0);
    sort(index.begin(), index.end(), [&](int a, int b) { return A[a] < A[b]; });

    for (auto &i : index)
    {
        cout << (i + 1) << " ";
    }
    cout << endl;
}

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

    int gcd(int A, int B){
        if(A % B == 0)
            return B;
        else
            return(gcd(B, A%B));
    }

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

        int tmp, tmp2;
        int result = 0;
        for(int i = 1; i <= N; i++){
            for(int j = 1; j <= N; j++){
                for(int k = 1; k <= N; k++){
                    tmp = gcd(i,j);
                    tmp2 = gcd(tmp, k);
                    result += tmp2;
                }
            }
        }
        cout << result << endl;
    }

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
const ll mo=1000000007;
ll ans=0;
ll dp[0][0];
struct UnionFind {
  vector<ll> data;
  UnionFind(ll size) : data(size, -1) { }
  bool unionSet(ll x, ll y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(ll x, ll y) {
    return root(x) == root(y);
  }
  ll root(ll x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  ll size(ll x) {
    return -data[root(x)];
  }
};
int main()
{
ll n,m;
cin >> n>>m;
ll table[n]={};
rep(i,n) {
    cin >> table[i];
}
UnionFind arr(n);
rep(i,m){
    ll a,b;
    cin >> a>>b;
    arr.unionSet(a-1,b-1);
}
rep(i,n){
    if(arr.findSet(table[i]-1,i))ans++;
}
cout << ans << endl;
return 0;
}








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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


int N, W;
int dp[105][10005];

void solve() {
    cin >> N >> W;
    vec v(N), w(N);
    rep(i, N) cin >> v[i] >> w[i];
    rep(i, N){
        Rep1(j, 0, W){
            if(j < w[i]){
                dp[i+1][j] = dp[i][j];
            }else{
                dp[i+1][j] = max(dp[i][j], dp[i+1][j-w[i]]+v[i]);
            }
        }
    }
    cout << dp[N][W] << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}



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

void solve(int n){
    int w,h,s,t;
    int ans=0,count;
    cin>>w>>h;
    vector<vector<bool>> m;
    m=vector<vector<bool>>(h,vector<bool>(w,false));
    for(int i=0;i<n;i++){
        cin>>s>>t;
        m[t-1][s-1]=true;
    }
    cin>>s>>t;
    for(int i=0;i<h-t+1;i++){
        for(int j=0;j<w-s+1;j++){
            count=0;
            for(int k=0;k<t;k++){
                for(int l=0;l<s;l++){
                    if(m[i+k][j+l])count++;
                }
            }
            //cout<<i<<" "<<j<<" "<<count<<endl;
            ans=max(ans,count);
        }
    }
    cout<<ans<<endl;
}

int main(void){
    int n;
    while(cin>>n,n){
        solve(n);
    }
}

Measured memory_bytes: 3116
local n = io.read("*n")
local fact = {1}
for i = 2, n do
  fact[i] = i * fact[i - 1]
end
local function getrank(a)
  local box = {}
  for i = 1, n do box[i] = false end
  local r = 0
  for i = 1, n do
    for j = 1, a[i] - 1 do
      if not box[j] then
        r = r + fact[n - i]
      end
    end
    box[a[i]] = true
  end
  return r
end
local t = {}
for i = 1, n do
  t[i] = io.read("*n")
end
local ar = getrank(t)
for i = 1, n do
  t[i] = io.read("*n")
end
local br = getrank(t)
print(math.abs(ar - br))


Measured memory_bytes: 508
#include<stdio.h>
int main(void){
int a,b;
  scanf("%d",&a);
  scanf("%d",&b);
  if(a-b==1){
    printf("%d",a+b);
  }
  else if(a==b){
    printf("%d",a+b);
  }
  else if(b-a==1){
    printf("%d",a+b);
  }
  else if(a-b>=2){
    printf("%d",a+a-1);
  }
  else if(b-a>=2){
    printf("%d",b+b-1);
  }
return 0;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    long double D[N+1][N+1], p, S=0;
    for (int i = 0; i <= N; i++)
    {
        for (int y = 0; y <= N; y++)
        {
            D[i][y] = 0;
        }
    }
    D[0][0] = 1;
    for (int i = 1; i <= N; i++)
    {
        cin >> p;
        D[i][0] = D[i-1][0] * (1-p);
        for (int y = 1; y <= i; y++)
        {
            D[i][y] = D[i-1][y] * (1-p) + D[i-1][y-1] * p;
        }
    }
    for (int i = (N+1)/2; i <= N; i++)
    {
        S += D[N][i];
    }
    cout << fixed << setprecision(10) << S;
    return 0;
}


Measured memory_bytes: 140928
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(b/a,c)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(0); cin.tie(0);
#define fore(i, a, b) for(int i = a; i < b; i++)
#define fori(i, a, b) for(int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb push_back
#define popb pop_back
#define mk make_pair
#define fi first
#define se second
#define endl '\n'
#define MAX 60
typedef long long int lli;
typedef long double ld;
const double PI = acos(-1.0);
ld eps = 1e-9;

int main() {
	optimizar_io
	int a; cin >> a;
	int ans = a + (a * a) + (a * a * a);
	cout << ans << endl;
}

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

int main() {
int n;
  cin>>n;
  if(n<=1199)
    cout<<"ABC"<<endl;
  else if
    (n<=2799)
    cout<<"ARC"<<endl;
  else
    cout<<"AGC"<<endl;
}


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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#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 = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
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){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;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};


ll MAX_V = 2e5 + 5;
vector<vector<ll>> G(MAX_V);//隣接リスト(添え字は始点、値は終点)

//引数は各頂点(0-indexed)の入次数
vector<ll>tsort(vector<ll>v){
  ll n=v.size();
  vector<ll>ret(n);
  stack<ll>st;
  for(ll i=0;i<n;i++)if(v[i]==0)st.push(i);
  for(ll i=0;i<n;i++){
    if(st.empty())return vector<ll>();//閉路がある
    ll x=st.top();
    st.pop();
    ret[x]=i;
    for(ll j=0;j<G[x].size();j++){
      v[G[x][j]]--;
      if(v[G[x][j]]==0)st.push(G[x][j]);
    }
  }
  return ret;
}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n,m;cin>>n>>m;
  vector<ll>a(n);
  for(ll i=0;i<n+m-1;i++){
    ll p,q;
    cin>>p>>q;
    G[p-1].push_back(q-1);
    a[q-1]++;
  }
  auto v=tsort(a);
  vector<P>ret(n,{-1,-1});
  rep(i,0,n){
    rep(j,0,G[i].size()){
      if(ret[G[i][j]].se<v[i]){
        ret[G[i][j]].se=v[i];
        ret[G[i][j]].fi=i;
      }
    }
  }
  rep(i,0,n)cout<<ret[i].fi+1<<endl;
  return 0;
}

Measured memory_bytes: 11760
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 1e18
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A,B;
    cin>>A>>B;
    if((A+B)%2==0) cout<<(A+B)/2<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

int main(){
  int n;
  cin >> n;
  set<string> s;
  for(int i = 0; i < n; ++i){
  	string ss;
  	cin >> ss;
  	s.insert(ss);
  }

  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 19120
x = gets.chop.to_i

def judge(n)
  flag = true
  (1..n).each do |i|
    next if i == 1 || i == n
    if n % i == 0
      flag = false
    end
  end

  return flag
end

ans = 0
i = x

loop do
  if judge(i)
    ans = i
    break
  end
  i += 1
end

puts ans


Measured memory_bytes: 1788
fun main(args: Array<String>) {
    var n = readLine()!!.toInt()
    var a = readLine()!!.split(" ").map(String::toInt)
    var count = MutableList(n, {0})
    for (ai in a)
        count[ai-1] ++
    for (ci in count)
        println(ci)
}


Measured memory_bytes: 69976
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int K = 0;
ll pt[20];
int GETA = 9;
ll comb[2][20];
ll ans = 0ll;
void dfs(int d,ll rem,ll x){
	if(K-1-d==d){
		if(rem==0ll){
			ans += x*10ll;
		}
		return;
	}
	if(K-1-d<d){
		if(rem==0ll){
			//cout << d <<  ' ' << rem << ' ' << x << endl;
			ans += x;
		}
		return;
	}
	ll pl = LLINF; int p = -10;
	ll mi = -LLINF; int m = -10;
	for(int i=-9;i<=9;i++){
		ll tmp = rem+(ll)i*(pt[K-1-d]-pt[d]);
		if(tmp>0ll){
			if(pl>tmp){
				pl = tmp;
				p = i;
			}
		}else{
			if(mi<tmp){
				mi = tmp;
				m = i;
			}
		}
	}
	if(p!=-10)dfs(d+1,pl,x*comb[!d][p+GETA]);
	if(m!=-10)dfs(d+1,mi,x*comb[!d][m+GETA]);
}
int dig(ll X){
	int res = 0;
	while(X>0ll){
		X /= 10ll;
		res++;
	}
	return res;
}
int main(){
	ll D;
	cin >> D;
	pt[0]=1ll;
	for(int i=1;i<=18;i++){
		pt[i]=pt[i-1]*10ll;
	}
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			comb[0][i-j+GETA]++;
		}
	}
	for(int i=1;i<10;i++){
		for(int j=1;j<10;j++){
			comb[1][i-j+GETA]++;
		}
	}
	int DIG = dig(D);
	for(int i=DIG;i<=DIG*2;i++){
		K = i;
		dfs(0,D,1ll);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string str;
   cin>>str;

   if(str=="SUN")
   {
       cout<<"7"<<endl;
   }
   else if(str=="MON")
   {
       cout<<"6"<<endl;
   }
    else if(str=="TUE")
   {
       cout<<"5"<<endl;
   }
    else if(str=="WED")
   {
       cout<<"4"<<endl;
   }
    else if(str=="THU")
   {
       cout<<"3"<<endl;
   }
    else if(str=="FRI")
   {
       cout<<"2"<<endl;
   }
    else if(str=="SAT")
   {
       cout<<"1"<<endl;
   }
 return 0;
}


Measured memory_bytes: 3572
N,K = map(int, input().split())
A = list(map(int, input().split()))

cnts = [0] * 46

for a in A:
    for i in range(46):
        if a & (1 << i):
            cnts[i] += 1

L = 45
dp = [[-1 for _ in range(2)] for _ in range(L+1)]
dp[0][0] = 0

for i in range(L):
    
    p0 = pow(2, L-1 - i) * cnts[L-1-i]
    p1 = pow(2, L-1 - i) * (N - cnts[L-1-i])

    if K & (1 << (L-1 - i)):
        is_one = True
    else:
        is_one = False


    if dp[i][1] != -1:
        dp[i+1][1] = dp[i][1] + max(p0, p1)

    if dp[i][0] != -1 and is_one:
        dp[i+1][1] = max(dp[i+1][1], dp[i][0] + p0)

    if dp[i][0] != -1:
        if is_one:
            dp[i+1][0] = dp[i][0] + p1
        else:
            dp[i+1][0] = dp[i][0] + p0



print(max(dp[-1]))

Measured memory_bytes: 14176
import numpy as np
h, w, k = map(int, input().split())
s = np.zeros((h, w), dtype=int)
for i in range(h):
    line = [a == "#" for a in input()]
    s[i] = np.array(line)


board = np.zeros((h, w), dtype=int)
cur = 1


def fill(u, d):
    global cur
    rs = np.arange(w)[s[i-1] == 1]
    rs[-1] = w-1
    prevr = -1
    for r in rs:
        board[u:d, prevr+1:r+1] = cur
        prevr = r
        cur += 1


previ = 0
for i in range(1, h+1):
    if s[i-1].sum() > 0:
        fill(previ, i)
        previ = i
if previ != h:
    for i in range(previ-1, h):
        board[i] = board[previ-1]
for line in board:
    print(" ".join(map(str, line)))


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

void solve(long long N, long long A, long long B)
{
    long long sum = 0;
    long long keta_sum = 0;
    string ke;
    for (int i = 1; i <= N; i++)
    {
        keta_sum = 0;
        string num = to_string(i);
        for (int j = 0; j < (int)(num.size()); j++)
        {
            ke = num[j];
            int keta = stol(ke.c_str());
            keta_sum += keta;
        }

        if (keta_sum <= B && keta_sum >= A)
        {
            sum += i;
        }
    }
    cout << sum << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(N, A, B);
    return 0;
}


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

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

typedef long long ll;

const int M = 1e5;

int main() {
	int N; cin >> N;
	vector<int> l(N), r(N);
	rep(i, N) scanf("%d%d", &l[i], &r[i]), l[i]--, r[i]--;
	vector<int> a(M + 1);
	rep(i, N) a[l[i]]++, a[r[i]]--;
	rep(j, M) a[j + 1] += a[j];
	int ma = 0;
	rep(j, M) ma = max(ma, a[j]);
	vector<int> L = l, R = r;
	sort(L.begin(), L.end());
	sort(R.begin(), R.end());
	int ans = 0;
	rep(i, N) {
		int x = lower_bound(L.begin(), L.end(), r[i]) - L.begin();
		x = N - x;
		int y = upper_bound(R.begin(), R.end(), l[i]) - R.begin();
		ans = max(ans, N - x - y);
	}
	cout << ans << ' ' << ma << endl;
}

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

int main(){

  	int A,B,C;
	cin >> A >> B >> C;
  
    int box1,box2;
	box1 = B;
    box2 = C;
    B += C;
    if( B > A) {
      C = B - A;
    }else{
      C = 0;
    }
  
    cout << C << endl;  	
}

Measured memory_bytes: 256
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
  
import collections
N = int(input())

c = collections.Counter(prime_factorize(N))

ans = 0
for j in c:
    for i in range(1,c[j]+1):
        if c[j] == 1:
            ans += 1
        elif i*(i+1)<= 2*c[j] < (i+1)*(i+2):
            ans += i

print(ans)

Measured memory_bytes: 9472
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdint>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;
using std::lower_bound;
using std::upper_bound;
using std::find_if;
using std::copy;
using std::copy_if;

int main(){
    int w,a,b;
    cin >> w >> a >> b;

    if(a<b){
        cout << std::max(0,b-a-w) << endl;
    }
    else{
        cout << std::max(0,a-b-w) << endl;
    }
    return 0;
}



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

int main() {
  int h, w;
  cin >> h >> w;

  vector<string> v(h);
  for (int i = 0; i < h; i++) {
    cin >> v.at(i);
  }

  vector<int> dx{ -1, -1, -1,  0, 0,  1, 1, 1 };
  vector<int> dy{ -1,  0,  1, -1, 1, -1, 0, 1 };

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (v.at(i).at(j) == '.') {
        int num = 0;
        for (int k = 0; k < 8; k++) {
          int x = i - dx.at(k);
          int y = j - dy.at(k);
          if (x >= 0 && x < h && y >= 0 && y < w) {
            if (v.at(x).at(y) == '#') {
              num++;
            }
          }
        }
        cout << num;
      } else {
        cout << '#';
      }
    }
    cout << endl;
  }

  return 0;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

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

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int k;
    cin >> k;
    set<int> st;
    int x = 7%k;
    rep1(i, k) {
        if (x == 0) {
            cout << i << endl;
            return 0;
        }
        if (st.find(x)!=st.end()) break;
        st.insert(x);
        x = (x * 10 + 7) % k;
    }
    cout << -1 << endl;
    return 0;
}


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

int a[111111];
int main() {
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        int p;
        string s;
        cin >> p >> s;
        if(a[p] > 0)
            continue;
        if(s == "AC")
            a[p] = 1 - a[p];
        else
            a[p]--;
    }
    int x = 0, y = 0;
    for(int i = 1; i <= n; i++)
        x += a[i] > 0, y += max(a[i] - 1, 0);
    cout << x << ' ' << y << endl;
    return 0;
}


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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
int main() {
  int a,b;cin>>a>>b;
  int ans=a*b;
  cout <<((ans%2==0)?"No":"Yes") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using ll = long long;
using namespace std;

int main () {
	ll N;
	cin >> N;	
	vector<ll> A(N); 
	for (ll i=0; i<N; ++i) cin >> A[i];
	sort(A.begin(), A.end());

	vector<ll> I(N);
	// N == 3 => 3rd, 1st, 2nd ... or ... 1st, 3rd, 2nd
	// N == 4 => 2nd, 4th, 1st, 3rd ... or ... 3rd, 1st, 4th, 2nd ... they are the same. symmetric
	/*
	(1)
	I[N/2] = 0; 
	I[N/2 - 1] = N-1;
	I[N/2 + 1] = N-2;
	I[N/2 - 2] = 1;
	I[N/2 + 2] = 2;
	I[N/2 - 3] = N-3;
	I[N/2 + 3] = N-4;
	I[N/2 - 4] = 3;
	I[N/2 + 4] = 4;

	... or ...

	(2)
	I[N/2] = N-1; 
	I[N/2 - 1] = 0;
	I[N/2 + 1] = 1;
	I[N/2 - 2] = N-2;
	I[N/2 + 2] = N-3;
	I[N/2 - 3] = 2;
	I[N/2 + 3] = 3 
	I[N/2 - 4] = N-4;
	I[N/2 + 4] = N-5;

	that is, shifts array I one element to right with perioding boundary

	*/

	ll m = N/2;
	I[m] = 0;
	ll counter = 1;
	bool first_flag = true; 
	ll w = 1;
	while (counter < N) {
		ll temp;
		if(first_flag) {
			if (w % 2 == 0) {
				temp = w - 1;
			} else {
				temp = N - w;
			}
			I[m-w] = temp;
			first_flag = false;
		} else {
			if (w % 2 == 0) {
				temp = w; 
			} else {
				temp = N - w - 1; 
			}
			I[m+w] = temp;
			first_flag = true;
			w++;
		}
		counter++;
	}
	/*
	for (ll i=0;i<N;++i) cout << I[i] << " ";
	cout << endl;
	*/

	ll ans = 0;
	for (ll i=1; i<N; ++i) {
		ans += abs(A[I[i]] - A[I[i-1]]);
	}
	if (N % 2 == 1) {
		ll ans2 = 0;
		ans2 += abs(A[I[N-1]] - A[I[0]]);
		for (ll i=1; i<N-1; ++i) {
			ans2 += abs(A[I[i]] - A[I[i-1]]);
		}
		ans = max(ans, ans2);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1792
# include <iostream>
using namespace std;
int a,b,c,nr1,nr2;
int main () {
    cin>>a>>b>>c;
    if(a==5)
        nr1++;
    if(a==7)
        nr2++;
    if(b==5)
        nr1++;
    if(b==7)
        nr2++;
    if(c==5)
        nr1++;
    if(c==7)
        nr2++;
    if(nr1==2&&nr2==1)
        cout<<"YES\n";
    else
        cout<<"NO\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gcd __gcd
#define lcm(a, b) ((a) * (b) / gcd((a), b))
#define all(x) x.begin(), x.end()
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio() ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)
#define endl '\n'

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;

template <class T> inline T RD(T &a) {T x; cin >> x; return a = x;}

signed main()
{
//	freopen("TEXT.inp", "r", stdin); freopen("TEXT.out", "w", stdout);
	fastio();

	int a, b; cin >> a >> b;
	int socket = 1;
	int cnt = 0;
	while (socket < b) {
        cnt++;
        socket += a - 1;
	}
	cout << cnt;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(1){
		int n,m; cin >> n >> m;
		if(n==0&&m==0)break;
		int ans=0;
		int a[m][n];
		for(int i=0;i<m;i++){
			for(int j=0;j<n;j++){
				cin >> a[i][j];
			}
		}
		for(int i=0;i<n;i++){
			int sum=0;
			for(int j=0;j<m;j++){
				sum+=a[j][i];
			}
			ans=max(ans,sum);
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3276
#include<stdio.h>

int n, A[50];

int solve(int i, int m) {
  if ( m == 0 ) return 1;
  if ( i >= n ) return 0;
  int res = solve(i + 1, m) || solve (i + 1, m - A[i]);
  return res;
}

int main() {
  int q, M, i;

  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
  scanf("%d", &q);
  for ( i = 0; i < q; i++ ) {
    scanf("%d", &M);
    if ( solve(0, M) ) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}


Measured memory_bytes: 2688
#include <stdio.h>
int main (void){
int A,B;
scanf("%d%d",&A,&B);
if(A%2==0 && B%2==0){
    printf("%d",(A+B)/2);
}else if(A%2!=0&&B%2!=0){
    printf("%d",(A+B)/2);
}else{
    printf("IMPOSSIBLE");
}
}

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

int main(){
    int row, column, table[101][101]={{}};
    cin >> row >> column;

    for(int i=0; i<row; i++){
        for(int j=0; j<column; j++){
            cin >> table[i][j];
        }
    }

    for(int i=0; i<row; i++){
        for(int j=0; j<column; j++){
            table[i][column]+=table[i][j];
        }
    }
    for(int i=0; i<=column; i++){
        for(int j=0; j<row; j++){
            table[row][i]+=table[j][i];
        }
    }

    for(int i=0; i<=row; i++){
        for(int j=0; j<=column; j++){
            cout << table[i][j];
            if(j!=column)cout << " ";
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a, n) \
    REP(i, n) { cout << (a[i]) << (i == n - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

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

ll N;
vi A;

int main()
{
    cin >> N;
    A = vi(N);
    REP(i, N)
    {
        cin >> A[i];
    }

    bool ok = true;
    REP(i, N)
    {
        if (A[i] % 2 == 0)
        {
            ok &= A[i] % 3 == 0 or A[i] % 5 == 0;
        }
    }
    if (ok)
    {
        OUT("APPROVED");
    }
    else
    {
        OUT("DENIED");
    }
}

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

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.rbegin(), a.rend());
	Int ans = a[0];
	int n = N - 2;
	for (int i = 1; i < N; ++i) {
		if (n <= 0) { break; }
		if (n-- > 0) { ans += a[i]; }
		if (n-- > 0) { ans += a[i]; }
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4840
#include<bits/stdc++.h>
#define INF (1e9)
#define N 10005
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
int n,m,u,v,d,c;
vector<P1> G[N];

void dijkstra(){
  priority_queue<P1,vector<P1>,greater<P1> > q;
  P d[N];
  for(int i=0;i<N;i++)
    d[i]=P(INF,INF);
  d[0]=P(0,0);
  q.push(P1(0,P(0,0)));
  while(!q.empty()){
    P1 t=q.top(); q.pop();
    int cost1=t.first;
    int cost2=t.second.first;
    int node=t.second.second;
    if(d[node].first<cost1)continue;
    if(d[node].first==cost1&&d[node].second<cost2)continue;
    for(int i=0;i<G[node].size();i++){
      int nnode=G[node][i].first;
      int ncost1=cost1+G[node][i].second.first;
      int ncost2=G[node][i].second.second;
      if(d[nnode].first>ncost1){
	d[nnode].first=ncost1;
	d[nnode].second=ncost2;
	q.push(P1(ncost1,P(ncost2,nnode)));
      }
      if(d[nnode].first==ncost1&&d[nnode].second>ncost2){
	d[nnode].second=ncost2;
	q.push(P1(ncost1,P(ncost2,nnode)));
      }
    }
  }
  int ans=0;
  for(int i=0;i<n;i++)
    ans+=d[i].second;
  cout<<ans<<endl;
}

int main(){
  while(1){
    cin>>n>>m;
    if(!n&&!m)break;
    for(int i=0;i<m;i++){
      cin>>u>>v>>d>>c;
      u--,v--;
      G[u].push_back(P1(v,P(d,c)));
      G[v].push_back(P1(u,P(d,c)));
    }
    dijkstra();
    for(int i=0;i<n;i++)
      G[i].clear();
  }
  return 0;
}

Measured memory_bytes: 5036
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
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; }

ll INF = 100000;
int dp[21][21];
int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};
int h,w; 
char s[21][21];

int stepsum(int gh, int gw,int sh,int sw){
  queue<P> que;
  for(int i = 0; i < h; i++){
    for(int j=0; j < w; j++){
      dp[i][j] = INF;
    }
  }
  que.push(P(sh,sw));
  dp[sh][sw] = 0;
  while(que.size()){
    P p = que.front(); que.pop();
    if(p.first == gh && p.second == gw){
      break;
    }
    for(int i = 0; i < 4; i++){
      int nh = p.first + dx[i], nw = p.second+dy[i];
      if(0 <= nh && nh < h && 0 <= nw && nw < w && s[nh][nw] != '#' && dp[nh][nw] == INF){
        dp[nh][nw] = dp[p.first][p.second]+1;
        que.push(P(nh,nw));
      }
    }
  }
  return dp[gh][gw];
}

int main(void){
  cin >> h >> w;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> s[i][j];
    }
  }
  int ans = 0;
  rep(i,h){
    rep(j,h){
      rep(k,w){
        rep(l,w){
          if(s[i][k] == '#' || s[j][l] == '#') continue;
          ans = max(ans,stepsum(i,k,j,l));
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3604
def solve():
    m, mn, mx = map(int, input().split())
    if m == 0 and mn == 0 and mx == 0:
        return False

    p = [int(input()) for x in range(m)]

    result, ans = 0, 0

    for i in range(mn, mx + 1):
        if p[i - 1] - p[i] >= result:
            result = p[i - 1] - p[i]
            ans = i
    print(ans)
    return True

while solve(): pass

Measured memory_bytes: 7620
#include <iostream>

int main()
{
    int sec_in = 0;
    std::cin >> sec_in;
    int hour = (sec_in / (60*60)) % 60;
    int min = (sec_in / 60) % 60;
    int sec = sec_in % 60;
    std::cout << hour << ":" << min << ":" << sec << std::endl;
    return 0;
}

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

const int maxn = 200010;
int a[maxn];

int main()
{
	//freopen("C.in","r",stdin);
	int n;
	cin >> n;
	for (int i=1;i<=n;i++) cin >> a[i];
	long long ans = 0;
	for (int i=1;i<=n;i++)
	{
		if (a[1] > 0 || (i>1 && a[i] - a[i-1] > 1))
		{
			ans = -1;
			break;
		}
		if (a[i] == a[i-1] + 1) ans++;
		else ans += (long long)a[i];
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;

int main(){
    ll N; cin>>N;
    ll ans = 0;
    for(ll q = 1; q<=sqrt(N);++q){
        if(N%q==0){
            ll m = N/q -1;
            if(m>q){
                ans += m;
            }
        }
    }
    cout << ans << "\n";
}

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

typedef long long ll;
typedef pair<int,int> P;

#define fr first
#define sc second

template<class T=ll>
struct edge{
	int to;
	T cap;
	int rev;
};

template<int N=100010,class T=ll>
struct MaxFlow_Dinic{
	vector<edge<T>> G[N];
	int level[N];
	int iter[N];
	void add_edge(int from,int to,T cap){
			G[from].push_back((edge<T>){to,cap,(int)G[to].size()});
			G[to].push_back((edge<T>){from,0,(int)G[from].size()-1});
	}
	void bfs(int s){
		memset(level,-1,sizeof level);
		queue<int> que;
		level[s]=0;
		que.push(s);
		while(!que.empty()){
			int v=que.front(); que.pop();
			for(edge<T> &e: G[v]){
				if(e.cap>0&&level[e.to]<0){
					level[e.to]=level[v]+1;
					que.push(e.to);
				}
			}
		}
	}
	T dfs(int v,int t,T f){
		if(v==t)return f;
		for(int &i=iter[v];i<G[v].size();i++){
			edge<T> &e=G[v][i];
			if(e.cap>0&&level[v]<level[e.to]){
				T d=dfs(e.to,t,min(f,e.cap));
				if(d>0){
					e.cap-=d;
					G[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}
	T run(int s,int t,T inf=1000000000){
		T ret=0;
		while(1){
			bfs(s);
			if(level[t]<0)return ret;
			memset(iter,0,sizeof iter);
			T f;
			while((f=dfs(s,t,inf))>0){
				ret+=f;
			}
		}
	}
};

template<int N=100010>
struct MatchingBigraph{
	MaxFlow_Dinic<N,int> G;
	int type[N];
	void add_edge(int u,int v){
		G.add_edge(u,v,1);
		type[u]=1;
		type[v]=2;
	}
	vector<P> run(){
		for(int i=0;i<N;i++){
			if(type[i]==1)G.add_edge(N-2,i,1);
			if(type[i]==2)G.add_edge(i,N-1,1);
		}
		int t=G.run(N-2,N-1);
		vector<P> ret;
		for(int i=0;i<N;i++){
			if(type[i]!=1)continue;
			for(edge<int> e: G.G[i]){
				if(e.to!=N-2&&e.cap==0)ret.push_back(P(i,e.to));
			}
		}
		return ret;
	}
};

/*int main(){
	static int L,R,M;
	static int a[200010],b[200010];
	scanf("%d%d%d",&L,&R,&M);
	for(int i=0;i<M;i++){
		scanf("%d%d",&a[i],&b[i]);
	}
	static MatchingBigraph<200010> G;
	for(int i=0;i<M;i++){
		G.add_edge(a[i],L+b[i]);
	}
	vector<P> ret=G.run();
	printf("%d\n",(int)ret.size());
	for(P p: ret){
		printf("%d %d\n",p.fr,p.sc-L);
	}
}*/

bool is_prime(int x){
	if(x==1)return false;
	for(int i=2;i*i<=x;i++){
		if(x%i==0)return false;
	}
	return true;
}

int main(){
	int n;
	int x[102];
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&x[i]);
	
	set<int> S;
	for(int i=0;i<n;i++){
		if(S.find(x[i])!=S.end())S.erase(x[i]);
		else S.insert(x[i]);
		if(S.find(x[i]+1)!=S.end())S.erase(x[i]+1);
		else S.insert(x[i]+1);
	}
	vector<int> v[2];
	for(int a: S){
		v[a&1].push_back(a);
	}
	
	static MatchingBigraph<205> G;
	for(int i=0;i<v[0].size();i++){
		for(int j=0;j<v[1].size();j++){
			if(is_prime(abs(v[0][i]-v[1][j]))){
				G.add_edge(i,v[0].size()+j);
			}
		}
	}
	int t=G.run().size();
	int ret=v[0].size()+v[1].size()-t+((v[0].size()-t)&1);
	cout<<ret<<endl;
}



Measured memory_bytes: 384
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  auto n = readln.chomp.to!int;
  auto h = readln.chomp.split.to!(int[]);
  int res;
  foreach (i; 0..n) {
    while (h[i]) {
      int j = i + 1;
      while (j < n && h[j]) {
        j++;
      }
      h[i..j] -= 1;
      res++;
    }
  }
  res.writeln;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() -> i64 {
    input! {
        n: usize,
        m: usize,
        mut a_s: [i64; n],
        mut bcs: [(i64, i64); m],
    }
    a_s.sort();
    bcs.sort_by(|x, y| y.1.cmp(&x.1));
    let mut idx = 0;
    for (b, c) in bcs {
        for _ in 0..b {
            if idx < a_s.len() && a_s[idx] < c {
                a_s[idx] = c;
                idx += 1;
            } else {
                let ans = a_s.iter().fold(0, |sum, a| sum + a);
                return ans;
            }
        }
    }
    let ans = a_s.iter().fold(0, |sum, a| sum + a);
    ans
}

fn main() {
    println!("{}", solve());
}


Measured memory_bytes: 8444
#include <cstdio>
using namespace std;
int main() {
	long long n=0;scanf("%lld",&n);
	long long ans=0;
	for (int i=2; i<=1000000; i++) {
		int cnt=0;while(n%i==0){cnt++;n/=i;}
		int x=0;while((x+1)*(x+2)/2<=cnt)x++;
		ans += x;
	}
	if (n>1) ans++;
    printf("%lld",ans);
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
typedef vector<vector<int>> VV;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+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 rrep(i,n) for(int i=(int)(n-1);i>=0;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 PRALL(a) a.begin(),a.end(),greater<pair<int,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)
/*--------------------------------------------*/
int main(){
    int n,q;cin>>n>>q;
    string s;cin>>s;
    V memo(n+1);
    for(int now=0;now<n;now++){
        memo[now+1]=memo[now];
        if(s[now]=='A'&&s[now+1]=='C'){
            memo[now+1]++;
        }
    }
    rep(i,q){
        int a,b;cin>>a>>b;
        a--;b--;
        int cnt=memo[b]-memo[a];
        cout<<cnt<<endl;
    }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
#define all(x) begin(x), end(x)
#define range(x) begin(x), begin(x)
#define what(x) cout << #x << ": " << x << '\n'
#define print(x) for (auto &el: x) cout << el << ' '; cout << '\n'
using namespace std;

template<typename S, typename T>
ostream& operator <<(ostream &os, pair<S, T> &m) { 
    os << '[' << m.first << " " << m.second << ']';
    return os;
}

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

    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
  
    
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define RNG(i,from,to) for(ll i=(from); i<(ll)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;

int main(int argc, char const *argv[])
{

  ll N; cin >> N;

  ll pat = 0;
  RNG(i, 1, N+1) {
    ll cnt = 0;
    ll current = i;
    RNG(x, 1, (ll)sqrt(i)+1) {
      ll tmp1 = current - x*x;
      if (tmp1 > 0) {
        RNG(y, 1, (ll)sqrt(tmp1)+1) {
          ll c = -tmp1 + y*y + x*y;
          if (-c <= 0) break;

          ll b = y+x;
          double d = sqrt(b*b - 4*c);
          ll z = (ll)((-(double)b + d)/2.0);
          cnt += (z > 0 && z*z + z*y + z*x + c == 0);
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}


Measured memory_bytes: 3436