akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
const int MAXN=2e5+10;
int n;
vector<int>G[MAXN];
int a[MAXN];
int ans[MAXN];
int idx=0;
int lst[MAXN];
void dfs(int rt,int fa)
{
    int k=a[rt];
    int p;
    if(idx==0)p=1;
    else {
        p=lower_bound(lst+1,lst+1+idx,k)-lst;
    }
    if(lst[p]==0)idx++;
    int old=lst[p];
    lst[p]=k;
    ans[rt]=idx;
    for(int v:G[rt]){
        if(v==fa)continue;
        dfs(v,rt);
    }
    lst[p]=old;
    if(lst[p]==0)idx--;
}
void solve()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int u=1;u<=n;u++)cin>>a[u];
    for(int u=0;u<n-1;u++){
        int f,t;
        cin>>f>>t;
        G[f].push_back(t);
        G[t].push_back(f);
    }
    dfs(1,0);
    for(int u=1;u<=n;u++)cout<<ans[u]<<'\n';
}
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    solve();
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int x,y;
    cin>>x;
    vector<int>vec(x);
    for(int i=0;i<x;i++)
        cin>>vec[i];
    int ma=0;
    for(int i=0;i<x;i++){
        for(int c=0;c<x;c++){
            if(i==c)
                continue;
            ma=max(ma,abs(vec[i]-vec[c]));
        }
    }
    cout<<ma;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int> 

int main(){
  int N; cin >> N;
  int x = (int)(1.0*N/1.08);

  if ((int)(x*1.08)==N) cout << x << endl;
  else if ((int)((x+1)*1.08)==N) cout << x+1 << endl;
  else cout << ":(" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

int main () {
  int n, d, x;
  cin >> n >> d >> x;

  int ans = x;
  rep(i,n) {
    int a;
    cin >> a;
    ans += (d-1)/a + 1;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int N,X; cin>>N>>X;
  ll sum=0,A[N];
  rep(i,N){
    cin>>A[i];
    sum+=A[i];
  }
  sort(A,A+N);
  if(sum==X){
    cout<<N<<endl;
  }else if(sum<X){
    cout<<N-1<<endl;
  }else{
    int ans=0;
    ll cnt=0;
    rep(i,N){
      if(cnt+A[i]<=X){
        ans++;
        cnt+=A[i];
      }else{
        break;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
# if __name__ == "__main__":
#   A, B, C, X, Y = [int(item) for item in input().split()]
  
#   min_cost = None
#   for Na in range(0, X+1):
#     for Nb in range(0, Y+1):
#       Nc = max(X - Na, Y - Nb) * 2
      
#       cost = Na*A + Nb*B + Nc*C
#       if not min_cost:
#         min_cost = Na*A + Nb*B + Nc*C
#       else:
#         min_cost = min(cost, min_cost)
      
#   print(min_cost)
  
if __name__ == "__main__":
  A, B, C, X, Y = [int(item) for item in input().split()]

  min_cost = None
  for Nc in range(0, max(X, Y)*2+1):
    Na = max(0, X - Nc//2)
    Nb = max(0, Y - Nc//2)
    
    # print(Na, Nb, Nc)
    cost = Na*A + Nb*B + Nc*C
    if not min_cost:
      min_cost = Na*A + Nb*B + Nc*C
    else:
      min_cost = min(cost, min_cost)

  print(min_cost)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    lint n; cin >> n;
    if (n == 0) {
        cout << 0 << endl;
        return 0;
    }
    
    auto iseven = [](lint i) -> bool {
        return (i % 2) == 0;
    };
    
    bool isnegativeodd = false;
    bool isnegativeeven = false;
    if (n < 0) {
        if (iseven(n)) {
            n /= (-2);
            isnegativeeven = true;
        }
        else {
            --n;
            n /= (-2);
            isnegativeodd = true;
        }
    }
    
    // 正と仮定
    string ans = "";
    repeat (i, 40) {
        if (iseven(i)) {
            if ((n >> i) % 2 == 0) {
                ans = "0" + ans;
            }
            else {
                ans = "1" + ans;
            }
        }
        else {
            if ((n >> i) % 2 == 0) {
                ans = "0" + ans;
            }
            else {
                ans = "1" + ans;
                n += (1 << i);
            }
        }
    }
    
    if (isnegativeeven) {
        ans = ans + "0";
    }
    if (isnegativeodd) {
        ans = ans + "1";
    }
    
    bool notappear = true;
    repeat (i, ans.length()) {
        if (ans[i] == '0' and notappear) continue;
        if (ans[i] == '1' and notappear) {
            notappear = false;
            cout << ans[i];
            continue;
        }
        cout << ans[i];
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a;
	cin>>a;
	if(a>='a'&&a<='z')
	{
		cout<<'a'<<"\n";
	}
	else
	{
		cout<<'A'<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e5;
int n,aa[N+2],dp[N+2];
int dfs(int k)
{
  if(dp[k]!=-1)return dp[k];
  set<int>st;
  for(int i=1;i<=n;i++)
    if(k-aa[i]>=0)
      st.insert(dfs(k-aa[i]));
  for(int i=0; ;i++)
    if(st.find(i)==st.end())
      return dp[k]=i;
}
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int k;cin>>n>>k;
  for(int i=1;i<=n;i++)
    cin>>aa[i];
  memset(dp,-1,sizeof(dp));
  if(dfs(k))cout<<"First"<<endl;
  else cout<<"Second"<<endl;
  return 0;
}

Measured memory_bytes: 13184
#include<iostream>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
int a[100005],dp[100005];
int main()
{
    ll n,i,j;
    int k;
	cin>>n>>k; 
	for(i=1;i<=n;i++)
	cin>>a[i];
	dp[1]=0;
	dp[2]=abs(a[2]-a[1]);
	for(i=3;i<=n;i++)
	{
		ll mi=inf,x;
		for(j=1;j<=k;j++)
		{
			if(i-j<=0)
			break;
			x=dp[i-j]+abs(a[i]-a[i-j]);
			mi=mi<x?mi:x;
		}
		dp[i]=mi;
	}
	cout<<dp[n];
	return 0;
}


Measured memory_bytes: 4400
n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

count = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
use = []
a.map{ |i| count[i] }.uniq.sort.each do |k|
    9.downto(1).each do |i|
        if k == count[i] && a.include?(i)
            use << i
            break
        end
    end
end

f = ['!'] * (n + 1)
f[0] = ''
(n+1).times do |j|
    use.each do |i|
        len = count[i]
        break if j + len > n
        if f[j] != '!'
            s = f[j] + i.to_s
            if f[j + len].size < s.size || f[j + len].size == s.size &&  f[j + len] < s
                f[j + len] = s
            end
        end
    end
end

puts f[n]



Measured memory_bytes: 60924
// header {{{
using namespace std;

// C++
#include <algorithm>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>

#pragma GCC optimization_level 3

// util {{{
#define print(x)	        cout << (x)
#define printvec(x)       for(int i = 0;i < (x).size();i++)cout << (x).at(i) << " ";cout << endl
#define println(x)	        cout << (x) << endl
#define printn		        cout << endl
#define read(x)	            cin >> (x)
#define readvec(x)        for(int i = 0; i < (x).size();i++)cin >> (x).at(i)

#define rep(i, n)	        for(int i = 0; i < (int)(n); i++)
#define rep_1(i, n) 	    for(int i = 1; i <=(int)(n); i++)

#define all(x) 		        (x).begin(),(x).end()
#define vint                vector<int>
#define outif(x,y,z)        if(x) cout<<(y)<<endl; else cout<<(z)<<endl
#define loop 		        while(true)

// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------
void draw(int H,int W){
    rep(i,H){
        if(!(i == 0 || i == H - 1)){
            rep(i,W){
                if(i == 0 || i == W - 1){
                    print("#");
                } else {
                    print(".");
                }
            }
        } else {
            rep(i,W){
                print("#");
            }
        }

        printn;
    }
    printn;
}

void solve() {
    vector<pair<int,int>> squares;
    loop{
        int H,W;
        read(H);
        read(W);
        if(H == W && W == 0){
            break;
        }
        pair<int,int> tmp;
        tmp.first=H;
        tmp.second=W;
        squares.push_back(tmp);
    };
    rep(i,squares.size()){
        draw(squares.at(i).first,squares.at(i).second);
    }

}

signed main() {
    solve();
    return 0;
}


Measured memory_bytes: 3108
#include <stdio.h>

int main()
{
	long long a,b,c;
	scanf ("%lld %lld %lld",&a,&b,&c);
	
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) puts("0");
	else{
		long long ans = a * b;
		if (ans > a * c) ans = a * c;
		if (ans > c * b) ans = c * b;
		printf ("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 128
import math
N,X = list(map(int,input().split()))
x = list(map(int,input().split()))
for i in range(N):
    x[i] = abs(x[i] - X)
ans = x[0]
for i in range(1, N):
    ans = math.gcd(ans, x[i])
print(ans)

Measured memory_bytes: 20404
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,M = map(int,input().split())
A = [input().rstrip() for _ in range(N)]
B = [input().rstrip() for _ in range(M)]

for dh in range(N-M+1):
    for dw in range(N-M+1):
        flg = True
        for h in range(M):
            for w in range(M):
                if B[h][w] != A[h+dh][w+dw]:
                    flg = False
                    break
        if flg:
            print("Yes")
            sys.exit()

print("No")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
 const int N=1e5+5;
 int a[N];
 int main()
 {
 	memset(a,0,sizeof(a));
 	int n,ai;
 	scanf("%d",&n);
 	while(n--)
 	{
 		scanf("%d",&ai);
 		a[ai]++;
 		a[ai-1]++;
 		a[ai+1]++;
	}
	int max=0;
	for(int i=0;i<N-1;i++)
	{
		if(max<a[i])
		{
			max=a[i];
		}
	}
	printf("%d",max);
 } 

Measured memory_bytes: 4220
#65 標準偏差

while True:
    n = int(input())
    if n == 0:
        break
    
    s = list(map(int, input().split()))
    m = sum(s)/n
    v = 0
    for si in s:
        v += (si - m)**2
    import math
    ans = math.sqrt(v/n)
    
    print("{:.5f}".format(ans))


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

using namespace std;

using ll = long long int;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

ll solve(ll k, ll a, ll b) {
	if (a > b) {
		return (k - b - 1) / (a - b) * 2 + 1;
	} else if (a >= k) {
		return 1;
	} else {
		return -1;
	}
}

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

	ll k, a, b;
	cin >> k >> a >> b;

	cout << solve(k, a, b) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,c;
    cin>>a>>b>>c;
    if (!(a%2)||!(b%2)||!(c%2)) printf("0");
    else 
       printf("%lld",min(min(a*b,b*c),c*a));
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

int main() {
    int n,cnt=0;
    cin>>n;
    vector<int> A(n);
    for(int i=0;i<n;i++){
        cin>>A.at(i);
    }
    set<int> B(A.begin(),A.end());
    cnt=B.size();
    if(cnt%2==0)
        cout<<cnt-1<<endl;
    else
        cout<<cnt<<endl;
}

Measured memory_bytes: 5376
#include <algorithm>
#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>
#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 get(vector<vector<int>>&s, int a, int b, int c, int d){
    int res = 0;
    res+=s[c][d];
//    show(s[c][d],s[a-1][d],s[c][b-1],s[a][b]);
    if(a)res-=s[a-1][d];
    if(b)res-=s[c][b-1];
    if(a>0 and b>0)res += s[a-1][b-1];
    return res;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    vector<vector<int>>s(h, vector<int>(w));
    int q;
    cin >> q;
    rep(i,h){
        string ss;
        cin >> ss;
        rep(j,w)s[i][j] = ss[j] - '0';
    }
    vector<vector<int>>t(2 * h - 1, vector<int>(2 * w - 1));
    rep(i,h-1){
        rep(j,w){
            if(s[i][j]&s[i+1][j])t[2 * i + 1][2 * j] = 1;
        }
    }
    rep(i,h){
        rep(j,w-1){
            if(s[i][j]&s[i][j+1])t[2 * i][2 * j + 1] = 1;
        }
    }
//    rep(i,2*h-1){
//        rep(j,2*w-1)cout << t[i][j] << " ";
//        cout << endl;
//    }
    rep(i,h-1)rep(j,w)s[i+1][j] += s[i][j];
    rep(i,h)rep(j,w-1)s[i][j+1] += s[i][j];
    rep(i,2*h-2)rep(j,2*w-1)t[i+1][j] += t[i][j];
    rep(i,2*h-1)rep(j,2*w-2)t[i][j+1] += t[i][j];
    while(q--){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        a--,b--,c--,d--;
        int ans = get(s,a,b,c,d);
        show(ans);
        ans -= get(t,2*a,2*b,2*c,2*d);
        cout << ans << "\n";
    }
//    rep(i,h){
//        rep(j,w)cout << s[i][j] << " ";
//        cout << endl;
//    }
//    rep(i,2*h-1){
//        rep(j,2*w-1)cout << t[i][j] << " ";
//        cout << endl;
//    }
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int k;

bool visited[MAX_N];
ll dist[MAX_N];

ll ans;

ll solve() {
  fill_n(visited, k + 1, false);
  fill_n(dist, k + 1, INF);

  deque<pair<int, ll>> deq;

  deq.push_front(make_pair(1, 0LL));

  ll ret = 0;

  while (!deq.empty()) {
    auto cur = deq.front();
    deq.pop_front();

    int node = cur.first;
    ll cost = cur.second;

    if (visited[node]) continue;

    visited[node] = true;
    dist[node] = cost;

    if (node == 0) {
      ret = cost;
      break;
    }

    int next_p1 = (node + 1) % k;
    if (dist[next_p1] > cost + 1LL) {
      deq.push_back(make_pair(next_p1, cost + 1LL));
    }

    int next_t10 = (node * 10) % k;
    if (dist[next_t10] > cost) {
      deq.push_front(make_pair(next_t10, cost));
    }
  }

  return ret + 1LL;
}

int main(void) {
  // Here your code !
  scanf("%d", &k);

  ans = solve();

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 2048
#include<stdio.h>
int main(){
	int n,a[22],c=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=2;i<n;i++){
		if((a[i-1]>a[i] && a[i]>a[i+1]) || (a[i-1]<a[i] && a[i]<a[i+1]))
			c++;
	}
	printf("%d",c);
	return 0;
}

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

using namespace std;
using LL = long long;

int main() {
    int N, M, P[1002];

    while (cin >> N >> M) {
        if ((N | M) == 0) break;

        P[0] = 0;
        for (int i = 1; i <= N; i++) cin >> P[i];

        vector<LL> S;
        for (int i = 0; i <= N; i++) {
            for (int j = 0; j <= N; j++) {
                S.push_back(P[i] + P[j]);
            }
        }
        sort(S.begin(), S.end());

        LL ans = 0;
        for (auto s : S) {
            if (M - s > 0) {
                ans = max(ans, s + *(lower_bound(S.begin(), S.end(), M - s) - 1));
            }
        }

        cout << ans << endl;
    }
}



Measured memory_bytes: 18888
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
 
int main(){
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> vec(n);
  rep(i,n) vec.at(i)=k-q;
//  vector<int> que(q);
  rep(i,q){
    int tmp;
    cin >> tmp;
    tmp--;
    vec.at(tmp)++;
  }
  rep(i,n){
    string ret;
    if (vec.at(i)>0) ret = "Yes";
    else ret = "No";
    cout << ret << endl;
  }
}
     

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


int main(){
    int N,M;
    int ans = 0;
    cin >> N >> M;
    vector<int> like_foods(M,0);

    rep(i,N){
        int k;
        cin >> k;
        vector<int> A(k);
        rep(j,k) cin >> A[j];
        for (int a : A){
            like_foods[a-1] += 1;
        }
    }
    for (int food : like_foods){
        if (food == N){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N, K, C = map(int, input().split())
S = input()

def calc(S):
    now = 1
    ret = [0] * (N + 1)
    while now <= N:
        if S[now] == 'x':
            now += 1
            continue
        ret[now] += 1
        now += C + 1
    for i in range(N):
        ret[i + 1] += ret[i]

    return ret

L = calc('-' + S)
R = calc('-' + S[::-1])[::-1]

ans = []
for mid in range(1, N + 1):
    if S[mid - 1] == 'o' and L[mid] != L[mid - 1] and R[mid] != R[mid - 1] and L[mid] + R[mid] == K:
        ans.append(mid)

print(*ans, sep='\n')

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

#define ll long long
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)

//library----------------------------------------------


int main(){
  int x; cin>>x;
  if(x==5||x==7||x==3){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}

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


#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

int main(){
  long long n,k;
  long long ans = 0;
  cin>>n>>k;
  long long array[n];
  for(int i=0;i<n;i++){
    cin>>array[i];
  }
  sort(array, array + SIZE_OF_ARRAY(array), std::greater<>());
  if(k<n){
    for(int i=k;i<n;i++){
      ans+=array[i];
    }
  }
  cout<<ans;
 
  return 0;
}

Measured memory_bytes: 1792
import itertools
import math

n = int(input())
x = [None for i in range(n)]
y = [None for i in range(n)]

for i in range(n):
  x[i], y[i] = [int(char) for char in input().split()]

towns = [i for i in range(n)]

sum = 0

for arranged_towns in itertools.permutations(towns):
  current_town = arranged_towns[0]

  for next_town in arranged_towns[1:]:
    sum += math.sqrt((x[current_town] - x[next_town])** 2
              + (y[current_town] - y[next_town]) ** 2)
    current_town = next_town

result = sum / math.factorial(n)

print(result)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> p;
typedef unsigned long long int ull;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const int INF=2e9;

ll N,D,A;
vector<ll> X,H;

ll solve(){
    vector<int> isd(N);
    for(int i=0;i<N;++i) isd[i]=i;
    sort(isd.begin(),isd.end(),[&](int i,int j){
        return X[i]<X[j];
    });
    vector<ll> nX(N),nH(N);
    for(int i=0;i<N;++i){
        nX[i]=X[isd[i]];nH[i]=H[isd[i]];
    }
    X=nX;H=nH;
    vector<ll> S(N+1,0);
    ll res=0;
    for(int i=0;i<N;++i){
        if(S[i]<H[i]){
            ll need=(H[i]-S[i]+A-1)/A;
            ll right=upper_bound(X.begin(),X.end(),X[i]+2*D)-X.begin();
            S[i]+=need*A;
            S[right]-=need*A;
            res+=need;
        }
        S[i+1]+=S[i];
    }
    return res;
}

int main(){
    cin>>N>>D>>A;
    X.resize(N);H.resize(N);
    for(int i=0;i<N;++i) cin>>X[i]>>H[i];
    cout<<solve()<<endl;
    return 0; 
}

Measured memory_bytes: 11888
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static int mod =1000000007;
	public static void main(String[] args) {
		
		int N=sc.nextInt();
		int M=sc.nextInt();
		int maxL=0,minR=0;
		for(int i=0;i<M;i++) {
			if(i==0) {
				maxL=sc.nextInt();
				minR=sc.nextInt();
			}else {
				maxL=Math.max(maxL,sc.nextInt());
				minR=Math.min(minR, sc.nextInt());
			}
		}
		//if(minR>N)minR=N;
		if(minR<maxL)p(0);
		else p(minR-maxL+1);
		
	}

	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


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

using namespace std;

void dfs(int remain, int limit, vector<int> v) {
    if (remain == 0) {
        for (int i = 0; i < v.size(); i++) {
            if (i > 0)cout << " ";
            cout << v[i];
        }
        cout << endl;
        return;
    }

    for (int i = min(remain, limit); i > 0; i--) {
        v.push_back(i);
        dfs(remain - i, i, v);
        v.pop_back();
    }
}

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0)break;
        dfs(n, n, {});
    }
    return 0;
}


Measured memory_bytes: 3152
N = int(input())

S = input()

ans = float("inf")

lb = 0
rw = 0

for i in range(N):
    if S[i] == ".":
        rw += 1

for i in range(N+1):

    ans = min(ans , lb + rw)

    if i == N:
        break

    if S[i] == "#":
        lb += 1
    else:
        rw -= 1

print (ans)
        


Measured memory_bytes: 41948
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<tuple<int,int,int64_t>> V;
    rep(i,0,N){
        int x,y;
        int64_t h;
        cin>>x>>y>>h;

        V.emplace_back(h,x,y);
    }

    sort(ToEnd(V),greater<tuple<int,int,int64_t>>());

    tuple<int,int,int64_t> ans;
    rep(cx,0,101){
        bool match;
        rep(cy,0,101){
            match=true;
            int64_t ch=get<0>(V.front())+abs(get<1>(V.front())-cx)+abs(get<2>(V.front())-cy);
            rep(i,0,N){
                int x,y;
                int64_t h;
                tie(h,x,y)=V.at(i);
                
                int64_t _h=max((int64_t)0,ch-abs(x-cx)-abs(y-cy));
                if(h!=_h){
                    match=false;
                    break;
                }
            }
            if(match) ans=make_tuple(cx,cy,ch);
        }
        if(match) break;
    }

    cout<<get<0>(ans)<<" "<<get<1>(ans)<<" "<<get<2>(ans)<<endl;
}

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

long A,B,K;

int main() {
    cin>>A>>B>>K;
    if (A>=K) cout<<A-K<<' '<<B<<endl;
    else if (A+B>=K) cout<<0<<' '<<A+B-K<<endl;
    else cout<<0<<' '<<0<<endl;
    return 0;
}


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

//動画見て別解

int main(){
    int n; cin >> n;
    map<string,int> mp;
    rep(i,n){
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        mp[s]++;
    }
    ll ans=0;
    for(auto& p: mp){
        int s=p.second;
        ans+=(ll)s*(s-1)/2;
    }
    cout << ans << endl;
}

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



int main() {
  int x;
  cin >> x;
  
  int ans=1;
  if(x<600) ans=8;
  else if(x<800) ans=7;
  else if(x<1000) ans=6;
  else if(x<1200) ans=5;
  else if(x<1400) ans=4;
  else if(x<1600) ans=3;
  else if(x<1800) ans=2;
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
void Swap(char S[ ][11], int i, int j)
{
    char tmp[11];
    strcpy(tmp,S[i]);
    strcpy(S[i],S[j]);
    strcpy(S[j],tmp);
    return;
}

void QSort(char S[][11], int left, int right){
    int i, j;
    char pivot[11];
    
    i = left;
    j = right;
    
    strcpy(pivot,S[(left + right) / 2]);
    while (1) {
        while (strcmp(S[i],pivot) < 0){
            i++;
        }
        while (strcmp(pivot,S[j]) < 0){
            j--;
        }
        if (i >= j){
            break;
        }
        
        Swap(S, i, j);
        i++;
        j--;
    }
   
    
    if (left < i - 1)
        QSort(S, left, i - 1);
    if (j + 1 <  right)
        QSort(S, j + 1, right);
}

int main(){
    int N;
    scanf("%d",&N);
    char S[N+1][11];
    for (int i=0; i<N; i++) {
        scanf("%s",S[i]);
    }
    QSort(S,0,N-1);
    int sum=1;
    for (int i=1; i<N; i++) {
    if(strcmp(S[i],S[i-1])!=0){
            sum++;
        }
    }
    
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 3876
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n; cin>>n;
    vector<int> c(26,inf);
    rep(i,n){
        string s; cin>>s;
        vector<int> cnt(26,0);
        for(auto ch:s) cnt[ch-'a']++;
        rep(j,26) c[j]=min(c[j],cnt[j]);
    }
    rep(i,26)rep(j,c[i]){
        cout<<(char)('a'+i);
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod = 1e9 + 7;
const int maxn = 1e6 + 10;
LL fac[maxn], inv_fac[maxn], num[maxn];

LL qpow(LL a, LL b) {
    LL ret = 1LL;
    while (b) {
        if (b & 1) ret = ret * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ret;
}

LL inv(LL x) {
    return qpow(x, mod - 2);
}

LL C(int n, int m) {
    return fac[n] * inv_fac[m] % mod * inv_fac[n - m] % mod;
}

int main() {
    int N;
    scanf("%d", &N);
    if(N == 2) {puts("1"); return 0;}
    fac[0] = 1;
    for (int i = 1; i <= N; ++i) fac[i] = fac[i - 1] * i % mod;
    inv_fac[N] = inv(fac[N]);
    for (int i = N - 1; i >= 0; --i) inv_fac[i] = inv_fac[i + 1] * (i + 1) % mod;
    for (int i = (N + 1) / 2; i <= N - 1; ++i)
        num[i] = C(i - 1, N - 1 - i) * fac[i] % mod * fac[N - 1 - i] % mod;
    LL ans = 0;
    for (int i = N - 1; i >= (N + 1) / 2; i--) {
        num[i] = (num[i] - num[i - 1] + mod) % mod;
        ans = (ans + num[i] * i) % mod;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 21632
import sys
input = sys.stdin.readline

N = int(input())
tree = [[] for _ in range(N)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    tree[u-1].append([v-1,w])
    tree[v-1].append([u-1,w])

dist = [None]*N
dist[0] = 0
comp = [0]*N
next_ptr = [0]
for ptr in next_ptr:
    comp[ptr] = 1
    edges = tree[ptr]
    for edge in edges:
        if comp[edge[0]] == 0:
            dist[edge[0]] = dist[ptr] + edge[1]
            next_ptr.append(edge[0])

for item in dist:
    print(item%2)

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

int main() {
	int x,y,z,n,count=0;
	cin>>x>>y>>z>>n;
	
	for(int i=0;i<=(n/x);i++){
		for(int j=0;j<=(n-i*x)/y;j++){
			if((n-i*x-j*y)%z==0) count++;
		}
	}
	cout<<count<<endl;
	// your code goes here
	return 0;
}

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

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rInt(a) scanf("%d",&a);

main(){
    int n,H;
    scanf("%d %d",&n,&H);
    vector<pii> arr;
    int a,b;
    int maxi = 0;
    rep(i,n){
        scanf("%d %d",&a,&b);
        arr.push_back(pii(b,a));
        maxi = max(a,maxi);
    }
    sort(arr.begin(),arr.end());
    ll cont = 0;
    for(int i=arr.size()-1;i>=0;--i){
        if(arr[i].first<maxi) continue;
        H -= arr[i].first;
        cont++;
        if(H<=0) break;
    }
    if(H>0){
        if(maxi>H) cont++;
        else {
            int val = (H/maxi);
            if(val*maxi<H) val++;
            cont += val;
        }
    }
    cout << cont << endl;
}

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

int main() {
    int H, W; cin >> H >> W;
    vector< vector<char> > S(H, vector<char>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) cin >> S[i][j];
    }
    vector< vector<int> > L(H, vector<int>(W)), R(H, vector<int>(W)), U(H, vector<int>(W)), D(H, vector<int>(W));
    for (int i = 0; i < H; i++) {
        if (S[i][0] == '.') L[i][0] = 1;
        for (int j = 1; j < W; j++) {
            if (S[i][j] == '.') L[i][j] = L[i][j-1] + 1;
        }
    }
    for (int i = 0; i < H; i++) {
        if (S[i][W-1] == '.') R[i][W-1] = 1;
        for (int j = W-2; j >= 0; j--) {
            if (S[i][j] == '.') R[i][j] = R[i][j+1] + 1;
        }
    }
    for (int i = 0; i < W; i++) {
        if (S[0][i] == '.') U[0][i] = 1;
        for (int j = 1; j < H; j++) {
            if (S[j][i] == '.') U[j][i] = U[j-1][i] + 1;
        }
    }
    for (int i = 0; i < W; i++) {
        if (S[H-1][i] == '.') D[H-1][i] = 1;
        for (int j = H-2; j >= 0; j--) {
            if (S[j][i] == '.') D[j][i] = D[j+1][i] + 1;
        }
    }
    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3);
        }
    }
    cout << ans << endl;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    string s, ans1 = "", ans2 = "";
    map<string, int> mp;
    int n1 = 0, n2 = 0;
    while (cin >> s)
    {
        if (ans2.size() <= s.size())
            ans2 = s;
        mp[s]++;
        if (mp[s] >= mp[ans1])
            ans1 = s;
    }
    cout << ans1 << " " << ans2 << endl;

    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main() {
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  string res = "";
  vector<string> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S[i];
  }
  for (int i = 0; i < N; i++) {
    if (S[i] == "AB") {
      if (A > B) {
        A--;
        B++;
        res += 'B';
      } else if (A < B) {
        A++;
        B--;
        res += 'A';
      } else if (A == B && A != 1) {
        A++;
        B--;
        res += 'A';
      } else {
        if (i < N - 1 && S[i + 1] == "AC") {
          A++;
          B--;
          res += 'A';
        } else {
          B++;
          A--;
          res += 'B';
        }
      }
    } else if (S[i] == "AC") {
      if (A > C) {
        A--;
        C++;
        res += 'C';
      } else if (A < C) {
        A++;
        C--;
        res += 'A';
      } else if (A == C && A != 1) {
        A++;
        C--;
        res += 'A';
      } else {
        if (i < N - 1 && S[i + 1] == "AB") {
          A++;
          C--;
          res += 'A';
        } else {
          C++;
          A--;
          res += 'C';
        }
      }
    } else {
      if (B > C) {
        B--;
        C++;
        res += 'C';
      } else if (B < C) {
        B++;
        C--;
        res += 'B';
      } else if (B == C && B != 1) {
        B++;
        C--;
        res += 'B';
      } else {
        if (i < N - 1 && S[i + 1] == "AB") {
          B++;
          C--;
          res += 'B';
        } else {
          C++;
          B--;
          res += 'C';
        }
      }
    }
    if (A < 0 || B < 0 || C < 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  for (char ch : res) {
    cout << ch << endl;
  }
  return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n,m; cin >> n >> m;
  vector<int> h(n); cin >> h;
  set<int> ng;
  for(int i = 0; i < m; ++i){
    int a,b; cin >> a >> b; --a;--b;
    if(h[a] >= h[b]) ng.emplace(b);
    if(h[b] >= h[a]) ng.emplace(a);
  }
  cout << n-ng.size() << endl;
  return 0;
}


Measured memory_bytes: 6432
/*
  AtCoder Beginner Contest 094
  C - Many Medians
*/

#include<iostream>
#include<algorithm>
using namespace std;

int N;
int X[200000];
int sortedX[200000];

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &X[i]);
    sortedX[i] = X[i];
  }
  sort(sortedX, sortedX+N);

  int before_med = sortedX[N/2-1], after_med = sortedX[N/2];
  if (before_med == after_med) {
    for (int i = 0; i < N; ++i) printf("%d\n", before_med);
  }
  else {
    for (int i = 0; i < N; ++i) {
      if (X[i] < after_med) printf("%d\n", after_med);
      else printf("%d\n", before_med);
    }
  }
  return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  int sum = 700;
  cin >> S;
  if (S[0] == 'o') sum += 100;
  if (S[1] == 'o') sum += 100; 
  if (S[2] == 'o') sum += 100; 
  cout << sum << endl;
}

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

using namespace std;

using int64 = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n, x;
  cin >> n >> x;
  vector<int> ls(n);
  for (int i =0; i < n; i++) {
    cin >> ls[i];
  }

  int current = 0;
  int count = 1;
  for (int i = 0; i < n; i++) {
    current += ls[i];
    if (current <= x) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;


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


void solve(){
	long long int n;
	cin >> n;
	long long int a[n+1];
	ll nodes[n+1];
	ll ans = 0;
	for(long long int i =0;i<n+1;i++){
		cin >> a[i];
		nodes[i] = a[i];
	}
	ans = nodes[n];
	for(long long int i =n-1;i>=0;i--){
		// cout << ans <<endl;
		nodes[i]+=nodes[i+1];
		ans+=nodes[i];
	}
	long long int pos = 1;
	// cout << ans << endl;
	for(long long int i =0;i<=n;i++){
		pos-=a[i];
		
		// cout << ans << " " << pos << endl;

		if(pos<0){
			// cout << pos << " " << i << endl;
			cout << -1 << endl;return;
		}
		// if(i==n && pos!=0){
		// 	cout << pos <<endl;
		// 	cout << -1 << endl;return;
		// }
		if(nodes[i]-a[i]>pos){
			ans-=nodes[i];
			ans+=pos + a[i];
		}
		else{
			pos = nodes[i] - a[i];
		}
		pos*=2;
	}

	cout << ans << endl;
	
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 5172
#include<stdio.h>
int main() {
  int h,count,x,y;
  
  
  while(1){
    count=0;
    scanf("%d %d",&x,&y);
    if(x<y)
      {
	h=x;
	x=y;
	y=h;
      }    

    if(x==0 && y==0){ break;}
    
    while(1)  /*àÁÄéê is here*/
      {
	x=x%y;  /*à*/

	h=x;   /*à*/
	x=y;  /*à*/
	y=h; /*à*/
	
	if(y==0){break;}	
	count++;
      }
    
    
    printf("%d %d\n",x,(count+1));
  }
  return 0; 
}

Measured memory_bytes: 0
from bisect import *

def index(a, x):
    'Locate the leftmost value exactly equal to x'
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    raise ValueError

def find_lt(a, x):
    'Find rightmost value less than x'
    i = bisect_left(a, x)
    try:
        if i:
            return a[i-1]
    except:
        return -1

def find_le(a, x):
    'Find rightmost value less than or equal to x'
    i = bisect_right(a, x)
    try:
        if i:
            return a[i-1]
        else:
            return -1
    except:
        return -1

def find_gt(a, x):
    'Find leftmost value greater than x'
    i = bisect_right(a, x)
    try:
        if i != len(a):
            return a[i]
    except:
        return -1

def find_ge(a, x):
    'Find leftmost item greater than or equal to x'
    i = bisect_left(a, x)
    try:
        if i != len(a):
            return a[i]
        else:
            return -1
    except:
        return -1

def fun(a,b):
    if b==-1:
        return -1
    elif b==0:
        return 0
    return (b+1)*(2*a-b)/2 - b*(b+1)/2

N=int(raw_input())
X=map(int, raw_input().split())
Y=sorted(X)
ans=[-1,0,0]
if len(Y)==2:
    print Y[1],Y[0]

else:
    for y in Y[::-1]:
        qry=y/2
        tmp1=find_ge(Y, qry)
        tmp2=find_le(Y, qry)
        if ans[0]<fun(y,tmp1):
            ans=[fun(y,tmp1),y,tmp1]
        if ans[0]<fun(y,tmp2):
            ans=[fun(y,tmp2),y,tmp2]
    print ans[1], ans[2]


Measured memory_bytes: 11360
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

int binpow(int a, int b) {
    if (b == 0)
    {
        return 1;
    }
    ll res = binpow(a, b / 2);
    res*=res;
    if (b % 2)
    {
        return res * a;
    }
    return res;
}

ll gcd(ll a,ll b)
{
    if (b==0) return a;
    return gcd(b,a%b);
}
string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,mini,ans=1;
    cin>>n;
    int p[n];
    for (int i=0;i<n;++i)
    {
        cin>>p[i];
    }
    mini=p[0];
    for (int i=1;i<n;++i)
    {
        if (mini>=p[i])
        {
            ++ans;
        }
        mini=min(mini,p[i]);
    }
    cout<<ans;
    return 0;
}

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


void main()
{
  auto n = readln.chomp.to!int;
  auto a = readln.chomp.split.to!(int[]);
  auto b = readln.chomp.split.to!(int[]);
  auto c = readln.chomp.split.to!(int[]);
  auto prev = -1;
  int res;
  foreach (i; 0..n) {
    res += b[a[i]-1];
    if (prev + 1 == a[i]) {
      res += c[a[i]-2];
    }
    prev = a[i];
  }
  res.writeln;
}


Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    a,b = LI()
    a_b = str(a)*b
    b_a = str(b)*a
    print(sorted([a_b,b_a])[0])

main()



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

int main() {
    vector<int> abc(3);
    for (auto& e : abc) cin >> e;
    int k;
    cin >> k;
    sort(begin(abc), end(abc));
    cout << abc[0] + abc[1] + abc[2] * pow(2, k) << endl;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using ll = long long int;
#define int ll

const int MOD = 1e9 + 7;
const int INF = 1e15 + 373;

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

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> init_vector2(size_t n0, size_t n1, T e = T()) {
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> init_vector3(size_t n0, size_t n1, size_t n2, T e = T()) {
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

bool solve(int n, vector<int>& a, vector<int>& b) {
    vector<int> c(n);
    rep(i, n) { c[i] = b[i] - a[i]; }

    int neg_sum = 0;
    int pos_sum = 0;
    rep(i, n) {
        if (c[i] > 0) {
            pos_sum += c[i] / 2;
        }
        if (c[i] < 0) {
            neg_sum += -c[i];
        }
    }

    return pos_sum >= neg_sum;
}

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) { cin >> a[i]; }
    vector<int> b(n);
    rep(i, n) { cin >> b[i]; }
    cout << (solve(n, a, b) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 888