akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

ll gcd_euclid(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r; /* swap */
  }
  return u;
}

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

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    ll a,b;
    cin >> a >> b;
    ll g=gcd_euclid(a,b);
    set<ll> s=prime_factor(g);
    cout << sz(s)+1;
    


}

/*



 */



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
int n;
int main(){
    scanf("%d",&n);
    ll low = 0;
    ll sum = 0;
    ll minhi = 1000000001;
    for(int i=0;i<n;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        if (a < b){
            low += b-a;
        }
        sum += a;
        if (a > b)minhi = min(minhi, (ll)b);
    }
    if (low == 0){
        printf("0\n");
    }
    else {
        printf("%lld\n", sum - minhi);
    }
}


Measured memory_bytes: 128
from sys import stdin
#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
N,K = map(int, stdin.readline().rstrip().split())
P = list(map(int, stdin.readline().rstrip().split()))

Q = [(p+1)/2 for p in P]
c = [0]
for q in Q:
    c.append(c[-1] + q)

ans = 0
for i in range(K,N+1):
    ans = max(ans, c[i] - c[i-K])
print(ans)


Measured memory_bytes: 24804
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;



int main() {
	string S;
	cin >> S;
	if (S.at(0) == S.at(1)&&S.at(2)==S.at(3)&&S.at(1)!=S.at(2)) {
		cout<<"Yes"<<endl;
	}
	else if (S.at(0) == S.at(2) && S.at(1) == S.at(3) && S.at(2) != S.at(1)) {
		cout<<"Yes"<<endl;
	}
	else if (S.at(0) == S.at(3) && S.at(1) == S.at(2) && S.at(3) != S.at(1)) {
		cout<<"Yes"<<endl;
	}
	else {
		cout<<"No"<<endl;
	}
}










Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string.h>
#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 n;
string s;
int main()
{
	cin >> n >> s;

	int left = 0;

	int left_ans = 0;

	for(char c : s)
	{
		if(c == '(')
		{
			left++;
		}
		else
		{
			left--;
		}
		if(left == -1)
		{
			left_ans++;
			left= 0;
		}
	}

	for(int i = 0;i < left_ans;i++)
	{
		cout << "(";
	}

	cout << s;

	for(int i = 0;i < left;i++)
	{
		cout << ")";
	}
	cout << endl;
}




Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
vector<ll> ans;
void dfs(string now, ll d){
    //cout << now << endl;
    ans.push_back(stoll(now));
    if(d >= 10) return;
    string next = now;
    next.push_back(now.back());
    dfs(next, d + 1);
    if(now.back() - 1 >= '0'){
        next = now;
        next.push_back(now.back() - 1);
        dfs(next, d + 1);
    }

    if(now.back() + 1 <= '9'){
        next = now;
        next.push_back(now.back() + 1);
        dfs(next, d + 1);
    }
}
int main(void){
    ll k;
    cin >> k;

    for(int i = 1; i < 10; i++){
        string s = to_string(i);
        dfs(s, 0);
    }

    sort(all(ans));
    
    cout << ans[k - 1] << endl;


}

Measured memory_bytes: 10608
N = input()
K = int(input())

a = 1
b = [0] * (K + 1)
b[0] = 1
b[1] = int(N[0]) - 1

for c in N[1:]:
    t = int(c)
    for i in range(K - 1, -1, -1):
        b[i + 1] += b[i] * 9
    if t != 0:
        if a + 1 <= K:
            b[a + 1] += t - 1
        if a <= K:
            b[a] += 1
        a += 1

if a == K:
    print(b[K] + 1)
else:
    print(b[K])


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

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



Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

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

Measured memory_bytes: 256
//om nama sivaya
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define pb push_back
using namespace std;
void solve(){
   ll x,k,d,y,pa=0;
   cin>>x>>k>>d;
   x=abs(x);
   y=(x/d);
   if(k<=y){
       cout<<(x-(d*k));
   }else{
       k-=y;
       x-=(y*d);
       if(k%2)
       cout<<abs(x-d);
       else if(!(k%2))
       cout<<abs(x);
   }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tt=1;
    //cin>>tt;
    while(tt--){
        solve();
    }
}


Measured memory_bytes: 3648
n = int(input())
a, b = map(int, input().split())
li = list(map(int, input().split()))
li.sort()
x = len([i for i in li if i <= a])
y = len([i for i in li if a < i <= b])
z = len([i for i in li if b < i])
print(min(x, y, z))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const long long M =1e6+10,MOD=1000000007;
typedef long long ll;
 
int main()
{
     ios::sync_with_stdio(false);
     cin.tie(0);
     int k,sum=0;
     cin>>k;
     for(int i=1;i<=k;i++)
      for(int j=1;j<=k;j++)
        for(int l=1;l<=k;l++)
        {
          int a=__gcd(i,j);
          sum+=(__gcd(a,l));
        }
        cout<<sum<<"\n";
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define per(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#ifdef LOCAL
#define debug(x) cerr << '[' << #x << " = " << (x) << "]\n"
#else
#define debug(x)
#endif
const int maxn=1e5+1;
vector<int>adj[maxn],topo;
bool proc[maxn];
int dp[maxn];
void dfs(int i){
	if(proc[i])return;
	proc[i]=1;
	for(int nbr:adj[i]){
		dfs(nbr);
	}
	topo.pb(i);
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n,m;cin>>n>>m;
	rep(i,0,m){
		int x,y;cin>>x>>y;
		adj[x].pb(y);
	}
	rep(i,1,n+1){
		if(!proc[i]){
			dfs(i);
		}
	}
	reverse(all(topo));
	int ans=0;
	rep(i,0,n){
		for(int nbr:adj[topo[i]]){
			dp[nbr]=max(dp[nbr],dp[topo[i]]+1);
			ans=max(ans,dp[nbr]);
		}
	}
	cout<<ans<<'\n';
}

Measured memory_bytes: 11672
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,m;
    cin >> n >> m;
    long long h[n];
    for (long long i = 0; i < n; i++){
        cin >> h[i];
    }
    long long a[m],b[m];
    for (long long i = 0; i < m; i++){
        cin >> a[i] >> b[i];
    }
    long long mark[n] = {};
    for (long long i = 0; i < m; i++){
        //cout << h[a[i] -1] << h[b[i]-1] << endl;

        if (h[a[i]-1] > h[b[i]-1]){
            mark[b[i]-1] = 1; //1だと必ず、良い展望台じゃない
        }else if (h[a[i]-1] < h[b[i]-1]){
            mark[a[i]-1] = 1;
        }else{
            mark[a[i]-1] = 1;
            mark[b[i]-1] = 1;
        }
    }
    long long count = 0;
    for (long long i = 0; i < n; i++){
        //cout << mark[i] << endl;
        if (mark[i] != 1){
            count++;
        }
    }
    cout << count <<endl;
    //cout << 1.0 * clock() / CLOCKS_PER_SEC;
    return 0;
}

Measured memory_bytes: 6732
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
int main(){
  int n,m,k; cin>>n;
  m=n/100; k=n%100;
  if(m*5<k)cout<<0<<endl;
  else cout<<1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define in insert
#define ld long double


#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
#define int ll
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e18;
const ll MAX_NODES =200001;
const ll MAX_LOG =50;
const ll maxn = 100000+1;

int32_t main()
{ 

  IOS 
    int a,b,c;
    cin>>a>>b>>c;
    int k;
    cin>>k;
    int ans = min(a,k);
    k -= ans;
    k-=(min(b,k));
    ans-=(min(c,k));
    cout<<ans<<endl;

  

  




}


Measured memory_bytes: 3652
#include<stdio.h>

#define MAX 100

static const int INFTY = (1<<21);
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,m[MAX][MAX];

void dijkstra() {
  int minv,i,u,v;
  int d[MAX],color[MAX];

  for (i=0;i<n;i++){
    d[i] = INFTY;
    color[i] = WHITE;
  }
  d[0] = 0;
  color[0] = GRAY;
  
  while(1) {
    minv = INFTY;
    u = -1;
    for(i=0;i<n;i++){
      if(minv>d[i] && color[i] != BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1)break;
    color[u] = BLACK;
    for(v=0;v<n;v++){
      if(color[v] != BLACK && m[u][v] != INFTY){
	if(d[v] > d[u] +  m[u][v]){
  	  d[v] = d[u] + m[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }

  for(i=0;i<n;i++){
    if(d[i] == INFTY) printf("%d -1\n",i);
    else printf("%d %d\n",i,d[i]);
  }
}

int main() {
  int i,j;
  int k,c,u,v;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      m[i][j] = INFTY;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d %d",&v,&c);
      m[u][v] = c;
    }
  }

  dijkstra();

  return 0;
}
  
	   



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

using namespace std;

typedef long long ll;

inline ll read(){
	char ch=getchar();ll x=0,f=1;
    while(ch<'0' || ch>'9') {
       if(ch=='-') f=-1;
	  	  ch=getchar();
	}
    while(ch<='9' && ch>='0') {
	   x=x*10+ch-'0';
	   ch=getchar();
	}
    return x*f;
}



int main(){
	int x=read();
	if(x==7 || x==3 || x==5){
		cout<<"YES";
	}
	else cout<<"NO";

	return 0;
}





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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
int x , y ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>x>>y ;
	for(int i = 0 ; i <= x ; ++i)
	{
		int a = i * 2 + (x - i) * 4 ;
		if(a == y)
			return cout<<"Yes\n" , 0 ;
	}
	return cout<<"No\n" , 0 ;
}		

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100005
#define LL long long int
LL ans;
struct Apple
{
    int d,flg;
    bool operator <(const Apple &t )const{
        return d>t.d||(d==t.d&&flg>t.flg);
    }
}apples[MAXN<<2];
int x,y,a,b,c;
int main()
{
    scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
    int sum=a+b+c;
    for(int i=1;i<=sum;i++)
    {
        scanf("%d",&apples[i].d);
        if(i<=a)
        apples[i].flg=1;
        else if(i<=a+b)
        apples[i].flg=2;
        else apples[i].flg=3;
    }
    sort(apples+1,apples+sum+1);
    int cnt=0;
    
    for(int i=1;i<=sum;i++)
    {
        if(apples[i].flg==1)
        {if(x>0)x--,ans+=apples[i].d;}
        else if(apples[i].flg==2)
        {if(y>0)y--,ans+=apples[i].d;}
        else
        {
            cnt++;ans+=apples[i].d;
        }
        if(cnt>=x+y)
        break;
    }
    printf("%lld",ans);
    return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL ans = 0;
	LL N; cin >> N;
	string MARCH = "MARCH";
	VL a(5, 0);
	FOR(i, 0, N) {
		string s; cin >> s;
		FOR(k, 0, 5) {
			if (s.front() == MARCH[k]) {
				a[k]++;
			}
		}
	}
	FOR(i, 0, 5) {
		FOR(j, i + 1, 5) {
			FOR(k, j + 1, 5) {
				ans += a[i] * a[j] * a[k];
			}
		}
	}
	cout << ans << endl;

	return 0;
}


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

int main(){
    int n;cin >> n;
    string s;
    cin >> s;
    int m = 0;
    int cnt = 0;
    rep(i,n){
        if(s[i] == '(') cnt++;
        else cnt--;
        m = min(m,cnt);
    }
    m = abs(m);
    string t = "";
    rep(i,m) t.push_back('(');
    s = t+s;
    t = "";
    if(cnt+m>0){
        rep(i,cnt+m) t.push_back(')');
        s = s+t;
    }

    cout << s << endl;


}

Measured memory_bytes: 3576
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
long long int N,M,A,B,C,sum=0,X[600005],Y[100500],Z[100500],dp[5]={},four[1000]={},dp2[2000500]={};
pll key[1005];
string S,T;


bool used[200020]={};
long long int res=0;
int main()
{
    cout << fixed << setprecision(18);
    cin>>A>>B>>C;
    if((3*max({A,B,C})-A-B-C)%2==0){
        cout<<(3*max({A,B,C})-A-B-C)/2<<endl;
    }else{
        
        cout<<(3*max({A,B,C})-A-B-C)/2+2<<endl;
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long 

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int n; cin >> n;
	int a[n];
	rep(i, n) cin >> a[i];

	int ans1 = 0, ans2 = 0;
	int sum1 = 0, sum2 = 0;
	rep(i, n) {
		sum1 += a[i];
		sum2 += a[i];
		if (i % 2 == 0) {
			ans1 += max(0LL, -sum1 + 1);
			ans2 += max(0LL, sum2+ 1);
			sum1 += max(0LL, -sum1 + 1);
			sum2 -= max(0LL, sum2 + 1);
		}
		else {
			ans1 += max(0LL, sum1 + 1);
			ans2 += max(0LL, -sum2 + 1);
			sum1 -= max(0LL, sum1 + 1);
			sum2 += max(0LL, -sum2 + 1);
		}
		//cout << sum1 << " " << sum2 << endl;
	}
	cout << min(ans1, ans2) << endl;

    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int m = sc.NextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = sc.NextInt();
            b[i] = sc.NextInt();
        }

        int[] c = new int[m];
        int[] d = new int[m];
        for (int i = 0; i < m; i++)
        {
            c[i] = sc.NextInt();
            d[i] = sc.NextInt();

        }

        int[] ans = new int[n];

        for (int i = 0; i < n; i++)
        {
            int min = int.MaxValue;
            int num = -1;
            for (int j = 0; j < m; j++)
            {
                int dist = Math.Abs(c[j] - a[i]) + Math.Abs(d[j] - b[i]);
                if(dist < min)
                {
                    min = dist;
                    num = j;
                }
            }
            ans[i] = num + 1;
        }

        Console.WriteLine(string.Join("\n",ans));
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 27620
# include <bits/stdc++.h>
# pragma GCC optimize("Ofast")
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define forn(i, n) for (int i = 0; i < int(n); i++)
# define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define fore(i, l, r) for (int i = int(l); i < int(r); i++)
# define in freopen("input.txt", "r", stdin)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
  
using namespace std;
  
const ll INF = 1e18;
const int mod = 1e9 + 7;
const ll N = 1e5 + 7;

int dp[N][3];
   
int main()
{   
    speed;
    int n;
    cin >> n;
    vector < vector < int > > vc;
    forn( i, n ) {
        vector < int > v(3);
        cin >> v[0] >> v[1] >> v[2];
        vc.pb(v);
    }
    dp[0][0] = vc[0][0];
    dp[0][1] = vc[0][1];
    dp[0][2] = vc[0][2];
    fore( i, 1, n ) {
        forn( j, 3 ) {
            forn( k, 3 ) {
                if ( j == k ) continue;
                dp[i][j] = max( dp[i][j], dp[i - 1][k] );
            }
            dp[i][j] += vc[i][j];
        }
    }
    cout << max( {dp[ n - 1 ][0], dp[ n - 1 ][1], dp[ n - 1 ][2]} );
    time;
}

Measured memory_bytes: 7472
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>

using namespace std;

int main()
{
  long long N;
  cin >> N;
  long long minv = 1e16;
  for (int i = 0; i < 5; ++i) {
    long long v;
    cin >> v;
    minv = min(minv, v);
  }
  long long ans = N / minv + 5;
  if (N % minv == 0) --ans;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int h, w, K;
    cin >> h >> w >> K;
    vector<vector<int>>a(h, vector<int>(w));
    rep(i,h){
        string s;
        cin >> s;
        rep(j,w)a[i][j] = s[j]-'0';
    }
    int res = INT_MAX;
    rep(i,1<<(h-1)){
        vector<vector<int>> b;
        vector<int> c(w, 0);
        rep(j,h){
            rep(k,w){
                c[k] += a[j][k];
            }
            if(j == h -1){
                b.push_back(c);
            }else if(i >> j & 1){
                b.push_back(c);
                c = vector<int>(w, 0);
            }
        }
        int sz = (int)b.size();
        show(sz);
        rep(j,sz)show(b[j]);
        int ans = sz - 1;
        vector<int>d(sz);
        bool f = false;
        rep(j,sz){
            for(auto x:  b[j])if(x > K)f = true;
        }
        if(f)continue;
        rep(k,w){
            rep(j,sz){
                d[j] += b[j][k];
            }
            show(k,d);
            rep(j,sz){
                if(d[j] >= K + 1){
                    ans++;
                    rep(jj,sz)d[jj]=b[jj][k];
                    break;
                }
            }
        }
        show(ans);
        res = min(res, ans);
    }
    cout << res << endl;
}


Measured memory_bytes: 384
N = int(input())
T, A = map(int, input().split()) # 横に2個
H = list(map(int, input().split()))

D = -1
for i, h in enumerate(H):
    tem = abs(T - h * 0.006 - A)

    if tem < D or i == 0:
        D = tem
        ans = i + 1
print(ans)


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

vector<string> field;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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

  field.resize(h);
  for(int i = 0; i < h; ++i)cin >> field[i];

  vector<vector<int>> dist(h, vector<int>(w, -1)); // init
  queue<pair<int, int>> que;

  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      if(field[i][j] == '#'){
        dist[i][j] = 0;
        que.push(make_pair(j, i));
      }
    }
  }

  while(!que.empty()){
    pair<int, int> v = que.front(); 
    que.pop();

    for(int i = 0; i < 4; ++i){
      int nx = v.first + dx[i];
      int ny = v.second + dy[i];

      if(ny < 0 || ny >= h || nx < 0 || nx >= w)continue;

      if(dist[ny][nx] != -1)continue;

      dist[ny][nx] = dist[v.second][v.first] + 1;
      que.push(make_pair(nx, ny));
    }
  }
  int ans = 0;
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      ans = max(ans, dist[i][j]);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 13456
#include<stdio.h>
#include<string.h>
int main()
{
	char s[102];
	scanf("%s", s);
	int n = strlen(s), i;
	int ans = 0;
	for (i = 0; i < n / 2; i++)
		if (s[i] != s[n - i - 1])
			ans++;
	printf("%d\n", ans);
	return 0;
}

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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if( a * b * c == 5 * 7 * 5 ){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
  return 0;
}


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

map<string,int> mp;
void init(){
  mp["yotta"]=24;
  mp["zetta"]=21;
  mp["exa"]=18;
  mp["peta"]=15;
  mp["tera"]=12;
  mp["giga"]=9;
  mp["mega"]=6;
  mp["kilo"]=3;
  mp["hecto"]=2;
  mp["deca"]=1;
  mp["deci"]=-1;
  mp["centi"]=-2;
  mp["milli"]=-3;
  mp["micro"]=-6;
  mp["nano"]=-9;
  mp["pico"]=-12;
  mp["femto"]=-15;
  mp["ato"]=-18;
  mp["zepto"]=-21;
  mp["yocto"]=-24;
}

string num,A,B;

bool check(){
  if(num.size()==1)return true;
  if(num[0]!='0'&&num[1]=='.')return true;
  return false;
}

void mul(){
  assert(num[0]=='0'&&num[1]=='.');

  if(num.size()==3){
    num=num.substr(2);
  }else if(num[2]=='0'){
    num="0."+num.substr(3);
  }else{
    swap(num[2],num[1]);
    num=num.substr(1);
  }
}

void divi(){
  int id=-1,len=num.size();
  for(int i=0;i<len;i++){
    if(num[i]=='.')id=i;
  }
  if(id==-1){
    num.push_back('.');
    swap(num[len],num[len-1]);
  }else{
    swap(num[id],num[id-1]);
  }
}

int main(){
  init();
  int T;
  cin>>T;
  cin.ignore();
  while(T--){
    string tmp,str;
    getline(cin,tmp);
    stringstream ss(tmp);
    vector< string > t;
    while(ss>>str){
      t.push_back(str);
    }
    int ans;    
    num=t[0];
    if(t.size()==2){
      B=t[1];
      ans=0;
    }else{
      B=t[2];
      ans=mp[t[1]];
    }

    while(!check()){
      if(num[0]=='0'){
        mul();
        ans--;
      }else{
        divi();
        ans++;
      }

      //cout<<num<<' '<<'?'<<endl;
    }
    cout<<num<<" * 10^"<<ans<<' '<<B<<endl;
  }
  return 0;
}

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

using namespace std;

int main()
{
    long long int a,b,x; cin>>a>>b>>x;
    long long int t=a%x;
    long long xd=b-a+1;
    long long int res=xd/x;
    long long int left=xd-res*x;
    if(left>0)
    {
        if(t==0) res++;
        else
        {
            if(t+left-1>=x) res++;
        }
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = (ll)(1e9 + 7);
vector<string> grid;
int dp[1100][1100];
int main() {
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        string s;cin >> s;
        grid.push_back(s);
    }
    dp[0][0] = 1;
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
        dp[i][j] %= MOD;        //////// この処理をループの最後に持ってくるとなぜかacしない
           /////////　pythonだとacするが後に持ってくるのと先に行うのでは処理速度が違う
           /////////　先に持ってくるのが5倍程度早い(PyPy3の場合)
        if (i + 1 < h && grid[i+1][j] == '.') {dp[i+1][j] += dp[i][j];}
        if (j + 1 < w && grid[i][j+1] == '.') {dp[i][j+1] += dp[i][j];}
        // dp[i][j] %= MOD;     
    }
    cout << dp[h-1][w-1] << endl;
    return 0;
}

Measured memory_bytes: 8916
a,b=map(int,input().split())
p=abs(abs(a)-abs(b))
if(a<0 and b<a) or(a>0 and a>b and b>0):
    p+=2
print(p+1 if a*b<0 or (a>0and b==0)or(a==0and b<0) else p)

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

// http://drken1215.hatenablog.com/entry/2019/04/27/224100_1

int n;
ll* A;

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

int main(void) {
    cin >> n;

    A = new ll[n];

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

    // あるA[i]が無い状態での最大公約数を求める
    // gcd(left[i], right[i])のうちで，もっとも大きい値が解

    ll *left, *right;
    // nが抜けてたときのために，+1
    left = new ll[n+1];
    right = new ll[n+1];

    // forward 前向きに入れていく
    left[0] = 0;
    for(int i = 0; i < n; ++i) {
        left[i+1] = gcd(left[i], A[i]);
    }

    // backward 後ろ向きにいれていく
    right[n] = 0;
    for(int i = n-1; i >= 0; --i) {
        right[i] = gcd(right[i+1], A[i]);
    }

    // 集計する
    int maxv = 0;

    for(int i = 0; i < n; ++i) {

        // index問題に弱すぎ...ちゃんと確認すること
        int l = left[i];
        int r = right[i+1];
        int cand = gcd(l,r);

        if(maxv < cand) {
            maxv = cand;
        }
    }

    cout << maxv << endl;

    return 0;
}

Measured memory_bytes: 2560
S = list(input())
l = len(S)
sub = []
for i in range(2 ** (l-1)):
    chk = []
    for j in range(l):
        chk.append(S[j])
        if i >> j & 1:
            chk.append('+')
    sub.append(''.join(chk))
ans = [eval(a) for a in sub]
print(sum(ans))

Measured memory_bytes: 3060
/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n,m;
  cin >> n>>m;
  if(n<=m)cout<<"unsafe"<<endl;
  else cout<<"safe"<<endl;
}


Measured memory_bytes: 3616
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  int A,B;
  cin>>A>>B;
  cout<<A-B+1;
return 0;}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = (int)1e9+7;
const double PI = 3.14159265359;



set<ll> st;

void dfs(ll x){
	
	if(st.find(x)!=st.end())
		return;
	if(x>3234566667)
		return;
	if(x==0){
		for(int i=1;i<=9;i++){
			dfs(i);
		}
	}	
	st.insert(x);
	
	int l = x % 10;
	if(l>0)
		dfs(x*10 + l-1);
	dfs(x*10 + l);
	if(l<9)
		dfs(x*10 + l+1)	;
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t;
	//ctrl + /cin>>t;
	t = 1;
	while(t--){
		ll k;
		cin>>k;
		dfs(0);
		while(k){
			st.erase(st.begin());
			k--;
		}
		cout<<*st.begin();
	}
	return 0;
}
































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

using namespace std;

int main(){
	int n, k;
	cin>>n>>k;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin>>a[i];
	vector<int> dp(n, 1e9 + 5);
	dp[n - 1] = 0;
	dp[n - 2] = abs(a[n - 1] - a[n - 2]);
	for(int i = n - 3; i >= 0; i--){
		for(int j = 1; j<=min(k,n - 1 - i); j++ ){
			dp[i] = min(dp[i], abs(a[i] - a[i + j]) + dp[i + j]);
		}
	}
	cout<<dp[0]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
	int size=1;
	int i,j;
	int paint[3];
	scanf("%d",&paint[0]);
	int box;
	for(i=0;i<2;++i){
		scanf("%d",&box);
		for(j=0;j<size&&paint[j]!=box;++j);
		if(j==size){
			paint[j]=box;
			size++;
		}
	}
	printf("%d\n",size);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    ll n;cin>>n;
    ll a[n];
    rep(i,n){cin>>a[i];}
    sort(a,a+n);
    ll val=a[0], cur=0;
    for(int i=1;i<n;i++){
        if(val*2>=a[i]){
            val += a[i];
        }else{
            val += a[i];
            cur= i;
        }
    }
    cout << n-cur << endl;
    return 0;
}


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

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

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll H,N;
    cin >> H >> N;
    ll cnt = 0;
    for (int i = 0; i < N; i++) {
        ll a; cin >> a;
        cnt += a;
    }
    Yes(H <= cnt);
}

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

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

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

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

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

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

    ($next:expr, 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")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      aa: [f64; n],
    }
    let mut ans = 0.0;
    for i in 0..n {
        ans += 1.0 / aa[i];
    }
    ans = 1.0 /ans;
    puts!("{}\n", ans);
}


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

using namespace std;

const int N = 10000;

int solve (vector<int> & v) {
    for (auto elm : v) {
        if (elm % 2)
            return false;
    }
    return true;
}

int main () {
    int N, M;
    cin >> N >> M;
    vector<int> tb (N);
    
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;

        tb[a-1] += 1;
        tb[b-1] += 1;
    }

    if (solve (tb)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 150
#define Inc(x,y) ((x+=(y))>=X&&(x-=X))
using namespace std;
int n,m,X;
class EvenSolver
{
	private:
		int f[N+5][N+5];
		I int DP(CI n,CI m)
		{
			RI i,j,ans=0;memset(f,0,sizeof(f));
			for(f[0][0]=1,i=0;i^n;++i) for(j=0;j<=m;++j) Inc(f[i+1][0],f[i][j]),Inc(f[i+1][j+1],f[i][j]);
			for(i=0;i<=m;++i) Inc(ans,f[n][i]);return ans;
		}
	public:
		I void Solve() {printf("%d",1LL*DP(n+1>>1,m>>1)*DP(n>>1,m>>1)%X);}
}E;
class OddSolver
{
	private:
		int f[N+5][N+5][N+5];
	public:
		I void Solve()
		{
			RI i,j,k,ans=0;f[0][0][0]=1;
			for(i=0;i<(m>>1)+(n+1>>1);++i) for(j=0;j<=(n>>1);++j) for(k=0;k<=m+1;++k)
				Inc(f[i+1][0][0],f[i][j][k]),i<(n>>1)&&Inc(f[i+1][j+1][0],f[i][j][k]),
				i>=(m>>1)&&Inc(f[i+1][0][k?k+1:0],f[i][j][k]),
				i>=(m>>1)&&i<(n>>1)&&Inc(f[i+1][j+1][max(j+2,k+1)],f[i][j][k]);
			for(j=0;j<=(n>>1);++j) for(k=0;k<=m+1;++k) Inc(ans,f[(m>>1)+(n+1>>1)][j][k]);
			printf("%d",ans);
		}
}O;
int main()
{
	return scanf("%d%d%d",&n,&m,&X),m&1?O.Solve():E.Solve(),0;
}

Measured memory_bytes: 13568
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	priority_queue<int> pq;
	int n;
	cin >> n;
	while(n--)
	{
		int a;
		cin >> a;
		pq.push(a);
	}
	int alice = 0, bob = 0, count = 0;
	while(!pq.empty())
	{
		++count % 2 ? alice += pq.top() : bob += pq.top();
		pq.pop();
	}
	cout << alice - bob << '\n';
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n,x) for(int i=(n);i<(x);++i)
#define SORT(x) sort(x.begin(),x.end())
using ll = long long;

int main() {
	ll n; cin >> n;
	vector<ll> x(n); rep(i, 0, n) cin >> x[i];

	vector<ll> a = x;
	SORT(a);
	ll median1 = a[n / 2], median2 = a[n / 2 - 1];

	rep(i, 0, n) {
		if (x[i] >= median1) cout << median2 << endl;
		else cout << median1 << endl;
	}

	return 0;
}

Measured memory_bytes: 5376