akhauriyash/Code-Regression huggingface dataset:
#include  <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1000000007
//vector<vector<int>> vec(縦, vector<int>(横));
#define REP(i,N) for(int i=0;i<N;i++)
int gcd(int a, int b) {
    if(a>b){
        swap(a,b);
        }
    while(b%a!=0){
        b%=a;
        swap(a,b);
    }
    return a;
}


//cout << setprecision(123)<<ans;
//a=atoi(S.c_str());
//S=to_string(a);
//int &a=b;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a!=c)cout<<1<<endl;
  else cout<<0<<endl;
}


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

typedef long long ll ;
typedef unsigned long long ull ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define rrep(i , n) for ( int i = n-1; i >=0 ; i--)

#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

class UnionFind {
private:
	ull size_; 
	std::vector<ull> par, rank, count;

public:
	UnionFind() : size_(0), par(std::vector<ull>()), rank(std::vector<ull>()), count(std::vector<ull>()) {};
	UnionFind(ull size__) : size_(size__) {
		par.resize(size_); rank.resize(size_); count.resize(size__);
		for (ull i = 0; i < size_; i++) par[i] = i, rank[i] = 0, count[i] = 1;
	}
	ull size() { return size_; }
	// ull root(ull x) { return par[x] == x ? x : par[x] = root(par[x]); }
	
	ull root(ull x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	
	bool same(ull x, ull y) { return root(x) == root(y); }

	void unite(ull x, ull y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y, count[y]+=count[x], count[x]=0;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++, count[x]+=count[y], count[y]=0;
		else par[y] = x, count[x] += count[y], count[y] = 0;
	}

	ull size__(ull x)
	{
		return count[root(x)];
	}

	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};
/*
maybe sth wrong 
got wa in one problem
*/
ll modpow(ll a, ll b)
{
	if (b == 0)
	{
		return 1;
	}

	if (b % 2)
	{
		return a * modpow(a, b-1) % MOD;
	}
	else
	{
		ll halfB = b / 2;
		ll half = modpow(a, halfB);
		return half * half % MOD;
	}
}

ll calcComb(ll n, ll m)
{
	if (m > n-m)
	{
		return calcComb(n, n-m);
	}

	ll ansMul = 1;
	ll ansDiv = 1;

	rep(i, m)
	{
		ansMul *= (n-i);
		ansDiv *= (i+1);
		ansMul %= MOD;
		ansDiv %= MOD;
	}

	return ansMul * modpow(ansDiv, MOD - 2) % MOD;
}

__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}


int main()
{
	int N, M;
	
	cin >> N >> M;
	
	#if 0 // TLE
	ll A[N];
	
	rep(i, N)
	{
		cin >> A[i];
	}

	
	int n = 0;

	while(n < M)
	{
		sort(A, A+N);
		if (A[N-1] > 0)
		{
			A[N-1] /= 2;
		}
		else
		{
			break;
		}
		n++;
	}

	ll sum = 0;
	rep(i, N)
	{
		sum += A[i];
	}

	cout << sum << endl;
	#endif

	priority_queue<ll> qu;
	rep(i, N)
	{
		ll a;
		cin >> a;
		qu.push(a);
	}

	int n = 0;

	while(n < M)
	{
		ll t = qu.top();
		qu.pop();
		qu.push(t / 2);
		n++;
	}

	ll sum = 0;
	while(!qu.empty())
	{
		sum += qu.top();
		qu.pop();
	}

	cout << sum << endl;

	return 0;
}


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

#define ll long long
#define ld long double
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define sz(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/
const ll mod=1e9+7;
const ll INF=1e18;
/*****************************************************************************/

using namespace std;

ll f1(ll a, ll b) {
	if (a>=0) {
		return (a+b-1)/b;
	}
	else {
		return a/b;
	}
}

ll f2(ll a, ll b){
	if (a<0) {
		return (a-b+1)/b;
	}
	else {
		return a/b;
	}
}

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ll n,k;
	cin >>n >>k;
	vector <ll> a(n);
	for(int i=0;i<n;i++) cin >>a[i];
	sort(a.begin(),a.end());
	ll l=INF,h=-INF-1;
	while (l-h>1) {
		ll m=(l+h)/2;
		ll num=0;
		for(int i=0;i<n;i++) {
			if (a[i]<0) {
				ll v=f1(-m,-a[i]);
				num+=a.begin()+i-lower_bound(a.begin(),a.begin()+i,v);
			}
			else if (a[i]==0) {
				if(m>=0) num+=i;
			}
			else {
				ll v = f2(m,a[i]);
				num+=upper_bound(a.begin(),a.begin()+i,v)-a.begin();
			}
		}
		(num>=k?l:h)=m;
	}
	cout <<l <<endl;
	return 0;
}
/******************************************************************************
******************************************************************************/


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;

#define TT template<typename T>
#define ET(T) typename T::value_type
TT inline T sq(T x){return x*x;}
TT inline T In(){T x;cin>>x;return x;}
TT inline int ubnd(T&v,ET(T) x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT inline int lbnd(T&v,ET(T) x){return lower_bound(begin(v),end(v),x)-begin(v);}
TT inline void sort(T&v){sort(begin(v),end(v));}
TT inline void revs(T&v){reverse(begin(v),end(v));}
TT inline void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT inline void inpt(T&v,int n,function<ET(T)()>f=In<ET(T)>){for(v.reserve(n);n--;v.emplace_back(f()));}
TT inline void show(T&v,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),cout<<x;cout<<e;}
#undef TT
#undef ET

inline void fast_io(){ios::sync_with_stdio(0); cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline string instr(){string x;cin>>x;return x;}
inline ll pow_mod(ll a, ll k, ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a, ll p){return pow_mod(a,p-2,p);}

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

inline int getm(int h, int m){ return h * 60 + m; }
inline int gett(int m)
{
  if (getm(9, 0) <= m && m <= getm(12, 59)) return 0;
  if (getm(16, 0) <= m && m <= getm(18, 59)) return 1;
  if (getm(19, 0) <= m && m <= getm(23, 59)) return 2;
  return 3;
}

int main()
{
  int n;
  vector<string> names{ "lunch", "dinner", "midnight" };
  while (n = in()){
    int cnt[4] = {}, suc[4] = {};
    vector<int> v;
    v.reserve(n);
    for (int i = 0; i < n; i++){
      int h, m, am;
      scanf("%d:%d %d", &h, &m, &am);
      h = (h + 22) % 24;
      m = getm(h, m);
      am = getm(h, am);
      if (m > am) am += 60;
      int tid = gett(m);
      cnt[tid]++;
      if (am - m <= 8) suc[tid]++;
    }
    for (int i = 0; i < 3; i++){
      cout << names[i] << " ";
      if (!cnt[i]) cout << "no guest\n";
      else cout << 100 * suc[i] / cnt[i] << "\n";
    }
  }

  return (0);
}

// priority_queue queue deque front top push pop map set stringstream max_element min_element insert count find get tie make_tuple

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main(void) {
	
	int n,d;
	cin >> n;
	cin >> d;
	int table[201];
	
	int x[n][d];
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < d; ++j){
			cin >> x[i][j];
		}
	}
	for(int i = 0; i < 201; ++i){
		table[i] = i*i;
	}
	
	int cnt = 0;
	for(int i = 0; i < n-1; ++i){
		for(int j = i+1; j < n; ++j){
			double dist = 0;
			for(int k = 0; k < d; ++k){
				dist += pow((double)x[i][k]-x[j][k], 2.0);
			}
			for(int k = 0; k < 201; ++k){
				if(dist == table[k]){
					cnt++;
					break;
				}
			}
		}
	}
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			(3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
template<class T> void chmax(T &a, const T &b){if(a<b)a=b;}
template<class T> void chmin(T &a, const T &b){if(a>b)a=b;}
void YN(bool b){cout<<(b?"YES":"NO")<<endl;}
void Yn(bool b){cout<<(b?"Yes":"No")<<endl;}
void yn(bool b){cout<<(b?"yes":"no")<<endl;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int n=s.size();
	bool ans=false;
	rep(i,8){
		string sub=s.substr(0,i)+s.substr(n-(7-i),(7-i));
		ans|=(sub=="keyence");
	}
	YN(ans);
}

 

Measured memory_bytes: 256
//#ifdef DEBUG
//#define _GLIBCXX_DEBUG
//#endif
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
mt19937 rnd(228);
ll g(ll x) {
    ll c = 1;
    for (int i = 1; i <= 7; i++) c *= x;
    return c;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    ll k;
    cin >> k;
    string p = "FESTIVAL";
    string cur;
    ll t = 1;
    while (g(t + 1) <= k) t++;
    for (int x = 1; x <= 7; x++) {
        for (int c = 1; c <= 300; c++) {
            cur += p[x];
        }
    }
    for (int c = 0; c <= 1500; c++) {
        int x = rnd() % 7 + 1;
        cur += p[x];
    }
    for (int c = 0; c <= 13; c++) {
        cur += p[c % 7 + 1];
    }
    vector < int > before(cur.size());
    vector < vector < ll > > calc(cur.size() + 1, vector<ll>(8, 0));
    calc[cur.size()][7] = 1;
    for (int i = cur.size() - 1; i >= 0; i--) {
        calc[i] = calc[i + 1];
        for (int j = 1; j <= 7; j++) {
            if (cur[i] == p[j]) {
                calc[i][j - 1] += calc[i][j];
                calc[i][j - 1] = min(calc[i][j - 1], k + 1);
            }
        }
    }
    for (int where = 0; where < cur.size(); where++) {
        if (k == 0) break;
        before[where] = k / calc[where][0];
        k %= calc[where][0];
    }
    string ans;
    for (int i = 0; i < cur.size(); i++) {
        ans += string(before[i], p[0]);
        ans += cur[i];
    }
    assert(k == 0);
    assert(ans.size() <= 5000);
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 4052
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main() {
    int x; // 2 <= x <= 10^5
    cin >> x;

    int a[200001];
    REP(i, 200001) {
        a[i] = 1;
    }
    int ub = ceil(sqrt(200000));

    int c = 2;
    while (true) {
        for (int i = c * 2; i <= 200000; i += c) {
            a[i] = 0;
        }
        FOR(i, c+1, 200000) {
            if (a[i] == 1) {
                c = i;
                break;
            }
        }
        if (c >= ub) {
            break;
        }
    }
    FOR(i, x, 200000) {
        if (a[i] == 1) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

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

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

    for (int i = 0; i < S.length(); i++)
    {
        int cnt = 0;
        while (cnt < N)
        {   
            cnt++;
            if (S[i] == 'Z')
            {
                S[i] = 'A';
                continue;
            } else
            {
                S[i]++;
            }
        }    
    }
    cout << S << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1e+9;
 
int main()
{
	string s;
	cin >> s;
 
	string a, b = "";
	a.push_back(s[0]);
	a.push_back(s[1]);
	b.push_back(s[2]);
	b.push_back(s[3]);
 
	string ans = "NA";
	// どちらもありえる
	if ((0 < stoi(a) && stoi(a) <= 12)  && (0 < stoi(b) && stoi(b) <= 12))
	{
		ans = "AMBIGUOUS";
	}
	else if (stoi(a) == 0 && stoi(b) == 0)
	{
		ans = "NA";
	}
	else if (stoi(a) > 12 && stoi(b) > 12)
	{
		ans = "NA";
	}
	else if (stoi(a) >= 0 && (stoi(b) > 0 && stoi(b) <= 12))
	{
		ans = "YYMM";
	}
	else if ((stoi(a) > 0 && stoi(a) <= 12) && stoi(b) >= 0)
	{
		ans = "MMYY";
	}

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

Measured memory_bytes: 768
#include<cstdio>
#include<map>

using namespace std;

typedef pair<int, int> P;

int p[2][200000], r[2][200000];

int find(int t, int x){
	if(p[t][x] == x) return x;
	return p[t][x] = find(t, p[t][x]);
}

void unite(int t, int x, int y){
	x = find(t, x); y = find(t, y);
	if(x == y) return;
	if(r[t][x] < r[t][y]) p[t][x] = y;
	else{
		p[t][y] = x;
		if(r[t][x] == r[t][y]) r[t][x]++;
	}
}

int main(){
	int n, k, l; scanf("%d %d %d", &n, &k, &l);
	for(int i = 0; i < n; i++){ p[0][i] = p[1][i] = i; r[0][i] = r[1][i] = 0; }
	for(int i = 0; i < k; i++){
		int a, b; scanf("%d %d", &a, &b);
		unite(0, a - 1, b - 1);
	}
	for(int i = 0; i < l; i++){
		int a, b; scanf("%d %d", &a, &b);
		unite(1, a - 1, b - 1);
	}
	for(int i = 0; i < n; i++){ find(0, i); find(1, i); }
	map<P, int> m;
	for(int i = 0; i < n; i++) m[P(p[0][i], p[1][i])]++;
	for(int i = 0; i < n; i++) printf("%d%c", m[P(p[0][i], p[1][i])], i + 1 == n ? '\n' : ' ');
	return 0;
}

Measured memory_bytes: 15104
bus = []
for i in range(2):
    l = list(map(int, input().split()))
    N = l[0]
    t = l[1:]
    for j in range(N):
        bus.append(t[j * 2] * 60 + t[j * 2 + 1])
print(' '.join(['{0}:{1:02d}'.format(i // 60, i % 60) for i in sorted(set(bus))]))







Measured memory_bytes: 5624
INF=10**9
n,A,B,C=map(int,input().split())
l=[int(input()) for i in range(n)]
ans=INF
a=[0,0,0,0]
def yonsin(X):
    if(int(X/4)):
        return yonsin(int(X/4))+str(X%4)
    return str(X%4)

#a[1]はAにいれる　a[2]はBにいれる　a[0]は使わない
for i in range(4**n):
  s=yonsin(i)
  if len(s)<n:
    s='0'*(n-len(s))+s
  d=list(s)
  cost=0
  a=[0,0,0,0]
  if set(d)!={'1','2','3'} and set(d)!={'0','1','2','3'}:
    cost=INF
  else:  
    for j in range(n):          #j番目の竹に関する処理 4進数がABCどれにいれるか使わないか表す
      a[int(s[j])]+=l[j]
      if int(s[j])!=0:
        cost+=10
    cost+=abs(a[1]-A)+abs(a[2]-B)+abs(a[3]-C)-30
    

  ans=min(ans,cost)

print(ans)    
  



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}


int N,K;
int table[1005][1005];

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> N >> K;
  rep(i,N){
    int x,y;char c;cin >> x >> y >> c;
    x%=2*K;
    y%=2*K;
    int black = 1;
    if(c=='W')black^=1;
    if(x>=K)black^=1;
    if(y>=K)black^=1;
    x%=K;
    y%=K;
    table[1][1]+=black;
    if(!black)black=-1;
    table[1][y+2]-=black;
    table[x+2][1]-=black;
    table[x+2][y+2]+=2*black;
  }
  int ans = 0;
  rep(x,K)rep(y,K){
    table[x+1][y+1] += table[x+1][y] + table[x][y+1] - table[x][y];
    ans = max(ans, max(table[x+1][y+1], N-table[x+1][y+1]));
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 4224
#include <iostream>
#include <math.h>
using namespace std;

int main(){
  
  int A,B;
  cin >> A >> B;
  
  int sum = A+B;
  int diff = A-B;
  int mul = A*B;
  
  int m1 = max(sum,diff);
  int m2 = max(diff,mul);
  
  cout << max(m1,m2) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,M;
  cin >> N >> M;
  
  int A[N]; 
  int num_over = 0;
  float sum = 0.0;
  
  for(int i = 0; i < N; i++){
    cin >> A[i];
    sum += A[i];
    //num_over++;
  }
  for(int i = 0; i < N; i++){
    //cout << float(sum/(4*M));
    if(float(sum/(4*M)) <= A[i]){
      num_over++;
    }
  }

  if(num_over >= M){
    cout<<"Yes";
  }
  else{cout <<"No";}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pdbs;
using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define sf(x) sizeof(x)
#define len(x) x.length()
#define sz(x) x.size()
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define LB(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define UB(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef unsigned long long ull;
typedef long double ld; 
typedef tuple<int,int,int> State;

ll mod = 1e9 + 7;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define citc(tc) int tc; cin>>tc; while(tc--) 
#define each(a,x) for( auto &a:(x))
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define rep2r(i, l, r) for (ll i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()
#define deb(x) cout<<#x<<" "<<x<<endl;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinll2(l, z) ll l, z; cin>>l>>z;
#define cinll3(l, z, x) ll l, z, x; cin>>l>>z>>x;
#define cinai(a, n) vi a(n); rep(i, n) { cin>>a[i]; }
#define cinal(a, n) vl a(n); rep(i, n) { cin>>a[i]; }
#define coutai(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define coutal(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define ent cout<<endl;
#define ms(dp, x) memset(dp, x, sf(dp))

ll powm(ll a, ll b, ll mod) {
	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void solve()
{
	ll n, m;
	cin>>n>>m;
	cinal(a, m);
	ll sum = 0;
	rep(i, m)
		sum += a[i];
	cout<<max(-1ll, n - sum)<<endl;
}
int main()
{
	fastio();
	// citc(tc)
		solve();
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N; cin >> N;
  string S[N]; rep(i,N) cin >> S[i];
  set<string> s; rep(i,N) s.insert(S[i]);
  int result = s.size();
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 25432
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sWA = "WA";
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            int iM = int.Parse(sS[1]);
            List<ClsRes> lstRes = new List<ClsRes>();
            for (int i = 0; i < iN; i++) { lstRes.Add(new ClsRes()); }
            for (int i = 0; i < iM; i++)
            {
                sS = System.Console.ReadLine().Trim().Split(' ');
                int iI = int.Parse(sS[0]) - 1;
                if (lstRes[iI].iAC == 0)
                {
                    if (sS[1] == sWA)
                    {
                        lstRes[iI].iWA += 1;
                    }
                    else
                    {
                        lstRes[iI].iAC += 1;
                    }
                }
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iAC = lstRes.Sum(val => val.iAC);
            int iWA = 0;
            for (int i = 0; i < lstRes.Count; i++) { if (lstRes[i].iAC == 1) { iWA += lstRes[i].iWA; } }    // ペナ数は正解していないとダメ
            string sOut = iAC.ToString() + " " + iWA.ToString();

            // 出力
            System.Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

        // 結果
        private class ClsRes
        {
            public int iWA { get; set; } = 0;
            public int iAC { get; set; } = 0;
        }

}


Measured memory_bytes: 23372
#include <stdio.h>

int main(void) {
	char ch;
	scanf("%c", &ch);
	if (ch == 'a' || ch == 'i' || ch == 'u' || ch == 'e' || ch == 'o')
	printf("vowel\n");
	else
	printf("consonant\n");
	return 0;
}

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

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

  int N, K;
  cin >> N >> K;

  long long color = K;
  for (int i = 0; i < N - 1; ++i) {
    color *= (K - 1);
  }

  cout << color << endl;
  return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)
template<class T, class U> void umin(T& x, const U& y){ x = min(x, (T)y);}
template<class T, class U> void umax(T& x, const U& y){ x = max(x, (T)y);}
template<class T, class U> void init(vector<T> &v, U x, size_t n) { v=vector<T>(n, x); }
template<class T, class U> void init(vector<T> &v, U x, size_t n, size_t m...) { v=vector<T>(n); for(auto& a : v) init(a, x, m);}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int n;
    cin >> n;
//    n = 80;
    vector<int> a(n);
    FOR(i, n) cin >> a[i];
//    FOR(i, n) if (i%2) a[i] = 200;
//    else a[i] = 100;
//    FOR(i, n) a[i] = 100 + rand()%101;

    ll sol = 1000;
    const int inf = 1e8;
    map<ll, ll> H;
    H[0] = 1000;
    FOR(i, n){
        map<ll, ll> H2;
        for(auto it : H){
            //nothing
            umax(H2[it.first], it.second);
            //sell
            if (it.first){
                ll m2 = it.second + it.first * a[i];
                umax(H2[0], m2);
            }
            else{ //buy
                ll q = it.second / a[i];
                ll m2 = it.second - a[i] * q;
                umax(H2[q], m2);
            }
        }
        H = H2;
    }
    for(auto it : H) umax(sol, it.second);
    cout << sol << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}



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

typedef long long ll;
const int mod = 1e9 + 7;
const int INF = 1e9;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > to(n);
  for(int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
  }
  int sv, tv;
  cin >> sv >> tv;
  --sv; --tv;
  vector<vector<int> > dist(n, vector<int>(3));
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < 3; j++) {
      dist[i][j] = INF;
    }
  }
  queue<pair<int, int> > q;
  q.push({sv,0});
  dist[sv][0] = 0;
  while (!q.empty()) {
    int v = q.front().first;
    int l = q.front().second;
    q.pop();
    for (int u : to[v]) {
      int nl = (l+1)%3;
      if (dist[u][nl] != INF) continue;
      dist[u][nl] = dist[v][l]+1;
      q.push({u,nl});
    }
  }
  int ans = dist[tv][0];
  if (ans == INF) ans = -1;
  else ans /= 3;
  cout << ans << endl;
  return 0;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

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

  int ans;
  if(a>=13) ans = b;
  else if(6<=a && a<=12) ans = b/2;
  else ans = 0;

  cout << ans << endl;  

  return 0;
}


Measured memory_bytes: 3528
n = int(input())

words = [input() for i in range(n)]

def siritori(n, words):
    if len(set(words)) != n:
        return print("No")
    for i in range(n-1):
        if words[i][-1] != words[i+1][0]:
            return print("No")
    return print("Yes")

siritori(n, words)

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;
double pi = acos(-1);
void kock(int n,double p1x,double p1y,double p2x,double p2y){
    if(n==0){
        return;
    }
    double r=(60*pi)/180;
    double sx = (2.0*p1x+p2x)/3.0;
    double sy = (2*p1y+p2y)/3.0;
    double tx = (p1x+2.0*p2x)/3.0;
    double ty = (p1y+2.0*p2y)/3.0;
    double ux = (tx-sx)*cos(r)-(ty-sy)*sin(r)+sx;
    double uy = (tx-sx)*sin(r)+(ty-sy)*cos(r)+sy;
    
    kock(n-1,p1x,p1y,sx,sy);
    printf("%.8lf %.8lf\n", sx,sy);
    kock(n-1,sx,sy,ux,uy);
    printf("%.8lf %.8lf\n",ux,uy);
    kock(n-1,ux,uy,tx,ty);
    printf("%.8lf %.8lf\n",tx,ty);
    kock(n-1,tx,ty,p2x,p2y);
}
int main(){
    int n;
    cin>>n;
    double p1x=0.0;
    double p1y=0.0;
    double p2x=100.0;
    double p2y=0.0;
    
    printf("%.8lf %.8lf\n",p1x,p1y);
    kock(n,p1x,p1y,p2x,p2y);
    printf("%.8lf %.8lf",p2x,p2y);
    
    return 0;
}


Measured memory_bytes: 3328
n = int(input())
dp = [float("inf")]*100010
dp[0] = 0
h = list(map(int, input().split()))
for i in range(1, n):
    dp[i] = min(dp[i], dp[i-1]+abs(h[i]-h[i-1]))
    if i>1: dp[i] = min(dp[i], dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])

Measured memory_bytes: 21336
#include <stdio.h>

int main(void) {

  int n, m;

  do {
    scanf("%d", &n);
  } while (n < 3 || n > 20);

  int p[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
  }

  m = 0;
  for (int i = 1; i < n - 1; i++) {
    if (p[i - 1] <= p[i] && p[i] <= p[i + 1]) {
      m++;
    } else if (p[i + 1] <= p[i] && p[i] <= p[i-1]) {
      m++;
    }
  }

  printf("%d\n", m);

  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>

#define rep(i, n) for (int i = 0; i < n; i++) 
#define rrep(i, n) for(int i = n-1; i>=0; i--)
#define range(i, n, m) for (int i = n; i < m; i++) 
#define rrange(i, n, m) for (int i = n - 1; i => m; i--) 
#define MOD 1000000007;

typedef long long int ll;
typedef unsigned long long int ull;


using namespace std;

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

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

	ll N;
	cin >> N;
	

	vector<ll> V1(N), V2(N);
	vector<ll> Count1(100000, 0);
	vector<ll> Count2(100000, 0);
	rep(i, N) {
		if (i % 2 == 0) {
			cin >> V1[i];
			Count1[V1[i]]++;
		}else{
			cin >> V2[i];
			Count2[V2[i]]++;
		}
	}

	ll max11 = 0, max12 = 0;
	ll max21 = 0, max22 = 0;
	ll tmp = 0;

	auto itr = max_element(Count1.begin(), Count1.end());
	max11 = distance(Count1.begin(), itr);
	tmp = *itr;
	*itr = 0;
	itr = max_element(Count1.begin(), Count1.end());
	max12 = distance(Count1.begin(), itr);
	Count1[max11] = tmp;

	itr = max_element(Count2.begin(), Count2.end());
	max21 = distance(Count2.begin(), itr);
	tmp = *itr;
	*itr = 0;
	itr = max_element(Count2.begin(), Count2.end());
	max22 = distance(Count2.begin(), itr);
	Count2[max21] = tmp;




	ll out = N;
	if (max11 != max21) {
		ll a = ((N - 1) / 2) - Count1[max11] + 1;
		a += (N / 2) - Count2[max21];
		out = a;
	}
	else {
		if (max12 != max21) {

			ll a = ((N - 1) / 2) - Count1[max12] + 1;
			a += (N / 2) - Count2[max21];
			if (out > a) {
				out = a;
			}
		}
		if (max11 != max22) {

			ll a = ((N - 1) / 2) - Count1[max11] + 1;
			a += (N / 2) - Count2[max22];
			if (out > a) {
				out = a;
			}
		}

	}


	cout << out ;



	return 0;
}


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

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

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if(i < b && j < a || i >= b && j >= a) cout << '0';
      else cout << '1';
    }
    cout << '\n';
  }

}


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

int main() {
  string k;
  int count = 0;
  cin >> k;
  
  for(int i = 0; i < 3; i++) {
  	if(k.at(i) == '1') {
  	  count ++ ;
    }
  }

  cout << count << endl;
}
  

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

#define x first
#define y second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const int mod=1000000000+7;

int addm(int& a,int b) {return (a+=b)<mod?a:a-=mod;}

template<class T,class U> bool smin(T& a,U b) {return a>b?(a=b,1):0;}
template<class T,class U> bool smax(T& a,U b) {return a<b?(a=b,1):0;}

int mex[20][20];

bool seen[100];

int Mex(int i,int j) {
	int &r=mex[i][j];
	if (r>=0) return r;
	//fill(seen,seen+100,0);
	bool seen[100]{};
	for (int t=1;2*t<=i;t++) seen[Mex(i-2*t,j+t)]=1;
	for (int t=1;2*t<=j;t++) seen[Mex(i+t,j-2*t)]=1;
	r=0;
	while (seen[r]) r++;
	return r;
}



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

	/*fill(mex[0],mex[20],-1);
	for (int i=0;i<10;i++) {
		for (int j=0;j<10;j++) cout << Mex(i,j) << ' ';
		cout << endl;
	}*/

	ll X,Y;
	cin >> X >> Y;
	if (abs(X-Y)<=1) cout << "Brown\n";
	else cout << "Alice\n";
}

Measured memory_bytes: 256
result = True
words = []
n = int(input())

for i in range(n):
    words.append(input())

for i in range(n-1):
    word = words.pop(0)

    if word[-1] != words[0][0] or word in words:
        result = False
        break

if result:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#![allow(unused)]
use std::io::{self, Read};

fn get_stdin() -> String {
    let mut buf = String::new();
    let mut stdin = io::stdin();
    stdin.read_to_string(&mut buf);
    return buf
}

fn to_nums(ss: &str) -> Vec<usize> {
    ss.split_whitespace()
        .map(|x| x.parse::<usize>().unwrap())
        .collect()
}

fn main() {
    let input = get_stdin();
    let lines = input.split('\n');
    for line in lines {
        let v = to_nums(line);
        let rect = Rectangle {
            height: v[0],
            width: v[1],
        };
        if rect.is_valid() {
            println!("{}", rect.draw_chessboard());
        } else {
            break;
        }
    }
}

struct Rectangle {
    height: usize,
    width: usize,
}

impl Rectangle {
    fn draw_chessboard(&self) -> String {
        let mut buf = String::new();
        for i in 0..self.height {
            for j in 0..self.width {
                if (i+j) % 2 == 0 {
                    buf.push('#');
                } else {
                    buf.push('.');
                }
            }
            buf.push('\n');
        }
        return buf
    }

    fn is_valid(&self) -> bool {
        self.height > 0 && self.width > 0
    }
}



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

bool isExist(vector<int> v, int d)
{
	bool res = false;
	for(auto it = v.begin(); it != v.end(); ++it)
	{
		if(*it == d)
		{
			res = true;
			break;
		}
	}
	return res;
}

void make(vector<vector<int>>& s, vector<int> d, int n, int index)
{
	if(d.size() == n)
	{
		s.push_back(d);
	}
	else
	{
		for(int idx = 1; idx <= n; idx++)
		{
			if(::isExist(d, idx)) continue;
			vector<int> dmy = d;
			dmy.push_back(idx);
			::make(s, dmy, n, index + 1);
		}
	}
}

int getIndex(vector<vector<int>>& l, vector<int>& v)
{
	int cnt = 0;
	for(int idx1 = 0; idx1 < (int)l.size(); idx1++)
	{
		bool b = true;
		for(int idx2 = 0; idx2 < l[idx1].size(); idx2++)
		{
			if(l[idx1][idx2] != v[idx2])
			{
				b = false;
				break;
			}
		}
		cnt++;
		if(b)
		{
			break;
		}
	}
	return cnt;
}

int main()
{
	int n;
	vector<int> p, q;
	cin >> n;
	p.resize(n);
	q.resize(n);
	for(int idx = 0; idx < n; idx++) cin >> p[idx];
	for(int idx = 0; idx < n; idx++) cin >> q[idx];
	
	vector<vector<int>> s;
	::make(s, vector<int>(), n, 0);
	
	int pi = ::getIndex(s, p), qi = ::getIndex(s, q);
	cout << ::abs(pi - qi) << endl;
	
	return 0;
}

Measured memory_bytes: 3256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define ld long double
#define vi vector<int>
#define umap unordered_map
#define pii pair<int, int>
#define vpii vector<pii>
#define uset unordered_set
#define frw(i, a, b) for(int i = (a); i < (b); i++)
#define bck(i, a, b) for(int i = (a); i > (b); i--)
#define T() int testcases; cin >> testcases; frw(TC, 1, testcases + 1)
#define tez ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define fi first
#define se second
#define pow asdihagsiduh
#define pub push_back
#define in insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) (int)(a.size())
#define sq(a) ((a) * (a))

#define trace(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1> 
void ZZ(const char* name, Arg1&& arg1){
    cerr << name << " = " << arg1 << endl;
}
template<typename Arg1, typename... Args>
void ZZ(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1;
    ZZ(comma, args...);
}

//console o/p without variable names
#define trace1(...) ZZZ(__VA_ARGS__)
template<typename Arg1>
void ZZZ(Arg1&& arg1){
    cerr << arg1 << endl;
}
template<typename Arg1, typename... Args>
void ZZZ(Arg1&& arg1, Args&&... args){
    cerr << arg1 << ' ';
    ZZZ(args...);
}

signed main(){
    tez
    int h, w, n; cin >> h >> w >> n;
    if(h > w)   swap(h, w);
    frw(i, 1, h + 1){
        if(i * w >= n){
            cout << i;
            return 0;
        }
    }
}

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

using namespace std;

int main(int argc, const char** argv) {
    vector<int> v;
    int N,K;
    cin>>N>>K;
    for(int i=0;i<N;i++){
        int p;
        cin>>p;
        v.push_back(p);
    }
    sort(v.begin(),v.end());
    int sum = 0;
    for(int i=0;i<K;i++){
        sum+=v[i];
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

/*---------------------------------------------------*/

int prime[100005];
bool is_prime[10000005];

void sieve(){
  int p=0;
  for(int i=0;i<10000000;i++)is_prime[i]=true;
  is_prime[0]=is_prime[1]=false;
  for(int i=2;i<10000000;i++){
    if(is_prime[i]){
      prime[p++]=i;
      for(int j=2*i;j<=10000000;j+=i)is_prime[j]=false;
    }
    if(p==100000)return;
  }
  //cout<<prime[10000-1]<<endl;
}
  
ll prime_sum(int n){
  ll sum=0;
  for(int i=0;i<n;i++){
    //cout<<prime[i]<<" ";
    sum+=prime[i];
  }
  //cout<<endl;
  return sum;
}

int main(){
  int n;
  sieve();
  while(cin>>n){
    if(n==0)break;
    cout<<prime_sum(n)<<endl;
  }
}

Measured memory_bytes: 13224
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, k, tmp, ans = 0;
    vector<int> a;

    cin >> k >> n;

    for (int i = 0; i < n; ++i)
    {
        cin >> tmp;
        a.push_back(tmp);
    }

    for (int i = 0; i < n; ++i)
    {
        if (i == n - 1)
            ans = max(ans, k + a[0] - a[i]);
        else
            ans = max(ans, a[i + 1] - a[i]);
    }

    cout << k - ans << endl;
}

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

int main()
{
  int a[3][3];
  int n,i,j,k,b,c[3][3]={0},count;

  for(i=0; i<3; i++){
    for(j=0; j<3; j++){
      scanf("%d",&a[i][j] );
    }
  }
  scanf("%d",&n );

  for(k=0; k<n; k++)
  {
    scanf("%d",&b);
    for(i=0; i<3; i++){
      for(j=0; j<3; j++){
        if(a[i][j] == b)
          c[i][j] = 1;
      }
    }
  }

  if(c[0][0]+c[1][1]+c[2][2]==3||c[0][2]+c[1][1]+c[2][0]==3){
      puts("Yes");
      return 0;
    }

  for(i=0;i<3;i++){
      if(c[i][0]+c[i][1]+c[i][2]==3||c[0][i]+c[1][i]+c[2][i]==3){
        puts("Yes");
        return 0;
      }
    }

    puts("No");

    return 0;
}


Measured memory_bytes: 1592
class Combination:
    def __init__(self, n_max, mod=10**9+7):
        # O(n_max + log(mod))
        self.mod = mod
        f = 1
        self.fac = fac = [f]
        for i in range(1, n_max+1):
            f = f * i % mod
            fac.append(f)
        f = pow(f, mod-2, mod)
        self.facinv = facinv = [f]
        for i in range(n_max, 0, -1):
            f = f * i % mod
            facinv.append(f)
        facinv.reverse()

    def __call__(self, n, r):  # self.C と同じ
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def C(self, n, r):
        if not 0 <= r <= n: return 0
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def P(self, n, r):
        if not 0 <= r <= n: return 0
        return self.fac[n] * self.facinv[n-r] % self.mod

    def H(self, n, r):
        if n == 0 and r > 0: return 0
        return self.fac[n+r-1] * self.facinv[r] % self.mod * self.facinv[n-1] % self.mod

    def rising_factorial(self, n, r):  # 上昇階乗冪 n * (n+1) * ... * (n+r-1)
        return self.fac[n+r-1] * self.facinv[n-1] % self.mod

    def stirling_first(self, n, k):  # 第 1 種スターリング数  lru_cache を使うと O(nk)  # n 要素を k 個の巡回列に分割する場合の数
        if n == k: return 1
        if k == 0: return 0
        return (self.stirling_first(n-1, k-1) + (n-1)*self.stirling_first(n-1, k)) % self.mod

    def stirling_second(self, n, k):  # 第 2 種スターリング数 O(k + log(n))  # n 要素を区別のない k グループに分割する場合の数
        if n == k: return 1  # n==k==0 のときのため
        return self.facinv[k] * sum((-1)**(k-m) * self.C(k, m) * pow(m, n, self.mod) for m in range(1, k+1)) % self.mod

    def balls_and_boxes_3(self, n, k):  # n 要素を区別のある k グループに分割する場合の数  O(k + log(n))
        return sum((-1)**(k-m) * self.C(k, m) * pow(m, n, self.mod) for m in range(1, k+1)) % self.mod

    def bernoulli(self, n):  # ベルヌーイ数  lru_cache を使うと O(n**2 * log(mod))
        if n == 0: return 1
        if n % 2 and n >= 3: return 0  # 高速化
        return (- pow(n+1, self.mod-2, self.mod) * sum(self.C(n+1, k) * self.bernoulli(k) % self.mod for k in range(n))) % self.mod

    def faulhaber(self, k, n):  # べき乗和 0^k + 1^k + ... + (n-1)^k
        # bernoulli に lru_cache を使うと O(k**2 * log(mod))  bernoulli が計算済みなら O(k * log(mod))
        return pow(k+1, self.mod-2, self.mod) * sum(self.C(k+1, j) * self.bernoulli(j) % self.mod * pow(n, k-j+1, self.mod) % self.mod for j in range(k+1)) % self.mod

    def lah(self, n, k):  # n 要素を k 個の空でない順序付き集合に分割する場合の数  O(1)
        return self.C(n-1, k-1) * self.fac[n] % self.mod * self.facinv[k] % self.mod

    def bell(self, n, k):  # n 要素を k 個以下に分割する場合の数  O(k**2 + k*log(mod))
        return sum(self.stirling_second(n, j) for j in range(1, k+1)) % self.mod

mod = 10**9+7
comb = Combination(2000)
n, k = map(int, input().split())
print(comb.C(k, n))



Measured memory_bytes: 5776
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;

int main(){
    string x;
    cin>>x;
    int ans=1e9;
    for(int i=0;i<x.size()-2;i++){
        int tmp=stoi(x.substr(i,3));
        ans=min(ans,abs(tmp-753));
    }
    cout<<ans<<endl;
    return 0;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mod 1000000007ll
const ll maxn = 9e18;
using namespace std;


void solve() {
	int n;
	cin >> n;
	ll arr[n];
	ll ans = 9e18;
	for(int i = 0; i < n; ++i) cin >> arr[i];
	vector<ll> l_sum(n), r_sum(n);
	l_sum[0]= arr[0]; r_sum[0] = arr[n- 1];
	for(int i = 1; i < n; ++i) 
	l_sum[i] = arr[i], r_sum[i] = arr[n - i - 1],l_sum[i] += l_sum[i - 1], r_sum[i] += r_sum[i - 1];
	reverse(r_sum.begin(), r_sum.end());
	for(int i = 0; i < n - 1; ++i) {
		ans = min(ans , abs(l_sum[i] - r_sum[i + 1]));
		}
		cout << ans << endl;
}

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.precision(35);
	solve();
	return 0;
	}


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

const int N = 200+19;
int A[N],ans;

int main() {
    int n;
    cin >> n;
    for(int i = 0 ; i < 2*n ; ++i)
        cin >> A[i];
    sort(A,A+2*n);
    for(int i = 0 ; i < 2*n ; i += 2)
        ans += min(A[i],A[i+1]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        vll P(N);
        rep(i, 0, N) cin >> P[i];

        ll mn = P[0];
        ll ans = 0;
        rep(i, 0, N) {
                if (P[i] <= mn) ++ans;
                chmin(mn, P[i]);
        }

        cout << ans << endl;
}

Measured memory_bytes: 4748
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<cstdio>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
int tree[N],lazy[N];
void update(int i,int l,int r,int L,int R,int v){
	if(L<=l&&r<=R){
		tree[i]=v+l-L;
		lazy[i]=1;
		return;
	}
	int m=mid(l,r);
	if(l!=r&&lazy[i]){
		lazy[i]=0;
		lazy[2*i]=lazy[2*i+1]=1;
		tree[2*i]=tree[i];
		tree[2*i+1]=tree[i]+m+1-l;
	}
	if(L<=m)update(2*i,l,m,L,R,v);
	if(m<R)update(2*i+1,m+1,r,L,R,v);
	tree[i]=min(tree[2*i],tree[2*i+1]);
}
int query(int i,int l,int r,int L,int R){
	if(L<=l&&r<=R)return tree[i];
	int m=mid(l,r);
	if(l!=r&&lazy[i]){
		lazy[i]=0;
		lazy[2*i]=lazy[2*i+1]=1;
		tree[2*i]=tree[i];
		tree[2*i+1]=tree[i]+m+1-l;
	}
	if(r<L||R<l)return inf;
	return min(query(2*i,l,m,L,R),query(2*i+1,m+1,r,L,R));
}
void solve(){
	int h,w;
	cin>>h>>w;
	for(int i=1;i<=h;i++){
		int l,r;
		cin>>l>>r;
		if(l==1)update(1,1,w,l,r,inf);
		else update(1,1,w,l,r,query(1,1,w,l-1,l-1)+1);
		if(tree[1]>=inf)cout<<-1<<"\n";
		else cout<<tree[1]+i<<"\n";
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 7676
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

int main() {
	int T; cin >> T;
	while (T--) {
		[]() {
			ll a, b, c, d;
			cin >> a >> b >> c >> d;
			if (a < b || d < b) {
				cout << "No" << endl;
				return;
			}
			if (c >= b && d >= b) {
				cout << "Yes" << endl;
				return;
			}
			ll g = gcd(b, d);
			if (b - g + a%g > c) cout << "No" << endl;
			else cout << "Yes" << endl;
		}();
	}
	return 0;
}

Measured memory_bytes: 256