akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }




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

    int N;
    while (cin >> N) {
        vector<long long> A(N);
        for (int i = 0; i < N; ++i) cin >> A[i];
        auto B = A;

        sort(B.begin(), B.end());
        long long ma = B.back();
        long long ma2 = B[B.size()-2];

        for (int i = 0; i < N; ++i) {
            if (A[i] == ma) cout << ma2 << endl;
            else cout << ma << endl;
        }
    }
}


















Measured memory_bytes: 4736
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>

#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define debug(var) cout << #var << ": " << var << endl
using namespace std;
using Int = int64_t;
using Uint = uint64_t;
constexpr Uint mod = 1e9 + 7;
constexpr Int INF = INT_MAX;
template<typename T>
using Grid = vector<vector<T>>; // 二次元配列。[y][x]
template<typename T, typename U>
using Umap = unordered_map<T, U>;
template<typename T>
using Uset = unordered_set<T>;
template<typename T>
using P = pair<T, T>;

int main() {

	Int N; cin >> N;
	if (N % 2 == 0)cout << N / 2;
	else cout << N / 2 + 1;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<long long> a(N);
  for (int i=0; i<N; ++i) cin >> a[i];
  
  vector<long long> dpf(N), dpb(N), sum(N+1);
  for (int i=1; i<N; ++i) {
    dpf[i] = dpf[i-1];
    if (a[i-1] > 0) dpf[i] += a[i-1];
  }
  for (int i=N-2; i>=0; --i) {
    dpb[i] = dpb[i+1];
    if (a[i+1] > 0) dpb[i] += a[i+1];
  }
  for (int i=1; i<N+1; ++i) {
    sum[i] = sum[i-1] + a[i-1];
  }
  
  long long res = 0;
  for (int i=0; i<N-K+1; ++i) {
    long long tmp = max(0LL, sum[i+K] - sum[i]) + dpf[i] + dpb[i+K-1];
    if (res < tmp) res = tmp;
  }
  cout << res << endl;
  return 0;
}


  
  

Measured memory_bytes: 3456
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    long long tmp = 0;
    for(int i=0; i<n; ++i){
        if(i % 2 == 0)
            tmp += a[i];
        else
            tmp -= a[i];
    }

    cout << tmp;
    for(int i=0; i<n-1; ++i){
        tmp = (a[i] - tmp / 2) * 2;
        cout << ' ' << tmp;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 1664
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
lst = [a,b,c,d,e]

lst2 = []

for x in lst:
    amari = x % 10
    if amari == 0:
        pass
    else:
        lst2.append(10 - amari)

if not lst2:
    pass
else:
    lst2.remove(max(lst2))
print(sum(lst)+sum(lst2))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  bool c = true;
  for(int i=0;i<n;i++){
    if(a.at(i)%2 == 0){//2で割り切れる場合
    if(a.at(i)%3!=0&&a.at(i)%5!=0){//3でも5でも割り切れない場合
      c=false;
    }
   }
  } 
      if(c){//trueなら
    cout << "APPROVED" << endl;
  }
  else{//falseなら
    cout << "DENIED" << endl;
  }
}



Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100010
#define INF 2140000000
#define MOD 1000000007

int main() {
	int n,m;
 	cin>>n>>m;
    vector<int> a(n);
  	vector<pair<int,int>> v(m);
	for(int i=0;i<n;i++)
    {
      cin>>a[i];
    }
    for(int i=0;i<m;i++)
    {
       cin>>v[i].second>>v[i].first;
    }
    sort(a.begin(),a.end());
  	sort(v.rbegin(),v.rend());
	int k=0;
    for(int i=0;i<m;i++)
    {
      int s = v[i].second,val = v[i].first;
      
      while(k<a.size() && a[k]<val && s--)
      {
        a[k]=val;
        k++;
      }
    }
    long long ans = 0;

	for (int i = 0; i < (int) a.size(); ++i) {
		ans += a[i];
	}

	cout << ans << endl;
     return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
  }
  int64_t ans = 0;
  map<int,int> mp;
  for(int i=0; i<N; i++){
    int x = vec[i] - i;
    if(mp.count(x*-1)){
      ans += mp[x*-1];
    }
    x = vec[i] + i;
    if(mp.count(x)){
      mp[x]++;
    }
    else{
      mp[x] = 1;
    }
  }
  cout << ans << endl;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

lint calc(lint n){
    lint res = 0;
    while(n){
        n /= 10LL;
        ++res;
    }
    return res;
}

template<typename T>
bool chmin(T &_a, T _b){
    if(_a > _b){
        _a = _b;
        return true;
    }else{
        return false;
    }
}

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

    lint n;
    cin >> n;

    lint ans = LLINF;
    for(lint i = 1 ; i * i <= n ; ++i){
        if(n % i == 0){
            chmin(ans, max(calc(i), calc(n / i)));
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/* knapsack Problem */
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define rep(i,j) for(int (i)=0;(i)<(j);(i)++)

#define W_MAX 10000 +10
int main()
{
  ios::sync_with_stdio(false);
  int N,W;
  cin >> N >> W;
  vector<int> value(N+1),weight(N+1);
  for(int i=1;i<=N;i++){
    cin >> value[i] >> weight[i];
  }
  int DP[W_MAX]={};
  for(int n=1;n<=N;n++){
    for(int w=W;w-weight[n]>=0;w--){ //?????? ?????????
      DP[w]=max(DP[w],DP[w-weight[n]]+value[n]);
    }
  }
  cout<<DP[W]<<endl;
  
  return 0;
}

Measured memory_bytes: 1244
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<random>

#include<stack>
#include<queue>
#include<bitset>
#include<sstream>

using namespace std;
using ll = long long;

int main(int argc, char const *argv[]){
    int n;
    cin >> n;
    vector<ll> h;
    for(int i=0;i<n;i++){
        ll _h;
        cin >> _h;
        h.push_back(_h);
    }
    int p = h[0];
    for(int i=1;i<n;i++){
        if((h[i]-p)<0){
            cout << "No" << endl;return 0;
        }
        if((h[i]-p)>0){
            p = h[i]-1;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main(void){
  double time[5];
  int time2[5];
  int ans;
  cin >> time[0] >> time[1] >> time[2] >> time[3] >> time[4];
  for(int i=0;i<5;i++){
    time2[i]=(int)time[i]%10;
    time[i]=time[i]/10;
  }
  for(int i=0;i<5;i++){
    time[i]=ceil(time[i]);
  }
  for(int i=0;i<5;i++){
    time[i]=time[i]*10;
  }
  ans=time[0]+time[1]+time[2]+time[3]+time[4];
  for(int i=0;i<5;i++){
    if(time2[i]!=0){
      time2[i]=10-time2[i];
    }
  }
  int max=time2[0];
  for(int i=1;i<5;i++){
    if(max<time2[i]){
      max=time2[i];
    }
  }
  ans=ans-max;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)


typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


/*************************************************************************/
//多次元配列の確保及び初期化用マクロ
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}
/*************************************************************************/



const ll INF = 1e9 + 7;


int main() {

	int a, b;
	cin >> a >> b;
	cout << (a - 1) * (b - 1) << endl;


	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int 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 gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    ll g = gcd(a, b);
    return a / g * b;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    ll l = lcm(n, m);
    ll p = l/n, q = l/m;
    map<ll, char> cnt;
    map<ll, bool> used;
    rep(i,n){
        cnt[i*p] = s[i];
        used[i*p] = true;
    }
    rep(i,m){
        if(used[i*q] && (cnt[i*q] != t[i])){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 18984
#include<stdio.h>
int main(void){
	int n,max,min,x,v,a[10000];
	long int sum=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
		}
	 max=a[0];
	 min=a[0];
	for(x=1;x<n;x++){
		if(max<a[x]){
			max=a[x];
		}
	}
	for(v=1;v<n;v++){
		if(a[v]<min){
			min=a[v];
		}
	}
		printf("%d %d %ld\n",min,max,sum);
	return 0;
}


Measured memory_bytes: 2104
N,X,Y=map(int, input().split())
X-=1
Y-=1

d=[[10**9]*N for _ in range(N)]

for i in range(N):
    for j in range(N):
        d[i][j]=abs(i-j)
d[X][Y]=1
d[Y][X]=1
for i in range(N):
    for j in range(N):
        d[i][j] = min(d[i][j], d[i][X]+d[Y][j]+1)
        d[i][j] = min(d[i][j], d[i][Y]+d[X][j]+1)

ans = [0]*N
for i in range(N):
    for j in range(i+1,N):
        ans[d[i][j]]+=1

for k in range(1,N):
    print(ans[k])


Measured memory_bytes: 78428
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
unordered_map<ll,ll>dp;
ll fun(ll n){
	if(dp[n]) return dp[n];
	return dp[n]=(fun(n/2)+fun((n-1)/2)+fun((n-2)/2))%mod;
}
int main(){
	dp[0]=1,dp[1]=2;ll n;
	scanf("%lld",&n);
	printf("%lld\n",fun(n));
	return 0;
}

Measured memory_bytes: 3804
/*
Author: CNYALI_LK
LANG: C++
PROG: D.cpp
*/
#include<bits/stdc++.h>
#define up(a,b,c) for (ll a(b),end##a(c);a<=end##a;++a)
#define down(a,c,b) for (ll a(b),end##a(c);a>=end##a;--a)
#define uup(a,c,b) for (ll a(b),end##a(c);a<=end##a;++a)
#define udown(a,b,c) for (ll a(b),end##a(c);a>=end##a;--a)
#define endl '\n'
#define debug(...) fprllf(stderr,__VA_ARGS__)
using namespace std;
const double eps=1e-8;
const double PI=acos(-1.0);
typedef unsigned ll;
struct inout{
	static const ll ibufl=1<<25;
	static const ll obufl=1<<25;
	char in_buf[ibufl],out_buf[obufl],*inf,*ouf;
	inout(){
		inf=in_buf;ouf=out_buf;
	}
	void init(){
		fread(in_buf,1,ibufl,stdin);
	}
	inout& operator >>(ll &a){
		ll fh=1;
		while(!(isdigit(*inf)||*inf=='-'))++inf;
		if(*inf=='-')fh=-1,++inf;
		a=0;
		while(isdigit(*inf)){a=a*10+*inf-'0';++inf;}
		a*=fh;
		return *this;
	}
	inout& operator >>(char &a){
		while(*inf==' '||*inf=='\n')++inf;
		a=*inf;
		++inf;
		return *this;
	}
	inout& operator >>(char *a){
		while(*inf==' '||*inf=='\n')++inf;
		while(!(*inf==' '||*inf=='\n'||*inf=='\0')){*a=*inf;++inf;++a;}
		*a='\0';
		return *this;
	}

	inout& operator >>(double &a){
		ll fh=1;
		double s;
		while(!(isdigit(*inf)||*inf=='-'||*inf=='.'))++inf;
		if(*inf=='-')fh=-1,++inf;
		a=0;
		while(isdigit(*inf)){a=a*10+*inf-'0';++inf;}
		if(*inf=='.'){
			s=0.1;
			++inf;
			while(isdigit(*inf)){
				a+=s*(*inf-'0');
				++inf;
				s*=0.1;
			}
		}
		if(*inf=='E'||*inf=='e'){
			ll ss;
			++inf;
			*this>>ss;
			if(ss>0){
				while(ss){
					--ss;
					a*=10;
				}
			}
			if(ss<0){
				while(ss){
					++ss;
					a/=10;
				}
			}
			
		}
		a*=fh;
		return *this;
	}
	void writell(ll x){
		if(x/10)writell(x/10);
		*ouf=x%10+'0';
		++ouf;
	}
	inout& operator <<(ll a){
		
		if(a<0){*ouf='-';++ouf;a=-a;}
		writell(a);
		return *this;
	}
	static const ll sz=7;
	inout& operator <<(char a){
		*ouf=a;++ouf;
		return *this;
	}
	inout& operator <<(char *a){
		while(*a){
			*ouf=*a;
			++ouf;
			++a;
		}
		return *this;
	}
	inout& operator <<(double a){
		if(a<-eps){*ouf='-';++ouf;a=-a;}
		writell((ll)a);
		a-=(ll)a;
		*ouf='.';
		++ouf;
		up(i,1,sz){
			a=a*10;
			*ouf=(ll)a+'0';
			++ouf;
			a-=(ll)a;
		}
		return *this;
	}
	void out(){
		fwrite(out_buf,1,ouf-out_buf,stdout);
		ouf=out_buf;
	}
};
inout io;
template<class T>void chkmin(T &a,T b){a=a<b?a:b;}
template<class T>void chkmax(T &a,T b){a=a>b?a:b;}
char s1[54],s2[54];
ll f[54];
int main(){
#ifdef cnyali_lk
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
	io.init();
	ll n,t;
	io>>n>>s1+1>>s2+1;
	if(s1[1]==s2[1]){
		f[1]=3;
		t=2;
	}
	else{
		f[2]=6;
		t=3;
	}
	while(t<=n){
		if(s1[t]==s2[t]){
			if(s1[t-1]!=s2[t-1])f[t]=f[t-1];
			else f[t]=f[t-1]*2;
			if(f[t]>=1000000007)f[t]-=1000000007;
		}
		else{
			++t;
			if(s1[t-2]==s2[t-2])f[t]=f[t-2]*2;
			else f[t]=f[t-2]*3;
			while(f[t]>=1000000007)f[t]-=1000000007;
		}
		++t;
	}
	io<<f[n]<<endl;
	io.out();
	return 0;
}


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

namespace ABC063A
{
	class Program
	{
		static void Main(string[] args)
		{
			int a, b;
			var word = Console.ReadLine().Split(' ');
			a = int.Parse(word[0]);
			b = int.Parse(word[1]);
			if (10> (a + b))
			{
				Console.WriteLine(a+b);
				Console.ReadKey();
			}
			else 
			{
				Console.WriteLine("error");

				Console.ReadKey();
			}
		}
	}
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 28)

template<typename T>
void remove(vector<T>& vector, unsigned int index){
vector.erase(vector.begin() + index);
}

typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int n, ans;
int deal[102];
long long dp[102][21];

long long dfs(int now, long long sum){
	if(now == n-1){
		if(sum == ans)return true;
		else return false;
	}
	if(sum > 20 || sum < 0)return false;
	if(dp[now][sum] != -1)return dp[now][sum];
	return dp[now][sum] = dfs(now+1, sum-deal[now]) + dfs(now+1, sum+deal[now]);
}

int main(void){
	cin >> n;
	fill_n(deal, 102, -1);
	fill_n(*dp, 21*102, -1);

	rep(i, n){
		cin >> deal[i];
	}
	ans = deal[n-1];
	cout << dfs(1, deal[0]) << endl;

}

int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())
#define maxIndex(v) max_element(v.begin(), v.end()) - v.begin()
#define maxElement(v) *max_element(v.begin(), v.end())
#define minIndex(v) min_element(v.begin(), v.end()) - v.begin()
#define minElement(v) *min_element(v.begin(), v.end())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
using namespace std;

int main()
{
  ll N; cin >> N;
  string S;
  vector<vector<ll>> alpha(N, vector<ll>(26, 0));
  rep(i, 0, N) {
  	cin >> S;
    rep(j, 0, S.size()) {
    	alpha[i][S[j] - 'a']++;
    }
  }
  rep(j, 0, 26) {
  	ll max = 100000;
    rep(i, 0, N) {
    	if (max > alpha[i][j]) {
        	max = alpha[i][j];
        }
    }
    rep(i, 0, max) {
    	cout << char('a' + j);
    }
  }
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

void solve() {
    int n, k;
    cin >> n >> k;

    int sunuke[n];
    bzero(sunuke, sizeof(sunuke));

    int d, a;
    rep(0, k) {
        cin >> d;
        for (int j = 0; j < d; j++) {
            cin >> a;
            sunuke[a-1]++;
        }
    }

    int cnt = 0;
    rep(0, n) {
        if (sunuke[i] == 0) cnt++;
    }

    cout << cnt << endl;
}

int main() {
    solve();

    return 0;
}


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

int n;
long unsigned int a[100010],b[100010];
bool c[100010];

int euc(long unsigned int a, long unsigned int b){
	if (a == b)return a;
	if (a < b) {
		int c = b;
		b = a;
		a = c;
	}
		while (1) {
			a = a % b;
			if (a == 0)return b;
			b = b % a;
			if (b == 0)return a;
		}
}
int ser(long unsigned int r,int e) {
	
	for (int i = e+1; i < n; i++) {
		r = euc(a[i], r);
		if (r == 1) break;
	}
	b[e] = r;
}

int main(){
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	long unsigned int r=a[0];
	long unsigned int f;
	for (int i = 0; i < n; i++) {
		
		f = euc(a[i], r);
		if (f < r) {
			c[i] = true;
			ser(r, i);
		}
		r = f;
		if (r == 1) break;
	}
	c[0] = true;
	ser(a[1], 0);
	long unsigned int ans=1;
	for (int i = 0; i < n; i++) {
		if (c[i]) {
			if (ans < b[i])ans = b[i];
		}
	}
	cout << ans << endl;
return 0;
}


Measured memory_bytes: 1024
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    MAX = 100000
    SENTINEL = 2000000000

    class Card():
        def __init__(self, suit, value):
            self.suit = suit
            self.value = value

    def merge(A, n ,left, mid, right):
        n1 = mid - left
        n2 = right - mid
        L = [Card(None, None) for _ in range(n1+1)]
        R = [Card(None, None) for _ in range(n2+1)]
        for i in range(n1):
            L[i] = A[left + i]
        for i in range(n2):
            R[i] = A[mid + i]
        L[n1].value = SENTINEL
        R[n2].value = SENTINEL
        i, j = 0, 0
        for k in range(left, right):
            if L[i].value <= R[j].value:
                A[k] = L[i]
                i += 1
            else:
                A[k] = R[j]
                j += 1


    def mergeSort(A, n, left, right):
        if left+1 < right:
            mid = (left + right)//2
            mergeSort(A, n, left, mid)
            mergeSort(A, n, mid, right)
            merge(A, n, left, mid, right)


    def swap(a, i, j):
        # list aのi番目の要素とj番目の要素を交換する関数
        k = a[j]
        a[j] = a[i]
        a[i] = k

    def partition(A, p, r):
        x = A[r]
        i = p-1
        for j in range(p, r):
            if A[j].value <= x.value:
                i += 1
                swap(A, i, j)
        swap(A, i+1, r)
        return i+1

    def quickSort(A, p, r):
        if p < r:
            q = partition(A, p, r)
            quickSort(A, p, q-1)
            quickSort(A, q+1, r)


    n = int(input())

    A = [Card(None, None) for _ in range(n)]
    B = [Card(None, None) for _ in range(n)]

    for i in range(n):
        suit, value = input().split()
        A[i].suit = suit
        B[i].suit = suit
        A[i].value = int(value)
        B[i].value = int(value)

    mergeSort(A, n, 0, n)
    quickSort(B, 0, n-1)

    for i in range(n):
        if A[i].suit != B[i].suit:
            print('Not stable')
            break
    else:
        print('Stable')

    for b in B:
        print(b.suit, b.value)



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

int main() {
  int N;
  long long D;
  cin >> N >> D;
  
  long long list[N][2];
  for(int i=0; i<N; i++)
    cin >> list[i][0] >> list[i][1];
  
  int res = 0;
  long long dis = 0;
  
  for(int i=0; i<N; i++){
    dis = list[i][0]*list[i][0] + list[i][1]*list[i][1];
    
    if(dis <= D*D)
      res++;
  }
  cout << res << endl;
}

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

int main() {
  ll n;
  cin >> n;
  bool ans = true;
  ll now = 0;
  rep(i, n) {
    ll h;
    cin >> h;
    if(h < now) ans = false;
    if(h > now) h--;
    now = h;
  }
  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import Control.Applicative

main :: IO ()
main = do
    n <- getLine
    xs <- map read . words <$> getLine
    print $ solve xs

solve :: [Int] -> Int
solve = foldr (\x acc -> acc + (so x)) 0

so :: Int -> Int
so x
    | even x = 1 + (so (x `div` 2))
so x = 0


Measured memory_bytes: 7164
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define free  freopen ("input.txt", "r", stdin);freopen ("output.txt", "w", stdout);
#define Fast  ios::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second

bool vowel(char che)
{
    if (che == 'A' || che == 'E' || che == 'I' || che == 'O' || che == 'U' || che == 'Y')
        return true;
    else
        return false;
}

const int N = 1e5+5;
const int mod = 1e9+7;
ll a[N], b[N], c[N], d, dp, dis;
//pair <int, int> p[N];
char o;
bool mark[N], h;
//string s, s1;
//stack <int> st;
//set <ll> st1, st2;
//deque <int> dq;
//vector <int> vt[N];
//int a1[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};



int main()
{
    Fast
    int t, n, m, k = 0, f = 0, sum = 0, ans = 0;
    cin >> n >> m >> k;
    n = (n+m-1)/m;
    cout << n * k << endl;
}


Measured memory_bytes: 3516
#include <stdio.h>

/** Application main entry point. */
int main (
  int argc,
  char *argv[ ]
  )
{
  int a, b;

  while ( scanf ( "%d%d", &a, &b ) == 2 )
  {
    while ( b != 0 )
    {
      int tmp = b;
      b = a % b;
      a = tmp;
    }

    printf ( "%d\n", a );
  }

  return ( 0 );
}

Measured memory_bytes: 0
//Nipah!~☆
#include<bits/stdc++.h>
using namespace std;

const long long maxn = 5e3 + 10;
const long long mod = 924844033;

long long ans;
long long n, k, m;
long long inv[maxn];
long long fact[maxn];
bool mark[maxn];
vector<long long> paths;
long long dp[maxn][maxn];
long long pick[maxn][maxn];

void in();
void solve();
long long pwr(long long, long long);
void add(long long);
void pp(long long);
long long C(long long ,long long);
void out();

int main(){
	ios::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
	in();
	solve();
	out();
}

void in(){
	cin >> n >> k;
}

void solve(){
	fact[0] = 1;
	for(long long i = 1; i < maxn; i++)
		fact[i] = fact[i - 1] * i % mod;
	inv[maxn - 1] = pwr(fact[maxn - 1], -1);
	for(long long i = maxn - 2; i >= 0; i--)
		inv[i] = inv[i + 1] * (i + 1) % mod;
	for(long long i = 0; i < n; i++)
		if(!mark[i])
			add(i);
	m = paths.size();
	for(long long i = 0; i < m; i++)
		pp(i);
	dp[0][0] = 1;
	for(long long i = 1; i <= m; i++)
		for(long long j = 0; j <= n; j++)
			for(long long k = 0; k <= (paths[i - 1] + 1) / 2; k++)
				if(j - k >= 0)
					dp[i][j] = (dp[i][j] + dp[i - 1][j - k] * pick[i - 1][k] % mod) % mod;
	long long zarib = -1;
	for(long long i = 0; i <= n; i++){
		zarib *= -1;
		ans += dp[m][i] * fact[n - i] % mod * zarib;
		ans = (ans % mod + mod) % mod;
	}
}

void pp(long long x){
	for(long long i = 0; i <= (paths[x] + 1) / 2; i++)
		pick[x][i] = C(paths[x] - i + 1, i);
}

long long pwr(long long a, long long b){
	if(b < 0)
		return pwr(a, mod - 1 + b);
	if(b == 0)
		return 1;
	long long c = pwr(a, b / 2);
	if(b % 2)
		return c * c % mod * a % mod;
	return c * c % mod;
}

long long C(long long a, long long b){
	return fact[a] * inv[b] % mod * inv[a - b] % mod;
}

void add(long long x){
	long long num = 0;
	for(long long i = x; i < n; i += k){
		num++;
		mark[i] = 1;
	}
	if(num - 1){
		paths.push_back(num - 1);
		paths.push_back(num - 1);
	}
}

void out(){
	cout << ans;
}

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

using namespace std;

#define int long long
#define ar array
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)

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

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

template<class A>
void read(vt<A> &v);

template<class A, size_t S>
void read(ar<A, S> &a);

template<class T>
void read(T &x) {
    cin >> x;
}

void read(double &d) {
    string t;
    read(t);
    d = stod(t);
}

void read(long double &d) {
    string t;
    read(t);
    d = stold(t);
}

template<class H, class... T>
void read(H &h, T &... t) {
    read(h);
    read(t...);
}

template<class A>
void read(vt<A> &x) {
    EACH(a, x)read(a);
}

template<class A, size_t S>
void read(array<A, S> &x) {
    EACH(a, x)read(a);
}

string to_string(char c) {
    return string(1, c);
}

string to_string(bool b) {
    return b ? "true" : "false";
}

string to_string(const char *s) {
    return string(s);
}

string to_string(string s) {
    return s;
}

string to_string(vt<bool> v) {
    string res;
    FOR(sz(v))res += char('0' + v[i]);
    return res;
}

template<size_t S>
string to_string(bitset<S> b) {
    string res;
    FOR(S)res += char('0' + b[i]);
    return res;
}

template<class T>
string to_string(T v) {
    bool f = 1;
    string res;
    EACH(x, v) {
        if (!f)
            res += ' ';
        f = 0;
        res += to_string(x);
    }
    return res;
}

template<class A>
void write(A x) {
    cout << to_string(x);
}

template<class H, class... T>
void write(const H &h, const T &... t) {
    write(h);
    write(t...);
}

void print() {
    write("\n");
}

template<class H, class... T>
void print(const H &h, const T &... t) {
    write(h);
    if (sizeof...(t))
        write(' ');
    print(t...);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n) {
    v = vt<T>(n, x);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n, size_t m...) {
    v = vt<T>(n);
    EACH(a, v)vti(a, x, m);
}

void solve() {
    int n;
    read(n);
    vt<int> a(n);
    read(a);
    
    map<int, int> mp;
    FOR(n) {
        mp[a[i]]++;
    }
    
    int ev = 0, od = 0;
    EACH(x, mp) {
        if (x.second & 1) {
            od++;
        }
        else {
            ev++;
        }
    }
    
    if (ev % 2 == 0) {
        print(ev + od);
    }
    else {
        print(ev + od - 1);
    }
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int tt = 1;
    //read(tt);
    FOR(tt) {
//        write("Case #", i + 1, ": ");
        solve();
    }
    
}



Measured memory_bytes: 10124
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int w,h;

int main()
{
    while(cin >> w >> h,w)
    {
        vector<vector<int>> fie(h,vector<int>(w,0));
        rep(i,0,h - 1)rep(j,0,w - 1) cin >> fie[i][j];
        int res = 0;
        rep(i,0,h - 1)rep(j,0,w - 1){
            if(fie[i][j])
            {
                queue<P> que;
                res++;
                que.push({i,j});
                fie[i][j] = 0;
                while(!que.empty())
                {
                    auto p = que.front();
                    que.pop();

                    for(int i = p.first - 1;i <= p.first + 1;i++)
                    {
                        for(int j = p.second - 1;j <= p.second + 1;j++)
                        {
                            if(0 <= i && i < h && 0 <= j && j < w && fie[i][j])
                            {
                                que.push({i,j});
                                fie[i][j] = 0;
                            }
                        }
                    }
                }
            }
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 3144
N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]
h.sort(reverse=True)
mini = 10 ** 9

for i in range(N-K+1):
  a = h[i] - h[i+K-1]
  if a < mini:
    mini = a
    
print(mini)

Measured memory_bytes: 7384
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}

signed main()
{
int n,m;
cin>>n>>m;
int s[m],c[m];
for(int i=0;i<m;i++)
    cin>>s[i]>>c[i];
int ans[n];
memset(ans,-1,sizeof(ans));
int flag=0;
//for(int i=0;i<n;i++)
  //  cout<<ans[i]<<endl;
for(int i=0;i<m;i++)
{
    if(s[i]==1&&c[i]==0&&n!=1)
        flag=1;
    if(ans[s[i]-1]==-1||ans[s[i]-1]==c[i])
      ans[s[i]-1]=c[i];
    else
        flag=1;
}
if(flag==1)
{
    cout<<-1<<endl;
    return 0;
}
if(n==1)
{
    if(ans[0]==-1)
        cout<<0<<endl;
    else
        cout<<ans[0]<<endl;
return 0;
}
for(int i=0;i<n;i++)
{
    if(ans[i]==-1)
        ans[i]=0;
}
if(ans[0]==0)
    ans[0]=1;
for(int i=0;i<n;i++)
    cout<<ans[i];
}





Measured memory_bytes: 256
#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter,mul
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left,bisect_right
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time
#from functools import lru_cache,reduce
#from math import factorial,hypot
#import sys
#from fractions import gcd
setrecursionlimit(10**6+1)
input=stdin.readline

n,m=map(int,input().split())
a=[int(i) for i in input().split()]
print(n-sum(a) if n>=sum(a) else -1)

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

using namespace std;

typedef long long ll;

ll gcd(ll x, ll y) {
    if (y == 0)
        return x;
    else 
        return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
    ll g = gcd(x, y);
    return x / g * y;
}

int main() {
    ll N, M;   cin >> N >> M;
    ll *A = new ll[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        A[i] /= 2;
    }

    vector<ll> p(N, 0);
    for (int i = 0; i < N; i++) {
        ll x = A[i];
        while (x % 2 == 0) {
            p[i]++;
            x /= 2;
        }
    }

    bool flag = true;
    for (int i = 0; i < N-1; i++) {
        if (p[i] != p[i+1])
            flag = false;
    }
    if (!flag) {
        cout << 0 << endl;
        return 0;
    }

    ll l = A[0];
    for (int i = 1; i < N; i++) {
        l = lcm(l, A[i]);
    }

    cout << ((M/l)+1)/2 << endl;

    return 0;
}

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

int main(){
  ll n,a=2,b=1;
  cin>>n;
  fr(i,n-1){
    b+=a;
    a=b-a;
  }
  cout<<b<<endl;
}

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

#define MIN(X,Y) ((X)<(Y)?(X):(Y))
#define MAX(X,Y) ((X)>(Y)?(X):(Y))

int dp[1001][1001];

int main(void){
  char x[1001], y[1001];
  int xln, yln;
  int dataNum;
  
  cin >> dataNum;
  for (int did=0; did<dataNum; did++){
    cin >> &(x[1]) >> &(y[1]);
    xln = strlen(x+1); yln = strlen(y+1);
    // dp tableの初期化
    for (int i=0; i<=xln; i++) dp[i][0] = 0;
    for (int j=0; j<=yln; j++) dp[0][j] = 0;
    // dp
    for (int i=1; i<=xln; i++){
      for (int j=1; j<=yln; j++){
        if (x[i]==y[j]){
          dp[i][j] = dp[i-1][j-1]+1;
        } else {
          dp[i][j] = MAX(dp[i][j-1], dp[i-1][j]);
        }
      }
    }
/*    for (int i=0; i<=yln; i++){
      for (int j=0; j<=xln;j++){
        cout << dp[j][i] << " ";
      }
      cout << endl;
    }*/
    cout << dp[xln][yln] << endl;
  }
  return 0;
}



Measured memory_bytes: 7016
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

ll _solve(ll a, ll b, ll j){
	for (int i = 0; i < a; ++i){
		if (((a - i) ^ (b + i)) == j){
			return i;
		}
	}
	return -1;
}

ll solve(ll a, ll b, ll j, ll res = 0, bool f = false){
	if (f) cout << "called : " << a << " " << b << " " << j << endl;
	
	if ((a ^ b) == j){
		return res;
	}

	for (int i = 50; i > 0; --i){
		if ((a ^ b ^ j) & (1LL << i)){
			// aのi桁目を変えるのに必要なmin
			ll tmp1 = (a & ((1LL << i) - 1)) + 1;
			// bのi桁目を変えるのに必要なmin
			ll tmp2 = (1LL << i) - (b & ((1LL << i) - 1));
			// 除く分
			ll rem = min(tmp1, tmp2);
			if (a - rem <= 0){
				return -1;
			}
			return solve(a - rem, b + rem, j, res + rem, f);
		}
	}

	return -1;
}

int main(void){
	 
	/* for (ll a = 1; a <= 100; ++a){
		for (ll b = 1; b <= 100; ++b){
			for (int j = 0; j <= 100; ++j){
				if (solve(a, b, j) != _solve(a, b, j)){
					cout << "!!! " << a << " " << b << " " << j << endl;
					cout << "_solve : " << _solve(a, b, j) << endl;
					cout << "solve : " << solve(a, b, j, 0, true) << endl;
					return 0;
				}
			}
		}
	} */

	int N; cin >> N;
	ll a1, a2, j = 0;
	cin >> a1 >> a2;
	for (int i = 2; i < N; ++i){
		ll ai; cin >> ai;
		j ^= ai;
	}

	cout << solve(a1, a2, j, 0, false) << endl;

	return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

long long N;
string S;
int P;

long long solve() {
    // 2と5は大丈夫
    if (P == 2 || P == 5) {
        long long res = 0;
        for (int i = 0; i < N; ++i) {
          if ((S[N-i-1]-'0') % P == 0) {
            res += N-i;
          }
        }
        return res;
    }

    vector<long long> val(P, 0);
    long long tenfactor = 1;
    long long cur = 0;
    val[cur]++;
    for (int i = 0; i < N; ++i) {
        cur = (cur + (S[N-i-1]-'0') * tenfactor) % P; // 和をmodでとっても結果は変わらないのでわる
        tenfactor = (tenfactor * 10) % P;
        val[cur]++;
    }
    long long res = 0;
    // 2この選択肢の個数を数える
    for (int p = 0; p < P; ++p) {
      res += val[p] * (val[p] - 1) / 2;
    }
    return res;
}

int main() {
    cin >> N >> P >> S;
    cout << solve() << endl;
}


Measured memory_bytes: 640
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)*}
    };
}

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

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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashMap;
use std::cmp::{max,min};
fn main(){
    input!{
        s:chars,
        t:chars,
    }
    let ans = s.iter().zip(t.iter()).filter(|&(x,y)| x == y).count();
    println!("{}",ans);
}


fn is_prime(x:i64) -> bool {
    if x == 2 {return true;}
    if x < 2 || x % 2 == 0 {return false;}
    let mut j = 3;
    while j <= (x as f64).sqrt() as i64 {
        if x % j == 0 {
            return false;
        }
        j += 2;
    }
    true
}


Measured memory_bytes: 4352
n = input()

if (n[-1] == '2') or (n[-1] == '4') or (n[-1] == '5') or (n[-1] == '7') or (n[-1] == '9'):
    print('hon')
    
if (n[-1] == '0') or (n[-1] == '1') or (n[-1] == '6') or (n[-1] == '8'):
    print('pon')
    
    
if (n[-1] == '3') :
    print('bon')

Measured memory_bytes: 9136
import os, sys, re, math

def doit(N):
    ret = 0
    for i in range(105, N+1, 2):
        if countit(i) == 8:
            ret += 1
    return ret


def countit(N):
    cnt = 0
    for i in range(1, N+1):
        if N % i == 0:
            cnt += 1
    return cnt

N = int(input())
print(doit(N))


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

// 互除法で2正数x,yのgcdを返す関数
ll gcd (ll x, ll y) {
    ll p = x % y;
    while(p){
        x = y;
        y = p;
        p = x % y;
    }
    return y;
}

// 素因数分解, 2^3 なら (2, 3)
vector<pair<ll, int>> factoring(ll n){
    vector<pair<ll, int>> res;
    for (ll i = 2; i * i <= n; ++i) {
        int k = 0;
        while (n % i == 0){
            n /= i;
            k++;
        }
        if(k != 0) res.push_back({i, k});
    }
    if(n != 1) res.push_back({n, 1});
    return res;
}

int main() {
    ll A, B;
    cin >> A >> B;

    ll N = gcd(A, B);
    auto v = factoring(N);
    ll ans = 1;
    ans += v.size();
    cout << ans;
    return 0;
}

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

int main()
{
    double a , sum , result;
    long long n ;
    sum = result = 0.0 ;
    scanf("%lld",&n);
    for(int i=1; i<=n; i++)
    {
        scanf("%lf",&a);
        sum = sum+1.0/a;
    }
    result = 1.0 / sum;
    
    printf("%.14lf\n",result);
    
  return 0;
}
// 66.66666666666667 %.14lf 

Measured memory_bytes: 1728
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(scanner.nextInt());
        }

        list.sort(Integer::compareTo);

        int hoge = list.size() / 2;
        int left = list.get(hoge - 1);
        int right = list.get(hoge);
        System.out.println(right - left);
    }
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

const int INF = 1e9;
using S = int;
int op(int a, int b){ return max(a, b); }
int e(){ return 0; }

void Main(){
  int n, k; cin >> n >> k;
  segtree<S, op, e> seg(300005);
  rep(i, n){
    int x; cin >> x;
    int l = max(x-k, 0);
    int r = min(x+k, 300000);
    int tmp = seg.prod(l, r+1) + 1;
    seg.set(x, tmp);
  }
  cout << seg.all_prod() << endl;
  return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 8492
import heapq
N, M = map(int, input().split())
A = [-int(a) for a in input().split()]
heapq.heapify(A)
for _ in range(M):
    a = heapq.heappop(A)
    heapq.heappush(A, a / 2)
print(sum(int(-a) for a in A))

Measured memory_bytes: 14184
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int SIZEN = 100010;
typedef long long LL;
const int mod = 1e9+7;
LL fac[SIZEN]={0};
LL inv[SIZEN]={0};
LL qpow(LL x,LL len){
	LL ret = 1;
	for(;len;len>>=1,x=x*x%mod)
	if(len & 1)ret = ret*x%mod;
	return ret;	
}
int N;
void Init(){
	fac[0] = 1;inv[0] = 1;
	for(int i = 1;i <= N+1;i++)fac[i] = fac[i-1]*i%mod;
	inv[N+1] = qpow(fac[N+1],mod-2);
	for(int i = N;i >= 1;i--)inv[i] = inv[i+1]*(i+1)%mod;
}
LL C(int n,int m){
	if(n < m||m < 0)return 0;
	if(n == m || m == 0)return 1;	
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int last[SIZEN] = {0};
int a[SIZEN] = {0};
int main(){
	scanf("%d",&N);
	for(int i = 1;i <= N+1;i++)scanf("%d",&a[i]);
	Init();
	int l,r,len;
	for(int i = 1;i <= N+1;i++){
		if(!last[a[i]])last[a[i]] = i;
		else{
			l = last[a[i]];
			r = i;
			len = r-l+1;
			break;
		}	
	}	//printf("l = %d,r = %d\n",l,r);
	printf("%d\n",N);
	for(int i = 2;i <= N+1;i++){
		LL ans = C(N+1,i)-C(N+1-len,i-1);
	//	printf("C(%d,%d) = %lld,C(%d,%d) = %lld\n",N+1,i,C(N+1,i),N+1-len,i-1,C(N+1-len,i-1));
		ans = (ans%mod+mod)%mod;
		printf("%lld\n",ans);
	}
	getchar();getchar();
	return 0;
}


Measured memory_bytes: 3456
#include <stdio.h>
#define PI 3.141592653589
int main(void){
    double r, m, s;
    
    scanf("%lf\n", &r);
    
    m = r * r * PI;
    s = 2 * r * PI;
    
    printf("%.6f %.6f\n", m, s);
    
    return 0;
}


Measured memory_bytes: 2056